Issues (6)

src/Message/CreateCardRequest.php (1 issue)

Severity
1
<?php
2
3
namespace Omnipay\Moneris\Message;
4
5
class CreateCardRequest extends AbstractRequest
6
{
7 6
    public function getData()
8
    {
9 6
        $data = null;
10 6
        $card = $this->getCard();
11
12 6
        if ($card) {
0 ignored issues
show
$card is of type Omnipay\Common\CreditCard, thus it always evaluated to true.
Loading history...
13 6
            $card->validate();
14 6
            $request = new \SimpleXMLElement('<?xml version="1.0" encoding="utf-8"?><request></request>');
15 6
            $request->addChild('store_id', $this->getMerchantId());
16 6
            $request->addChild('api_token', $this->getMerchantKey());
17
18 6
            $res_add_cc = $request->addChild('res_add_cc');
19 6
            $res_add_cc->addChild('cust_id', $card->getBillingName());
20 6
            $phone = $card->getBillingPhone() != '' ? $card->getBillingPhone() : 'NA';
21 6
            $res_add_cc->addChild('phone', $phone);
22 6
            $res_add_cc->addChild('email', $card->getEmail());
23 6
            $res_add_cc->addChild('note', 'NA');
24 6
            $res_add_cc->addChild('pan', $card->getNumber());
25 6
            $res_add_cc->addChild('expdate', $card->getExpiryDate('my'));
26 6
            $res_add_cc->addChild('crypt_type', $this->getCryptType());
27
28 6
            $avs_info = $res_add_cc->addChild('avs_info');
29 6
            $avs_info->addChild('avs_street_number', 'NA');
30 6
            $avs_street_name = $card->getBillingAddress1() != '' ? $card->getBillingAddress1() : 'NA';
31 6
            $avs_info->addChild('avs_street_name', $avs_street_name);
32 6
            $avs_info->addChild('avs_zipcode', $card->getBillingPostcode());
33
34 6
            $data = $request->asXML();
35
        }
36
37 6
        return preg_replace('/\n/', '', $data);
38
    }
39
}
40