1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace Omnipay\IcepayPayments\Message; |
6
|
|
|
|
7
|
|
|
use Omnipay\Common\Message\ResponseInterface; |
8
|
|
|
use Symfony\Component\HttpFoundation\Request; |
9
|
|
|
|
10
|
|
|
class CreateTransactionRequest extends AbstractRequest |
11
|
|
|
{ |
12
|
|
|
/** |
13
|
|
|
* {@inheritdoc} |
14
|
|
|
*/ |
15
|
2 |
|
public function getData(): array |
16
|
|
|
{ |
17
|
2 |
|
$parentData = parent::getData(); |
18
|
|
|
$data = [ |
19
|
1 |
|
'ConsumerFootprint' => [ |
20
|
|
|
'IPAddress' => '127.0.0.1', |
21
|
|
|
'TimeStampUTC' => '0', |
22
|
|
|
], |
23
|
|
|
'Contract' => [ |
24
|
1 |
|
'ContractProfileId' => $this->getContractProfileId(), |
25
|
1 |
|
'AmountInCents' => $this->getAmountInteger(), |
26
|
1 |
|
'CurrencyCode' => $this->getCurrencyCode(), |
27
|
1 |
|
'Reference' => $this->getTransactionId(), |
28
|
|
|
], |
29
|
|
|
'Fulfillment' => [ |
30
|
1 |
|
'PaymentMethod' => $this->getPaymentMethod(), |
31
|
1 |
|
'IssuerCode' => $this->getIssuerCode(), |
32
|
1 |
|
'AmountInCents' => $this->getAmountInteger(), |
33
|
1 |
|
'CurrencyCode' => $this->getCurrencyCode(), |
34
|
1 |
|
'Timestamp' => $this->getTimestamp()->format(self::TIMESTAMP_FORMAT), |
35
|
1 |
|
'LanguageCode' => $this->getLanguageCode(), |
36
|
1 |
|
'CountryCode' => $this->getCountryCode(), |
37
|
1 |
|
'Reference' => $this->getTransactionId(), |
38
|
1 |
|
'Description' => $this->getDescription(), |
39
|
|
|
], |
40
|
|
|
'IntegratorFootprint' => [ |
41
|
|
|
'IPAddress' => '127.0.0.1', |
42
|
|
|
'TimeStampUTC' => '0', |
43
|
|
|
], |
44
|
|
|
'Postback' => [ |
45
|
1 |
|
'UrlCompleted' => $this->getReturnUrl(), |
46
|
1 |
|
'UrlError' => $this->getCancelUrl(), |
47
|
|
|
'UrlsNotify' => [ |
48
|
1 |
|
$this->getNotifyUrl(), |
49
|
|
|
], |
50
|
|
|
], |
51
|
|
|
]; |
52
|
|
|
|
53
|
1 |
|
return array_merge($parentData, $data); |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* {@inheritdoc} |
58
|
|
|
* |
59
|
|
|
* @see https://documentation.icepay.com/api/#operation/Transaction |
60
|
|
|
*/ |
61
|
1 |
|
public function sendData($data): ResponseInterface |
62
|
|
|
{ |
63
|
1 |
|
$response = $this->sendRequest( |
64
|
1 |
|
Request::METHOD_POST, |
65
|
1 |
|
'/api/contract/transaction', |
66
|
1 |
|
$data |
67
|
|
|
); |
68
|
|
|
|
69
|
1 |
|
return new CreateTransactionResponse( |
70
|
1 |
|
$this, |
71
|
1 |
|
$this->getResponseBody($response) |
72
|
|
|
); |
73
|
|
|
} |
74
|
|
|
} |
75
|
|
|
|