1 | <?php |
||
2 | |||
3 | namespace ByTIC\Omnipay\Twispay\Message; |
||
4 | |||
5 | use ByTIC\Omnipay\Twispay\Helper; |
||
6 | |||
7 | /** |
||
8 | * Class PurchaseRequest |
||
9 | * @package ByTIC\Omnipay\Twispay\Message |
||
10 | * |
||
11 | * @method PurchaseResponse send() |
||
12 | */ |
||
13 | class PurchaseRequest extends AbstractRequest |
||
14 | { |
||
15 | |||
16 | /** |
||
17 | * @inheritdoc |
||
18 | */ |
||
19 | 2 | public function initialize(array $parameters = []) |
|
20 | { |
||
21 | 2 | $parameters['orderType'] = isset($parameters['orderType']) ? $parameters['orderType'] : 'purchase'; |
|
22 | |||
23 | 2 | $parameters['identifier'] = isset($parameters['identifier']) ? $parameters['identifier'] : 'anonymous'. microtime(true); |
|
24 | 2 | return parent::initialize($parameters); |
|
25 | } |
||
26 | |||
27 | /** |
||
28 | * @inheritdoc |
||
29 | */ |
||
30 | 2 | public function sendData($data) |
|
31 | { |
||
32 | 2 | $data['checksum'] = Helper::generateChecksum($data, $this->getApiKey()); |
|
33 | 2 | $data['redirectUrl'] = $this->getSecureUrl(); |
|
34 | |||
35 | 2 | return parent::sendData($data); |
|
36 | } |
||
37 | |||
38 | /** |
||
39 | * @return array |
||
40 | * @throws \Omnipay\Common\Exception\InvalidCreditCardException |
||
41 | * @throws \Omnipay\Common\Exception\InvalidRequestException |
||
42 | */ |
||
43 | 2 | public function getData() |
|
44 | { |
||
45 | 2 | $this->validate( |
|
46 | 2 | 'siteId', 'apiKey', 'amount', 'currency', 'description', 'orderId', 'notifyUrl', 'returnUrl', 'card' |
|
47 | ); |
||
48 | |||
49 | $data = [ |
||
50 | // 'apiKey' => $this->getSiteId(), |
||
0 ignored issues
–
show
|
|||
51 | // 'notifyUrl' => $this->getNotifyUrl(), |
||
52 | 2 | 'siteId' => $this->getSiteId(), |
|
53 | 2 | 'backUrl' => $this->getReturnUrl(), |
|
54 | 2 | 'identifier' => $this->getIdentifier(), |
|
55 | 2 | 'amount' => $this->getAmount(), |
|
56 | 2 | 'currency' => $this->getCurrency(), |
|
57 | 2 | 'description' => $this->getDescription(), |
|
58 | 2 | 'orderType' => $this->getOrderType(), |
|
59 | 2 | 'orderId' => $this->getOrderId(), |
|
60 | // 'checksum' => $this->getChecksum(), |
||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
64% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them.
Loading history...
|
|||
61 | ]; |
||
62 | |||
63 | 2 | $card = $this->getCard(); |
|
64 | |||
65 | 2 | $data['firstName'] = $card->getBillingFirstName(); |
|
66 | 2 | $data['lastName'] = $card->getBillingLastName(); |
|
67 | // $data['address'] = $card->getBillingAddress1(); |
||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
65% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them.
Loading history...
|
|||
68 | 2 | $data['phone'] = $card->getBillingPhone(); |
|
69 | 2 | $data['email'] = $card->getEmail(); |
|
70 | 2 | $data['invoiceEmail'] = $card->getEmail(); |
|
71 | |||
72 | 2 | return $data; |
|
73 | } |
||
74 | |||
75 | /** |
||
76 | * @return mixed |
||
77 | */ |
||
78 | 2 | public function getIdentifier() |
|
79 | { |
||
80 | 2 | return $this->getParameter('identifier'); |
|
81 | } |
||
82 | |||
83 | /** |
||
84 | * @return mixed |
||
85 | */ |
||
86 | 2 | public function getOrderType() |
|
87 | { |
||
88 | 2 | return $this->getParameter('orderType'); |
|
89 | } |
||
90 | |||
91 | /** |
||
92 | * @return mixed |
||
93 | */ |
||
94 | 2 | public function getOrderId() |
|
95 | { |
||
96 | 2 | return $this->getParameter('orderId'); |
|
97 | } |
||
98 | |||
99 | /** |
||
100 | * @return mixed |
||
101 | */ |
||
102 | public function getChecksum() |
||
103 | { |
||
104 | return $this->getParameter('checksum'); |
||
105 | } |
||
106 | |||
107 | /** |
||
108 | * @param $value |
||
109 | * @return \Omnipay\Common\Message\AbstractRequest |
||
110 | */ |
||
111 | 2 | public function setIdentifier($value) |
|
112 | { |
||
113 | 2 | return $this->setParameter('identifier', $value); |
|
114 | } |
||
115 | |||
116 | /** |
||
117 | * @param $value |
||
118 | * @return \Omnipay\Common\Message\AbstractRequest |
||
119 | */ |
||
120 | 2 | public function setOrderType($value) |
|
121 | { |
||
122 | 2 | return $this->setParameter('orderType', $value); |
|
123 | } |
||
124 | |||
125 | /** |
||
126 | * @param $value |
||
127 | * @return \Omnipay\Common\Message\AbstractRequest |
||
128 | */ |
||
129 | 2 | public function setOrderId($value) |
|
130 | { |
||
131 | 2 | return $this->setParameter('orderId', $value); |
|
132 | } |
||
133 | |||
134 | /** |
||
135 | * @param $value |
||
136 | * @return \Omnipay\Common\Message\AbstractRequest |
||
137 | */ |
||
138 | public function setChecksum($value) |
||
139 | { |
||
140 | return $this->setParameter('checksum', $value); |
||
141 | } |
||
142 | } |
||
143 |
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.
The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.
This check looks for comments that seem to be mostly valid code and reports them.