1 | <?php |
||
13 | class Handler |
||
14 | { |
||
15 | /** |
||
16 | * @var string |
||
17 | */ |
||
18 | protected $sharedKey1; |
||
19 | |||
20 | /** |
||
21 | * @var string |
||
22 | */ |
||
23 | protected $sharedKey2; |
||
24 | |||
25 | /** |
||
26 | * @var string |
||
27 | */ |
||
28 | protected $checksum1; |
||
29 | |||
30 | /** |
||
31 | * @var string |
||
32 | */ |
||
33 | protected $checksum2; |
||
34 | |||
35 | /** |
||
36 | * @var PaymentRequest |
||
37 | */ |
||
38 | protected $paymentRequest; |
||
39 | |||
40 | 12 | public function __construct(ServerRequestInterface $request, string $sharedKey1, string $sharedKey2) |
|
49 | |||
50 | /** |
||
51 | * Returns true if the checksum given from Dandomain matches the checksum we can compute. |
||
52 | * |
||
53 | * @return bool |
||
54 | */ |
||
55 | 3 | public function checksumMatches(): bool |
|
59 | |||
60 | /** |
||
61 | * @return string |
||
62 | */ |
||
63 | 3 | public function getChecksum1() |
|
76 | |||
77 | /** |
||
78 | * @return string |
||
79 | */ |
||
80 | 3 | public function getChecksum2() |
|
92 | |||
93 | /** |
||
94 | * @param int $orderId |
||
95 | * @param float $amount |
||
96 | * @param string $sharedKey |
||
97 | * @param int $currency |
||
98 | * |
||
99 | * @return string |
||
100 | */ |
||
101 | 6 | public static function generateChecksum1(int $orderId, float $amount, string $sharedKey, int $currency): string |
|
108 | |||
109 | /** |
||
110 | * Dandomain has a bug in their payment implementation where they don't |
||
111 | * include amount in checksum on their complete/success page. |
||
112 | * That is why we have a second method for computing that checksum. |
||
113 | * |
||
114 | * @param int $orderId |
||
115 | * @param string $sharedKey |
||
116 | * @param int $currency |
||
117 | * |
||
118 | * @return string |
||
119 | */ |
||
120 | 3 | public static function generateChecksum2(int $orderId, string $sharedKey, int $currency): string |
|
124 | |||
125 | /** |
||
126 | * @return PaymentRequest |
||
127 | */ |
||
128 | 6 | public function getPaymentRequest(): PaymentRequest |
|
132 | |||
133 | /** |
||
134 | * @param PaymentRequest $paymentRequest |
||
135 | * |
||
136 | * @return Handler |
||
137 | */ |
||
138 | 9 | public function setPaymentRequest(PaymentRequest $paymentRequest): self |
|
144 | } |
||
145 |