Fast docking payjs personal payment interface (cash register mode)

Recent payment interface in the understanding of individuals, hoping to solve the problem I pay on micro letter. Find a lot of platform comparison again, feeling payjs more professional, mostly imitation payjs other things. At the same time support payments and micro-letters, because I Alipay has not opened (only need to have a certain flow to the opening), it highlights some docking micro letter cashier mode. Record it.
Cashier docking mode is very simple, there is an official development kit can be used directly, or develop their own relatively simple.
A personal approach through code implementation

Business communication key number and configuration

. 1 $ mchid = ' ************** ' ; // PAYJS merchant No. 
2     $ = Key ' ************** ' ; // Communication key

 

Construction orders

1   // configuration parameter line 
2     $ Data = [
 . 3         'mchid' => $ mchid ,
 . 4         'body' => 'I is a test order header',
 . 5         'total_fee' => 1,
 . 6         'out_trade_no' => ' . payjs_jspay_demo_ ' Time (),
 . 7     ];

 

Signature Algorithm

1    // 获取签名
2    function sign($data, $key)
3    {
4        array_filter($data);
5        ksort($data);
6        return strtoupper(md5(urldecode(http_build_query($data) . '&key=' . $key)));
7    }

 

Orders endorsement

1   // add signature data 
2   $ Data [ 'Sign'] = Sign ( $ Data , $ Key );

 

Browser Jump

1   // browser to jump to the cashier 
2  $ url = 'https://payjs.cn/api/cashier?'. Http_build_query ( $ the Data );
 3  header ( 'the Location:'. $ Url );

 

All steps have been completed. You can normally initiate the payment.

Need to remind that the last step in the browser jump action, need to launch a browser, you can not get back-end code and then initiate
two, handle asynchronous notification

My domain name is  http://www.abc.com  , receiving asynchronous notification url is  http://www.abc.com/payjs/notify.php  only at construction orders, you can add the following fields

1  // configuration parameter line 
2     $ Data = [
 . 3         'mchid' => $ mchid ,
 . 4         'body' => 'I is a test order header',
 . 5         'total_fee' => 1,
 . 6         'out_trade_no' => ' '. payjs_jspay_demo_ Time (),
 . 7         ' the notify_url '=>' http://www.abc.com/payjs/notify.php ',
 . 8     ];

 

Thus, after the user pays finished, my server can receive the asynchronous notification. After testing, asynchronous notification of the arrival time is generally within 1 second they received, feel the delay. Just when I was in the front end of polling polls may three seconds relatively low frequency

The entire process is very simple, if there are questions you can ask questions at any time. This is my invitation link  https://payjs.cn/ref/DPVPJD  , this link has opened exclusive 10000 Peas reward.
The next article will introduce jsapi mode of payment, the more perfect to use, suitable for development the ability of students to use

Guess you like

Origin www.cnblogs.com/schack/p/11032561.html