xinetzone/SpecWeave / .agents/skills/alipay-payment-integration
alipay-payment-integration
Flagged支付宝开放平台支付产品接入最佳实践。涵盖当面付、订单码支付、App 支付、JSAPI 支付、手机网站支付、电脑网站支付、预授权支付、商家扣款等全场景产品选型与集成指导。 当用户提到"接入支付宝"、"集成支付宝支付"、"对接支付"、"支付宝收款"、"加个支付功能"、"支付宝下单"、"H5 支付"、"小程序支付"、"预授权"、"付款码"、"扫码支付"、"网页支付"、"PC 支付"、"周期扣款"、"自动续费"、"会员订阅"、"连续包月"、"代扣"时,或咨询支付产品相关报错、排查问题时使用此 Skill。
references/code-examples/python/1_通用接口/统一收单交易退款查询接口代码示例.md
View on GitHub# 统一收单交易退款查询接口 - PYTHON 示例
## 请求示例
```python
import json
from alipay.aop.api.AlipayClientConfig import AlipayClientConfig
from alipay.aop.api.DefaultAlipayClient import DefaultAlipayClient
from alipay.aop.api.request.AlipayTradeFastpayRefundQueryRequest import AlipayTradeFastpayRefundQueryRequest
from alipay.aop.api.domain.AlipayTradeFastpayRefundQueryModel import AlipayTradeFastpayRefundQueryModel
# 初始化SDK
config = AlipayClientConfig()
config.server_url = "https://openapi.alipay.com/gateway.do"
config.app_id = "<-- 请填写您的AppId,例如:2019091767145019 -->"
config.app_private_key = "<-- 请填写您的应用私钥,例如:MIIEvQIBADANB ... ... -->"
config.alipay_public_key = "<-- 请填写您的支付宝公钥,例如:MIIBIjANBg... -->"
config.charset = "utf-8"
config.sign_type = "RSA2"
client = DefaultAlipayClient(alipay_client_config=config)
# 构造请求参数以调用接口
request = AlipayTradeFastpayRefundQueryRequest()
model = AlipayTradeFastpayRefundQueryModel()
# 设置支付宝交易号
model.trade_no = "2021081722001419121412730660"
# 设置商户订单号
model.out_trade_no = "2014112611001004680073956707"
# 设置退款请求号
model.out_request_no = "HZ01RF001"
# 设置查询选项
model.query_options = ["refund_detail_item_list"]
request.biz_model = model
# 第三方代调用模式下请设置app_auth_token
# request.add_other_text_param("app_auth_token", "<-- 请填写应用授权令牌 -->")
response_content = client.execute(request)
print(response_content)
# 解析响应结果
response = json.loads(response_content)
result = response.get("alipay_trade_fastpay_refund_query_response", {})
if result.get("code") == "10000":
print("调用成功")
else:
print("调用失败")
```
## 响应示例
### 正常示例
```json
{
"alipay_trade_fastpay_refund_query_response": {
"code": "10000",
"msg": "Success",
"trade_no": "2014112611001004680073956707",
"out_trade_no": "20150320010101001",
"out_request_no": "20150320010101001",
"total_amount": "100.20",
"refund_amount": "12.33",
"refund_status": "REFUND_SUCCESS",
"refund_royaltys": [
{
"refund_amount": "10",
"royalty_type": "transfer",
"result_code": "SUCCESS",
"trans_out": "2088102210397302",
"trans_out_email": "alipay-test03@alipay.com",
"trans_in": "2088102210397302",
"trans_in_email": "zen_gwen@hotmail.com",
"ori_trans_out": "2088111111111111",
"ori_trans_in": "2088111111111111"
}
],
"gmt_refund_pay": "2014-11-27 15:45:57",
"refund_detail_item_list": [
{
"fund_channel": "ALIPAYACCOUNT",
"amount": "10",
"real_amount": "11.21",
"fund_type": "DEBIT_CARD"
}
],
"send_back_fee": "88",
"deposit_back_info": {
"has_deposit_back": "true",
"dback_status": "S",
"dback_amount": "1.01",
"bank_ack_time": "2020-06-02 14:03:48",
"est_bank_receipt_time": "2020-06-02 14:03:48"
},
"refund_hyb_amount": "10.24",
"refund_charge_info_list": [
{
"refund_charge_fee": "0.01",
"switch_fee_rate": "0.01",
"charge_type": "trade",
"refund_sub_fee_detail_list": [
{
"refund_charge_fee": "0.10",
"switch_fee_rate": "0.01"
}
]
}
],
"deposit_back_info_list": [
{
"has_deposit_back": "true",
"dback_status": "S",
"dback_amount": "1.01",
"bank_ack_time": "2020-06-02 14:03:48",
"est_bank_receipt_time": "2020-06-02 14:03:48"
}
],
"refund_voucher_detail_list": [
{
"id": "2015102600073002039000002D5O",
"name": "XX超市5折优惠",
"type": "ALIPAY_FIX_VOUCHER",
"amount": "10.00",
"merchant_contribute": "9.00",
"other_contribute": "1.00",
"memo": "学生专用优惠",
"template_id": "20171030000730015359000EMZP0",
"other_contribute_detail": [
{
"contribute_type": "BRAND",
"contribute_amount": "8.00"
}
],
"purchase_buyer_contribute": "2.01",
"purchase_merchant_contribute": "1.03",
"purchase_ant_contribute": "0.82"
}
],
"pre_auth_cancel_fee": "12.45"
},
"sign": "ERITJKEIJKJHKKKKKKKHJEREEEEEEEEEEE"
}
```
### 异常示例
```json
{
"alipay_trade_fastpay_refund_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 |