1 | <?php |
||
11 | class ChecksumHelper |
||
12 | { |
||
13 | /** |
||
14 | * @var string |
||
15 | */ |
||
16 | protected $sharedKey1; |
||
17 | |||
18 | /** |
||
19 | * @var string |
||
20 | */ |
||
21 | protected $sharedKey2; |
||
22 | |||
23 | /** |
||
24 | * @var string |
||
25 | */ |
||
26 | protected $checksum1; |
||
27 | |||
28 | /** |
||
29 | * @var string |
||
30 | */ |
||
31 | protected $checksum2; |
||
32 | |||
33 | /** |
||
34 | * @var Payment |
||
35 | */ |
||
36 | protected $payment; |
||
37 | |||
38 | 6 | public function __construct(Payment $payment, string $sharedKey1, string $sharedKey2) |
|
44 | |||
45 | /** |
||
46 | * Returns true if the checksum given from Dandomain matches the checksum we can compute. |
||
47 | * |
||
48 | * @return bool |
||
49 | */ |
||
50 | 3 | public function checksumMatches(): bool |
|
54 | |||
55 | /** |
||
56 | * @return string |
||
57 | */ |
||
58 | 3 | public function getChecksum1() |
|
71 | |||
72 | /** |
||
73 | * @return string |
||
74 | */ |
||
75 | 3 | public function getChecksum2() |
|
87 | |||
88 | /** |
||
89 | * @param int $orderId |
||
90 | * @param Money $amount |
||
91 | * @param string $sharedKey |
||
92 | * @param int $currency |
||
93 | * |
||
94 | * @return string |
||
95 | */ |
||
96 | 6 | public static function generateChecksum1(int $orderId, Money $amount, string $sharedKey, int $currency): string |
|
105 | |||
106 | /** |
||
107 | * Dandomain has a bug in their payment implementation where they don't |
||
108 | * include amount in checksum on their complete/success page. |
||
109 | * That is why we have a second method for computing that checksum. |
||
110 | * |
||
111 | * @param int $orderId |
||
112 | * @param string $sharedKey |
||
113 | * @param int $currency |
||
114 | * |
||
115 | * @return string |
||
116 | */ |
||
117 | 3 | public static function generateChecksum2(int $orderId, string $sharedKey, int $currency): string |
|
121 | } |
||
122 |