-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmulti_kassa.php
More file actions
38 lines (31 loc) · 1.28 KB
/
multi_kassa.php
File metadata and controls
38 lines (31 loc) · 1.28 KB
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
<?php
$keys = array(
'YOUR_TEST_KEY' => 'TEST.KASSA', //ONLY FOR TESTING
'YOUR_SHOP1_KEY' => 'SHOP1.KASSA',
'YOUR_SHOP2_KEY' => 'SHOP2.KASSA',
);
$sha_keys = array();
foreach ($keys as $key => $val)
$sha_keys[$key] = hash('sha256', $_POST['cashboxCode'].'&'.$_POST['orderId'].'&'.$_POST['baseSum'].'&'.$_POST['totalSum'].'&'.$_POST['contact'].'&'.$_POST['paymentCode'].'&'.$_POST['cashboxCurrencyCode'].'&'.$_POST['paymentCurrencyCode'].'&'.$_POST['customInfo'].'&'.$key );
//Checking
if( empty($_POST['sha256_hash']) || !in_array( $_POST['sha256_hash'], $sha_keys) )
exit();
/*
* Use $_POST to work with your Orders/Users/etc
* Example:
*/
//Get kassa name
$kassa_name = $keys[array_search($_POST['sha256_hash'], $sha_keys)];
//Add balance to user (Note! orderId must be unique)
function yourBalanceFunction( int $user_id, float $sum, string $currency ) {}
yourBalanceFunction( $_POST['customInfo'], $_POST['baseSum'], $_POST['paymentCurrencyCode'] );
//Payment verification for order
function orderPayment( int $order_id, float $sum, string $currency ) {
if(
ceil($sum) != ceil($order_sum) ||
$currency != $order_currency
)
return false;
//SUCCESS!
}
orderPayment( $_POST['orderId'], $_POST['baseSum'], $_POST['paymentCurrencyCode'] );