xinetzone/SpecWeave / .agents/skills/alipay-payment-integration
alipay-payment-integration
Flagged支付宝开放平台支付产品接入最佳实践。涵盖当面付、订单码支付、App 支付、JSAPI 支付、手机网站支付、电脑网站支付、预授权支付、商家扣款等全场景产品选型与集成指导。 当用户提到"接入支付宝"、"集成支付宝支付"、"对接支付"、"支付宝收款"、"加个支付功能"、"支付宝下单"、"H5 支付"、"小程序支付"、"预授权"、"付款码"、"扫码支付"、"网页支付"、"PC 支付"、"周期扣款"、"自动续费"、"会员订阅"、"连续包月"、"代扣"时,或咨询支付产品相关报错、排查问题时使用此 Skill。
references/code-examples/csharp/2_当面付/统一收单交易支付接口代码示例.md
View on GitHub# 统一收单交易支付接口 - C# 示例
## 请求示例
```csharp
using System;
using System.Collections.Generic;
using Aop.Api;
using Aop.Api.Request;
using Aop.Api.Response;
using Aop.Api.Domain;
using Aop.Api.Util;
namespace SdkDemoTest
{
public class AlipayTradePay
{
public static void Main(string[] args)
{
// 初始化SDK
IAopClient alipayClient = new DefaultAopClient(GetAlipayConfig());
// 构造请求参数以调用接口
AlipayTradePayRequest request = new AlipayTradePayRequest();
AlipayTradePayModel model = new AlipayTradePayModel();
// 设置商户订单号
model.OutTradeNo = "20150320010101001";
// 设置订单总金额
model.TotalAmount = "88.88";
// 设置订单标题
model.Subject = "Iphone6 16G";
// 设置支付授权码
model.AuthCode = "28763443825664394";
// 设置支付场景
model.Scene = "bar_code";
// 设置产品码
model.ProductCode = "FACE_TO_FACE_PAYMENT";
// 设置卖家支付宝用户ID
model.SellerId = "2088102146225135";
// 设置订单包含的商品列表信息
List<GoodsDetail> goodsDetail = new List<GoodsDetail>();
GoodsDetail goodsDetail0 = new GoodsDetail();
goodsDetail0.GoodsName = "ipad";
goodsDetail0.Quantity = 1;
goodsDetail0.Price = "2000";
goodsDetail0.GoodsId = "apple-01";
goodsDetail0.GoodsCategory = "34543238";
goodsDetail0.CategoriesTree = "124868003|126232002|126252004";
goodsDetail0.ShowUrl = "http://www.alipay.com/xxx.jpg";
goodsDetail.Add(goodsDetail0);
model.GoodsDetail = goodsDetail;
// 设置业务扩展参数
ExtendParams extendParams = new ExtendParams();
extendParams.SysServiceProviderId = "2088511833207846";
extendParams.CardType = "S0JP0000";
model.ExtendParams = extendParams;
// 设置商户传入业务信息
BusinessParams businessParams = new BusinessParams();
businessParams.McCreateTradeIp = "127.0.0.1";
model.BusinessParams = businessParams;
// 设置优惠明细参数
PromoParam promoParams = new PromoParam();
promoParams.ActualOrderTime = "2018-09-25 22:47:33";
model.PromoParams = promoParams;
// 设置商户门店编号
model.StoreId = "NJ_001";
// 设置商户操作员编号
model.OperatorId = "yx_001";
// 设置商户机具终端编号
model.TerminalId = "NJ_T_001";
// 设置返回参数选项
List<String> queryOptions = new List<String>();
queryOptions.Add("fund_bill_list");
queryOptions.Add("voucher_detail_list");
queryOptions.Add("discount_goods_detail");
model.QueryOptions = queryOptions;
request.SetBizModel(model);
// 第三方代调用模式下请设置app_auth_token
// request.PutOtherTextParam("app_auth_token", "<-- 请填写应用授权令牌 -->");
AlipayTradePayResponse response = alipayClient.Execute(request);
if(!response.IsError)
{
Console.WriteLine("调用成功");
}
else
{
Console.WriteLine("调用失败");
}
}
private static AlipayConfig GetAlipayConfig()
{
string privateKey = "<-- 请填写您的应用私钥,例如:MIIEvQIBADANB ... ... -->";
string alipayPublicKey = "<-- 请填写您的支付宝公钥,例如:MIIBIjANBg... -->";
AlipayConfig alipayConfig = new AlipayConfig();
alipayConfig.ServerUrl = "https://openapi.alipay.com/gateway.do";
alipayConfig.AppId = "<-- 请填写您的AppId,例如:2019091767145019 -->";
alipayConfig.PrivateKey = privateKey;
alipayConfig.Format = "json";
alipayConfig.AlipayPublicKey = alipayPublicKey;
alipayConfig.Charset = "UTF-8";
alipayConfig.SignType = "RSA2";
return alipayConfig;
}
}
}
```
## 响应示例
### 正常示例
```json
{
"alipay_trade_pay_response": {
"code": "10000",
"msg": "Success",
"trade_no": "2013112011001004330000121536",
"out_trade_no": "6823789339978248",
"buyer_logon_id": "159****5620",
"total_amount": "120.88",
"receipt_amount": "88.88",
"buyer_pay_amount": "8.88",
"point_amount": "8.12",
"invoice_amount": "12.50",
"gmt_payment": "2014-11-27 15:45:57",
"fund_bill_list": [
{
"fund_channel": "ALIPAYACCOUNT",
"amount": "10",
"real_amount": "11.21"
}
],
"store_name": "证大五道口店",
"discount_goods_detail": "[{\"goods_id\":\"STANDARD1026181538\",\"goods_name\":\"雪碧\",\"discount_amount\":\"100.00\",\"voucher_id\":\"2015102600073002039000002D5O\"}]",
"buyer_open_id": "074a1CcTG1LelxKe4xQC0zgNdId0nxi95b5lsNpazWYoCo5",
"buyer_user_id": "2088101117955611",
"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",
"purchase_buyer_contribute": "2.01",
"purchase_merchant_contribute": "1.03",
"purchase_ant_contribute": "0.82"
}
],
"discount_amount": "88.88",
"mdiscount_amount": "88.88"
},
"sign": "ERITJKEIJKJHKKKKKKKHJEREEEEEEEEEEE"
}
```
### 异常示例
```json
{
"alipay_trade_pay_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 |