WSAuthorizeRequest::sendData()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 5
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 1
1
<?php
2
3
namespace Omnipay\Komerci\Message;
4
5
/**
6
 * Komerci Authorize Request
7
 */
8
class WSAuthorizeRequest extends WSAbstractRequest
9
{
10
11 6
    public function getData()
12
    {
13 6
        $this->validate('amount', 'apikey', 'card');
14
15
        $data = array(
16 6
            'Total' => sprintf("%.2F", round($this->getAmount() * 100) / 100),
17 6
            'Transacao' => '73', // 2-step authorization;
18 6
            'Parcelas' => $this->getFormattedInstallments(), // Docs said it needs to be empty but I am getting an error!
19 6
            'Filiacao' => $this->getApiKey(),
20 6
            'NumPedido' => $this->getTransactionId(),
21 6
            'Nrcartao' => $this->getCard()->getNumber(),
22 6
            'CVC2' => $this->getCard()->getCvv(),
23 6
            'Mes' => $this->getCard()->getExpiryMonth(),
24 6
            'Ano' => $this->getCard()->getExpiryYear(),
25 6
            'Portador' => $this->getCard()->getName(),
26 6
            'IATA' => '',
27 6
            'Distribuidor' => '',
28 6
            'Concentrador' => '',
29 6
            'TaxaEmbarque' => '',
30 6
            'Entrada' => '',
31 6
            'Numdoc1' => '',
32 6
            'Numdoc2' => '',
33 6
            'Numdoc3' => '',
34 6
            'Numdoc4' => '',
35 6
            'Pax1' => '',
36 6
            'Pax2' => '',
37 6
            'Pax3' => '',
38 6
            'Pax4' => '',
39 6
            'ConfTxn' => 'S',
40
            'Add_Data' => ''
41 6
        );
42
43
        // The test environment uses 'AddData' and the production environment uses 'Add_Data'
44 6
        if ($this->getTestMode()) {
45 1
            unset($data['Add_Data']);
46 1
            $data['AddData'] = '';
47 1
        }
48
49 6
        return $data;
50
    }
51
52 3
    public function sendData($data)
53
    {
54 3
        $httpResponse = $this->prepareSendData($data, 'GetAuthorized');
55 3
        return $this->response = new WSAuthorizeResponse($this, $httpResponse->xml());
0 ignored issues
show
Bug introduced by
The method xml() does not seem to exist on object<Omnipay\Common\Message\RequestInterface>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
56
    }
57
}
58