PurchaseRequest::sendData()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 1
1
<?php
2
/**
3
 * InterKassa driver for the Omnipay PHP payment processing library
4
 *
5
 * @link      https://github.com/hiqdev/omnipay-interkassa
6
 * @package   omnipay-interkassa
7
 * @license   MIT
8
 * @copyright Copyright (c) 2015-2017, HiQDev (http://hiqdev.com/)
9
 */
10
11
namespace Omnipay\InterKassa\Message;
12
13
/**
14
 * Class PurchaseRequest.
15
 */
16
class PurchaseRequest extends AbstractRequest
17
{
18
    /**
19
     * {@inheritdoc}
20
     */
21 3
    public function getData()
22
    {
23 3
        $this->validate('checkoutId', 'amount', 'currency', 'description', 'transactionId');
24
25
        $return = [
26 3
            'ik_co_id'          => $this->getCheckoutId(),
27 3
            'ik_am'             => $this->getAmount(),
28 3
            'ik_pm_no'          => $this->getTransactionId(),
29 3
            'ik_desc'           => $this->getDescription(),
30 3
            'ik_cur'            => $this->getCurrency(),
31
        ];
32
33 3
        if ($ik_pnd_u = $this->getReturnUrl()) {
34 3
            $return['ik_pnd_u'] = $ik_pnd_u;
35
36 3
            if ($ik_pnd_m = $this->getReturnMethod()) {
37 3
                $return['ik_pnd_m'] = $ik_pnd_m;
38
            }
39
        }
40
41 3
        if ($ik_suc_u = $this->getReturnUrl()) {
42 3
            $return['ik_suc_u'] = $ik_suc_u;
43
44 3
            if ($ik_suc_m = $this->getReturnMethod()) {
45 3
                $return['ik_suc_m'] = $ik_suc_m;
46
            }
47
        }
48
49 3
        if ($ik_fal_u = $this->getCancelUrl()) {
50 3
            $return['ik_fal_u'] = $ik_fal_u;
51
52 3
            if ($ik_fal_m = $this->getCancelMethod()) {
53 3
                $return['ik_fal_m'] = $ik_fal_m;
54
            }
55
        }
56
57 3
        if ($ik_ia_u = $this->getNotifyUrl()) {
58 3
            $return['ik_ia_u'] = $ik_ia_u;
59
60 3
            if ($ik_ia_m = $this->getNotifyMethod()) {
61 3
                $return['ik_ia_m'] = $ik_ia_m;
62
            }
63
        }
64
65 3
        if ($signKey = $this->getSignKey()) {
66 3
            $return['ik_sign'] = $this->calculateSign($return, $signKey);
67
        }
68
69 3
        return $return;
70
    }
71
72
    /**
73
     * {@inheritdoc}
74
     * @param mixed $data
75
     * @return PurchaseResponse
76
     */
77 2
    public function sendData($data)
78
    {
79 2
        return $this->response = new PurchaseResponse($this, $data);
80
    }
81
}
82