PHP code example of masterton / alipay-sdk-php
1. Go to this page and download the library: Download masterton/alipay-sdk-php 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/ */
masterton / alipay-sdk-php example snippets
// use Alipay\AopSdk;
$init = new Alipay\AopSdk;
$aop = new AopClient;
$aop->gatewayUrl = 'https://openapi.alipaydev.com/gateway.do';
$aop->appId = '请填写APPID';
$aop->rsaPrivateKey = '请填写商户私钥';
$aop->apiVersion = '1.0';
$aop->signType = 'RSA2';
$aop->postCharset= 'utf-8';
$aop->format='json';
$request = new AlipayTradePagePayRequest();
$request->setReturnUrl('请填写您的页面同步跳转地址');
$request->setNotifyUrl('请填写您的异步通知地址');
$request->setBizContent('{"product_code":"FAST_INSTANT_TRADE_PAY","out_trade_no":"20150320010101002","subject":"Iphone6 16G","total_amount":"0.01","body":"Iphone6 16G"}');
//请求
$result = $aop->pageExecute($request);
echo $result;