PHP code example of fantasystudio / easypay

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

    

fantasystudio / easypay example snippets


composer 

use \FantasyStudio\EasyPay\AliPay\Qr\Qr;

$qr = new Qr();
$qr->setAppId("201703300571632");
$qr->setSignType("RSA");
$qr->setPrivateKey("私钥内容,不要携带-----BEGIN RSA PRIVATE KEY-----");
$qr->purchase([
    "total_amount" => 0.01, "out_trade_no" => "2120960179264092", "subject" => "subjectaa"
]);

$result = $qr->sendPaymentRequest(); //发起扫码支付

var_dump($result->getRequestData()); //获取请求数据
var_dump($result->getResponseData()); //获取网关响应数据
var_dump($result->isSuccessful()); // 请求是否成功