PHP code example of jucheng / alipay

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

    

jucheng / alipay example snippets




//AppID
$appid = 1400009099; 

// 用户私钥
$rsaPrivateKey = "用户私钥";

//支付宝公钥
$alipayrsaPublicKey="支付宝公钥";

//支付回调地址
$notifyUrl="https://www.baidu.com";

use alipay;
$app_client=new alipay\AlipayClient($appid,$rsaPrivateKey,$alipayrsaPublicKey);
$data["total_amount"]="0.01";
$data["subject"]="预定酒店消费";
$data["out_trade_no"]="JD201909051809240201";
$data["product_code"]="QUICK_MSECURITY_PAY";
$result=$app_client->appPay($data,$notifyUrl);

use alipay;
$app_client=new alipay\AlipayClient($appid,$rsaPrivateKey,$alipayrsaPublicKey);
$flag = $app_client->rsaCheckV1($_POST, NULL, "RSA2");

use alipay;
$app_client=new alipay\AlipayClient($appid,$rsaPrivateKey,$alipayrsaPublicKey);
$data["out_trade_no"]="JD201909051809240201";
$data["trade_no"]="2019090922001444760542604693";
$data["refund_amount"]="0.01";
$result=$app_client->refundOrder($data);