PHP code example of atishoo / paylib

1. Go to this page and download the library: Download atishoo/paylib 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/ */

    

atishoo / paylib example snippets


use Atipay\alipay\Alipay;

$config = ['partner'=>'商户号','private_key'=>'私钥','public_key'=>'公钥','input_charset'=>'字符集','sign_type'=>'签名类型','service','cacert','transport'];
$alipay = new Alipay($config);

    $data = array(
        'notify_url'=>'"'.'这里写通知地址'.'"',
        'out_trade_no'=>'"'.'订单编号'.'"',
        'subject'=>'"'.'订单标题'.'"',
        'total_fee'=>'"'.'总金额,单位元'.'"',
        'body'=>'"'.'订单描述'.'"',
        'it_b_pay'=>'"'.'过期时间'.'m"'
        );

    // 将post接收到的数组所有元素,按照“参数=参数值”的模式用“&”字符拼接成字符串。
    $data = $alipay->createLinkstring($data);

    // 将待签名字符串使用私钥签名,且做urlencode. 注意:请求到支付宝只需要做一次urlencode.
    $rsa_sign = urlencode($alipay->rsaSign($data));

    // 把签名得到的sign和签名类型sign_type拼接在待签名字符串后面。
    $data = $data.'&sign='.'"'.$rsa_sign.'"'.'&sign_type='.'"'.alipay_sign_type.'"';
    

use Atipay\wxpay\WxPayUnifiedOrder;

$wxdata = new WxPayUnifiedOrder();