search

Home  >  Q&A  >  body text

How to connect to the personal WeChat code scanning payment interface of payjs

Among the many personal payment interface products, it is difficult to find a stable and reliable product. Fortunately, when I encountered payjs, I felt that it was of high quality and very satisfied with my taste. Recommended for everyone to use. Below are some of my experiences and techniques in the process of docking payjs, which I would like to share with you.

1. Apply for a merchant number

Open payjs.cn to apply for activation and obtain the merchant number and communication key

2. Scan the code to connect

php code As follows:

<?php
    $order = [
        'mchid' => 'xxxxxxxxxxx',
        'body' => 'test',               // 订单标题
        'out_trade_no' => time(),       // 订单号
        'total_fee' => 120,             // 金额,单位:分
    ];
    $order['sign'] = sign($order);
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, 'https://payjs.cn/api/native');
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $order);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
    $rst = curl_exec($ch);
    curl_close($ch);
    print_r($rst);
    function sign(array $attributes) {
        ksort($attributes);
        $sign = strtoupper(md5(urldecode(http_build_query($attributes)) . '&key=' . 'xxxxxxxxxxxx'));
        return $sign;
    }

● Please replace the above merchant number and communication key with your own. Finally, the result returned by the QR code scanning interface can be printed out.

● Among the results returned by the code scanning interface, code_url is the QR code content, which can be converted into a QR code through the class generated by the QR code. Or the qrcode parameter returned by the interface is the image address of the QR code

● Display the QR code to the user, and the user can scan the code through the scan function of WeChat on the mobile phone Pay.

● It should be noted that asynchronous notification is not demonstrated in the above demo code. If you need asynchronous notification, you can add a notify_url parameter, then after the payment is completed, the server will receive an asynchronous notification of successful payment. You can further trigger and process business logic by yourself.

payjqpayjq1993 days ago1290

reply all(1)I'll reply

  • payjq

    payjq2019-06-21 12:27:01

    Open PAYJS through the link below and get 10,000 Doudou for a limited time.

    https://payjs.cn/ref/ZGLGXD

    reply
    0
  • Cancelreply