PHP code example of hfpf / alipay
1. Go to this page and download the library: Download hfpf/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/ */
hfpf / alipay example snippets
use Alipay\AopClient;
use Alipay\BuilderModel\AlipayTradePagePayContentBuilder;
use Alipay\Request\AlipayTradePagePayRequest;
$payRequestBuilder = new AlipayTradePagePayContentBuilder();
$payRequestBuilder->setBody('body');
$payRequestBuilder->setSubject('subject');
$payRequestBuilder->setTotalAmount(1.00);
$payRequestBuilder->setOutTradeNo('xxxxxxxxxxxxxx');
$request = new AlipayTradePagePayRequest();
$request->setNotifyUrl('https://xxxx.com/notify');
$request->setReturnUrl('https://xxxx.com/return');
$request->setBizContent($payRequestBuilder->getBizContent());
$aop = new AopClient();
$aop->appId = 'app_id';
$aop->rsaPrivateKey = 'private_key';
$aop->alipayrsaPublicKey= 'public_key';
$aop->signType = 'RSA2';
$aop->logPath = storage_path('logs/alipay.log');
$pay_url = $aop->pageExecute($request,"get");
$result['sign'] = urlencode($result['sign']);