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