xinetzone/SpecWeave / .agents/skills/alipay-payment-integration
alipay-payment-integration
Flagged支付宝开放平台支付产品接入最佳实践。涵盖当面付、订单码支付、App 支付、JSAPI 支付、手机网站支付、电脑网站支付、预授权支付、商家扣款等全场景产品选型与集成指导。 当用户提到"接入支付宝"、"集成支付宝支付"、"对接支付"、"支付宝收款"、"加个支付功能"、"支付宝下单"、"H5 支付"、"小程序支付"、"预授权"、"付款码"、"扫码支付"、"网页支付"、"PC 支付"、"周期扣款"、"自动续费"、"会员订阅"、"连续包月"、"代扣"时,或咨询支付产品相关报错、排查问题时使用此 Skill。
references/code-examples/php/1_通用接口/统一收单交易查询接口代码示例.md
View on GitHub# 统一收单交易查询接口 - PHP 示例
## 请求示例
```php
<?php
require_once '../aop/AopClient.php';
require_once '../aop/AlipayConfig.php';
require_once '../aop/request/AlipayTradeQueryRequest.php';
// 初始化SDK
$alipayClient = new AopClient(getAlipayConfig());
// 构造请求参数以调用接口
$request = new AlipayTradeQueryRequest();
$model = array();
// 设置订单支付时传入的商户订单号
$model['out_trade_no'] = "20150320010101001";
// 设置支付宝交易号
$model['trade_no'] = "2014112611001004680073956707";
// 设置银行间联模式下有用
$model['org_pid'] = "2088101117952222";
// 设置查询选项
$queryOptions = array();
$queryOptions[] = "trade_settle_info";
$model['query_options'] = $queryOptions;
$request->setBizContent(json_encode($model,JSON_UNESCAPED_UNICODE));
// 如果是第三方代调用模式,请设置app_auth_token(应用授权令牌)
// $responseResult = $alipayClient->execute($request, null, "<-- 请填写应用授权令牌 -->", null);
$responseResult = $alipayClient->execute($request);
$responseApiName = str_replace(".","_",$request->getApiMethodName())."_response";
$response = $responseResult->$responseApiName;
if(!empty($response->code)&&$response->code=="10000"){
echo("调用成功");
}
else{
echo("调用失败");
}
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;
}
```
## 响应示例
### 正常示例
```json
{
"alipay_trade_query_response": {
"code": "10000",
"msg": "Success",
"trade_no": "2013112011001004330000121536",
"out_trade_no": "6823789339978248",
"buyer_logon_id": "159****5620",
"trade_status": "TRADE_CLOSED",
"additional_status": "SELLER_NOT_RECEIVED",
"total_amount": "88.88",
"trans_currency": "TWD",
"settle_currency": "USD",
"settle_amount": "2.96",
"pay_currency": "CNY",
"pay_amount": "8.88",
"settle_trans_rate": "30.025",
"trans_pay_rate": "0.264",
"send_pay_date": "2014-11-27 15:45:57",
"buyer_pay_amount": "8.88",
"invoice_amount": "12.11",
"point_amount": "10",
"receipt_amount": "15.25",
"store_id": "NJ_S_001",
"terminal_id": "NJ_T_001",
"fund_bill_list": [
{
"fund_channel": "ALIPAYACCOUNT",
"amount": "10",
"real_amount": "11.21"
}
],
"store_name": "证大五道口店",
"buyer_open_id": "01501o8f93I3nJAGB1jG4ONxtxV25DCN3Gec3uggnC4CJU0",
"buyer_user_id": "2088101117955611",
"industry_sepc_detail_gov": "{\"registration_order_pay\":{\"brlx\":\"1\",\"cblx\":\"1\"}}",
"industry_sepc_detail_acc": "{\"registration_order_pay\":{\"brlx\":\"1\",\"cblx\":\"1\"}}",
"charge_amount": "8.88",
"charge_flags": "bluesea_1",
"settlement_id": "2018101610032004620239146945",
"trade_settle_info": {
"trade_settle_detail_list": [
{
"operation_type": "replenish",
"operation_serial_no": "2321232323232",
"operation_dt": "2019-05-16 09:59:17",
"trans_out": "208811****111111",
"trans_in": "208811****111111",
"amount": "10.00",
"ori_trans_out": "2088111111111111",
"ori_trans_in": "2088111111111111"
}
],
"trade_unsettled_amount": "1.1"
},
"auth_trade_pay_mode": "CREDIT_PREAUTH_PAY",
"discount_amount": "88.88",
"subject": "Iphone6 16G",
"body": "Iphone6 16G",
"alipay_sub_merchant_id": "2088301372182171",
"ext_infos": "{\"action\":\"cancel\"}",
"passback_params": "merchantBizType%3d3C%26merchantBizNo%3d2016010101111",
"buyer_user_type": "PRIVATE",
"mdiscount_amount": "88.88",
"hb_fq_pay_info": {
"user_install_num": "3",
"fq_inst_id": "ALIPAY"
},
"credit_pay_mode": "creditAdvanceV2",
"credit_biz_order_id": "ZMCB99202103310000450000041833",
"hyb_amount": "10.24",
"bkagent_resp_info": {
"bindtrx_id": "123412341234",
"bindclrissr_id": "01",
"bindpyeracctbk_id": "123123123123",
"bkpyeruser_code": "123451234512345",
"estter_location": "+37.28/-121.268"
},
"biz_settle_mode": "PERIOD",
"req_goods_detail": [
{
"goods_id": "apple-01",
"alipay_goods_id": "20010001",
"goods_name": "ipad",
"quantity": 1,
"price": "2000",
"goods_category": "34543238",
"categories_tree": "124868003|126232002|126252004",
"body": "特价手机",
"show_url": "http://www.alipay.com/xxx.jpg",
"goods_ean_id": "6972829161111",
"out_item_id": "outItem_01",
"out_sku_id": "outSku_01"
}
],
"fulfillment_detail_list": [
{
"fulfillment_amount": "80.00",
"out_request_no": "20200320010101001",
"gmt_payment": "2021-03-17 09:45:57"
}
],
"period_scene": "账期交易的场景。",
"async_pay_apply_status": "S",
"cashier_type": "APP",
"tap_pay_info": {
"payment_medium_type": "TAP_PAY",
"total_discount_name": "碰一下共减",
"total_discount_amount": "2.00"
},
"pre_auth_pay_amount": "12.46",
"purchase_entity": "3008",
"unpaid_reason": "其他原因"
},
"sign": "ERITJKEIJKJHKKKKKKKHJEREEEEEEEEEEE"
}
```
### 异常示例
```json
{
"alipay_trade_query_response": {
"code": "20000",
"msg": "Service Currently Unavailable",
"sub_code": "isp.unknow-error",
"sub_msg": "系统繁忙"
},
"sign": "ERITJKEIJKJHKKKKKKKHJEREEEEEEEEEEE"
}
```
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 |