PHP code example of mrk / alipay

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

    

mrk / alipay example snippets


$config = array (
    //应用ID,您的APPID。
    'app_id' => "20xxxxxxxx69",

    //商户私钥,您的原始格式私钥,一行字符串
    'merchant_private_key' => "xxxxxx",

    //商户应用公钥,一行字符串
    'merchant_public_key' => "xxxxxxxx",

    //支付宝公钥,查看地址:https://openhome.alipay.com/platform/keyManage.htm 对应APPID下的支付宝公钥。
    'alipay_public_key' => "xxxxxx",


    //编码格式只支持GBK。
    'charset' => "UTF-8",

    //支付宝网关
    'gatewayUrl' => "https://openapi.alipay.com/gateway.do",

    //签名方式
    'sign_type'=>"RSA2",

    'return_url' => "xx",

    'notify_url' => "xx",
);

$arr = $_POST
$client = new AliPayH5($config);
$result = $client->check($arr);
if($result){
//业务

}else{
//业务
}