xinetzone/SpecWeave / .agents/skills/alipay-payment-integration
alipay-payment-integration
Flagged支付宝开放平台支付产品接入最佳实践。涵盖当面付、订单码支付、App 支付、JSAPI 支付、手机网站支付、电脑网站支付、预授权支付、商家扣款等全场景产品选型与集成指导。 当用户提到"接入支付宝"、"集成支付宝支付"、"对接支付"、"支付宝收款"、"加个支付功能"、"支付宝下单"、"H5 支付"、"小程序支付"、"预授权"、"付款码"、"扫码支付"、"网页支付"、"PC 支付"、"周期扣款"、"自动续费"、"会员订阅"、"连续包月"、"代扣"时,或咨询支付产品相关报错、排查问题时使用此 Skill。
references/code-examples/php/5_电脑网站支付/统一收单下单并支付页面接口代码示例.md
View on GitHub# 统一收单下单并支付页面接口 - PHP 示例
## 请求示例
```php
<?php
require_once '../aop/AopClient.php';
require_once '../aop/AopCertClient.php';
require_once '../aop/AopCertification.php';
require_once '../aop/AlipayConfig.php';
require_once '../aop/request/AlipayTradePagePayRequest.php';
// 初始化SDK
$alipayClient = new AopClient(getAlipayConfig());
// 构造请求参数以调用接口
$request = new AlipayTradePagePayRequest();
$model = array();
// 设置商户订单号
$model['out_trade_no'] = "20150320010101001";
// 设置订单总金额
$model['total_amount'] = "88.88";
// 设置订单标题
$model['subject'] = "Iphone6 16G";
// 设置产品码
$model['product_code'] = "FAST_INSTANT_TRADE_PAY";
// 设置PC扫码支付的方式
$model['qr_pay_mode'] = "1";
// 设置商户自定义二维码宽度
$model['qrcode_width'] = 100;
// 设置订单包含的商品列表信息
$goodsDetail = array();
$goodsDetail0 = array();
$goodsDetail0['goods_name'] = "ipad";
$goodsDetail0['alipay_goods_id'] = "20010001";
$goodsDetail0['quantity'] = 1;
$goodsDetail0['price'] = "2000";
$goodsDetail0['goods_id'] = "apple-01";
$goodsDetail0['goods_category'] = "34543238";
$goodsDetail0['categories_tree'] = "124868003|126232002|126252004";
$goodsDetail0['show_url'] = "http://www.alipay.com/xxx.jpg";
$goodsDetail[] = $goodsDetail0;
$model['goods_detail'] = $goodsDetail;
// 设置订单绝对超时时间
$model['time_expire'] = "2016-12-31 10:05:01";
// 设置二级商户信息
$subMerchant = array();
$subMerchant['merchant_id'] = "2088000603999128";
$subMerchant['merchant_type'] = "alipay";
$model['sub_merchant'] = $subMerchant;
// 设置业务扩展参数
$extendParams = array();
$extendParams['sys_service_provider_id'] = "2088511833207846";
$extendParams['hb_fq_seller_percent'] = "100";
$extendParams['hb_fq_num'] = "3";
$extendParams['industry_reflux_info'] = "{\"scene_code\":\"metro_tradeorder\",\"channel\":\"xxxx\",\"scene_data\":{\"asset_name\":\"ALIPAY\"}}";
$extendParams['royalty_freeze'] = "true";
$extendParams['card_type'] = "S0JP0000";
$model['extend_params'] = $extendParams;
// 设置商户传入业务信息
$model['business_params'] = "{\"mc_create_trade_ip\":\"127.0.0.1\"}";
// 设置优惠参数
$model['promo_params'] = "{\"storeIdType\":\"1\"}";
// 设置请求后页面的集成方式
$model['integration_type'] = "PCWEB";
// 设置请求来源地址
$model['request_from_url'] = "https://";
// 设置商户门店编号
$model['store_id'] = "NJ_001";
// 设置商户的原始订单号
$model['merchant_order_no'] = "20161008001";
// 设置外部指定买家
$extUserInfo = array();
$extUserInfo['cert_type'] = "IDENTITY_CARD";
$extUserInfo['cert_no'] = "362334768769238881";
$extUserInfo['mobile'] = "16587658765";
$extUserInfo['name'] = "李明";
$extUserInfo['min_age'] = "18";
$extUserInfo['need_check_info'] = "F";
$extUserInfo['identity_hash'] = "27bfcd1dee4f22c8fe8a2374af9b660419d1361b1c207e9b41a754a113f38fcc";
$model['ext_user_info'] = $extUserInfo;
// 设置开票信息
$invoiceInfo = array();
$keyInfo = array();
$keyInfo['tax_num'] = "1464888883494";
$keyInfo['is_support_invoice'] = true;
$keyInfo['invoice_merchant_name'] = "ABC|003";
$invoiceInfo['key_info'] = $keyInfo;
$invoiceInfo['details'] = "[{\"code\":\"100294400\",\"name\":\"服饰\",\"num\":\"2\",\"sumPrice\":\"200.00\",\"taxRate\":\"6%\"}]";
$model['invoice_info'] = $invoiceInfo;
$request->setBizContent(json_encode($model,JSON_UNESCAPED_UNICODE));
// 如果是第三方代调用模式,请设置app_auth_token(应用授权令牌)
$pageRedirectionData = $alipayClient->pageExecute($request, "POST", "<-- 请填写应用授权令牌 -->");
// 如果需要返回GET请求,请使用
// $pageRedirectionData = $alipayClient->pageExecute($request, "GET");
echo $pageRedirectionData;
function getAlipayConfig()
{
$privateKey = '<-- 请填写您的应用私钥,例如:MIIEvQIBADANB ... ... -->';
$alipayPublicKey = '<-- 请填写您的支付宝公钥,例如:MIIBIjANBg... -->';
$alipayConfig = new AlipayConfig();
$alipayConfig->setServerUrl('https://openapi.alipay.com/gateway.do');
$alipayConfig->setAppId('<-- 请填写您的AppId,例如:2019091767145019 -->');
$alipayConfig->setPrivateKey($privateKey);
$alipayConfig->setFormat('json');
$alipayConfig->setAlipayPublicKey($alipayPublicKey);
$alipayConfig->setCharset('UTF-8');
$alipayConfig->setSignType('RSA2');
return $alipayConfig;
}
```
## 响应示例
### 正常示例
```html
<form name="punchout_form" method="post" action="https://openapi.alipay.com/gateway.do?charset=UTF-8&method=alipay.trade.page.pay&format=json&sign=ERITJKEIJKJHKKKKKKKHJEREEEEEEEEEEE&version=1.0&app_id=2017060101317939&sign_type=RSA2×tamp=2014-07-24+03%3A07%3A50">
<input type="hidden" name="biz_content" value="{"time_expire":"2016-12-31 10:05:01","extend_params":"","query_options":"[\"hyb_amount\",\"enterprise_pay_info\"]","settle_info":"","subject":"Iphone6 16G","product_code":"FAST_INSTANT_TRADE_PAY","body":"Iphone6 16G","qr_pay_mode":"1","integration_type":"PCWEB","merchant_order_no":"20161008001","sub_merchant":"","invoice_info":"","ext_user_info":"","timeout_express":"90m","disable_pay_channels":"pcredit,moneyFund,debitCardExpress","agreement_sign_params":"","royalty_info":"","store_id":"NJ_001","request_from_url":"https://","qrcode_width":"100","goods_detail":"","enable_pay_channels":"pcredit,moneyFund,debitCardExpress","out_trade_no":"20150320010101001","total_amount":"88.88","business_params":"{\"mc_create_trade_ip\":\"127.0.0.1\"}","promo_params":"{\"storeIdType\":\"1\"}"}">
<input type="submit" value="立即支付" style="display:none" >
</form>
<script>document.forms[0].submit();</script>
```
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| reverse-engineer-anythingmorluto/reaReverse engineer native, managed, Electron/JavaScript, packaged, firmware, and browser targets with REA, and build agent environments (AgentEnv bundles) of web applications from a live instance or a capture, and of Linux desktop apps with a task from a request. Use shipped-artifact or requested runtime evidence to explain features, compare versions, decompile code, or guide a reconstruction. Skip REA for ordinary source-repository architecture analysis. | Stars: 472k | Updated | Claude CodeCodex | Verified | Install |
| diagnosing-superpowersobra/superpowersUse when a superpowers session went wrong and your human partner wants to know why — repeated work, ignored plans, stumbles, poor results, a skill that didn't fire, "it took too long", "why is it so expensive", "what is it doing" — or wants to build a bug report for the superpowers maintainers, for the current session or a past one identified by id or path, on any harness. | Stars: 323k | Updated | Claude CodeCodex | Verified | Install |
| dispatching-parallel-agentsobra/superpowersUse when facing 2+ independent tasks that can be worked on without shared state or sequential dependencies | Stars: 323k | Updated | Claude CodeCodex | Verified | Install |
| executing-plansobra/superpowersUse when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is available | Stars: 323k | Updated | Claude CodeCodex | Verified | Install |