|
2 | 2 |
|
3 | 3 | namespace Omnipay\SystemPay\Message;
|
4 | 4 |
|
| 5 | +use Omnipay\Common\Message\AbstractRequest as OmnipayAbstractRequest; |
| 6 | +use Omnipay\Common\Message\ResponseInterface; |
| 7 | + |
5 | 8 | /**
|
6 | 9 | * SystemPay Abstract Request
|
7 | 10 | */
|
8 |
| -abstract class AbstractRequest extends \Omnipay\Common\Message\AbstractRequest |
| 11 | +abstract class AbstractRequest extends OmnipayAbstractRequest |
9 | 12 | {
|
10 | 13 |
|
| 14 | + public function sendData($data) |
| 15 | + { |
| 16 | + $response = $this->httpClient->request('POST', $this->getEndPoint(), [], http_build_query($data)); |
| 17 | + $responseData = simplexml_load_string($response->getBody()->getContents()); |
| 18 | + |
| 19 | + return $this->createResponse($responseData); |
| 20 | + } |
| 21 | + |
| 22 | + abstract public function getEndpoint(); |
| 23 | + |
| 24 | + /** |
| 25 | + * @return mixed |
| 26 | + */ |
11 | 27 | public function getMerchantId()
|
12 | 28 | {
|
13 | 29 | return $this->getParameter('merchantId');
|
14 | 30 | }
|
15 | 31 |
|
| 32 | + /** |
| 33 | + * @param $value |
| 34 | + * @return AbstractRequest |
| 35 | + */ |
16 | 36 | public function setMerchantId($value)
|
17 | 37 | {
|
18 | 38 | return $this->setParameter('merchantId', $value);
|
19 | 39 | }
|
20 | 40 |
|
| 41 | + |
| 42 | + /** |
| 43 | + * @return mixed |
| 44 | + */ |
21 | 45 | public function getTransactionDate()
|
22 | 46 | {
|
23 | 47 | return $this->getParameter('transactionDate');
|
24 | 48 | }
|
25 | 49 |
|
| 50 | + /** |
| 51 | + * @param $value |
| 52 | + * @return AbstractRequest |
| 53 | + */ |
26 | 54 | public function setTransactionDate($value)
|
27 | 55 | {
|
28 | 56 | return $this->setParameter('transactionDate', $value);
|
29 | 57 | }
|
30 | 58 |
|
| 59 | + /** |
| 60 | + * @return mixed |
| 61 | + */ |
31 | 62 | public function getCertificate()
|
32 | 63 | {
|
33 | 64 | return $this->getParameter('certificate');
|
34 | 65 | }
|
35 | 66 |
|
| 67 | + /** |
| 68 | + * @param $value |
| 69 | + * @return AbstractRequest |
| 70 | + */ |
36 | 71 | public function setCertificate($value)
|
37 | 72 | {
|
38 | 73 | return $this->setParameter('certificate', $value);
|
39 | 74 | }
|
40 | 75 |
|
| 76 | + /** |
| 77 | + * @param $value |
| 78 | + * @return AbstractRequest |
| 79 | + */ |
41 | 80 | public function setSuccessUrl($value)
|
42 | 81 | {
|
43 | 82 | return $this->setParameter('successUrl', $value);
|
44 | 83 | }
|
45 | 84 |
|
| 85 | + /** |
| 86 | + * @return mixed |
| 87 | + */ |
46 | 88 | public function getSuccessUrl()
|
47 | 89 | {
|
48 | 90 | return $this->getParameter('successUrl');
|
49 | 91 | }
|
50 | 92 |
|
| 93 | + /** |
| 94 | + * @param string $value |
| 95 | + * @return AbstractRequest |
| 96 | + */ |
51 | 97 | public function setCancelUrl($value)
|
52 | 98 | {
|
53 | 99 | return $this->setParameter('cancelUrl', $value);
|
54 | 100 | }
|
55 | 101 |
|
| 102 | + /** |
| 103 | + * @return mixed|string |
| 104 | + */ |
56 | 105 | public function getCancelUrl()
|
57 | 106 | {
|
58 | 107 | return $this->getParameter('cancelUrl');
|
59 | 108 | }
|
60 | 109 |
|
| 110 | + /** |
| 111 | + * @param $value |
| 112 | + * @return AbstractRequest |
| 113 | + */ |
61 | 114 | public function setErrorUrl($value)
|
62 | 115 | {
|
63 | 116 | return $this->setParameter('errorUrl', $value);
|
64 | 117 | }
|
65 | 118 |
|
| 119 | + /** |
| 120 | + * @return mixed |
| 121 | + */ |
66 | 122 | public function getErrorUrl()
|
67 | 123 | {
|
68 | 124 | return $this->getParameter('errorUrl');
|
69 | 125 | }
|
70 | 126 |
|
| 127 | + /** |
| 128 | + * @param $value |
| 129 | + * @return AbstractRequest |
| 130 | + */ |
71 | 131 | public function setRefusedUrl($value)
|
72 | 132 | {
|
73 | 133 | return $this->setParameter('refusedUrl', $value);
|
74 | 134 | }
|
75 | 135 |
|
| 136 | + /** |
| 137 | + * @return mixed |
| 138 | + */ |
76 | 139 | public function getRefusedUrl()
|
77 | 140 | {
|
78 | 141 | return $this->getParameter('refusedUrl');
|
79 | 142 | }
|
80 | 143 |
|
| 144 | + /** |
| 145 | + * @param $value |
| 146 | + */ |
81 | 147 | public function setPaymentCards($value)
|
82 | 148 | {
|
83 | 149 | $this->setParameter('paymentCards', $value);
|
84 | 150 | }
|
85 | 151 |
|
| 152 | + /** |
| 153 | + * @return mixed |
| 154 | + */ |
86 | 155 | public function getPaymentCards()
|
87 | 156 | {
|
88 | 157 | return $this->getParameter('paymentCards');
|
89 | 158 | }
|
90 | 159 |
|
| 160 | + /** |
| 161 | + * @param $value |
| 162 | + * @return AbstractRequest |
| 163 | + */ |
91 | 164 | public function setOrderId($value)
|
92 | 165 | {
|
93 | 166 | return $this->setParameter('orderId', $value);
|
94 | 167 | }
|
95 | 168 |
|
| 169 | + /** |
| 170 | + * @return mixed |
| 171 | + */ |
96 | 172 | public function getOrderId()
|
97 | 173 | {
|
98 | 174 | return $this->getParameter('orderId');
|
99 | 175 | }
|
100 | 176 |
|
| 177 | + /** |
| 178 | + * @param $value |
| 179 | + * @return AbstractRequest |
| 180 | + */ |
101 | 181 | public function setUuid($value)
|
102 | 182 | {
|
103 | 183 | return $this->setParameter('vads_trans_uuid', $value);
|
104 | 184 | }
|
105 | 185 |
|
| 186 | + /** |
| 187 | + * @return AbstractRequest |
| 188 | + */ |
106 | 189 | public function getUuid()
|
107 | 190 | {
|
108 | 191 | return $this->setParameter('vads_trans_uuid');
|
109 | 192 | }
|
110 | 193 |
|
| 194 | + /** |
| 195 | + * @param string $amount |
| 196 | + * @return string |
| 197 | + */ |
111 | 198 | public function formatCurrency($amount)
|
112 | 199 | {
|
113 |
| - return (string) intval(strval($amount * 100)); |
| 200 | + return (string)intval(strval($amount * 100)); |
114 | 201 | }
|
115 | 202 |
|
| 203 | + /** |
| 204 | + * @param $key |
| 205 | + * @param $value |
| 206 | + */ |
116 | 207 | public function addParameter($key, $value)
|
117 | 208 | {
|
118 | 209 | return $this->parameters->set($key, $value);
|
119 | 210 | }
|
120 | 211 |
|
| 212 | + |
| 213 | + public function getAmount() |
| 214 | + { |
| 215 | + return $this->getAmountInteger().""; |
| 216 | + } |
| 217 | + |
| 218 | + |
121 | 219 | /**
|
122 | 220 | * @see https://payzen.eu/wp-content/uploads/2013/04/Guide_d_implementation_formulaire_paiement_PayZen_v3.4.pdf
|
123 | 221 | */
|
|
0 commit comments