|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Omnipay\IcepayPayments\Message; |
|
4
|
|
|
|
|
5
|
|
|
use Omnipay\Common\Message\ResponseInterface; |
|
6
|
|
|
use Symfony\Component\HttpFoundation\Request; |
|
7
|
|
|
|
|
8
|
|
|
/** |
|
9
|
|
|
* The request for creating a transaction at Icepay. |
|
10
|
|
|
*/ |
|
11
|
|
|
class CreateTransactionRequest extends AbstractRequest |
|
12
|
|
|
{ |
|
13
|
|
|
/** |
|
14
|
|
|
* {@inheritdoc} |
|
15
|
|
|
*/ |
|
16
|
|
|
public function getData(): array |
|
17
|
|
|
{ |
|
18
|
|
|
$parentData = parent::getData(); |
|
19
|
|
|
|
|
20
|
|
|
$data = [ |
|
21
|
|
|
'Contract' => [ |
|
22
|
|
|
'ContractProfileId' => $this->getContractProfileId(), |
|
23
|
|
|
'AmountInCents' => $this->getAmountInteger(), |
|
24
|
|
|
'CurrencyCode' => $this->getCurrencyCode(), |
|
25
|
|
|
'Reference' => $this->getTransactionId(), |
|
26
|
|
|
], |
|
27
|
|
|
'Postback' => [ |
|
28
|
|
|
'UrlCompleted' => $this->getReturnUrl(), |
|
29
|
|
|
'UrlError' => $this->getCancelUrl(), |
|
30
|
|
|
'UrlsNotify' => [ |
|
31
|
|
|
$this->getNotifyUrl(), |
|
32
|
|
|
], |
|
33
|
|
|
], |
|
34
|
|
|
'IntegratorFootprint' => [ |
|
35
|
|
|
'IPAddress' => '127.0.0.1', |
|
36
|
|
|
'TimeStampUTC' => '0', |
|
37
|
|
|
], |
|
38
|
|
|
'ConsumerFootprint' => [ |
|
39
|
|
|
'IPAddress' => '127.0.0.1', |
|
40
|
|
|
'TimeStampUTC' => '0', |
|
41
|
|
|
], |
|
42
|
|
|
'Fulfillment' => [ |
|
43
|
|
|
'PaymentMethod' => $this->getPaymentMethod(), |
|
44
|
|
|
'IssuerCode' => $this->getIssuerCode(), |
|
45
|
|
|
'AmountInCents' => $this->getAmountInteger(), |
|
46
|
|
|
'CurrencyCode' => $this->getCurrencyCode(), |
|
47
|
|
|
'Timestamp' => $this->getTimestamp()->format(self::TIMESTAMP_FORMAT), |
|
48
|
|
|
'LanguageCode' => $this->getLanguageCode(), |
|
49
|
|
|
'CountryCode' => $this->getCountryCode(), |
|
50
|
|
|
'Reference' => $this->getTransactionId(), |
|
51
|
|
|
'Consumer' => [ |
|
52
|
|
|
'Address' => [ |
|
53
|
|
|
'Street' => $this->getAddressStreet(), |
|
54
|
|
|
'HouseNumber' => $this->getAddressHouseNumber(), |
|
55
|
|
|
'PostalCode' => $this->getAddressPostalCode(), |
|
56
|
|
|
'City' => $this->getAddressCity(), |
|
57
|
|
|
'CountryCode' => $this->getCountryCode(), |
|
58
|
|
|
], |
|
59
|
|
|
'Phone' => $this->getPhoneNumber(), |
|
60
|
|
|
'Email' => $this->getEmailAddress(), |
|
61
|
|
|
], |
|
62
|
|
|
'Order' => [ |
|
63
|
|
|
'OrderNumber' => $this->getReference(), |
|
64
|
|
|
'CurrencyCode' => $this->getCurrencyCode(), |
|
65
|
|
|
'TotalGrossAmountCents' => $this->getAmountInteger(), |
|
66
|
|
|
'TotalNetAmountCents' => $this->getAmountInteger(), |
|
67
|
|
|
], |
|
68
|
|
|
'Description' => $this->getDescription(), |
|
69
|
|
|
], |
|
70
|
|
|
]; |
|
71
|
|
|
|
|
72
|
|
|
return array_merge($parentData, $data); |
|
73
|
|
|
} |
|
74
|
|
|
|
|
75
|
|
|
/** |
|
76
|
|
|
* {@inheritdoc} |
|
77
|
|
|
*/ |
|
78
|
1 |
|
public function sendData($data): ResponseInterface |
|
79
|
|
|
{ |
|
80
|
1 |
|
$this->sendRequest( |
|
81
|
1 |
|
Request::METHOD_POST, |
|
82
|
1 |
|
'/contract/transaction', |
|
83
|
1 |
|
$data |
|
84
|
|
|
); |
|
85
|
|
|
|
|
86
|
1 |
|
return new CreateTransactionResponse( |
|
87
|
1 |
|
$this, |
|
88
|
1 |
|
$this->getResponseBody() |
|
89
|
|
|
); |
|
90
|
|
|
} |
|
91
|
|
|
} |
|
92
|
|
|
|