-
Notifications
You must be signed in to change notification settings - Fork 2
/
Payment.php
77 lines (70 loc) · 2.05 KB
/
Payment.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
<?php
namespace PetervdBroek\iDEAL2\Endpoints;
class Payment extends Base
{
protected string $endpoint = '/xs2a/routingservice/services/ob/pis/v3/payments';
protected string $method = 'POST';
private float $amount;
private string $reference;
private string $notificationUrl;
private string $returnUrl;
/**
* @param float $amount
* @param string $reference
* @param string $notificationUrl
* @param string $returnUrl
* @return void
*/
public function initialize(float $amount, string $reference, string $notificationUrl, string $returnUrl): void
{
$this->amount = $amount;
$this->reference = $reference;
$this->notificationUrl = $notificationUrl;
$this->returnUrl = $returnUrl;
}
/**
* @return array
*/
public function getOptions(): array
{
return [
'headers' => $this->getHeaders(),
'json' => json_decode($this->getBody()),
];
}
/**
* @return string
*/
protected function getBody(): string
{
return json_encode([
'PaymentProduct' => ['IDEAL'],
'CommonPaymentData' => [
'Amount' => [
'Type' => 'Fixed',
'Amount' => number_format($this->amount, 2, '.', ''),
'Currency' => 'EUR',
],
'RemittanceInformation' => 'Cookie',
'RemittanceInformationStructured' => ['Reference' => $this->reference],
],
'IDEALPayments' => [
'UseDebtorToken' => false,
'FlowType' => 'Standard'
]
]);
}
/**
* @return array
*/
private function getHeaders(): array
{
return [
'Digest' => $this->getDigest(),
'X-Request-ID' => $this->requestId,
'MessageCreateDateTime' => date('c'),
'InitiatingPartyNotificationUrl' => $this->notificationUrl,
'InitiatingPartyReturnUrl' => $this->returnUrl,
];
}
}