· 7 years ago · Nov 19, 2018, 11:32 AM
1function make_bank_request(){
2 $params = Array(
3 // "testing" => "1",
4 "unix_timestamp" => time(),
5 "order_id" => "1",
6 "amount" => "1500",
7 "merchant" => *здеÑÑŒ вÑтавлен идентификатор магазина(Ñтрокой)*,
8 "description" => "Заказ N%1",
9 "client_phone" => "+7 912 9876543",
10 "client_email" => "test@test.ru",
11 "success_url" => "http://test.ru/",
12 "fail_url" => "http://test.ru/",
13 );
14
15 $signature = getSignature( $params, *здеÑÑŒ вÑтавлена Ñтрока Ñ Ñекретным ключом*);
16 $params['signature'] = $signature;
17 var_dump($params, $signature);
18
19
20 $opts = Array(
21 'http' => Array(
22 'method' => 'POST',
23 'header' => "Content-type: application/x-www-form-urlencoded",
24 'content' => http_build_query($params),
25 'timeout' => 60
26 )
27 );
28
29 $context = stream_context_create($opts);
30 $url = 'https://pay.modulbank.ru/pay';
31 $result = file_get_contents($url, false, $context);
32
33 $arSbrfResult = (array) json_decode($result);
34 var_dump($arSbrfResult);
35}
36
37function getSignature( $payment_params, $secret_key){
38 ksort($payment_params);
39 $param_string = '';
40 foreach($payment_params as $key=>$value){
41 $param_string .= $key . "=" . base64_encode($value).'&';
42 }
43
44 $sign = sha1($secret_key . strtolower(sha1($secret_key. $param_string)));
45 return $sign;
46}
47make_bank_request();