· 7 years ago · Nov 19, 2018, 01:44 PM
1function make_bank_request(){
2 $params = Array(
3 "merchant" => "bc76b2ce-b6d9-42bf-b388-1a5bd9c5ad1c",
4 "amount" => "1500",
5 "order_id" => "1",
6 "description" => "Заказ N%1",
7 "success_url" => "http://frk-company.ru/",
8 "testing" => "1",
9 "fail_url" => "http://frk-company.ru/",
10 "unix_timestamp" => time(),
11 // "client_phone" => "+7 912 9876543",
12 // "client_email" => "test@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
35 var_dump($result);
36}
37
38function getSignature( $payment_params, $secret_key ){
39 ksort($payment_params);
40 $param_string = '';
41 foreach($payment_params as $key=>$value){
42 $param_string .= $key . "=" . base64_encode($value).'&';
43 }
44
45 $sign = sha1($secret_key . strtolower(sha1($secret_key . substr($param_string,0,-1))));
46 return $sign;
47}
48
49
50make_bank_request();