PHP code example of ycpfzf / hspay

1. Go to this page and download the library: Download ycpfzf/hspay library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

ycpfzf / hspay example snippets


use Ycpfzf\Hspay\Client;

//以下参数由火速付进件时提供
$host='https://pay.xxx.yyy';
$appkey='HS_123456';
$appsecret='xxxyyyzzz';
$privateKey='-----BEGIN PRIVATE KEY-----
 ...
-----END PRIVATE KEY-----';
$hsPublicKey='-----BEGIN PUBLIC KEY-----
 ...
-----END PUBLIC KEY-----';

$client = new Client($host,$appkey,$appsecret,$privateKey,$hsPublicKey);
$resp=$client->pay([
    'orderNo'=>'xxxx',
    'amount'=>0.15,
    'goodsName'=>'测试商品',
    'notifyUrl'=>'http://www.xxyy.com/notify',
    'payWay'=>'MINI_PROGRAM',
    'channel'=>'WECHAT',
    'appId'=>'wx4186a2a7fxxxx',
    'userId'=>'oKFYv5AEybpl5v2uw1lyyyyyy'
]);

print_r($resp);