目录
获取支付参数拼接成的字符串
支付宝小程序内唤起签约并支付页面
获取支付参数拼接成的字符串
调用alipay.trade.app.pay接口,获取orderStr,具体参数如下:
公共请求参数
请求参数
function getOrderStr() {$orderList = array('alipay_sdk' => 'alipay-sdk-PHP-4.11.14.ALL','app_id' => '072300007148','biz_content' => '{"out_trade_no":"0817010101004","total_amount":0.01,"subject":"\u6d4b\u8bd5\u5546\u54c1","product_code":"CYCLE_PAY_AUTH","agreement_sign_params":{"external_logon_id":"F0_512333","personal_product_code":"CYCLE_PAY_AUTH_P","sign_scene":"INDUSTRY|APP","external_agreement_no":"F0_A_512333","access_params":{"channel":"ALIPAYAPP"},"period_rule_params":{"period_type":"DAY","period":"30","execute_time":"-11-01","single_amount":60,"total_amount":360,"total_payments":12}}}','charset' => 'utf-8','format' => 'json','method' => 'alipay.trade.app.pay','sign_type' => 'RSA2','timestamp' => '-11-01 20:39:23','version' => '1.0','sign' => 'Wp+BtMB1uepciIZa40iFI4Je5EV8nX/5VMzQGJTh/fX6nPTvaRH5lYii/v4GF46ZTcAHekiyMX1pJ9RhV+KrHKDLu+0WJTBIrXuS0w9wZYp12FRJgqvVivfK6svepxzequS68d8HUlCbyUwdU65yG5VFg5hufjk1xJwp7MlWalPyf8ciLUS5yRc84/J7ugb62sG8LuzG6s+ubIOOJ3aRNTKegPXUB5SRIrdp7DqjeFL8VnY+R8fPhlN4hVHcFc7aeZ2/L9K9N1IkcdRo1XHv9+68Q6twuE2OqpdKjaoCSzi2MecUYV6MNEuzRRE//69ORYicp0ndMEdANeKYJ2Lexw==');$orderStr = "";foreach ($orderList as $key => $value) {$orderStr .= $key . '=' . urlencode($value) . '&';}$orderStr = substr($orderStr, 0, strlen($orderStr) - 1);echo json_encode(array('ret' => 'OK', 'data' => $orderStr));}
支付宝小程序内唤起签约并支付页面
调用my.tradePayAPI,使用上一步得到的orderStr作为参数,在支付宝小程序内唤起签约并支付页面。
my.tradePay({orderStr: orderStr,success: (res) => {my.alert({title: 'success', // alert 框的标题content: JSON.stringify(res)});},fail: (res) => {my.alert({title: 'fail', // alert 框的标题content: JSON.stringify(res)});}});