添加网站文件

This commit is contained in:
2025-12-22 13:59:40 +08:00
commit 117aaf83d1
19468 changed files with 2111999 additions and 0 deletions

View File

@@ -0,0 +1 @@
*.* linguist-language=java

16
vendor/alipaysdk/easysdk/.gitignore vendored Normal file
View File

@@ -0,0 +1,16 @@
.DS_Store
node_modules
logs
.libraries.json
libraries
.idea
*.iml
target
dependency-reduced-pom.xml
bin
obj
.vs
publish/alipay-easysdk

821
vendor/alipaysdk/easysdk/APIDoc.md vendored Normal file
View File

@@ -0,0 +1,821 @@
# 基础能力 Base
## 用户授权 OAuth
### 获取授权访问令牌
* API声明
getToken(code: string)
* 入参说明
| 字段名 | 类型 | 必填 | 说明 |
|------|--------|----|----|
| code | string | | 授权码用户对应用授权后得到 |
* 出参说明
可前往[alipay.system.oauth.token](https://docs.open.alipay.com/api_9/alipay.system.oauth.token)查看更加详细的参数说明。
### 刷新授权访问令牌
* API声明
refreshToken(refreshToken: string)
* 入参说明
| 字段名 | 类型 | 必填 | 说明 |
|------|--------|----|----|
| refreshToken | string | | 刷新令牌上次换取访问令牌时得到见出参的refresh_token字段 |
* 出参说明
可前往[alipay.system.oauth.token](https://docs.open.alipay.com/api_9/alipay.system.oauth.token)查看更加详细的参数说明。
---
## 小程序二维码 Qrcode
### 创建小程序二维码
* API声明
create(urlParam: string, queryParam: string, describe: string)
* 入参说明
| 字段名 | 类型 | 必填 | 说明 |
|------|--------|----|----|
| urlParam | string | | 小程序中能访问到的页面路径例如page/component/component-pages/view/view |
| queryParam | string | | 小程序的启动参数打开小程序的query 在小程序 onLaunch的方法中获取 |
| describe | string | | 二维码描述 |
* 出参说明
可前往[alipay.open.app.qrcode.create](https://docs.open.alipay.com/api_5/alipay.open.app.qrcode.create)查看更加详细的参数说明。
---
## 图片 Image
### 上传图片
* API声明
upload(imageName: string, imageFilePath: string)
* 入参说明
| 字段名 | 类型 | 必填 | 说明 |
|------|--------|----|----|
| imageName | string | | 图片名称 |
| imageFilePath | string | | 待上传的本地图片文件路径 |
* 出参说明
可前往[alipay.offline.material.image.upload](https://docs.open.alipay.com/api_3/alipay.offline.material.image.upload)查看更加详细的参数说明。
---
## 视频 Video
### 上传视频
* API声明
upload(videoName: string, videoFilePath: string)
* 入参说明
| 字段名 | 类型 | 必填 | 说明 |
|------|--------|----|----|
| videoName | string | | 视频名称 |
| videoFilePath | string | | 待上传的本地视频文件路径 |
* 出参说明
可前往[alipay.offline.material.image.upload](https://docs.open.alipay.com/api_3/alipay.offline.material.image.upload)查看更加详细的参数说明。
---
# 营销能力 Marketing
## 生活号 OpenLife
### 创建图文消息内容
* API声明
createImageTextContent(title: string, cover: string, content: string, contentComment: string, ctype: string, benefit: string, extTags: string, loginIds: string)
* 入参说明
| 字段名 | 类型 | 必填 | 说明 |
|------|--------|----|----|
| title | string | | 标题 |
| cover | string | | 封面图URL, 尺寸为996*450最大不超过3M支持.jpg.png格式请先调用上传图片接口获得图片URL |
| content | string | | 消息正文支持富文本 |
| contentComment | string | | 是否允许评论T允许F不允许默认不允许 |
| ctype | string | | 图文类型填activity表示活动图文不填默认普通图文 |
| benefit | string | | 活动利益点图文类型ctype为activity类型时才需要传最多10个字符 |
| extTags | string | | 关键词列表英文逗号分隔最多不超过5个 |
| loginIds | string | | 可预览支付宝账号列表需要预览时才填写 英文逗号分隔最多不超过10个 |
* 出参说明
可前往[alipay.open.public.message.content.create](https://docs.open.alipay.com/api_6/alipay.open.public.message.content.create)查看更加详细的参数说明。
### 更新图文消息内容
* API声明
modifyImageTextContent(contentId: string, title: string, cover: string, content: string, couldComment: string, ctype: string, benefit: string, extTags: string, loginIds: string)
* 入参说明
| 字段名 | 类型 | 必填 | 说明 |
|------|--------|----|----|
| contentId | string | | 内容ID通过创建图文内容消息接口返回 |
| title | string | | 标题 |
| cover | string | | 封面图URL, 尺寸为996*450最大不超过3M支持.jpg.png格式请先调用上传图片接口获得图片URL |
| content | string | | 消息正文支持富文本 |
| contentComment | string | | 是否允许评论T允许F不允许默认不允许 |
| ctype | string | | 图文类型填activity表示活动图文不填默认普通图文 |
| benefit | string | | 活动利益点图文类型ctype为activity类型时才需要传最多10个字符 |
| extTags | string | | 关键词列表英文逗号分隔最多不超过5个 |
| loginIds | string | | 可预览支付宝账号列表需要预览时才填写 英文逗号分隔最多不超过10个 |
* 出参说明
可前往[alipay.open.public.message.content.modify](https://docs.open.alipay.com/api_6/alipay.open.public.message.content.modify)查看更加详细的参数说明。
### 群发本文消息
* API声明
sendText(text: string)
* 入参说明
| 字段名 | 类型 | 必填 | 说明 |
|------|--------|----|----|
| text | string | | 文本消息内容 |
* 出参说明
可前往[alipay.open.public.message.total.send](https://docs.open.alipay.com/api_6/alipay.open.public.message.total.send)查看更加详细的参数说明。
### 群发图文消息
* API声明
sendImageText(articles: [ Article ])
* 入参说明
| 字段名 | 类型 | 必填 | 说明 |
|------|--------|----|----|
| articles | Article数组 | | 图文消息内容 |
Article对象说明
| 字段名 | 类型 | 必填 | 说明 |
|------|--------|----|----|
| title | string | | 图文消息标题 |
| desc | string | | 图文消息描述 |
| imageUrl | string | 特殊可选 | 图片链接对于多条图文消息的第一条消息该字段不能为空请先调用上传图片接口获得图片URL |
| url | string | | 点击图文消息跳转的链接 |
| actionName | string | | 链接文字 |
* 出参说明
可前往[alipay.open.public.message.total.send](https://docs.open.alipay.com/api_6/alipay.open.public.message.total.send)查看更加详细的参数说明。
### 单发模板消息
* API声明
sendSingleMessage(toUserId: string, template: Template)
* 入参说明
| 字段名 | 类型 | 必填 | 说明 |
|------|--------|----|----|
| toUserId | string | | 消息接收用户的UserId |
| template | Template | | 消息接收用户的UserId |
Template对象说明
| 字段名 | 类型 | 必填 | 说明 |
|------|--------|----|----|
| templateId | string | | 消息模板ID |
| context | Context | | 消息模板上下文即模板中定义的参数及参数值 |
Context对象说明
| 字段名 | 类型 | 必填 | 说明 |
|------|--------|----|----|
| headColor | string | | 顶部色条的色值比如#85be53 |
| url | string | | 点击消息后承接页的地址 |
| actionName | string | | 底部链接描述文字查看详情最多能传8个汉字或16个英文字符 |
| keyword1 | Keyword | | 模板中占位符的值及文字颜色 |
| keyword2 | Keyword | | 模板中占位符的值及文字颜色 |
| first | Keyword | | 模板中占位符的值及文字颜色 |
| remark | Keyword | | 模板中占位符的值及文字颜色 |
Keyword对象说明
| 字段名 | 类型 | 必填 | 说明 |
|------|--------|----|----|
| color | string | | 当前文字颜色比如#85be53 |
| value | string | | 模板中占位符的值 |
* 出参说明
可前往[alipay.open.public.message.single.send](https://docs.open.alipay.com/api_6/alipay.open.public.message.single.send)查看更加详细的参数说明。
### 生活号消息撤回
* API声明
recallMessage(messageId: string)
* 入参说明
| 字段名 | 类型 | 必填 | 说明 |
|------|--------|----|----|
| messageId | string | | 消息ID |
* 出参说明
可前往[alipay.open.public.life.msg.recall](https://docs.open.alipay.com/api_6/alipay.open.public.life.msg.recall)查看更加详细的参数说明。
### 模板消息行业设置
* API声明
setIndustry(primaryIndustryCode: string, primaryIndustryName: string, secondaryIndustryCode: string, secondaryIndustryName: string)
* 入参说明
| 字段名 | 类型 | 必填 | 说明 |
|------|--------|----|----|
| primaryIndustryCode | string | | 服务窗消息模板所属主行业一级编码查看[行业信息](https://alipay.open.taobao.com/doc2/detail?treeId=197&docType=1&articleId=105043) |
| primaryIndustryName | string | | 服务窗消息模板所属主行业一级名称 |
| secondaryIndustryCode | string | | 服务窗消息模板所属主行业二级编码 |
| secondaryIndustryName | string | | 服务窗消息模板所属主行业二级名称 |
* 出参说明
可前往[alipay.open.public.template.message.industry.modify](https://docs.open.alipay.com/api_6/alipay.open.public.template.message.industry.modify)查看更加详细的参数说明。
### 生活号查询行业设置
* API声明
getIndustry()
* 入参说明
* 出参说明
可前往[alipay.open.public.setting.category.query](https://docs.open.alipay.com/api_6/alipay.open.public.setting.category.query)查看更加详细的参数说明。
---
## 支付宝卡包 Pass
### 卡券模板创建
* API声明
createTemplate(uniqueId: string, tplContent: string)
* 入参说明
| 字段名 | 类型 | 必填 | 说明 |
|------|--------|----|----|
| uniqueId | string | | 商户用于控制模版的唯一性可以使用时间戳保证唯一性 |
| tplContent | string | | 模板内容信息遵循JSON规范详情参见tpl_content[参数说明](https://doc.open.alipay.com/doc2/detail.htm?treeId=193&articleId=105249&docType=1#tpl_content) |
* 出参说明
可前往[alipay.pass.template.add](https://docs.open.alipay.com/api_24/alipay.pass.template.add)查看更加详细的参数说明。
### 卡券模板更新
* API声明
updateTemplate(uniqueId: string, tplContent: string)
* 入参说明
| 字段名 | 类型 | 必填 | 说明 |
|------|--------|----|----|
| uniqueId | string | | 商户用于控制模版的唯一性可以使用时间戳保证唯一性 |
| tplContent | string | | 模板内容信息遵循JSON规范详情参见tpl_content[参数说明](https://doc.open.alipay.com/doc2/detail.htm?treeId=193&articleId=105249&docType=1#tpl_content) |
* 出参说明
可前往[alipay.pass.template.update](https://docs.open.alipay.com/api_24/alipay.pass.template.update)查看更加详细的参数说明。
### 卡券实例发放
* API声明
addInstance(tplId: string, tplParams: string, recognitionType: string, recognitionInfo: string)
* 入参说明
| 字段名 | 类型 | 必填 | 说明 |
|------|--------|----|----|
| tplId | string | | 支付宝pass模版ID即调用模板创建接口时返回的tpl_id |
| tplParams | string | | 模版动态参数信息对应模板中$变量名$的动态参数见模板创建接口返回值中的tpl_params字段示例 |
| recognitionType | string | | Alipass添加对象识别类型填写1表示订单信息 |
| recognitionInfo | string | | 支付宝用户识别信息参见[UID发券组件对接文档](https://docs.open.alipay.com/199/sy3hs4 ) |
* 出参说明
可前往[alipay.pass.instance.add](https://docs.open.alipay.com/api_24/alipay.pass.instance.add)查看更加详细的参数说明。
### 卡券实例更新
* API声明
updateInstance(serialNumber: string, channelId: string, tplParams: string, status: string, verifyCode: string, verifyType: string)
* 入参说明
| 字段名 | 类型 | 必填 | 说明 |
|------|--------|----|----|
| serialNumber | string | | 商户指定卡券唯一值卡券JSON模板中fileInfo->serialNumber字段对应的值 |
| channelId | string | | 代理商代替商户发放卡券后再代替商户更新卡券时此值为商户的PID/AppID |
| tplParams | string | | Alipass添加对象识别类型填写1表示订单信息 |
| status | string | | 券状态支持更新为USEDCLOSED两种状态 |
| verifyCode | string | | 核销码串值当状态变更为USED时建议传该值正常为模板中核销区域Operation对应的message值 |
| verifyType | string | | 核销方式该值正常为模板中核销区域Operation对应的format值verifyCode和verifyType需同时传入 |
* 出参说明
可前往[alipay.pass.instance.update](https://docs.open.alipay.com/api_24/alipay.pass.instance.update)查看更加详细的参数说明。
---
## 小程序模板消息 TemplateMessage
### 发送模板消息
* API声明
send(toUserId: string, formId: string, userTemplateId: string, page: string, data: string)
* 入参说明
| 字段名 | 类型 | 必填 | 说明 |
|------|--------|----|----|
| toUserId | string | | 发送消息的支付宝账号 |
| formId | string | | 用户发生的交易行为的交易号或者用户在小程序产生表单提交的表单号用于信息发送的校验 |
| userTemplateId | string | | 用户申请的模板id号固定的模板id会发送固定的消息 |
| page | string | | 小程序的跳转页面用于消息中心用户点击之后详细跳转的小程序页面例如page/component/index |
| data | string | | 开发者需要发送模板消息中的自定义部分来替换模板的占位符例如{"keyword1": {"value" : "12:00"},"keyword2": {"value" : "20180808"},"keyword3": {"value" : "支付宝"}} |
* 出参说明
可前往[alipay.open.app.mini.templatemessage.send](https://docs.open.alipay.com/api_5/alipay.open.app.mini.templatemessage.send)查看更加详细的参数说明。
---
# 会员能力 Member
## 支付宝身份认证 Identification
### 身份认证初始化
* API声明
init(outerOrderNo: string, bizCode: string, identityParam: IdentityParam, merchantConfig: MerchantConfig)
* 入参说明
| 字段名 | 类型 | 必填 | 说明 |
|------|--------|----|----|
| outerOrderNo | string | | 商户请求的唯一标识商户要保证其唯一性值为32位长度的字母数字组合建议前面几位字符是商户自定义的简称中间可以使用一段时间后段可以使用一个随机或递增序列 |
| bizCode | string | | 认证场景码入参支持的认证场景码和商户签约的认证场景相关可选值有如下FACE多因子人脸认证CERT_PHOTO多因子证照认证CERT_PHOTO_FACE多因子证照和人脸认证SMART_FACE多因子快捷认证 |
| identityParam | IdentityParam | | 需要验证的身份信息参数 |
| merchantConfig | MerchantConfig | | 商户个性化配置 |
IdentityParam对象说明
| 字段名 | 类型 | 必填 | 说明 |
|------|--------|----|----|
| identityType | string | | 身份信息参数类型必须传入CERT_INFO |
| certType | string | | 证件类型当前支持身份证必须传入IDENTITY_CARD |
| certName | string | | 真实姓名 |
| certNo | string | | 证件号码 |
MerchantConfig对象说明
| 字段名 | 类型 | 必填 | 说明 |
|------|--------|----|----|
| returnUrl | string | | 需要回跳的目标URL地址一般指定为商户业务页面 |
* 出参说明
可前往[alipay.user.certify.open.initialize](https://docs.open.alipay.com/api_2/alipay.user.certify.open.initialize)查看更加详细的参数说明。
### 生成认证链接
* API声明
certify(certifyId: string)
* 入参说明
| 字段名 | 类型 | 必填 | 说明 |
|------|--------|----|----|
| certifyId | string | | 本次申请操作的唯一标识由身份认证初始化接口调用后生成后续的操作都需要用到 |
* 出参说明
可前往[alipay.user.certify.open.certify](https://docs.open.alipay.com/api_2/alipay.user.certify.open.certify)查看更加详细的参数说明。
### 身份认证记录查询
* API声明
query(certifyId: string)
* 入参说明
| 字段名 | 类型 | 必填 | 说明 |
|------|--------|----|----|
| certifyId | string | | 身份认证操作的唯一标识由身份认证初始化接口调用后生成 |
* 出参说明
可前往[alipay.user.certify.open.query](https://docs.open.alipay.com/api_2/alipay.user.certify.open.query)查看更加详细的参数说明。
---
# 支付能力 Payment
## 通用接口 Common
### 创建交易
* API声明
create(subject: string, outTradeNo: string, totalAmount: string, buyerId: string)
* 入参说明
| 字段名 | 类型 | 必填 | 说明 |
|------|--------|----|----|
| subject | string | | 订单标题 |
| outTradeNo | string | | 商户订单号64个字符以内可包含字母数字下划线需保证在商户端不重复 |
| totalAmount | string | | 订单总金额单位为元精确到小数点后两位取值范围[0.01,100000000] |
| buyerId | string | | 买家的支付宝唯一用户号2088开头的16位纯数字 |
* 出参说明
可前往[alipay.trade.create](https://docs.open.alipay.com/api_1/alipay.trade.create)查看更加详细的参数说明。
### 查询交易
* API声明
query(outTradeNo: string)
* 入参说明
| 字段名 | 类型 | 必填 | 说明 |
|------|--------|----|----|
| outTradeNo | string | | 交易创建时传入的商户订单号 |
* 出参说明
可前往[alipay.trade.query](https://docs.open.alipay.com/api_1/alipay.trade.query)查看更加详细的参数说明。
### 交易退款
* API声明
refund(outTradeNo: string, refundAmount: string)
* 入参说明
| 字段名 | 类型 | 必填 | 说明 |
|------|--------|----|----|
| outTradeNo | string | | 交易创建时传入的商户订单号 |
| refundAmount | string | | 需要退款的金额该金额不能大于订单金额单位为元支持两位小数 |
* 出参说明
可前往[alipay.trade.refund](https://docs.open.alipay.com/api_1/alipay.trade.refund)查看更加详细的参数说明。
### 关闭交易
* API声明
close(outTradeNo: string)
* 入参说明
| 字段名 | 类型 | 必填 | 说明 |
|------|--------|----|----|
| outTradeNo | string | | 交易创建时传入的商户订单号 |
* 出参说明
可前往[alipay.trade.close](https://docs.open.alipay.com/api_1/alipay.trade.close)查看更加详细的参数说明。
### 撤销交易
* API声明
cancel(outTradeNo: string)
* 入参说明
| 字段名 | 类型 | 必填 | 说明 |
|------|--------|----|----|
| outTradeNo | string | | 交易创建时传入的商户订单号 |
* 出参说明
可前往[alipay.trade.cancel](https://docs.open.alipay.com/api_1/alipay.trade.cancel)查看更加详细的参数说明。
### 交易退款查询
* API声明
queryRefund(outTradeNo: string, outRequestNo: string)
* 入参说明
| 字段名 | 类型 | 必填 | 说明 |
|------|--------|----|----|
| outTradeNo | string | | 交易创建时传入的商户订单号 |
| outRequestNo | string | | 请求退款接口时传入的退款请求号如果在退款请求时未传入则该值为创建交易时的外部交易号 |
* 出参说明
可前往[alipay.trade.fastpay.refund.query](https://opendocs.alipay.com/apis/api_1/alipay.trade.fastpay.refund.query)查看更加详细的参数说明。
### 查询对账单下载地址
* API声明
downloadBill(billType: string, billDate: string)
* 入参说明
| 字段名 | 类型 | 必填 | 说明 |
|------|--------|----|----|
| billType | string | | 账单类型商户通过接口或商户经开放平台授权后其所属服务商通过接口可以获取以下账单类型tradesigncustomertrade指商户基于支付宝交易收单的业务账单signcustomer是指基于商户支付宝余额收入及支出等资金变动的帐务账单 |
| billDate | string | | 账单时间日账单格式为yyyy-MM-dd最早可下载2016年1月1日开始的日账单月账单格式为yyyy-MM最早可下载2016年1月开始的月账单 |
* 出参说明
可前往[alipay.data.dataservice.bill.downloadurl.query](https://opendocs.alipay.com/apis/api_15/alipay.data.dataservice.bill.downloadurl.query)查看更加详细的参数说明。
### 异步通知验签
* API声明
verifyNotify(parameters: map[string]string)
* 入参说明
| 字段名 | 类型 | 必填 | 说明 |
|------|--------|----|----|
| parameters | map[string]string | | 异步通知中收到的待验签的所有参数 |
---
## 花呗分期 Huabei
### 创建花呗分期交易
* API声明
create(subject: string, outTradeNo: string, totalAmount: string, buyerId: string, extendParams: HuabeiConfig)
* 入参说明
| 字段名 | 类型 | 必填 | 说明 |
|------|--------|----|----|
| subject | string | | 订单标题 |
| outTradeNo | string | | 商户订单号64个字符以内可包含字母数字下划线需保证在商户端不重复 |
| totalAmount | string | | 订单总金额单位为元精确到小数点后两位取值范围[0.01,100000000] |
| buyerId | string | | 买家的支付宝用户ID如果为空会从传入的码值信息中获取买家ID |
| extendParams | HuabeiConfig | | 花呗交易扩展参数 |
HuabeiConfig对象说明
| 字段名 | 类型 | 必填 | 说明 |
|------|--------|----|----|
| hbFqNum | string | | 花呗分期数仅支持传入3612 |
| hbFqSellerPercent | string | | 代表卖家承担收费比例商家承担手续费传入100用户承担手续费传入0仅支持传入1000两种 |
* 出参说明
可前往[alipay.trade.create](https://docs.open.alipay.com/api_1/alipay.trade.create)查看更加详细的参数说明。
---
<a name="faceToFace"/>
## 当面付 FaceToFace
### 当面付交易付款
* API声明
pay(subject: string, outTradeNo: string, totalAmount: string, authCode: string)
* 入参说明
| 字段名 | 类型 | 必填 | 说明 |
|------|--------|----|----|
| subject | string | | 订单标题 |
| outTradeNo | string | | 交易创建时传入的商户订单号 |
| totalAmount | string | | 订单总金额单位为元精确到小数点后两位取值范围[0.01,100000000] |
| authCode | string | | 支付授权码即买家的付款码数字 |
* 出参说明
可前往[alipay.trade.pay](https://docs.open.alipay.com/api_1/alipay.trade.pay)查看更加详细的参数说明。
* 返佣说明
ISV对接当面付产品需涉及返佣时请先阅读[政策详情](https://opendocs.alipay.com/p/00fc2g)与[合作攻略](https://opendocs.alipay.com/open/300/taphxd)。
**对接时必须在支付接口的extend_params参数中设置sys_service_provider_id返佣参数 参数值为签约返佣协议的PID**示例代码如下Java为例
```java
Map<String, String> extendParams = new HashMap<>();
extendParams.put("sys_service_provider_id", "<--请填写ISV签约协议的PID比如2088511833207846-->");
AlipayTradePayResponse response = Factory.Payment.FaceToFace()
.agent("<--请填写商户应用授权后获取到的app_auth_token比如ca34ea491e7146cc87d25fca24c4cD11-->")
.optional("extend_params", extendParams)
.pay("iPhone6 16G", "64628156-f784-4572-9540-485b7c91b850", "0.01", "289821051157962364");
```
---
### 交易预创建生成正扫二维码
* API声明
precreate(subject: string, outTradeNo: string, totalAmount: string)
* 入参说明
| 字段名 | 类型 | 必填 | 说明 |
|------|--------|----|----|
| subject | string | | 订单标题 |
| outTradeNo | string | | 交易创建时传入的商户订单号 |
| totalAmount | string | | 订单总金额单位为元精确到小数点后两位取值范围[0.01,100000000] |
* 出参说明
可前往[alipay.trade.precreate](https://docs.open.alipay.com/api_1/alipay.trade.precreate)查看更加详细的参数说明。
* 返佣说明
ISV对接当面付产品需涉及返佣时请先阅读[政策详情](https://opendocs.alipay.com/p/00fc2g)与[合作攻略](https://opendocs.alipay.com/open/300/taphxd)。
**对接时必须在支付接口的extend_params参数中设置sys_service_provider_id返佣参数 参数值为签约返佣协议的PID**示例代码如下Java为例
```java
Map<String, String> extendParams = new HashMap<>();
extendParams.put("sys_service_provider_id", "<--请填写ISV签约协议的PID比如2088511833207846-->");
AlipayTradePrecreateResponse response = Payment.FaceToFace()
.agent("<--请填写商户应用授权后获取到的app_auth_token比如ca34ea491e7146cc87d25fca24c4cD11-->")
.optional("extend_params", extendParams)
.preCreate("iPhone6 16G", "64628156-f784-4572-9540-485b7c91b850", "0.01");
```
---
## 电脑网站 Page
### 电脑网站支付
* API声明
pay(subject: string, outTradeNo: string, totalAmount: string, returnUrl: string)
* 入参说明
| 字段名 | 类型 | 必填 | 说明 |
|------|--------|----|----|
| subject | string | | 订单标题 |
| outTradeNo | string | | 交易创建时传入的商户订单号 |
| totalAmount | string | | 订单总金额单位为元精确到小数点后两位取值范围[0.01,100000000] |
| returnUrl | string | | 支付成功后同步跳转的页面是一个http/https开头的字符串 |
* 出参说明
可前往[alipay.trade.page.pay](https://docs.open.alipay.com/api_1/alipay.trade.page.pay)查看更加详细的参数说明。
---
## 手机网站 Wap
### 手机网站支付
* API声明
pay(subject: string, outTradeNo: string, totalAmount: string, quitUrl: string, returnUrl: string)
* 入参说明
| 字段名 | 类型 | 必填 | 说明 |
|------|--------|----|----|
| subject | string | | 订单标题 |
| outTradeNo | string | | 交易创建时传入的商户订单号 |
| totalAmount | string | | 订单总金额单位为元精确到小数点后两位取值范围[0.01,100000000] |
| quitUrl | string | | 用户付款中途退出返回商户网站的地址 |
| returnUrl | string | | 支付成功后同步跳转的页面是一个http/https开头的字符串 |
* 出参说明
可前往[alipay.trade.wap.pay](https://docs.open.alipay.com/api_1/alipay.trade.wap.pay)查看更加详细的参数说明。
---
## App支付 App
### 手机APP支付
* API声明
pay(subject: string, outTradeNo: string, totalAmount: string)
* 入参说明
| 字段名 | 类型 | 必填 | 说明 |
|------|--------|----|----|
| subject | string | | 订单标题 |
| outTradeNo | string | | 交易创建时传入的商户订单号 |
| totalAmount | string | | 订单总金额单位为元精确到小数点后两位取值范围[0.01,100000000] |
* 出参说明
可前往[alipay.trade.app.pay](https://docs.open.alipay.com/api_1/alipay.trade.app.pay)查看更加详细的参数说明。
---
# 安全能力 Security
## 文本风险识别 TextRisk
### 检测内容风险
* API声明
detect(content: string)
* 入参说明
| 字段名 | 类型 | 必填 | 说明 |
|------|--------|----|----|
| content | string | | 待检测的文本内容 |
* 出参说明
可前往[alipay.security.risk.content.detect](https://docs.open.alipay.com/api_49/alipay.security.risk.content.detect)查看更加详细的参数说明。
---
# 辅助工具 Util
## 加解密 AES
### AES解密常用于会员手机号解密
* API声明
decrypt(cipherText: string)
* 入参说明
| 字段名 | 类型 | 必填 | 说明 |
|------|--------|----|----|
| cipherText | string | | 密文 |
* 出参说明
| 类型 | 说明 |
|------|----|
| string | 明文|
### AES加密
* API声明
encrypt(plainText: string)
* 入参说明
| 字段名 | 类型 | 必填 | 说明 |
|------|--------|----|----|
| plainText | string | | 明文 |
* 出参说明
| 类型 | 说明 |
|------|----|
| string | 密文|
<a name="generic"/>
## 通用接口 Generic
### 执行OpenAPI调用
* API声明
execute(method: string, textParams: map[string]string, bizParams: map[string]any): AlipayOpenApiGenericResponse
* 接口说明
对于Alipay Easy SDK尚未支持的Open API开发者可以通过调用此方法通过自行拼装请求参数完成几乎所有OpenAPI的调用且调用时可按需设置所有可选参数本接口同样会自动为您完成请求的加签和响应的验签工作
* 入参说明
| 字段名 | 类型 | 必填 | 说明 |
|------|--------|----|----|
| method | string | | OpenAPI的名称例如alipay.trade.pay |
| textParams | map[string]string | | **没有**包装在`biz_content`下的请求参数集合例如`app_auth_token`等参数 |
| bizParams | map[string]any | | 被包装在`biz_content`下的请求参数集合 |
* 出参说明
| 字段名 | 类型 | 必填 | 说明 |
|------|--------|----|----|
| httpBody | string | | 网关返回的HTTP响应是一个JSON格式的字符串开发者可按需从中解析出响应参数响应示例{"alipay_trade_create_response":{"code":"10000","msg":"Success","out_trade_no":"4ac9eac...","trade_no":"202003..."},"sign":"AUumfYgGSe7...02MA=="} |
| code | string | | [网关返回码](https://docs.open.alipay.com/common/105806) |
| msg | string | | [网关返回码描述](https://docs.open.alipay.com/common/105806) |
| subCode | string | | 业务返回码参见具体的API接口文档 |
| subMsg | string | | 业务返回码描述参见具体的API接口文档 |
---

161
vendor/alipaysdk/easysdk/CHANGELOG vendored Normal file
View File

@@ -0,0 +1,161 @@
最新变更
增加通用方法中sdkExecute与fileExecute功能。增加java与php的MultipleFactory多实例调用。
go版本sdk首次发布
Java版本
2021-01-18 Version: 2.2.0
1. 增加sdkExecute功能。
2. 增加fileExecute功能。
3. 增加MultipleFactory多实例调用。
2020-12-11 Version: 2.1.2
1. 增加可设置ignoreSSL忽略SSL校验功能。
2020-09-23 Version: 2.1.0
1. 升级Tea版本降低对OkHttp的特性依赖提升环境兼容性。
2. 提供Factory.getClient方法用于调用SDK扩展包中的方法。
2020-08-18 Version: 2.0.2
1. 取消shade打包便于排除冲突依赖。
2020-07-06 Version: 2.0.1
1. 私钥支持阿里云KMS。
2020-06-09 Version: 2.0.0
1. 支持可选业务参数的装配。
2. 支持ISV代调用。
3. 提供ResponseChecker辅助工具类帮助校验响应是否成功。
2020-05-06 Version: 1.2.1
1. 手机网站支付、电脑网站支付接口支持设置return_url同步跳转地址。
2020-04-15 Version: 1.2.0
1. 扩展支持的支付类OpenAPI接口
Factory.Payment.Common().queryRefund 查询退款信息
Factory.Payment.Common().downloadBill 下载对账单
Factory.Payment.FaceToFace().preCreate 交易预创建,生成正扫二维码
Factory.Payment.Wap().pay 手机网站支付
Factory.Payment.Page().pay 电脑网站支付
Factory.Payment.App().pay 手机APP支付
2. 支持支付的异步通知及其验签
初始化Alipay Easy SDK的Config参数中新增notifyUrl参数用户可以统一配置自己的回调地址。
提供如下接口,完成支付类异步通知的验签。
Factory.Payment.Common().verifyNotify
3. AES加解密功能
Factory.Util.AES().decrypt 支持会员手机号AES解密
Factory.Util.AES().encrypt AES加密
2020-03-31 Version: 1.1.3
1. 去除SDK内置的logback.xml日志配置文件以免意外覆盖开发者项目主体工程的日志配置。
2020-03-27 Version: 1.1.2
1. 修复返回的响应中存在数组类型字段时反序列化成Response对象可能抛异常的问题。
2020-03-16 Version: 1.1.1
1. 修复证书路径不支持从CLASS_PATH中加载的问题。
2020-03-10 Version: 1.1.0
1. 添加兜底通用接口支持通过自行拼接请求参数完成几乎所有OpenAPI的调用。
2020-02-26 Version: 1.0.0
1. 首次发布。
C#版本
2020-12-11 Version: 2.1.2
1. 增加可设置ignoreSSL忽略SSL校验功能。
2020-12-09 Version: 2.1.1
1. 增加httpProxy功能。
2020-09-23 Version: 2.1.0
1. 升级Tea版本。
2. 提供Factory.getClient方法用于调用SDK扩展包中的方法。
2020-08-18 Version: 2.0.1
1. 修复证书模式下异步验签异常的问题。
2020-06-09 Version: 2.0.0
1. 支持可选业务参数的装配。
2. 支持ISV代调用。
3. 提供ResponseChecker辅助工具类帮助校验响应是否成功。
2020-05-06 Version: 1.2.1
1. 手机网站支付、电脑网站支付接口支持设置return_url同步跳转地址。
2020-04-15 Version: 1.2.0
1. 扩展支持的支付类OpenAPI接口
Factory.Payment.Common().QueryRefund 查询退款信息
Factory.Payment.Common().DownloadBill 下载对账单
Factory.Payment.FaceToFace().PreCreate 交易预创建,生成正扫二维码
Factory.Payment.Wap().Pay 手机网站支付
Factory.Payment.Page().Pay 电脑网站支付
Factory.Payment.App().Pay 手机APP支付
2. 支持支付的异步通知及其验签
初始化Alipay Easy SDK的Config参数中新增notifyUrl参数用户可以统一配置自己的回调地址。
提供如下接口,完成支付类异步通知的验签。
Factory.Payment.Common().verifyNotify
3. AES加解密功能
Factory.Util.AES().Decrypt 支持会员手机号AES解密
Factory.Util.AES().Encrypt AES加密
2020-03-10 Version: 1.1.0
1. 添加兜底通用接口支持通过自行拼接请求参数完成几乎所有OpenAPI的调用。
2020-02-26 Version: 1.0.0
1. 首次发布。
PHP版本
2021-01-18 Version: 2.2.0
1. 增加sdkExecute功能。
2. 增加fileExecute功能。
3. 增加MultipleFactory多实例调用。
2020-12-11 Version: 2.0.3
1. 增加可设置ignoreSSL忽略SSL校验功能。
2020-12-09 Version: 2.0.2
1. 增加httpProxy功能。
2. 修复agent不生效问题。
2020-07-06 Version: 2.0.0
1. 支持可选业务参数的装配。
2. 支持ISV代调用。
3. 提供ResponseChecker辅助工具类帮助校验响应是否成功。
2020-05-06 Version: 1.2.1
1. 手机网站支付、电脑网站支付接口支持设置return_url同步跳转地址。
2020-04-15 Version: 1.2.0
1. 扩展支持的支付类OpenAPI接口
Factory::payment()->common()->queryRefund 查询退款信息
Factory::payment()->common()->downloadBill 下载对账单
Factory::payment()->faceToFace()->preCreate 交易预创建,生成正扫二维码
Factory::payment()->wap()->pay 手机网站支付
Factory::payment()->page()->pay 电脑网站支付
Factory::payment()->app()->pay 手机APP支付
2. 支持支付的异步通知及其验签
初始化Alipay Easy SDK的Config参数中新增notifyUrl参数用户可以统一配置自己的回调地址。
提供如下接口,完成支付类异步通知的验签。
Factory::payment()->common()->verifyNotify
3. AES加解密功能
Factory::util()->aes()->decrypt 支持会员手机号AES解密
Factory::util()->aes()->encrypt AES加密
4. 重构api的respone模型返回格式与Java、Net保持一致
2020-03-27 Version: 1.1.0
1. 修复大小写路径敏感问题。
2020-03-20 Version: 1.0.0
1. 首次发布。
PHP版本
2021-01-18 Version: 1.0.0
1. 首次发布。

21
vendor/alipaysdk/easysdk/LICENSE vendored Normal file
View File

@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2020 Ant Small and Micro Financial Services Group Co., Ltd.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

206
vendor/alipaysdk/easysdk/README.md vendored Normal file
View File

@@ -0,0 +1,206 @@
[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Falipay%2Falipay-easysdk.svg?type=shield)](https://app.fossa.com/projects/git%2Bgithub.com%2Falipay%2Falipay-easysdk?ref=badge_shield)
[![Maven Central](https://img.shields.io/maven-central/v/com.alipay.sdk/alipay-easysdk.svg)](https://mvnrepository.com/artifact/com.alipay.sdk/alipay-easysdk)
[![NuGet](https://badge.fury.io/nu/AlipayEasySDK.svg)](https://badge.fury.io/nu/AlipayEasySDK)
[![Packagist](https://poser.pugx.org/alipaysdk/easysdk/v/stable)](https://packagist.org/packages/alipaysdk/easysdk)
欢迎使用 Alipay **Easy** SDK
打造**最好用**的支付宝开放平台**服务端SDK**Alipay Easy SDK让您享受**极简编程**体验快速访问支付宝开放平台开放的各项**核心能力**
## 设计理念
不同于原有的Alipay SDK通用而全面的设计理念Alipay Easy SDK对开放能力的API进行了更加贴近高频场景的精心设计与裁剪简化了服务端调用方式让调用API像使用语言内置的函数一样简便
同时您也不必担心面向高频场景提炼的API可能无法完全契合自己的个性化场景Alipay Easy SDK支持灵活的[动态扩展](#extension)方式同样可以满足低频参数低频API的使用需求
Alipay Easy SDK提供了与[能力地图](https://opendocs.alipay.com/mini/00am3f)相对应的代码组织结构让开发者可以快速找到不同能力对应的API。
Alipay Easy SDK主要目标是提升开发者在**服务端**集成支付宝开放平台开放的各类核心能力的效率
### 化繁为简
| Alipay Easy SDK | Alipay SDK |
|------------------|----------------------------------------------------------------|
| 极简代码风格更贴近自然语言阅读习惯 | 传统代码风格需要多行代码完成一个接口的调用 |
| Factory单例全局任何地方都可直接引用 | AlipayClient实例需自行创建并在上下文中传递 |
| API中只保留高频场景下的必备参数同时提供低频可选参数的装配能力 | 没有区分高低频参数单API最多可达数十个入参对普通开发者的干扰较大 |
* Alipay Easy SDK :smiley:
```java
Factory.Payment.Common().create("Iphone6 16G", "202003019443", "0.10", "2088002656718920");
```
* Alipay SDK :confused:
```java
AlipayTradeCreateRequest request = new AlipayTradeCreateRequest();
AlipayTradeCreateModel model = new AlipayTradeCreateModel();
model.setSubject("Iphone6 16G");
model.setOutTradeNo("202003019443");
model.setTotalAmount("0.10");
model.setBuyerId("2088002656718920");
...
request.setBizModel(model);
...
alipayClient.execute(request);
```
### 如何切换
* 无论是Alipay Easy SDK还是Alipay SDK本质都是发送HTTP请求访问Open API网关所以只需将原来通过Alipay SDK调用Open API的代码替换为Alipay Easy SDK中对应API的调用即可Alipay Easy SDK和Alipay SDK并无冲突可以共存
* 如果您所需对接的开放平台能力Alipay Easy SDK尚未提炼出API支持[已支持的API列表](#apiList)您可以通过[通用接口](./APIDoc.md#generic)完成调用
* 我们会持续挖掘高频场景不断丰富Alipay Easy SDK支持的API让您在绝大多数常见场景下都能享受Alipay Easy SDK带来的便捷
## 技术特点
### 纯语言开发
所有Alipay Easy SDK的具体编程语言的实现均只采用纯编程语言进行开发不引入任何重量级框架减少潜在的框架冲突让SDK可以自由集成进任何代码环境中
### 结构清晰
我们按照能力类别和场景类别对API进行了归类结构更加清晰一目了然
> 更多信息请参见[API组织规范](#spec)
### 参数精简
Alipay Easy SDK对每个API都精心打磨剔除了`Open API`中不常用的可选参数减少普通用户的无效选择提升开发效率
<a name="extension"/>
### 灵活扩展
开发者可以通过Fluent风格的API链式调用在为高频场景打造的API基础上不断扩展自己的个性化场景需求
```java
// 通过调用agent方法扩展支持ISV代调用场景
Factory.Payment.FaceToFace().agent("ca34ea491e7146cc87d25fca24c4cD11").preCreate(...)
// 通过调用optional方法扩展支持个性化可选参数
Factory.Payment.FaceToFace().optional("extend_params", extendParams).preCreate(...)
// 多种扩展可灵活搭配,不同扩展方法功能详细说明请前往各语言主页中的“快速开始-扩展调用”栏目中查看
Factory.Payment.FaceToFace()
.agent(...)
.optionalArgs(...)
.auth(...)
.asyncNotify(...)
.preCreate(...)
```
### 测试/示例完备
每个API都有对应的单元测试进行覆盖良好的单元测试天生就是最好的示例
同时您也可以前往[API Doc](./APIDoc.md)查看每个API的详细使用说明
> 单元测试中使用到的私钥均进行了脱敏处理会导致单元测试无法直接执行您可以自行更改单元测试项目中的`TestAccout类``privateKey.json`文件中的相关账号与私钥配置后再执行单元测试
### 多语言
Alipay Easy SDK基于阿里集团研发的[`Darabonba`](https://github.com/aliyun/darabonba)进行架构通过DSL中间语言定义API模型再基于DSL语言自动生成不同编程语言Java、C#、PHP、TS等实现的SDK极大地提升了SDK能力的扩展效率和适用范围同时也保证了相同的`Easy API`在不同语言生态中体验的一致性。
API模型的DSL描述可以进入[tea](./tea)目录查看
### 快速集成
各语言SDK均会在各自的中央仓库MavenNuGetComposerNPM etc.中同步发布让您使用各语言主流依赖管理工具即可一键安装集成SDK
## 语言支持情况
Alipay Easy SDK首发暂只支持`Java``C#``PHP`编程语言更多编程语言支持正在积极新增中敬请期待
各语言具体的**使用说明****详细介绍**请点击如下链接进入各语言主目录查看
[Java](./java)
[C#](./csharp)
[PHP](./php)
<a name="spec"/>
## API组织规范
在Alipay Easy SDK中API的引用路径与能力地图的组织层次一致遵循如下规范
> Factory.能力类别.场景类别.接口方法名称( ... )
比如如果您想要使用[能力地图](https://opendocs.alipay.com/mini/00am3f)中`营销能力`下的`模板消息`场景中的`小程序发送模板消息`,只需按如下形式编写调用代码即可(不同编程语言的连接符号可能不同)。
`Factory.Marketing.TemplateMessage().send( ... )`
其中接口方法名称通常是对其依赖的OpenAPI功能的一个最简概况接口方法的出入参与OpenAPI中同名参数含义一致可参照OpenAPI相关参数的使用说明
Alipay Easy SDK将致力于保持良好的API命名以符合开发者的编程直觉
<a name="apiList"/>
## 已支持的API列表
| 能力类别 | 场景类别 | 接口方法名称 | 调用的OpenAPI名称 |
|-----------|-----------------|------------------------|-----------------------------------------------------------|
| Base<br/>基础能力 | OAuth<br/>用户授权 | getToken<br/>获取授权访问令牌和用户user_id | alipay\.system\.oauth\.token |
| Base<br/>基础能力 | OAuth<br/>用户授权 | refreshToken<br/>刷新授权访问令牌 | alipay\.system\.oauth\.token |
| Base<br/>基础能力 | Qrcode<br/>小程序二维码 | create<br/>创建小程序二维码 | alipay\.open\.app\.qrcode\.create |
| Base<br/>基础能力 | Image<br/>图片 | upload<br/>上传门店照片 | alipay\.offline\.material\.image\.upload |
| Base<br/>基础能力 | Video<br/>视频 | upload<br/>上传门店视频 | alipay\.offline\.material\.image\.upload |
| Member<br/>会员能力 | Identification<br/>支付宝身份认证 | init<br/>身份认证初始化 | alipay\.user\.certify\.open\.initialize |
| Member<br/>会员能力 | Identification<br/>支付宝身份认证 | certify<br/>生成认证链接 | alipay\.user\.certify\.open\.certify |
| Member<br/>会员能力 | Identification<br/>支付宝身份认证 | query<br/>身份认证记录查询 | alipay\.user\.certify\.open\.query |
| Payment<br/>支付能力 | Common<br/>通用 | create<br/>创建交易 | alipay\.trade\.create |
| Payment<br/>支付能力 | Common<br/>通用 | query<br/>查询交易 | alipay\.trade\.query |
| Payment<br/>支付能力 | Common<br/>通用 | refund<br/>交易退款 | alipay\.trade\.refund |
| Payment<br/>支付能力 | Common<br/>通用 | close<br/>关闭交易 | alipay\.trade\.close |
| Payment<br/>支付能力 | Common<br/>通用 | cancel<br/>撤销交易 | alipay\.trade\.cancel |
| Payment<br/>支付能力 | Common<br/>通用 | queryRefund<br/>交易退款查询 | alipay\.trade\.fastpay\.refund\.query |
| Payment<br/>支付能力 | Common<br/>通用 | downloadBill<br/>查询对账单下载地址 | alipay\.data\.dataservice\.bill\.downloadurl\.query |
| Payment<br/>支付能力 | Common<br/>通用 | verifyNotify<br/>异步通知验签 | - |
| Payment<br/>支付能力 | Huabei<br/>花呗分期 | create<br/>创建花呗分期交易 | alipay\.trade\.create |
| Payment<br/>支付能力 | FaceToFace<br/>当面付 | pay<br/>扫用户出示的付款码完成付款 | alipay\.trade\.pay |
| Payment<br/>支付能力 | FaceToFace<br/>当面付 | precreate<br/>生成交易付款码待用户扫码付款 | alipay\.trade\.precreate |
| Payment<br/>支付能力 | App<br/>手机APP | pay<br/>生成订单串再使用客户端 SDK 凭此串唤起支付宝收银台 | alipay\.trade\.app\.pay |
| Payment<br/>支付能力 | Page<br/>电脑网站 | pay<br/>生成交易表单渲染后自动跳转支付宝网站引导用户完成支付 | alipay\.trade\.page\.pay |
| Payment<br/>支付能力 | Wap<br/>手机网站 | pay<br/>生成交易表单渲染后自动跳转支付宝网站引导用户完成支付 | alipay\.trade\.wap\.pay |
| Security<br/>安全能力 | TextRisk<br/>文本内容安全 | detect<br/>检测内容风险 | alipay\.security\.risk\.content\.detect |
| Marketing<br/>营销能力 | Pass<br/>支付宝卡包 | createTemplate<br/>卡券模板创建 | alipay\.pass\.template\.add |
| Marketing<br/>营销能力 | Pass<br/>支付宝卡包 | updateTemplate<br/>卡券模板更新 | alipay\.pass\.template\.update |
| Marketing<br/>营销能力 | Pass<br/>支付宝卡包 | addInstance<br/>卡券实例发放 | alipay\.pass\.instance\.add |
| Marketing<br/>营销能力 | Pass<br/>支付宝卡包 | updateInstance<br/>卡券实例更新 | alipay\.pass\.instance\.update |
| Marketing<br/>营销能力 | TemplateMessage<br/>小程序模板消息 | send <br/>发送模板消息| alipay\.open\.app\.mini\.templatemessage\.send |
| Marketing<br/>营销能力 | OpenLife<br/>生活号 | createImageTextContent<br/>创建图文消息内容 | alipay\.open\.public\.message\.content\.create |
| Marketing<br/>营销能力 | OpenLife<br/>生活号 | modifyImageTextContent<br/>更新图文消息内容 | alipay\.open\.public\.message\.content\.modify |
| Marketing<br/>营销能力 | OpenLife<br/>生活号 | sendText<br/>群发本文消息 | alipay\.open\.public\.message\.total\.send |
| Marketing<br/>营销能力 | OpenLife<br/>生活号 | sendImageText<br/>群发图文消息 | alipay\.open\.public\.message\.total\.send |
| Marketing<br/>营销能力 | OpenLife<br/>生活号 | sendSingleMessage<br/>单发模板消息 | alipay\.open\.public\.message\.single\.send |
| Marketing<br/>营销能力 | OpenLife<br/>生活号 | recallMessage<br/>生活号消息撤回 | alipay\.open\.public\.life\.msg\.recall |
| Marketing<br/>营销能力 | OpenLife<br/>生活号 | setIndustry<br/>模板消息行业设置 | alipay\.open\.public\.template\.message\.industry\.modify |
| Marketing<br/>营销能力 | OpenLife<br/>生活号 | getIndustry<br/>生活号查询行业设置 | alipay\.open\.public\.setting\.category\.query |
| Util<br/>辅助工具 | AES<br/>加解密 | decrypt<br/>解密常用于会员手机号解密 | - |
| Util<br/>辅助工具 | AES<br/>加解密 | encrypt<br/>加密 | - |
| Util<br/>辅助工具 | Generic<br/>通用接口 | execute<br/>自行拼接参数执行OpenAPI调用 | - |
> 更多高频场景的API持续更新中敬请期待
您还可以前往[API Doc](./APIDoc.md)查看每个API的详细使用说明
# 变更日志
每个版本的详细更改记录在[变更日志](./CHANGELOG)
> 版本号最末一位修订号的增加比如从`1.0.0`升级为`1.0.1`意味着SDK的功能没有发生任何变化仅仅是修复了部分Bug该类升级可能不会记录在变更日志中
> 版本号中间一位次版本号的增加比如从`1.0.0`升级为`1.1.0`意味着SDK的功能发生了可向下兼容的新增或修改
> 版本号首位主版本号的增加比如从`1.0.0`升级为`2.0.0`意味着SDK的功能可能发生了不向下兼容的较大调整升级主版本号后请注意做好相关的回归测试工作
# 相关
* [支付宝开放平台](https://open.alipay.com/platform/home.htm)
* [支付宝开放平台文档中心](https://docs.open.alipay.com/catalog)
* [最新源码](https://github.com/alipay/alipay-easysdk)
# 许可证
[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Falipay%2Falipay-easysdk.svg?type=large)](https://app.fossa.com/projects/git%2Bgithub.com%2Falipay%2Falipay-easysdk?ref=badge_large)
# 交流与技术支持
不管您在使用Alipay Easy SDK的过程中遇到任何问题欢迎在当前 GitHub [提交 Issues](https://github.com/alipay/alipay-easysdk/issues/new)。
您也可以使用钉钉扫描下方二维码与更多开发者和支付宝工程师共同交流
![支付宝官方Alipay Easy SDK开源交流群](https://gw.alipayobjects.com/mdn/rms_0e15fa/afts/img/A*SUaHT7fpzSwAAAAAAAAAAABkARQnAQ)

56
vendor/alipaysdk/easysdk/composer.json vendored Normal file
View File

@@ -0,0 +1,56 @@
{
"name":"alipaysdk/easysdk",
"description":"支付宝官方 Alipay Easy SDK",
"type":"library",
"version":"2.2.0",
"authors":[
{
"name":"junying.wjy",
"email":"junying.wjy@antfin.com"
}
],
"autoload":{
"psr-4":{
"Alipay\\EasySDK\\":"php/src/"
}
},
"autoload-dev": {
"psr-4": {
"Alipay\\EasySDK\\Test\\": "php/test/"
}
},
"license":"Apache-2.0",
"minimum-stability":"dev",
"require":{
"php": ">=7.0",
"ext-curl":"*",
"ext-ctype":"*",
"ext-dom":"*",
"ext-fileinfo": "*",
"ext-json":"*",
"ext-libxml":"*",
"ext-simplexml":"*",
"ext-mbstring":"*",
"ext-openssl":"*",
"pimple/pimple": "^3.0",
"xin/container":"^2.0.1",
"guzzlehttp/guzzle":">=6.3",
"psr/log": "^1.1",
"ext-xmlwriter": "*",
"songshenzong/support": "^2.0",
"danielstjules/stringy": "^3.1",
"mtdowling/jmespath.php": "^2.4",
"adbario/php-dot-notation": "^2.2",
"alibabacloud/tea": "^3.1",
"alibabacloud/tea-fileform": "^0.3.2"
},
"require-dev": {
"phpunit/phpunit": "^7.5"
},
"repositories":{
"packagist":{
"type":"composer",
"url":"https://mirrors.aliyun.com/composer/"
}
}
}

View File

@@ -0,0 +1,23 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AlipayEasySDK", "AlipayEasySDK\AlipayEasySDK.csproj", "{14B089B9-C61C-46E6-BD93-5DFBBB77E2B2}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnitTest", "UnitTest\UnitTest.csproj", "{79DE080D-34C1-485E-996D-435A8515766D}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{14B089B9-C61C-46E6-BD93-5DFBBB77E2B2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{14B089B9-C61C-46E6-BD93-5DFBBB77E2B2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{14B089B9-C61C-46E6-BD93-5DFBBB77E2B2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{14B089B9-C61C-46E6-BD93-5DFBBB77E2B2}.Release|Any CPU.Build.0 = Release|Any CPU
{79DE080D-34C1-485E-996D-435A8515766D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{79DE080D-34C1-485E-996D-435A8515766D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{79DE080D-34C1-485E-996D-435A8515766D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{79DE080D-34C1-485E-996D-435A8515766D}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal

View File

@@ -0,0 +1,32 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netstandard2.0;net461</TargetFrameworks>
<PackOnBuild>true</PackOnBuild>
<PackageVersion>2.1.2</PackageVersion>
<Authors>antopen</Authors>
<NeutralLanguage>zh</NeutralLanguage>
<PackageLicenseUrl>https://github.com/alipay/alipay-easysdk/blob/master/LICENSE</PackageLicenseUrl>
<Description>Alipay Easy SDK for .NET allows you to enjoy a minimalist programming experience and quickly access the various high-frequency capabilities of the Alipay Open Platform.</Description>
<PackageId>AlipayEasySDK</PackageId>
<Owners>antopen</Owners>
<PackageProjectUrl>https://github.com/alipay/alipay-easysdk/tree/master/csharp</PackageProjectUrl>
<Summary>Alipay Easy SDK for .NET allows you to enjoy a minimalist programming experience and quickly access the various high-frequency capabilities of the Alipay Open Platform.</Summary>
<Title>Alipay Easy SDK</Title>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType></DebugType>
</PropertyGroup>
<ItemGroup>
<Compile Remove="Class1.cs" />
</ItemGroup>
<ItemGroup>
<Folder Include="Factory\" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="AlipayEasySDK.Kernel" Version="1.0.5" />
</ItemGroup>
</Project>

View File

@@ -0,0 +1,324 @@
// This file is auto-generated, don't edit it. Thanks.
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Threading.Tasks;
using Tea;
using Tea.Utils;
using Alipay.EasySDK.Base.Image.Models;
namespace Alipay.EasySDK.Base.Image
{
public class Client
{
protected Alipay.EasySDK.Kernel.Client _kernel;
public Client(Alipay.EasySDK.Kernel.Client kernel)
{
this._kernel = kernel;
}
public AlipayOfflineMaterialImageUploadResponse Upload(string imageName, string imageFilePath)
{
Dictionary<string, object> runtime_ = new Dictionary<string, object>
{
{"ignoreSSL", this._kernel.GetConfig("ignoreSSL")},
{"httpProxy", this._kernel.GetConfig("httpProxy")},
{"connectTimeout", 100000},
{"readTimeout", 100000},
{"retry", new Dictionary<string, int?>
{
{"maxAttempts", 0},
}},
};
TeaRequest _lastRequest = null;
Exception _lastException = null;
long _now = System.DateTime.Now.Millisecond;
int _retryTimes = 0;
while (TeaCore.AllowRetry((IDictionary) runtime_["retry"], _retryTimes, _now))
{
if (_retryTimes > 0)
{
int backoffTime = TeaCore.GetBackoffTime((IDictionary)runtime_["backoff"], _retryTimes);
if (backoffTime > 0)
{
TeaCore.Sleep(backoffTime);
}
}
_retryTimes = _retryTimes + 1;
try
{
TeaRequest request_ = new TeaRequest();
Dictionary<string, string> systemParams = new Dictionary<string, string>
{
{"method", "alipay.offline.material.image.upload"},
{"app_id", this._kernel.GetConfig("appId")},
{"timestamp", this._kernel.GetTimestamp()},
{"format", "json"},
{"version", "1.0"},
{"alipay_sdk", this._kernel.GetSdkVersion()},
{"charset", "UTF-8"},
{"sign_type", this._kernel.GetConfig("signType")},
{"app_cert_sn", this._kernel.GetMerchantCertSN()},
{"alipay_root_cert_sn", this._kernel.GetAlipayRootCertSN()},
};
Dictionary<string, object> bizParams = new Dictionary<string, object>(){};
Dictionary<string, string> textParams = new Dictionary<string, string>
{
{"image_type", "jpg"},
{"image_name", imageName},
};
Dictionary<string, string> fileParams = new Dictionary<string, string>
{
{"image_content", imageFilePath},
};
string boundary = this._kernel.GetRandomBoundary();
request_.Protocol = this._kernel.GetConfig("protocol");
request_.Method = "POST";
request_.Pathname = "/gateway.do";
request_.Headers = new Dictionary<string, string>
{
{"host", this._kernel.GetConfig("gatewayHost")},
{"content-type", this._kernel.ConcatStr("multipart/form-data;charset=utf-8;boundary=", boundary)},
};
request_.Query = this._kernel.SortMap(TeaConverter.merge<string>
(
new Dictionary<string, string>()
{
{"sign", this._kernel.Sign(systemParams, bizParams, textParams, this._kernel.GetConfig("merchantPrivateKey"))},
},
systemParams
));
request_.Body = this._kernel.ToMultipartRequestBody(textParams, fileParams, boundary);
_lastRequest = request_;
TeaResponse response_ = TeaCore.DoAction(request_, runtime_);
Dictionary<string, object> respMap = this._kernel.ReadAsJson(response_, "alipay.offline.material.image.upload");
if (this._kernel.IsCertMode())
{
if (this._kernel.Verify(respMap, this._kernel.ExtractAlipayPublicKey(this._kernel.GetAlipayCertSN(respMap))))
{
return TeaModel.ToObject<AlipayOfflineMaterialImageUploadResponse>(this._kernel.ToRespModel(respMap));
}
}
else
{
if (this._kernel.Verify(respMap, this._kernel.GetConfig("alipayPublicKey")))
{
return TeaModel.ToObject<AlipayOfflineMaterialImageUploadResponse>(this._kernel.ToRespModel(respMap));
}
}
throw new TeaException(new Dictionary<string, string>
{
{"message", "验签失败,请检查支付宝公钥设置是否正确。"},
});
}
catch (Exception e)
{
if (TeaCore.IsRetryable(e))
{
_lastException = e;
continue;
}
throw e;
}
}
throw new TeaUnretryableException(_lastRequest, _lastException);
}
public async Task<AlipayOfflineMaterialImageUploadResponse> UploadAsync(string imageName, string imageFilePath)
{
Dictionary<string, object> runtime_ = new Dictionary<string, object>
{
{"ignoreSSL", this._kernel.GetConfig("ignoreSSL")},
{"httpProxy", this._kernel.GetConfig("httpProxy")},
{"connectTimeout", 100000},
{"readTimeout", 100000},
{"retry", new Dictionary<string, int?>
{
{"maxAttempts", 0},
}},
};
TeaRequest _lastRequest = null;
Exception _lastException = null;
long _now = System.DateTime.Now.Millisecond;
int _retryTimes = 0;
while (TeaCore.AllowRetry((IDictionary) runtime_["retry"], _retryTimes, _now))
{
if (_retryTimes > 0)
{
int backoffTime = TeaCore.GetBackoffTime((IDictionary)runtime_["backoff"], _retryTimes);
if (backoffTime > 0)
{
TeaCore.Sleep(backoffTime);
}
}
_retryTimes = _retryTimes + 1;
try
{
TeaRequest request_ = new TeaRequest();
Dictionary<string, string> systemParams = new Dictionary<string, string>
{
{"method", "alipay.offline.material.image.upload"},
{"app_id", this._kernel.GetConfig("appId")},
{"timestamp", this._kernel.GetTimestamp()},
{"format", "json"},
{"version", "1.0"},
{"alipay_sdk", this._kernel.GetSdkVersion()},
{"charset", "UTF-8"},
{"sign_type", this._kernel.GetConfig("signType")},
{"app_cert_sn", this._kernel.GetMerchantCertSN()},
{"alipay_root_cert_sn", this._kernel.GetAlipayRootCertSN()},
};
Dictionary<string, object> bizParams = new Dictionary<string, object>(){};
Dictionary<string, string> textParams = new Dictionary<string, string>
{
{"image_type", "jpg"},
{"image_name", imageName},
};
Dictionary<string, string> fileParams = new Dictionary<string, string>
{
{"image_content", imageFilePath},
};
string boundary = this._kernel.GetRandomBoundary();
request_.Protocol = this._kernel.GetConfig("protocol");
request_.Method = "POST";
request_.Pathname = "/gateway.do";
request_.Headers = new Dictionary<string, string>
{
{"host", this._kernel.GetConfig("gatewayHost")},
{"content-type", this._kernel.ConcatStr("multipart/form-data;charset=utf-8;boundary=", boundary)},
};
request_.Query = this._kernel.SortMap(TeaConverter.merge<string>
(
new Dictionary<string, string>()
{
{"sign", this._kernel.Sign(systemParams, bizParams, textParams, this._kernel.GetConfig("merchantPrivateKey"))},
},
systemParams
));
request_.Body = this._kernel.ToMultipartRequestBody(textParams, fileParams, boundary);
_lastRequest = request_;
TeaResponse response_ = await TeaCore.DoActionAsync(request_, runtime_);
Dictionary<string, object> respMap = await this._kernel.ReadAsJsonAsync(response_, "alipay.offline.material.image.upload");
if (this._kernel.IsCertMode())
{
if (this._kernel.Verify(respMap, this._kernel.ExtractAlipayPublicKey(this._kernel.GetAlipayCertSN(respMap))))
{
return TeaModel.ToObject<AlipayOfflineMaterialImageUploadResponse>(this._kernel.ToRespModel(respMap));
}
}
else
{
if (this._kernel.Verify(respMap, this._kernel.GetConfig("alipayPublicKey")))
{
return TeaModel.ToObject<AlipayOfflineMaterialImageUploadResponse>(this._kernel.ToRespModel(respMap));
}
}
throw new TeaException(new Dictionary<string, string>
{
{"message", "验签失败,请检查支付宝公钥设置是否正确。"},
});
}
catch (Exception e)
{
if (TeaCore.IsRetryable(e))
{
_lastException = e;
continue;
}
throw e;
}
}
throw new TeaUnretryableException(_lastRequest, _lastException);
}
/// <summary>
/// ISV代商户代用指定appAuthToken
/// </summary>
/// <param name="appAuthToken">代调用token</param>
/// <returns>本客户端,便于链式调用</returns>
public Client Agent(string appAuthToken)
{
_kernel.InjectTextParam("app_auth_token", appAuthToken);
return this;
}
/// <summary>
/// 用户授权调用指定authToken
/// </summary>
/// <param name="authToken">用户授权token</param>
/// <returns>本客户端,便于链式调用</returns>
public Client Auth(string authToken)
{
_kernel.InjectTextParam("auth_token", authToken);
return this;
}
/// <summary>
/// 设置异步通知回调地址此处设置将在本调用中覆盖Config中的全局配置
/// </summary>
/// <param name="url">异步通知回调地址例如https://www.test.com/callback </param>
/// <returns>本客户端,便于链式调用</returns>
public Client AsyncNotify(string url)
{
_kernel.InjectTextParam("notify_url", url);
return this;
}
/// <summary>
/// 将本次调用强制路由到后端系统的测试地址上,常用于线下环境内外联调,沙箱与线上环境设置无效
/// </summary>
/// <param name="testUrl">后端系统测试地址</param>
/// <returns>本客户端,便于链式调用</returns>
public Client Route(string testUrl)
{
_kernel.InjectTextParam("ws_service_url", testUrl);
return this;
}
/// <summary>
/// 设置API入参中没有的其他可选业务请求参数(biz_content下的字段)
/// </summary>
/// <param name="key">业务请求参数名称biz_content下的字段名比如timeout_express</param>
/// <param name="value">
/// 业务请求参数的值一个可以序列化成JSON的对象
/// 如果该字段是一个字符串类型String、Price、Date在SDK中都是字符串请使用string储存
/// 如果该字段是一个数值型类型比如Number请使用long储存
/// 如果该字段是一个复杂类型请使用嵌套的Dictionary指定各下级字段的值
/// 如果该字段是一个数组请使用List储存各个值
/// 对于更复杂的情况也支持Dictionary和List的各种组合嵌套比如参数是值是个ListList中的每种类型是一个复杂对象
/// </param>
/// <returns>本客户端,便于链式调用</returns>
public Client Optional(string key, object value)
{
_kernel.InjectBizParam(key, value);
return this;
}
/// <summary>
/// 批量设置API入参中没有的其他可选业务请求参数(biz_content下的字段)
/// optional方法的批量版本
/// </summary>
/// <param name="optionalArgs">可选参数集合每个参数由key和value组成key和value的格式请参见optional方法的注释</param>
/// <returns>本客户端,便于链式调用</returns>
public Client BatchOptional(Dictionary<string, object> optionalArgs)
{
foreach (var pair in optionalArgs)
{
_kernel.InjectBizParam(pair.Key, pair.Value);
}
return this;
}
}
}

View File

@@ -0,0 +1,45 @@
// This file is auto-generated, don't edit it. Thanks.
using System;
using System.Collections.Generic;
using System.IO;
using Tea;
namespace Alipay.EasySDK.Base.Image.Models
{
public class AlipayOfflineMaterialImageUploadResponse : TeaModel {
/// <summary>
/// 响应原始字符串
/// </summary>
[NameInMap("http_body")]
[Validation(Required=true)]
public string HttpBody { get; set; }
[NameInMap("code")]
[Validation(Required=true)]
public string Code { get; set; }
[NameInMap("msg")]
[Validation(Required=true)]
public string Msg { get; set; }
[NameInMap("sub_code")]
[Validation(Required=true)]
public string SubCode { get; set; }
[NameInMap("sub_msg")]
[Validation(Required=true)]
public string SubMsg { get; set; }
[NameInMap("image_id")]
[Validation(Required=true)]
public string ImageId { get; set; }
[NameInMap("image_url")]
[Validation(Required=true)]
public string ImageUrl { get; set; }
}
}

View File

@@ -0,0 +1,528 @@
// This file is auto-generated, don't edit it. Thanks.
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Threading.Tasks;
using Tea;
using Tea.Utils;
using Alipay.EasySDK.Base.OAuth.Models;
namespace Alipay.EasySDK.Base.OAuth
{
public class Client
{
protected Alipay.EasySDK.Kernel.Client _kernel;
public Client(Alipay.EasySDK.Kernel.Client kernel)
{
this._kernel = kernel;
}
public AlipaySystemOauthTokenResponse GetToken(string code)
{
Dictionary<string, object> runtime_ = new Dictionary<string, object>
{
{"ignoreSSL", this._kernel.GetConfig("ignoreSSL")},
{"httpProxy", this._kernel.GetConfig("httpProxy")},
{"connectTimeout", 15000},
{"readTimeout", 15000},
{"retry", new Dictionary<string, int?>
{
{"maxAttempts", 0},
}},
};
TeaRequest _lastRequest = null;
Exception _lastException = null;
long _now = System.DateTime.Now.Millisecond;
int _retryTimes = 0;
while (TeaCore.AllowRetry((IDictionary) runtime_["retry"], _retryTimes, _now))
{
if (_retryTimes > 0)
{
int backoffTime = TeaCore.GetBackoffTime((IDictionary)runtime_["backoff"], _retryTimes);
if (backoffTime > 0)
{
TeaCore.Sleep(backoffTime);
}
}
_retryTimes = _retryTimes + 1;
try
{
TeaRequest request_ = new TeaRequest();
Dictionary<string, string> systemParams = new Dictionary<string, string>
{
{"method", "alipay.system.oauth.token"},
{"app_id", this._kernel.GetConfig("appId")},
{"timestamp", this._kernel.GetTimestamp()},
{"format", "json"},
{"version", "1.0"},
{"alipay_sdk", this._kernel.GetSdkVersion()},
{"charset", "UTF-8"},
{"sign_type", this._kernel.GetConfig("signType")},
{"app_cert_sn", this._kernel.GetMerchantCertSN()},
{"alipay_root_cert_sn", this._kernel.GetAlipayRootCertSN()},
};
Dictionary<string, object> bizParams = new Dictionary<string, object>(){};
Dictionary<string, string> textParams = new Dictionary<string, string>
{
{"grant_type", "authorization_code"},
{"code", code},
};
request_.Protocol = this._kernel.GetConfig("protocol");
request_.Method = "POST";
request_.Pathname = "/gateway.do";
request_.Headers = new Dictionary<string, string>
{
{"host", this._kernel.GetConfig("gatewayHost")},
{"content-type", "application/x-www-form-urlencoded;charset=utf-8"},
};
request_.Query = this._kernel.SortMap(TeaConverter.merge<string>
(
new Dictionary<string, string>()
{
{"sign", this._kernel.Sign(systemParams, bizParams, textParams, this._kernel.GetConfig("merchantPrivateKey"))},
},
systemParams,
textParams
));
request_.Body = TeaCore.BytesReadable(this._kernel.ToUrlEncodedRequestBody(bizParams));
_lastRequest = request_;
TeaResponse response_ = TeaCore.DoAction(request_, runtime_);
Dictionary<string, object> respMap = this._kernel.ReadAsJson(response_, "alipay.system.oauth.token");
if (this._kernel.IsCertMode())
{
if (this._kernel.Verify(respMap, this._kernel.ExtractAlipayPublicKey(this._kernel.GetAlipayCertSN(respMap))))
{
return TeaModel.ToObject<AlipaySystemOauthTokenResponse>(this._kernel.ToRespModel(respMap));
}
}
else
{
if (this._kernel.Verify(respMap, this._kernel.GetConfig("alipayPublicKey")))
{
return TeaModel.ToObject<AlipaySystemOauthTokenResponse>(this._kernel.ToRespModel(respMap));
}
}
throw new TeaException(new Dictionary<string, string>
{
{"message", "验签失败,请检查支付宝公钥设置是否正确。"},
});
}
catch (Exception e)
{
if (TeaCore.IsRetryable(e))
{
_lastException = e;
continue;
}
throw e;
}
}
throw new TeaUnretryableException(_lastRequest, _lastException);
}
public async Task<AlipaySystemOauthTokenResponse> GetTokenAsync(string code)
{
Dictionary<string, object> runtime_ = new Dictionary<string, object>
{
{"ignoreSSL", this._kernel.GetConfig("ignoreSSL")},
{"httpProxy", this._kernel.GetConfig("httpProxy")},
{"connectTimeout", 15000},
{"readTimeout", 15000},
{"retry", new Dictionary<string, int?>
{
{"maxAttempts", 0},
}},
};
TeaRequest _lastRequest = null;
Exception _lastException = null;
long _now = System.DateTime.Now.Millisecond;
int _retryTimes = 0;
while (TeaCore.AllowRetry((IDictionary) runtime_["retry"], _retryTimes, _now))
{
if (_retryTimes > 0)
{
int backoffTime = TeaCore.GetBackoffTime((IDictionary)runtime_["backoff"], _retryTimes);
if (backoffTime > 0)
{
TeaCore.Sleep(backoffTime);
}
}
_retryTimes = _retryTimes + 1;
try
{
TeaRequest request_ = new TeaRequest();
Dictionary<string, string> systemParams = new Dictionary<string, string>
{
{"method", "alipay.system.oauth.token"},
{"app_id", this._kernel.GetConfig("appId")},
{"timestamp", this._kernel.GetTimestamp()},
{"format", "json"},
{"version", "1.0"},
{"alipay_sdk", this._kernel.GetSdkVersion()},
{"charset", "UTF-8"},
{"sign_type", this._kernel.GetConfig("signType")},
{"app_cert_sn", this._kernel.GetMerchantCertSN()},
{"alipay_root_cert_sn", this._kernel.GetAlipayRootCertSN()},
};
Dictionary<string, object> bizParams = new Dictionary<string, object>(){};
Dictionary<string, string> textParams = new Dictionary<string, string>
{
{"grant_type", "authorization_code"},
{"code", code},
};
request_.Protocol = this._kernel.GetConfig("protocol");
request_.Method = "POST";
request_.Pathname = "/gateway.do";
request_.Headers = new Dictionary<string, string>
{
{"host", this._kernel.GetConfig("gatewayHost")},
{"content-type", "application/x-www-form-urlencoded;charset=utf-8"},
};
request_.Query = this._kernel.SortMap(TeaConverter.merge<string>
(
new Dictionary<string, string>()
{
{"sign", this._kernel.Sign(systemParams, bizParams, textParams, this._kernel.GetConfig("merchantPrivateKey"))},
},
systemParams,
textParams
));
request_.Body = TeaCore.BytesReadable(this._kernel.ToUrlEncodedRequestBody(bizParams));
_lastRequest = request_;
TeaResponse response_ = await TeaCore.DoActionAsync(request_, runtime_);
Dictionary<string, object> respMap = await this._kernel.ReadAsJsonAsync(response_, "alipay.system.oauth.token");
if (this._kernel.IsCertMode())
{
if (this._kernel.Verify(respMap, this._kernel.ExtractAlipayPublicKey(this._kernel.GetAlipayCertSN(respMap))))
{
return TeaModel.ToObject<AlipaySystemOauthTokenResponse>(this._kernel.ToRespModel(respMap));
}
}
else
{
if (this._kernel.Verify(respMap, this._kernel.GetConfig("alipayPublicKey")))
{
return TeaModel.ToObject<AlipaySystemOauthTokenResponse>(this._kernel.ToRespModel(respMap));
}
}
throw new TeaException(new Dictionary<string, string>
{
{"message", "验签失败,请检查支付宝公钥设置是否正确。"},
});
}
catch (Exception e)
{
if (TeaCore.IsRetryable(e))
{
_lastException = e;
continue;
}
throw e;
}
}
throw new TeaUnretryableException(_lastRequest, _lastException);
}
public AlipaySystemOauthTokenResponse RefreshToken(string refreshToken)
{
Dictionary<string, object> runtime_ = new Dictionary<string, object>
{
{"ignoreSSL", this._kernel.GetConfig("ignoreSSL")},
{"httpProxy", this._kernel.GetConfig("httpProxy")},
{"connectTimeout", 15000},
{"readTimeout", 15000},
{"retry", new Dictionary<string, int?>
{
{"maxAttempts", 0},
}},
};
TeaRequest _lastRequest = null;
Exception _lastException = null;
long _now = System.DateTime.Now.Millisecond;
int _retryTimes = 0;
while (TeaCore.AllowRetry((IDictionary) runtime_["retry"], _retryTimes, _now))
{
if (_retryTimes > 0)
{
int backoffTime = TeaCore.GetBackoffTime((IDictionary)runtime_["backoff"], _retryTimes);
if (backoffTime > 0)
{
TeaCore.Sleep(backoffTime);
}
}
_retryTimes = _retryTimes + 1;
try
{
TeaRequest request_ = new TeaRequest();
Dictionary<string, string> systemParams = new Dictionary<string, string>
{
{"method", "alipay.system.oauth.token"},
{"app_id", this._kernel.GetConfig("appId")},
{"timestamp", this._kernel.GetTimestamp()},
{"format", "json"},
{"version", "1.0"},
{"alipay_sdk", this._kernel.GetSdkVersion()},
{"charset", "UTF-8"},
{"sign_type", this._kernel.GetConfig("signType")},
{"app_cert_sn", this._kernel.GetMerchantCertSN()},
{"alipay_root_cert_sn", this._kernel.GetAlipayRootCertSN()},
};
Dictionary<string, object> bizParams = new Dictionary<string, object>(){};
Dictionary<string, string> textParams = new Dictionary<string, string>
{
{"grant_type", "refresh_token"},
{"refresh_token", refreshToken},
};
request_.Protocol = this._kernel.GetConfig("protocol");
request_.Method = "POST";
request_.Pathname = "/gateway.do";
request_.Headers = new Dictionary<string, string>
{
{"host", this._kernel.GetConfig("gatewayHost")},
{"content-type", "application/x-www-form-urlencoded;charset=utf-8"},
};
request_.Query = this._kernel.SortMap(TeaConverter.merge<string>
(
new Dictionary<string, string>()
{
{"sign", this._kernel.Sign(systemParams, bizParams, textParams, this._kernel.GetConfig("merchantPrivateKey"))},
},
systemParams,
textParams
));
request_.Body = TeaCore.BytesReadable(this._kernel.ToUrlEncodedRequestBody(bizParams));
_lastRequest = request_;
TeaResponse response_ = TeaCore.DoAction(request_, runtime_);
Dictionary<string, object> respMap = this._kernel.ReadAsJson(response_, "alipay.system.oauth.token");
if (this._kernel.IsCertMode())
{
if (this._kernel.Verify(respMap, this._kernel.ExtractAlipayPublicKey(this._kernel.GetAlipayCertSN(respMap))))
{
return TeaModel.ToObject<AlipaySystemOauthTokenResponse>(this._kernel.ToRespModel(respMap));
}
}
else
{
if (this._kernel.Verify(respMap, this._kernel.GetConfig("alipayPublicKey")))
{
return TeaModel.ToObject<AlipaySystemOauthTokenResponse>(this._kernel.ToRespModel(respMap));
}
}
throw new TeaException(new Dictionary<string, string>
{
{"message", "验签失败,请检查支付宝公钥设置是否正确。"},
});
}
catch (Exception e)
{
if (TeaCore.IsRetryable(e))
{
_lastException = e;
continue;
}
throw e;
}
}
throw new TeaUnretryableException(_lastRequest, _lastException);
}
public async Task<AlipaySystemOauthTokenResponse> RefreshTokenAsync(string refreshToken)
{
Dictionary<string, object> runtime_ = new Dictionary<string, object>
{
{"ignoreSSL", this._kernel.GetConfig("ignoreSSL")},
{"httpProxy", this._kernel.GetConfig("httpProxy")},
{"connectTimeout", 15000},
{"readTimeout", 15000},
{"retry", new Dictionary<string, int?>
{
{"maxAttempts", 0},
}},
};
TeaRequest _lastRequest = null;
Exception _lastException = null;
long _now = System.DateTime.Now.Millisecond;
int _retryTimes = 0;
while (TeaCore.AllowRetry((IDictionary) runtime_["retry"], _retryTimes, _now))
{
if (_retryTimes > 0)
{
int backoffTime = TeaCore.GetBackoffTime((IDictionary)runtime_["backoff"], _retryTimes);
if (backoffTime > 0)
{
TeaCore.Sleep(backoffTime);
}
}
_retryTimes = _retryTimes + 1;
try
{
TeaRequest request_ = new TeaRequest();
Dictionary<string, string> systemParams = new Dictionary<string, string>
{
{"method", "alipay.system.oauth.token"},
{"app_id", this._kernel.GetConfig("appId")},
{"timestamp", this._kernel.GetTimestamp()},
{"format", "json"},
{"version", "1.0"},
{"alipay_sdk", this._kernel.GetSdkVersion()},
{"charset", "UTF-8"},
{"sign_type", this._kernel.GetConfig("signType")},
{"app_cert_sn", this._kernel.GetMerchantCertSN()},
{"alipay_root_cert_sn", this._kernel.GetAlipayRootCertSN()},
};
Dictionary<string, object> bizParams = new Dictionary<string, object>(){};
Dictionary<string, string> textParams = new Dictionary<string, string>
{
{"grant_type", "refresh_token"},
{"refresh_token", refreshToken},
};
request_.Protocol = this._kernel.GetConfig("protocol");
request_.Method = "POST";
request_.Pathname = "/gateway.do";
request_.Headers = new Dictionary<string, string>
{
{"host", this._kernel.GetConfig("gatewayHost")},
{"content-type", "application/x-www-form-urlencoded;charset=utf-8"},
};
request_.Query = this._kernel.SortMap(TeaConverter.merge<string>
(
new Dictionary<string, string>()
{
{"sign", this._kernel.Sign(systemParams, bizParams, textParams, this._kernel.GetConfig("merchantPrivateKey"))},
},
systemParams,
textParams
));
request_.Body = TeaCore.BytesReadable(this._kernel.ToUrlEncodedRequestBody(bizParams));
_lastRequest = request_;
TeaResponse response_ = await TeaCore.DoActionAsync(request_, runtime_);
Dictionary<string, object> respMap = await this._kernel.ReadAsJsonAsync(response_, "alipay.system.oauth.token");
if (this._kernel.IsCertMode())
{
if (this._kernel.Verify(respMap, this._kernel.ExtractAlipayPublicKey(this._kernel.GetAlipayCertSN(respMap))))
{
return TeaModel.ToObject<AlipaySystemOauthTokenResponse>(this._kernel.ToRespModel(respMap));
}
}
else
{
if (this._kernel.Verify(respMap, this._kernel.GetConfig("alipayPublicKey")))
{
return TeaModel.ToObject<AlipaySystemOauthTokenResponse>(this._kernel.ToRespModel(respMap));
}
}
throw new TeaException(new Dictionary<string, string>
{
{"message", "验签失败,请检查支付宝公钥设置是否正确。"},
});
}
catch (Exception e)
{
if (TeaCore.IsRetryable(e))
{
_lastException = e;
continue;
}
throw e;
}
}
throw new TeaUnretryableException(_lastRequest, _lastException);
}
/// <summary>
/// ISV代商户代用指定appAuthToken
/// </summary>
/// <param name="appAuthToken">代调用token</param>
/// <returns>本客户端,便于链式调用</returns>
public Client Agent(string appAuthToken)
{
_kernel.InjectTextParam("app_auth_token", appAuthToken);
return this;
}
/// <summary>
/// 用户授权调用指定authToken
/// </summary>
/// <param name="authToken">用户授权token</param>
/// <returns>本客户端,便于链式调用</returns>
public Client Auth(string authToken)
{
_kernel.InjectTextParam("auth_token", authToken);
return this;
}
/// <summary>
/// 设置异步通知回调地址此处设置将在本调用中覆盖Config中的全局配置
/// </summary>
/// <param name="url">异步通知回调地址例如https://www.test.com/callback </param>
/// <returns>本客户端,便于链式调用</returns>
public Client AsyncNotify(string url)
{
_kernel.InjectTextParam("notify_url", url);
return this;
}
/// <summary>
/// 将本次调用强制路由到后端系统的测试地址上,常用于线下环境内外联调,沙箱与线上环境设置无效
/// </summary>
/// <param name="testUrl">后端系统测试地址</param>
/// <returns>本客户端,便于链式调用</returns>
public Client Route(string testUrl)
{
_kernel.InjectTextParam("ws_service_url", testUrl);
return this;
}
/// <summary>
/// 设置API入参中没有的其他可选业务请求参数(biz_content下的字段)
/// </summary>
/// <param name="key">业务请求参数名称biz_content下的字段名比如timeout_express</param>
/// <param name="value">
/// 业务请求参数的值一个可以序列化成JSON的对象
/// 如果该字段是一个字符串类型String、Price、Date在SDK中都是字符串请使用string储存
/// 如果该字段是一个数值型类型比如Number请使用long储存
/// 如果该字段是一个复杂类型请使用嵌套的Dictionary指定各下级字段的值
/// 如果该字段是一个数组请使用List储存各个值
/// 对于更复杂的情况也支持Dictionary和List的各种组合嵌套比如参数是值是个ListList中的每种类型是一个复杂对象
/// </param>
/// <returns>本客户端,便于链式调用</returns>
public Client Optional(string key, object value)
{
_kernel.InjectBizParam(key, value);
return this;
}
/// <summary>
/// 批量设置API入参中没有的其他可选业务请求参数(biz_content下的字段)
/// optional方法的批量版本
/// </summary>
/// <param name="optionalArgs">可选参数集合每个参数由key和value组成key和value的格式请参见optional方法的注释</param>
/// <returns>本客户端,便于链式调用</returns>
public Client BatchOptional(Dictionary<string, object> optionalArgs)
{
foreach (var pair in optionalArgs)
{
_kernel.InjectBizParam(pair.Key, pair.Value);
}
return this;
}
}
}

View File

@@ -0,0 +1,57 @@
// This file is auto-generated, don't edit it. Thanks.
using System;
using System.Collections.Generic;
using System.IO;
using Tea;
namespace Alipay.EasySDK.Base.OAuth.Models
{
public class AlipaySystemOauthTokenResponse : TeaModel {
/// <summary>
/// 响应原始字符串
/// </summary>
[NameInMap("http_body")]
[Validation(Required=true)]
public string HttpBody { get; set; }
[NameInMap("code")]
[Validation(Required=true)]
public string Code { get; set; }
[NameInMap("msg")]
[Validation(Required=true)]
public string Msg { get; set; }
[NameInMap("sub_code")]
[Validation(Required=true)]
public string SubCode { get; set; }
[NameInMap("sub_msg")]
[Validation(Required=true)]
public string SubMsg { get; set; }
[NameInMap("user_id")]
[Validation(Required=true)]
public string UserId { get; set; }
[NameInMap("access_token")]
[Validation(Required=true)]
public string AccessToken { get; set; }
[NameInMap("expires_in")]
[Validation(Required=true)]
public long ExpiresIn { get; set; }
[NameInMap("refresh_token")]
[Validation(Required=true)]
public string RefreshToken { get; set; }
[NameInMap("re_expires_in")]
[Validation(Required=true)]
public long ReExpiresIn { get; set; }
}
}

View File

@@ -0,0 +1,318 @@
// This file is auto-generated, don't edit it. Thanks.
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Threading.Tasks;
using Tea;
using Tea.Utils;
using Alipay.EasySDK.Base.Qrcode.Models;
namespace Alipay.EasySDK.Base.Qrcode
{
public class Client
{
protected Alipay.EasySDK.Kernel.Client _kernel;
public Client(Alipay.EasySDK.Kernel.Client kernel)
{
this._kernel = kernel;
}
public AlipayOpenAppQrcodeCreateResponse Create(string urlParam, string queryParam, string describe)
{
Dictionary<string, object> runtime_ = new Dictionary<string, object>
{
{"ignoreSSL", this._kernel.GetConfig("ignoreSSL")},
{"httpProxy", this._kernel.GetConfig("httpProxy")},
{"connectTimeout", 15000},
{"readTimeout", 15000},
{"retry", new Dictionary<string, int?>
{
{"maxAttempts", 0},
}},
};
TeaRequest _lastRequest = null;
Exception _lastException = null;
long _now = System.DateTime.Now.Millisecond;
int _retryTimes = 0;
while (TeaCore.AllowRetry((IDictionary) runtime_["retry"], _retryTimes, _now))
{
if (_retryTimes > 0)
{
int backoffTime = TeaCore.GetBackoffTime((IDictionary)runtime_["backoff"], _retryTimes);
if (backoffTime > 0)
{
TeaCore.Sleep(backoffTime);
}
}
_retryTimes = _retryTimes + 1;
try
{
TeaRequest request_ = new TeaRequest();
Dictionary<string, string> systemParams = new Dictionary<string, string>
{
{"method", "alipay.open.app.qrcode.create"},
{"app_id", this._kernel.GetConfig("appId")},
{"timestamp", this._kernel.GetTimestamp()},
{"format", "json"},
{"version", "1.0"},
{"alipay_sdk", this._kernel.GetSdkVersion()},
{"charset", "UTF-8"},
{"sign_type", this._kernel.GetConfig("signType")},
{"app_cert_sn", this._kernel.GetMerchantCertSN()},
{"alipay_root_cert_sn", this._kernel.GetAlipayRootCertSN()},
};
Dictionary<string, object> bizParams = new Dictionary<string, object>
{
{"url_param", urlParam},
{"query_param", queryParam},
{"describe", describe},
};
Dictionary<string, string> textParams = new Dictionary<string, string>(){};
request_.Protocol = this._kernel.GetConfig("protocol");
request_.Method = "POST";
request_.Pathname = "/gateway.do";
request_.Headers = new Dictionary<string, string>
{
{"host", this._kernel.GetConfig("gatewayHost")},
{"content-type", "application/x-www-form-urlencoded;charset=utf-8"},
};
request_.Query = this._kernel.SortMap(TeaConverter.merge<string>
(
new Dictionary<string, string>()
{
{"sign", this._kernel.Sign(systemParams, bizParams, textParams, this._kernel.GetConfig("merchantPrivateKey"))},
},
systemParams,
textParams
));
request_.Body = TeaCore.BytesReadable(this._kernel.ToUrlEncodedRequestBody(bizParams));
_lastRequest = request_;
TeaResponse response_ = TeaCore.DoAction(request_, runtime_);
Dictionary<string, object> respMap = this._kernel.ReadAsJson(response_, "alipay.open.app.qrcode.create");
if (this._kernel.IsCertMode())
{
if (this._kernel.Verify(respMap, this._kernel.ExtractAlipayPublicKey(this._kernel.GetAlipayCertSN(respMap))))
{
return TeaModel.ToObject<AlipayOpenAppQrcodeCreateResponse>(this._kernel.ToRespModel(respMap));
}
}
else
{
if (this._kernel.Verify(respMap, this._kernel.GetConfig("alipayPublicKey")))
{
return TeaModel.ToObject<AlipayOpenAppQrcodeCreateResponse>(this._kernel.ToRespModel(respMap));
}
}
throw new TeaException(new Dictionary<string, string>
{
{"message", "验签失败,请检查支付宝公钥设置是否正确。"},
});
}
catch (Exception e)
{
if (TeaCore.IsRetryable(e))
{
_lastException = e;
continue;
}
throw e;
}
}
throw new TeaUnretryableException(_lastRequest, _lastException);
}
public async Task<AlipayOpenAppQrcodeCreateResponse> CreateAsync(string urlParam, string queryParam, string describe)
{
Dictionary<string, object> runtime_ = new Dictionary<string, object>
{
{"ignoreSSL", this._kernel.GetConfig("ignoreSSL")},
{"httpProxy", this._kernel.GetConfig("httpProxy")},
{"connectTimeout", 15000},
{"readTimeout", 15000},
{"retry", new Dictionary<string, int?>
{
{"maxAttempts", 0},
}},
};
TeaRequest _lastRequest = null;
Exception _lastException = null;
long _now = System.DateTime.Now.Millisecond;
int _retryTimes = 0;
while (TeaCore.AllowRetry((IDictionary) runtime_["retry"], _retryTimes, _now))
{
if (_retryTimes > 0)
{
int backoffTime = TeaCore.GetBackoffTime((IDictionary)runtime_["backoff"], _retryTimes);
if (backoffTime > 0)
{
TeaCore.Sleep(backoffTime);
}
}
_retryTimes = _retryTimes + 1;
try
{
TeaRequest request_ = new TeaRequest();
Dictionary<string, string> systemParams = new Dictionary<string, string>
{
{"method", "alipay.open.app.qrcode.create"},
{"app_id", this._kernel.GetConfig("appId")},
{"timestamp", this._kernel.GetTimestamp()},
{"format", "json"},
{"version", "1.0"},
{"alipay_sdk", this._kernel.GetSdkVersion()},
{"charset", "UTF-8"},
{"sign_type", this._kernel.GetConfig("signType")},
{"app_cert_sn", this._kernel.GetMerchantCertSN()},
{"alipay_root_cert_sn", this._kernel.GetAlipayRootCertSN()},
};
Dictionary<string, object> bizParams = new Dictionary<string, object>
{
{"url_param", urlParam},
{"query_param", queryParam},
{"describe", describe},
};
Dictionary<string, string> textParams = new Dictionary<string, string>(){};
request_.Protocol = this._kernel.GetConfig("protocol");
request_.Method = "POST";
request_.Pathname = "/gateway.do";
request_.Headers = new Dictionary<string, string>
{
{"host", this._kernel.GetConfig("gatewayHost")},
{"content-type", "application/x-www-form-urlencoded;charset=utf-8"},
};
request_.Query = this._kernel.SortMap(TeaConverter.merge<string>
(
new Dictionary<string, string>()
{
{"sign", this._kernel.Sign(systemParams, bizParams, textParams, this._kernel.GetConfig("merchantPrivateKey"))},
},
systemParams,
textParams
));
request_.Body = TeaCore.BytesReadable(this._kernel.ToUrlEncodedRequestBody(bizParams));
_lastRequest = request_;
TeaResponse response_ = await TeaCore.DoActionAsync(request_, runtime_);
Dictionary<string, object> respMap = await this._kernel.ReadAsJsonAsync(response_, "alipay.open.app.qrcode.create");
if (this._kernel.IsCertMode())
{
if (this._kernel.Verify(respMap, this._kernel.ExtractAlipayPublicKey(this._kernel.GetAlipayCertSN(respMap))))
{
return TeaModel.ToObject<AlipayOpenAppQrcodeCreateResponse>(this._kernel.ToRespModel(respMap));
}
}
else
{
if (this._kernel.Verify(respMap, this._kernel.GetConfig("alipayPublicKey")))
{
return TeaModel.ToObject<AlipayOpenAppQrcodeCreateResponse>(this._kernel.ToRespModel(respMap));
}
}
throw new TeaException(new Dictionary<string, string>
{
{"message", "验签失败,请检查支付宝公钥设置是否正确。"},
});
}
catch (Exception e)
{
if (TeaCore.IsRetryable(e))
{
_lastException = e;
continue;
}
throw e;
}
}
throw new TeaUnretryableException(_lastRequest, _lastException);
}
/// <summary>
/// ISV代商户代用指定appAuthToken
/// </summary>
/// <param name="appAuthToken">代调用token</param>
/// <returns>本客户端,便于链式调用</returns>
public Client Agent(string appAuthToken)
{
_kernel.InjectTextParam("app_auth_token", appAuthToken);
return this;
}
/// <summary>
/// 用户授权调用指定authToken
/// </summary>
/// <param name="authToken">用户授权token</param>
/// <returns>本客户端,便于链式调用</returns>
public Client Auth(string authToken)
{
_kernel.InjectTextParam("auth_token", authToken);
return this;
}
/// <summary>
/// 设置异步通知回调地址此处设置将在本调用中覆盖Config中的全局配置
/// </summary>
/// <param name="url">异步通知回调地址例如https://www.test.com/callback </param>
/// <returns>本客户端,便于链式调用</returns>
public Client AsyncNotify(string url)
{
_kernel.InjectTextParam("notify_url", url);
return this;
}
/// <summary>
/// 将本次调用强制路由到后端系统的测试地址上,常用于线下环境内外联调,沙箱与线上环境设置无效
/// </summary>
/// <param name="testUrl">后端系统测试地址</param>
/// <returns>本客户端,便于链式调用</returns>
public Client Route(string testUrl)
{
_kernel.InjectTextParam("ws_service_url", testUrl);
return this;
}
/// <summary>
/// 设置API入参中没有的其他可选业务请求参数(biz_content下的字段)
/// </summary>
/// <param name="key">业务请求参数名称biz_content下的字段名比如timeout_express</param>
/// <param name="value">
/// 业务请求参数的值一个可以序列化成JSON的对象
/// 如果该字段是一个字符串类型String、Price、Date在SDK中都是字符串请使用string储存
/// 如果该字段是一个数值型类型比如Number请使用long储存
/// 如果该字段是一个复杂类型请使用嵌套的Dictionary指定各下级字段的值
/// 如果该字段是一个数组请使用List储存各个值
/// 对于更复杂的情况也支持Dictionary和List的各种组合嵌套比如参数是值是个ListList中的每种类型是一个复杂对象
/// </param>
/// <returns>本客户端,便于链式调用</returns>
public Client Optional(string key, object value)
{
_kernel.InjectBizParam(key, value);
return this;
}
/// <summary>
/// 批量设置API入参中没有的其他可选业务请求参数(biz_content下的字段)
/// optional方法的批量版本
/// </summary>
/// <param name="optionalArgs">可选参数集合每个参数由key和value组成key和value的格式请参见optional方法的注释</param>
/// <returns>本客户端,便于链式调用</returns>
public Client BatchOptional(Dictionary<string, object> optionalArgs)
{
foreach (var pair in optionalArgs)
{
_kernel.InjectBizParam(pair.Key, pair.Value);
}
return this;
}
}
}

View File

@@ -0,0 +1,41 @@
// This file is auto-generated, don't edit it. Thanks.
using System;
using System.Collections.Generic;
using System.IO;
using Tea;
namespace Alipay.EasySDK.Base.Qrcode.Models
{
public class AlipayOpenAppQrcodeCreateResponse : TeaModel {
/// <summary>
/// 响应原始字符串
/// </summary>
[NameInMap("http_body")]
[Validation(Required=true)]
public string HttpBody { get; set; }
[NameInMap("code")]
[Validation(Required=true)]
public string Code { get; set; }
[NameInMap("msg")]
[Validation(Required=true)]
public string Msg { get; set; }
[NameInMap("sub_code")]
[Validation(Required=true)]
public string SubCode { get; set; }
[NameInMap("sub_msg")]
[Validation(Required=true)]
public string SubMsg { get; set; }
[NameInMap("qr_code_url")]
[Validation(Required=true)]
public string QrCodeUrl { get; set; }
}
}

View File

@@ -0,0 +1,324 @@
// This file is auto-generated, don't edit it. Thanks.
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Threading.Tasks;
using Tea;
using Tea.Utils;
using Alipay.EasySDK.Base.Video.Models;
namespace Alipay.EasySDK.Base.Video
{
public class Client
{
protected Alipay.EasySDK.Kernel.Client _kernel;
public Client(Alipay.EasySDK.Kernel.Client kernel)
{
this._kernel = kernel;
}
public AlipayOfflineMaterialImageUploadResponse Upload(string videoName, string videoFilePath)
{
Dictionary<string, object> runtime_ = new Dictionary<string, object>
{
{"ignoreSSL", this._kernel.GetConfig("ignoreSSL")},
{"httpProxy", this._kernel.GetConfig("httpProxy")},
{"connectTimeout", 100000},
{"readTimeout", 100000},
{"retry", new Dictionary<string, int?>
{
{"maxAttempts", 0},
}},
};
TeaRequest _lastRequest = null;
Exception _lastException = null;
long _now = System.DateTime.Now.Millisecond;
int _retryTimes = 0;
while (TeaCore.AllowRetry((IDictionary) runtime_["retry"], _retryTimes, _now))
{
if (_retryTimes > 0)
{
int backoffTime = TeaCore.GetBackoffTime((IDictionary)runtime_["backoff"], _retryTimes);
if (backoffTime > 0)
{
TeaCore.Sleep(backoffTime);
}
}
_retryTimes = _retryTimes + 1;
try
{
TeaRequest request_ = new TeaRequest();
Dictionary<string, string> systemParams = new Dictionary<string, string>
{
{"method", "alipay.offline.material.image.upload"},
{"app_id", this._kernel.GetConfig("appId")},
{"timestamp", this._kernel.GetTimestamp()},
{"format", "json"},
{"version", "1.0"},
{"alipay_sdk", this._kernel.GetSdkVersion()},
{"charset", "UTF-8"},
{"sign_type", this._kernel.GetConfig("signType")},
{"app_cert_sn", this._kernel.GetMerchantCertSN()},
{"alipay_root_cert_sn", this._kernel.GetAlipayRootCertSN()},
};
Dictionary<string, object> bizParams = new Dictionary<string, object>(){};
Dictionary<string, string> textParams = new Dictionary<string, string>
{
{"image_type", "mp4"},
{"image_name", videoName},
};
Dictionary<string, string> fileParams = new Dictionary<string, string>
{
{"image_content", videoFilePath},
};
string boundary = this._kernel.GetRandomBoundary();
request_.Protocol = this._kernel.GetConfig("protocol");
request_.Method = "POST";
request_.Pathname = "/gateway.do";
request_.Headers = new Dictionary<string, string>
{
{"host", this._kernel.GetConfig("gatewayHost")},
{"content-type", this._kernel.ConcatStr("multipart/form-data;charset=utf-8;boundary=", boundary)},
};
request_.Query = this._kernel.SortMap(TeaConverter.merge<string>
(
new Dictionary<string, string>()
{
{"sign", this._kernel.Sign(systemParams, bizParams, textParams, this._kernel.GetConfig("merchantPrivateKey"))},
},
systemParams
));
request_.Body = this._kernel.ToMultipartRequestBody(textParams, fileParams, boundary);
_lastRequest = request_;
TeaResponse response_ = TeaCore.DoAction(request_, runtime_);
Dictionary<string, object> respMap = this._kernel.ReadAsJson(response_, "alipay.offline.material.image.upload");
if (this._kernel.IsCertMode())
{
if (this._kernel.Verify(respMap, this._kernel.ExtractAlipayPublicKey(this._kernel.GetAlipayCertSN(respMap))))
{
return TeaModel.ToObject<AlipayOfflineMaterialImageUploadResponse>(this._kernel.ToRespModel(respMap));
}
}
else
{
if (this._kernel.Verify(respMap, this._kernel.GetConfig("alipayPublicKey")))
{
return TeaModel.ToObject<AlipayOfflineMaterialImageUploadResponse>(this._kernel.ToRespModel(respMap));
}
}
throw new TeaException(new Dictionary<string, string>
{
{"message", "验签失败,请检查支付宝公钥设置是否正确。"},
});
}
catch (Exception e)
{
if (TeaCore.IsRetryable(e))
{
_lastException = e;
continue;
}
throw e;
}
}
throw new TeaUnretryableException(_lastRequest, _lastException);
}
public async Task<AlipayOfflineMaterialImageUploadResponse> UploadAsync(string videoName, string videoFilePath)
{
Dictionary<string, object> runtime_ = new Dictionary<string, object>
{
{"ignoreSSL", this._kernel.GetConfig("ignoreSSL")},
{"httpProxy", this._kernel.GetConfig("httpProxy")},
{"connectTimeout", 100000},
{"readTimeout", 100000},
{"retry", new Dictionary<string, int?>
{
{"maxAttempts", 0},
}},
};
TeaRequest _lastRequest = null;
Exception _lastException = null;
long _now = System.DateTime.Now.Millisecond;
int _retryTimes = 0;
while (TeaCore.AllowRetry((IDictionary) runtime_["retry"], _retryTimes, _now))
{
if (_retryTimes > 0)
{
int backoffTime = TeaCore.GetBackoffTime((IDictionary)runtime_["backoff"], _retryTimes);
if (backoffTime > 0)
{
TeaCore.Sleep(backoffTime);
}
}
_retryTimes = _retryTimes + 1;
try
{
TeaRequest request_ = new TeaRequest();
Dictionary<string, string> systemParams = new Dictionary<string, string>
{
{"method", "alipay.offline.material.image.upload"},
{"app_id", this._kernel.GetConfig("appId")},
{"timestamp", this._kernel.GetTimestamp()},
{"format", "json"},
{"version", "1.0"},
{"alipay_sdk", this._kernel.GetSdkVersion()},
{"charset", "UTF-8"},
{"sign_type", this._kernel.GetConfig("signType")},
{"app_cert_sn", this._kernel.GetMerchantCertSN()},
{"alipay_root_cert_sn", this._kernel.GetAlipayRootCertSN()},
};
Dictionary<string, object> bizParams = new Dictionary<string, object>(){};
Dictionary<string, string> textParams = new Dictionary<string, string>
{
{"image_type", "mp4"},
{"image_name", videoName},
};
Dictionary<string, string> fileParams = new Dictionary<string, string>
{
{"image_content", videoFilePath},
};
string boundary = this._kernel.GetRandomBoundary();
request_.Protocol = this._kernel.GetConfig("protocol");
request_.Method = "POST";
request_.Pathname = "/gateway.do";
request_.Headers = new Dictionary<string, string>
{
{"host", this._kernel.GetConfig("gatewayHost")},
{"content-type", this._kernel.ConcatStr("multipart/form-data;charset=utf-8;boundary=", boundary)},
};
request_.Query = this._kernel.SortMap(TeaConverter.merge<string>
(
new Dictionary<string, string>()
{
{"sign", this._kernel.Sign(systemParams, bizParams, textParams, this._kernel.GetConfig("merchantPrivateKey"))},
},
systemParams
));
request_.Body = this._kernel.ToMultipartRequestBody(textParams, fileParams, boundary);
_lastRequest = request_;
TeaResponse response_ = await TeaCore.DoActionAsync(request_, runtime_);
Dictionary<string, object> respMap = await this._kernel.ReadAsJsonAsync(response_, "alipay.offline.material.image.upload");
if (this._kernel.IsCertMode())
{
if (this._kernel.Verify(respMap, this._kernel.ExtractAlipayPublicKey(this._kernel.GetAlipayCertSN(respMap))))
{
return TeaModel.ToObject<AlipayOfflineMaterialImageUploadResponse>(this._kernel.ToRespModel(respMap));
}
}
else
{
if (this._kernel.Verify(respMap, this._kernel.GetConfig("alipayPublicKey")))
{
return TeaModel.ToObject<AlipayOfflineMaterialImageUploadResponse>(this._kernel.ToRespModel(respMap));
}
}
throw new TeaException(new Dictionary<string, string>
{
{"message", "验签失败,请检查支付宝公钥设置是否正确。"},
});
}
catch (Exception e)
{
if (TeaCore.IsRetryable(e))
{
_lastException = e;
continue;
}
throw e;
}
}
throw new TeaUnretryableException(_lastRequest, _lastException);
}
/// <summary>
/// ISV代商户代用指定appAuthToken
/// </summary>
/// <param name="appAuthToken">代调用token</param>
/// <returns>本客户端,便于链式调用</returns>
public Client Agent(string appAuthToken)
{
_kernel.InjectTextParam("app_auth_token", appAuthToken);
return this;
}
/// <summary>
/// 用户授权调用指定authToken
/// </summary>
/// <param name="authToken">用户授权token</param>
/// <returns>本客户端,便于链式调用</returns>
public Client Auth(string authToken)
{
_kernel.InjectTextParam("auth_token", authToken);
return this;
}
/// <summary>
/// 设置异步通知回调地址此处设置将在本调用中覆盖Config中的全局配置
/// </summary>
/// <param name="url">异步通知回调地址例如https://www.test.com/callback </param>
/// <returns>本客户端,便于链式调用</returns>
public Client AsyncNotify(string url)
{
_kernel.InjectTextParam("notify_url", url);
return this;
}
/// <summary>
/// 将本次调用强制路由到后端系统的测试地址上,常用于线下环境内外联调,沙箱与线上环境设置无效
/// </summary>
/// <param name="testUrl">后端系统测试地址</param>
/// <returns>本客户端,便于链式调用</returns>
public Client Route(string testUrl)
{
_kernel.InjectTextParam("ws_service_url", testUrl);
return this;
}
/// <summary>
/// 设置API入参中没有的其他可选业务请求参数(biz_content下的字段)
/// </summary>
/// <param name="key">业务请求参数名称biz_content下的字段名比如timeout_express</param>
/// <param name="value">
/// 业务请求参数的值一个可以序列化成JSON的对象
/// 如果该字段是一个字符串类型String、Price、Date在SDK中都是字符串请使用string储存
/// 如果该字段是一个数值型类型比如Number请使用long储存
/// 如果该字段是一个复杂类型请使用嵌套的Dictionary指定各下级字段的值
/// 如果该字段是一个数组请使用List储存各个值
/// 对于更复杂的情况也支持Dictionary和List的各种组合嵌套比如参数是值是个ListList中的每种类型是一个复杂对象
/// </param>
/// <returns>本客户端,便于链式调用</returns>
public Client Optional(string key, object value)
{
_kernel.InjectBizParam(key, value);
return this;
}
/// <summary>
/// 批量设置API入参中没有的其他可选业务请求参数(biz_content下的字段)
/// optional方法的批量版本
/// </summary>
/// <param name="optionalArgs">可选参数集合每个参数由key和value组成key和value的格式请参见optional方法的注释</param>
/// <returns>本客户端,便于链式调用</returns>
public Client BatchOptional(Dictionary<string, object> optionalArgs)
{
foreach (var pair in optionalArgs)
{
_kernel.InjectBizParam(pair.Key, pair.Value);
}
return this;
}
}
}

View File

@@ -0,0 +1,45 @@
// This file is auto-generated, don't edit it. Thanks.
using System;
using System.Collections.Generic;
using System.IO;
using Tea;
namespace Alipay.EasySDK.Base.Video.Models
{
public class AlipayOfflineMaterialImageUploadResponse : TeaModel {
/// <summary>
/// 响应原始字符串
/// </summary>
[NameInMap("http_body")]
[Validation(Required=true)]
public string HttpBody { get; set; }
[NameInMap("code")]
[Validation(Required=true)]
public string Code { get; set; }
[NameInMap("msg")]
[Validation(Required=true)]
public string Msg { get; set; }
[NameInMap("sub_code")]
[Validation(Required=true)]
public string SubCode { get; set; }
[NameInMap("sub_msg")]
[Validation(Required=true)]
public string SubMsg { get; set; }
[NameInMap("image_id")]
[Validation(Required=true)]
public string ImageId { get; set; }
[NameInMap("image_url")]
[Validation(Required=true)]
public string ImageUrl { get; set; }
}
}

View File

@@ -0,0 +1,244 @@
using System;
using Alipay.EasySDK.Kernel;
using System.Reflection;
namespace Alipay.EasySDK.Factory
{
/// <summary>
/// 客户端工厂用于快速配置和访问各种场景下的API Client
///
/// 注该Factory获取的Client不可储存重复使用请每次均通过Factory完成调用
/// </summary>
public static class Factory
{
public const string SDK_VERSION = "alipay-easysdk-net-2.1.0";
/// <summary>
/// 将一些初始化耗时较多的信息缓存在上下文中
/// </summary>
private static Context context;
/// <summary>
/// 设置客户端参数只需设置一次即可反复使用各种场景下的API Client
/// </summary>
/// <param name="options">客户端参数对象</param>
public static void SetOptions(Config options)
{
context = new Context(options, SDK_VERSION);
}
/// <summary>
/// 获取调用OpenAPI所需的客户端实例
/// 本方法用于调用SDK扩展包中的API Client下的方法
///
/// 注:返回的实例不可重复使用,只可用于单次调用
/// </summary>
/// <typeparam name="T">泛型参数</typeparam>
/// <param name="client">API Client的类型对象</param>
/// <returns>client实例用于发起单次调用</returns>
public static T GetClient<T>()
{
Type type = typeof(T);
ConstructorInfo constructor = type.GetConstructor(new Type[] { typeof(Client) });
context.SdkVersion = GetSdkVersion(type);
return (T)constructor.Invoke(new object[] { new Client(context) });
}
private static string GetSdkVersion(Type client)
{
return context.SdkVersion + "-" + client.FullName
.Replace("EasySDK.", "")
.Replace(".Client", "")
.Replace(".", "-");
}
/// <summary>
/// 基础能力相关
/// </summary>
public static class Base
{
/// <summary>
/// 获取图片相关API Client
/// </summary>
/// <returns>图片相关API Client</returns>
public static EasySDK.Base.Image.Client Image()
{
return new EasySDK.Base.Image.Client(new Client(context));
}
/// <summary>
/// 获取视频相关API Client
/// </summary>
/// <returns>视频相关API Client</returns>
public static EasySDK.Base.Video.Client Video()
{
return new EasySDK.Base.Video.Client(new Client(context));
}
/// <summary>
/// 获取OAuth认证相关API Client
/// </summary>
/// <returns>OAuth认证相关API Client</returns>
public static EasySDK.Base.OAuth.Client OAuth()
{
return new EasySDK.Base.OAuth.Client(new Client(context));
}
/// <summary>
/// 获取小程序二维码相关API Client
/// </summary>
/// <returns>小程序二维码相关API Client</returns>
public static EasySDK.Base.Qrcode.Client Qrcode()
{
return new EasySDK.Base.Qrcode.Client(new Client(context));
}
}
/// <summary>
/// 营销能力相关
/// </summary>
public static class Marketing
{
/// <summary>
/// 获取生活号相关API Client
/// </summary>
/// <returns>生活号相关API Client</returns>
public static EasySDK.Marketing.OpenLife.Client OpenLife()
{
return new EasySDK.Marketing.OpenLife.Client(new Client(context));
}
/// <summary>
/// 获取支付宝卡包相关API Client
/// </summary>
/// <returns>支付宝卡包相关API Client</returns>
public static EasySDK.Marketing.Pass.Client Pass()
{
return new EasySDK.Marketing.Pass.Client(new Client(context));
}
/// <summary>
/// 获取小程序模板消息相关API Client
/// </summary>
/// <returns>小程序模板消息相关API Client</returns>
public static EasySDK.Marketing.TemplateMessage.Client TemplateMessage()
{
return new EasySDK.Marketing.TemplateMessage.Client(new Client(context));
}
}
/// <summary>
/// 会员能力相关
/// </summary>
public static class Member
{
/// <summary>
/// 获取支付宝身份认证相关API Client
/// </summary>
/// <returns>支付宝身份认证相关API Client</returns>
public static EasySDK.Member.Identification.Client Identification()
{
return new EasySDK.Member.Identification.Client(new Client(context));
}
}
/// <summary>
/// 支付能力相关
/// </summary>
public static class Payment
{
/// <summary>
/// 获取支付通用API Client
/// </summary>
/// <returns>支付通用API Client</returns>
public static EasySDK.Payment.Common.Client Common()
{
return new EasySDK.Payment.Common.Client(new Client(context));
}
/// <summary>
/// 获取当面付API Client
/// </summary>
/// <returns>当面付API Client</returns>
public static EasySDK.Payment.FaceToFace.Client FaceToFace()
{
return new EasySDK.Payment.FaceToFace.Client(new Client(context));
}
/// <summary>
/// 获取花呗API Client
/// </summary>
/// <returns>花呗API Client</returns>
public static EasySDK.Payment.Huabei.Client Huabei()
{
return new EasySDK.Payment.Huabei.Client(new Client(context));
}
/// <summary>
/// 获取手机APP支付API Client
/// </summary>
/// <returns>手机APP支付API Client</returns>
public static EasySDK.Payment.App.Client App()
{
return new EasySDK.Payment.App.Client(new Client(context));
}
/// <summary>
/// 获取电脑网站支付API Client
/// </summary>
/// <returns>电脑网站支付API</returns>
public static EasySDK.Payment.Page.Client Page()
{
return new EasySDK.Payment.Page.Client(new Client(context));
}
/// <summary>
/// 获取手机网站支付API Client
/// </summary>
/// <returns>手机网站支付API</returns>
public static EasySDK.Payment.Wap.Client Wap()
{
return new EasySDK.Payment.Wap.Client(new Client(context));
}
}
/// <summary>
/// 安全能力相关
/// </summary>
public static class Security
{
/// <summary>
/// 获取文本风险识别相关API Client
/// </summary>
/// <returns>文本风险识别相关API Client</returns>
public static EasySDK.Security.TextRisk.Client TextRisk()
{
return new EasySDK.Security.TextRisk.Client(new Client(context));
}
}
/// <summary>
/// 辅助工具
/// </summary>
public static class Util
{
/// <summary>
/// 获取OpenAPI通用接口可通过自行拼装参数调用几乎所有OpenAPI
/// </summary>
/// <returns>OpenAPI通用接口</returns>
public static EasySDK.Util.Generic.Client Generic()
{
return new EasySDK.Util.Generic.Client(new Client(context));
}
/// <summary>
/// 获取AES128加解密相关API Client常用于会员手机号的解密
/// </summary>
/// <returns>AES128加解密相关API Client</returns>
public static EasySDK.Util.AES.Client AES()
{
return new EasySDK.Util.AES.Client(new Client(context));
}
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,37 @@
// This file is auto-generated, don't edit it. Thanks.
using System;
using System.Collections.Generic;
using System.IO;
using Tea;
namespace Alipay.EasySDK.Marketing.OpenLife.Models
{
public class AlipayOpenPublicLifeMsgRecallResponse : TeaModel {
/// <summary>
/// 响应原始字符串
/// </summary>
[NameInMap("http_body")]
[Validation(Required=true)]
public string HttpBody { get; set; }
[NameInMap("code")]
[Validation(Required=true)]
public string Code { get; set; }
[NameInMap("msg")]
[Validation(Required=true)]
public string Msg { get; set; }
[NameInMap("sub_code")]
[Validation(Required=true)]
public string SubCode { get; set; }
[NameInMap("sub_msg")]
[Validation(Required=true)]
public string SubMsg { get; set; }
}
}

View File

@@ -0,0 +1,45 @@
// This file is auto-generated, don't edit it. Thanks.
using System;
using System.Collections.Generic;
using System.IO;
using Tea;
namespace Alipay.EasySDK.Marketing.OpenLife.Models
{
public class AlipayOpenPublicMessageContentCreateResponse : TeaModel {
/// <summary>
/// 响应原始字符串
/// </summary>
[NameInMap("http_body")]
[Validation(Required=true)]
public string HttpBody { get; set; }
[NameInMap("code")]
[Validation(Required=true)]
public string Code { get; set; }
[NameInMap("msg")]
[Validation(Required=true)]
public string Msg { get; set; }
[NameInMap("sub_code")]
[Validation(Required=true)]
public string SubCode { get; set; }
[NameInMap("sub_msg")]
[Validation(Required=true)]
public string SubMsg { get; set; }
[NameInMap("content_id")]
[Validation(Required=true)]
public string ContentId { get; set; }
[NameInMap("content_url")]
[Validation(Required=true)]
public string ContentUrl { get; set; }
}
}

View File

@@ -0,0 +1,45 @@
// This file is auto-generated, don't edit it. Thanks.
using System;
using System.Collections.Generic;
using System.IO;
using Tea;
namespace Alipay.EasySDK.Marketing.OpenLife.Models
{
public class AlipayOpenPublicMessageContentModifyResponse : TeaModel {
/// <summary>
/// 响应原始字符串
/// </summary>
[NameInMap("http_body")]
[Validation(Required=true)]
public string HttpBody { get; set; }
[NameInMap("code")]
[Validation(Required=true)]
public string Code { get; set; }
[NameInMap("msg")]
[Validation(Required=true)]
public string Msg { get; set; }
[NameInMap("sub_code")]
[Validation(Required=true)]
public string SubCode { get; set; }
[NameInMap("sub_msg")]
[Validation(Required=true)]
public string SubMsg { get; set; }
[NameInMap("content_id")]
[Validation(Required=true)]
public string ContentId { get; set; }
[NameInMap("content_url")]
[Validation(Required=true)]
public string ContentUrl { get; set; }
}
}

View File

@@ -0,0 +1,37 @@
// This file is auto-generated, don't edit it. Thanks.
using System;
using System.Collections.Generic;
using System.IO;
using Tea;
namespace Alipay.EasySDK.Marketing.OpenLife.Models
{
public class AlipayOpenPublicMessageSingleSendResponse : TeaModel {
/// <summary>
/// 响应原始字符串
/// </summary>
[NameInMap("http_body")]
[Validation(Required=true)]
public string HttpBody { get; set; }
[NameInMap("code")]
[Validation(Required=true)]
public string Code { get; set; }
[NameInMap("msg")]
[Validation(Required=true)]
public string Msg { get; set; }
[NameInMap("sub_code")]
[Validation(Required=true)]
public string SubCode { get; set; }
[NameInMap("sub_msg")]
[Validation(Required=true)]
public string SubMsg { get; set; }
}
}

View File

@@ -0,0 +1,41 @@
// This file is auto-generated, don't edit it. Thanks.
using System;
using System.Collections.Generic;
using System.IO;
using Tea;
namespace Alipay.EasySDK.Marketing.OpenLife.Models
{
public class AlipayOpenPublicMessageTotalSendResponse : TeaModel {
/// <summary>
/// 响应原始字符串
/// </summary>
[NameInMap("http_body")]
[Validation(Required=true)]
public string HttpBody { get; set; }
[NameInMap("code")]
[Validation(Required=true)]
public string Code { get; set; }
[NameInMap("msg")]
[Validation(Required=true)]
public string Msg { get; set; }
[NameInMap("sub_code")]
[Validation(Required=true)]
public string SubCode { get; set; }
[NameInMap("sub_msg")]
[Validation(Required=true)]
public string SubMsg { get; set; }
[NameInMap("message_id")]
[Validation(Required=true)]
public string MessageId { get; set; }
}
}

View File

@@ -0,0 +1,45 @@
// This file is auto-generated, don't edit it. Thanks.
using System;
using System.Collections.Generic;
using System.IO;
using Tea;
namespace Alipay.EasySDK.Marketing.OpenLife.Models
{
public class AlipayOpenPublicSettingCategoryQueryResponse : TeaModel {
/// <summary>
/// 响应原始字符串
/// </summary>
[NameInMap("http_body")]
[Validation(Required=true)]
public string HttpBody { get; set; }
[NameInMap("code")]
[Validation(Required=true)]
public string Code { get; set; }
[NameInMap("msg")]
[Validation(Required=true)]
public string Msg { get; set; }
[NameInMap("sub_code")]
[Validation(Required=true)]
public string SubCode { get; set; }
[NameInMap("sub_msg")]
[Validation(Required=true)]
public string SubMsg { get; set; }
[NameInMap("primary_category")]
[Validation(Required=true)]
public string PrimaryCategory { get; set; }
[NameInMap("secondary_category")]
[Validation(Required=true)]
public string SecondaryCategory { get; set; }
}
}

View File

@@ -0,0 +1,37 @@
// This file is auto-generated, don't edit it. Thanks.
using System;
using System.Collections.Generic;
using System.IO;
using Tea;
namespace Alipay.EasySDK.Marketing.OpenLife.Models
{
public class AlipayOpenPublicTemplateMessageIndustryModifyResponse : TeaModel {
/// <summary>
/// 响应原始字符串
/// </summary>
[NameInMap("http_body")]
[Validation(Required=true)]
public string HttpBody { get; set; }
[NameInMap("code")]
[Validation(Required=true)]
public string Code { get; set; }
[NameInMap("msg")]
[Validation(Required=true)]
public string Msg { get; set; }
[NameInMap("sub_code")]
[Validation(Required=true)]
public string SubCode { get; set; }
[NameInMap("sub_msg")]
[Validation(Required=true)]
public string SubMsg { get; set; }
}
}

View File

@@ -0,0 +1,34 @@
// This file is auto-generated, don't edit it. Thanks.
using System;
using System.Collections.Generic;
using System.IO;
using Tea;
namespace Alipay.EasySDK.Marketing.OpenLife.Models
{
public class Article : TeaModel {
[NameInMap("title")]
[Validation(Required=false)]
public string Title { get; set; }
[NameInMap("desc")]
[Validation(Required=true)]
public string Desc { get; set; }
[NameInMap("image_url")]
[Validation(Required=false)]
public string ImageUrl { get; set; }
[NameInMap("url")]
[Validation(Required=true)]
public string Url { get; set; }
[NameInMap("action_name")]
[Validation(Required=false)]
public string ActionName { get; set; }
}
}

View File

@@ -0,0 +1,42 @@
// This file is auto-generated, don't edit it. Thanks.
using System;
using System.Collections.Generic;
using System.IO;
using Tea;
namespace Alipay.EasySDK.Marketing.OpenLife.Models
{
public class Context : TeaModel {
[NameInMap("head_color")]
[Validation(Required=true)]
public string HeadColor { get; set; }
[NameInMap("url")]
[Validation(Required=true)]
public string Url { get; set; }
[NameInMap("action_name")]
[Validation(Required=true)]
public string ActionName { get; set; }
[NameInMap("keyword1")]
[Validation(Required=false)]
public Keyword Keyword1 { get; set; }
[NameInMap("keyword2")]
[Validation(Required=false)]
public Keyword Keyword2 { get; set; }
[NameInMap("first")]
[Validation(Required=false)]
public Keyword First { get; set; }
[NameInMap("remark")]
[Validation(Required=false)]
public Keyword Remark { get; set; }
}
}

View File

@@ -0,0 +1,22 @@
// This file is auto-generated, don't edit it. Thanks.
using System;
using System.Collections.Generic;
using System.IO;
using Tea;
namespace Alipay.EasySDK.Marketing.OpenLife.Models
{
public class Keyword : TeaModel {
[NameInMap("color")]
[Validation(Required=true)]
public string Color { get; set; }
[NameInMap("value")]
[Validation(Required=true)]
public string Value { get; set; }
}
}

View File

@@ -0,0 +1,22 @@
// This file is auto-generated, don't edit it. Thanks.
using System;
using System.Collections.Generic;
using System.IO;
using Tea;
namespace Alipay.EasySDK.Marketing.OpenLife.Models
{
public class Template : TeaModel {
[NameInMap("template_id")]
[Validation(Required=true)]
public string TemplateId { get; set; }
[NameInMap("context")]
[Validation(Required=true)]
public Context Context { get; set; }
}
}

View File

@@ -0,0 +1,22 @@
// This file is auto-generated, don't edit it. Thanks.
using System;
using System.Collections.Generic;
using System.IO;
using Tea;
namespace Alipay.EasySDK.Marketing.OpenLife.Models
{
public class Text : TeaModel {
[NameInMap("title")]
[Validation(Required=true)]
public string Title { get; set; }
[NameInMap("content")]
[Validation(Required=true)]
public string Content { get; set; }
}
}

View File

@@ -0,0 +1,964 @@
// This file is auto-generated, don't edit it. Thanks.
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Threading.Tasks;
using Tea;
using Tea.Utils;
using Alipay.EasySDK.Marketing.Pass.Models;
namespace Alipay.EasySDK.Marketing.Pass
{
public class Client
{
protected Alipay.EasySDK.Kernel.Client _kernel;
public Client(Alipay.EasySDK.Kernel.Client kernel)
{
this._kernel = kernel;
}
public AlipayPassTemplateAddResponse CreateTemplate(string uniqueId, string tplContent)
{
Dictionary<string, object> runtime_ = new Dictionary<string, object>
{
{"ignoreSSL", this._kernel.GetConfig("ignoreSSL")},
{"httpProxy", this._kernel.GetConfig("httpProxy")},
{"connectTimeout", 15000},
{"readTimeout", 15000},
{"retry", new Dictionary<string, int?>
{
{"maxAttempts", 0},
}},
};
TeaRequest _lastRequest = null;
Exception _lastException = null;
long _now = System.DateTime.Now.Millisecond;
int _retryTimes = 0;
while (TeaCore.AllowRetry((IDictionary) runtime_["retry"], _retryTimes, _now))
{
if (_retryTimes > 0)
{
int backoffTime = TeaCore.GetBackoffTime((IDictionary)runtime_["backoff"], _retryTimes);
if (backoffTime > 0)
{
TeaCore.Sleep(backoffTime);
}
}
_retryTimes = _retryTimes + 1;
try
{
TeaRequest request_ = new TeaRequest();
Dictionary<string, string> systemParams = new Dictionary<string, string>
{
{"method", "alipay.pass.template.add"},
{"app_id", this._kernel.GetConfig("appId")},
{"timestamp", this._kernel.GetTimestamp()},
{"format", "json"},
{"version", "1.0"},
{"alipay_sdk", this._kernel.GetSdkVersion()},
{"charset", "UTF-8"},
{"sign_type", this._kernel.GetConfig("signType")},
{"app_cert_sn", this._kernel.GetMerchantCertSN()},
{"alipay_root_cert_sn", this._kernel.GetAlipayRootCertSN()},
};
Dictionary<string, object> bizParams = new Dictionary<string, object>
{
{"unique_id", uniqueId},
{"tpl_content", tplContent},
};
Dictionary<string, string> textParams = new Dictionary<string, string>(){};
request_.Protocol = this._kernel.GetConfig("protocol");
request_.Method = "POST";
request_.Pathname = "/gateway.do";
request_.Headers = new Dictionary<string, string>
{
{"host", this._kernel.GetConfig("gatewayHost")},
{"content-type", "application/x-www-form-urlencoded;charset=utf-8"},
};
request_.Query = this._kernel.SortMap(TeaConverter.merge<string>
(
new Dictionary<string, string>()
{
{"sign", this._kernel.Sign(systemParams, bizParams, textParams, this._kernel.GetConfig("merchantPrivateKey"))},
},
systemParams,
textParams
));
request_.Body = TeaCore.BytesReadable(this._kernel.ToUrlEncodedRequestBody(bizParams));
_lastRequest = request_;
TeaResponse response_ = TeaCore.DoAction(request_, runtime_);
Dictionary<string, object> respMap = this._kernel.ReadAsJson(response_, "alipay.pass.template.add");
if (this._kernel.IsCertMode())
{
if (this._kernel.Verify(respMap, this._kernel.ExtractAlipayPublicKey(this._kernel.GetAlipayCertSN(respMap))))
{
return TeaModel.ToObject<AlipayPassTemplateAddResponse>(this._kernel.ToRespModel(respMap));
}
}
else
{
if (this._kernel.Verify(respMap, this._kernel.GetConfig("alipayPublicKey")))
{
return TeaModel.ToObject<AlipayPassTemplateAddResponse>(this._kernel.ToRespModel(respMap));
}
}
throw new TeaException(new Dictionary<string, string>
{
{"message", "验签失败,请检查支付宝公钥设置是否正确。"},
});
}
catch (Exception e)
{
if (TeaCore.IsRetryable(e))
{
_lastException = e;
continue;
}
throw e;
}
}
throw new TeaUnretryableException(_lastRequest, _lastException);
}
public async Task<AlipayPassTemplateAddResponse> CreateTemplateAsync(string uniqueId, string tplContent)
{
Dictionary<string, object> runtime_ = new Dictionary<string, object>
{
{"ignoreSSL", this._kernel.GetConfig("ignoreSSL")},
{"httpProxy", this._kernel.GetConfig("httpProxy")},
{"connectTimeout", 15000},
{"readTimeout", 15000},
{"retry", new Dictionary<string, int?>
{
{"maxAttempts", 0},
}},
};
TeaRequest _lastRequest = null;
Exception _lastException = null;
long _now = System.DateTime.Now.Millisecond;
int _retryTimes = 0;
while (TeaCore.AllowRetry((IDictionary) runtime_["retry"], _retryTimes, _now))
{
if (_retryTimes > 0)
{
int backoffTime = TeaCore.GetBackoffTime((IDictionary)runtime_["backoff"], _retryTimes);
if (backoffTime > 0)
{
TeaCore.Sleep(backoffTime);
}
}
_retryTimes = _retryTimes + 1;
try
{
TeaRequest request_ = new TeaRequest();
Dictionary<string, string> systemParams = new Dictionary<string, string>
{
{"method", "alipay.pass.template.add"},
{"app_id", this._kernel.GetConfig("appId")},
{"timestamp", this._kernel.GetTimestamp()},
{"format", "json"},
{"version", "1.0"},
{"alipay_sdk", this._kernel.GetSdkVersion()},
{"charset", "UTF-8"},
{"sign_type", this._kernel.GetConfig("signType")},
{"app_cert_sn", this._kernel.GetMerchantCertSN()},
{"alipay_root_cert_sn", this._kernel.GetAlipayRootCertSN()},
};
Dictionary<string, object> bizParams = new Dictionary<string, object>
{
{"unique_id", uniqueId},
{"tpl_content", tplContent},
};
Dictionary<string, string> textParams = new Dictionary<string, string>(){};
request_.Protocol = this._kernel.GetConfig("protocol");
request_.Method = "POST";
request_.Pathname = "/gateway.do";
request_.Headers = new Dictionary<string, string>
{
{"host", this._kernel.GetConfig("gatewayHost")},
{"content-type", "application/x-www-form-urlencoded;charset=utf-8"},
};
request_.Query = this._kernel.SortMap(TeaConverter.merge<string>
(
new Dictionary<string, string>()
{
{"sign", this._kernel.Sign(systemParams, bizParams, textParams, this._kernel.GetConfig("merchantPrivateKey"))},
},
systemParams,
textParams
));
request_.Body = TeaCore.BytesReadable(this._kernel.ToUrlEncodedRequestBody(bizParams));
_lastRequest = request_;
TeaResponse response_ = await TeaCore.DoActionAsync(request_, runtime_);
Dictionary<string, object> respMap = await this._kernel.ReadAsJsonAsync(response_, "alipay.pass.template.add");
if (this._kernel.IsCertMode())
{
if (this._kernel.Verify(respMap, this._kernel.ExtractAlipayPublicKey(this._kernel.GetAlipayCertSN(respMap))))
{
return TeaModel.ToObject<AlipayPassTemplateAddResponse>(this._kernel.ToRespModel(respMap));
}
}
else
{
if (this._kernel.Verify(respMap, this._kernel.GetConfig("alipayPublicKey")))
{
return TeaModel.ToObject<AlipayPassTemplateAddResponse>(this._kernel.ToRespModel(respMap));
}
}
throw new TeaException(new Dictionary<string, string>
{
{"message", "验签失败,请检查支付宝公钥设置是否正确。"},
});
}
catch (Exception e)
{
if (TeaCore.IsRetryable(e))
{
_lastException = e;
continue;
}
throw e;
}
}
throw new TeaUnretryableException(_lastRequest, _lastException);
}
public AlipayPassTemplateUpdateResponse UpdateTemplate(string tplId, string tplContent)
{
Dictionary<string, object> runtime_ = new Dictionary<string, object>
{
{"ignoreSSL", this._kernel.GetConfig("ignoreSSL")},
{"httpProxy", this._kernel.GetConfig("httpProxy")},
{"connectTimeout", 15000},
{"readTimeout", 15000},
{"retry", new Dictionary<string, int?>
{
{"maxAttempts", 0},
}},
};
TeaRequest _lastRequest = null;
Exception _lastException = null;
long _now = System.DateTime.Now.Millisecond;
int _retryTimes = 0;
while (TeaCore.AllowRetry((IDictionary) runtime_["retry"], _retryTimes, _now))
{
if (_retryTimes > 0)
{
int backoffTime = TeaCore.GetBackoffTime((IDictionary)runtime_["backoff"], _retryTimes);
if (backoffTime > 0)
{
TeaCore.Sleep(backoffTime);
}
}
_retryTimes = _retryTimes + 1;
try
{
TeaRequest request_ = new TeaRequest();
Dictionary<string, string> systemParams = new Dictionary<string, string>
{
{"method", "alipay.pass.template.update"},
{"app_id", this._kernel.GetConfig("appId")},
{"timestamp", this._kernel.GetTimestamp()},
{"format", "json"},
{"version", "1.0"},
{"alipay_sdk", this._kernel.GetSdkVersion()},
{"charset", "UTF-8"},
{"sign_type", this._kernel.GetConfig("signType")},
{"app_cert_sn", this._kernel.GetMerchantCertSN()},
{"alipay_root_cert_sn", this._kernel.GetAlipayRootCertSN()},
};
Dictionary<string, object> bizParams = new Dictionary<string, object>
{
{"tpl_id", tplId},
{"tpl_content", tplContent},
};
Dictionary<string, string> textParams = new Dictionary<string, string>(){};
request_.Protocol = this._kernel.GetConfig("protocol");
request_.Method = "POST";
request_.Pathname = "/gateway.do";
request_.Headers = new Dictionary<string, string>
{
{"host", this._kernel.GetConfig("gatewayHost")},
{"content-type", "application/x-www-form-urlencoded;charset=utf-8"},
};
request_.Query = this._kernel.SortMap(TeaConverter.merge<string>
(
new Dictionary<string, string>()
{
{"sign", this._kernel.Sign(systemParams, bizParams, textParams, this._kernel.GetConfig("merchantPrivateKey"))},
},
systemParams,
textParams
));
request_.Body = TeaCore.BytesReadable(this._kernel.ToUrlEncodedRequestBody(bizParams));
_lastRequest = request_;
TeaResponse response_ = TeaCore.DoAction(request_, runtime_);
Dictionary<string, object> respMap = this._kernel.ReadAsJson(response_, "alipay.pass.template.update");
if (this._kernel.IsCertMode())
{
if (this._kernel.Verify(respMap, this._kernel.ExtractAlipayPublicKey(this._kernel.GetAlipayCertSN(respMap))))
{
return TeaModel.ToObject<AlipayPassTemplateUpdateResponse>(this._kernel.ToRespModel(respMap));
}
}
else
{
if (this._kernel.Verify(respMap, this._kernel.GetConfig("alipayPublicKey")))
{
return TeaModel.ToObject<AlipayPassTemplateUpdateResponse>(this._kernel.ToRespModel(respMap));
}
}
throw new TeaException(new Dictionary<string, string>
{
{"message", "验签失败,请检查支付宝公钥设置是否正确。"},
});
}
catch (Exception e)
{
if (TeaCore.IsRetryable(e))
{
_lastException = e;
continue;
}
throw e;
}
}
throw new TeaUnretryableException(_lastRequest, _lastException);
}
public async Task<AlipayPassTemplateUpdateResponse> UpdateTemplateAsync(string tplId, string tplContent)
{
Dictionary<string, object> runtime_ = new Dictionary<string, object>
{
{"ignoreSSL", this._kernel.GetConfig("ignoreSSL")},
{"httpProxy", this._kernel.GetConfig("httpProxy")},
{"connectTimeout", 15000},
{"readTimeout", 15000},
{"retry", new Dictionary<string, int?>
{
{"maxAttempts", 0},
}},
};
TeaRequest _lastRequest = null;
Exception _lastException = null;
long _now = System.DateTime.Now.Millisecond;
int _retryTimes = 0;
while (TeaCore.AllowRetry((IDictionary) runtime_["retry"], _retryTimes, _now))
{
if (_retryTimes > 0)
{
int backoffTime = TeaCore.GetBackoffTime((IDictionary)runtime_["backoff"], _retryTimes);
if (backoffTime > 0)
{
TeaCore.Sleep(backoffTime);
}
}
_retryTimes = _retryTimes + 1;
try
{
TeaRequest request_ = new TeaRequest();
Dictionary<string, string> systemParams = new Dictionary<string, string>
{
{"method", "alipay.pass.template.update"},
{"app_id", this._kernel.GetConfig("appId")},
{"timestamp", this._kernel.GetTimestamp()},
{"format", "json"},
{"version", "1.0"},
{"alipay_sdk", this._kernel.GetSdkVersion()},
{"charset", "UTF-8"},
{"sign_type", this._kernel.GetConfig("signType")},
{"app_cert_sn", this._kernel.GetMerchantCertSN()},
{"alipay_root_cert_sn", this._kernel.GetAlipayRootCertSN()},
};
Dictionary<string, object> bizParams = new Dictionary<string, object>
{
{"tpl_id", tplId},
{"tpl_content", tplContent},
};
Dictionary<string, string> textParams = new Dictionary<string, string>(){};
request_.Protocol = this._kernel.GetConfig("protocol");
request_.Method = "POST";
request_.Pathname = "/gateway.do";
request_.Headers = new Dictionary<string, string>
{
{"host", this._kernel.GetConfig("gatewayHost")},
{"content-type", "application/x-www-form-urlencoded;charset=utf-8"},
};
request_.Query = this._kernel.SortMap(TeaConverter.merge<string>
(
new Dictionary<string, string>()
{
{"sign", this._kernel.Sign(systemParams, bizParams, textParams, this._kernel.GetConfig("merchantPrivateKey"))},
},
systemParams,
textParams
));
request_.Body = TeaCore.BytesReadable(this._kernel.ToUrlEncodedRequestBody(bizParams));
_lastRequest = request_;
TeaResponse response_ = await TeaCore.DoActionAsync(request_, runtime_);
Dictionary<string, object> respMap = await this._kernel.ReadAsJsonAsync(response_, "alipay.pass.template.update");
if (this._kernel.IsCertMode())
{
if (this._kernel.Verify(respMap, this._kernel.ExtractAlipayPublicKey(this._kernel.GetAlipayCertSN(respMap))))
{
return TeaModel.ToObject<AlipayPassTemplateUpdateResponse>(this._kernel.ToRespModel(respMap));
}
}
else
{
if (this._kernel.Verify(respMap, this._kernel.GetConfig("alipayPublicKey")))
{
return TeaModel.ToObject<AlipayPassTemplateUpdateResponse>(this._kernel.ToRespModel(respMap));
}
}
throw new TeaException(new Dictionary<string, string>
{
{"message", "验签失败,请检查支付宝公钥设置是否正确。"},
});
}
catch (Exception e)
{
if (TeaCore.IsRetryable(e))
{
_lastException = e;
continue;
}
throw e;
}
}
throw new TeaUnretryableException(_lastRequest, _lastException);
}
public AlipayPassInstanceAddResponse AddInstance(string tplId, string tplParams, string recognitionType, string recognitionInfo)
{
Dictionary<string, object> runtime_ = new Dictionary<string, object>
{
{"ignoreSSL", this._kernel.GetConfig("ignoreSSL")},
{"httpProxy", this._kernel.GetConfig("httpProxy")},
{"connectTimeout", 15000},
{"readTimeout", 15000},
{"retry", new Dictionary<string, int?>
{
{"maxAttempts", 0},
}},
};
TeaRequest _lastRequest = null;
Exception _lastException = null;
long _now = System.DateTime.Now.Millisecond;
int _retryTimes = 0;
while (TeaCore.AllowRetry((IDictionary) runtime_["retry"], _retryTimes, _now))
{
if (_retryTimes > 0)
{
int backoffTime = TeaCore.GetBackoffTime((IDictionary)runtime_["backoff"], _retryTimes);
if (backoffTime > 0)
{
TeaCore.Sleep(backoffTime);
}
}
_retryTimes = _retryTimes + 1;
try
{
TeaRequest request_ = new TeaRequest();
Dictionary<string, string> systemParams = new Dictionary<string, string>
{
{"method", "alipay.pass.instance.add"},
{"app_id", this._kernel.GetConfig("appId")},
{"timestamp", this._kernel.GetTimestamp()},
{"format", "json"},
{"version", "1.0"},
{"alipay_sdk", this._kernel.GetSdkVersion()},
{"charset", "UTF-8"},
{"sign_type", this._kernel.GetConfig("signType")},
{"app_cert_sn", this._kernel.GetMerchantCertSN()},
{"alipay_root_cert_sn", this._kernel.GetAlipayRootCertSN()},
};
Dictionary<string, object> bizParams = new Dictionary<string, object>
{
{"tpl_id", tplId},
{"tpl_params", tplParams},
{"recognition_type", recognitionType},
{"recognition_info", recognitionInfo},
};
Dictionary<string, string> textParams = new Dictionary<string, string>(){};
request_.Protocol = this._kernel.GetConfig("protocol");
request_.Method = "POST";
request_.Pathname = "/gateway.do";
request_.Headers = new Dictionary<string, string>
{
{"host", this._kernel.GetConfig("gatewayHost")},
{"content-type", "application/x-www-form-urlencoded;charset=utf-8"},
};
request_.Query = this._kernel.SortMap(TeaConverter.merge<string>
(
new Dictionary<string, string>()
{
{"sign", this._kernel.Sign(systemParams, bizParams, textParams, this._kernel.GetConfig("merchantPrivateKey"))},
},
systemParams,
textParams
));
request_.Body = TeaCore.BytesReadable(this._kernel.ToUrlEncodedRequestBody(bizParams));
_lastRequest = request_;
TeaResponse response_ = TeaCore.DoAction(request_, runtime_);
Dictionary<string, object> respMap = this._kernel.ReadAsJson(response_, "alipay.pass.instance.add");
if (this._kernel.IsCertMode())
{
if (this._kernel.Verify(respMap, this._kernel.ExtractAlipayPublicKey(this._kernel.GetAlipayCertSN(respMap))))
{
return TeaModel.ToObject<AlipayPassInstanceAddResponse>(this._kernel.ToRespModel(respMap));
}
}
else
{
if (this._kernel.Verify(respMap, this._kernel.GetConfig("alipayPublicKey")))
{
return TeaModel.ToObject<AlipayPassInstanceAddResponse>(this._kernel.ToRespModel(respMap));
}
}
throw new TeaException(new Dictionary<string, string>
{
{"message", "验签失败,请检查支付宝公钥设置是否正确。"},
});
}
catch (Exception e)
{
if (TeaCore.IsRetryable(e))
{
_lastException = e;
continue;
}
throw e;
}
}
throw new TeaUnretryableException(_lastRequest, _lastException);
}
public async Task<AlipayPassInstanceAddResponse> AddInstanceAsync(string tplId, string tplParams, string recognitionType, string recognitionInfo)
{
Dictionary<string, object> runtime_ = new Dictionary<string, object>
{
{"ignoreSSL", this._kernel.GetConfig("ignoreSSL")},
{"httpProxy", this._kernel.GetConfig("httpProxy")},
{"connectTimeout", 15000},
{"readTimeout", 15000},
{"retry", new Dictionary<string, int?>
{
{"maxAttempts", 0},
}},
};
TeaRequest _lastRequest = null;
Exception _lastException = null;
long _now = System.DateTime.Now.Millisecond;
int _retryTimes = 0;
while (TeaCore.AllowRetry((IDictionary) runtime_["retry"], _retryTimes, _now))
{
if (_retryTimes > 0)
{
int backoffTime = TeaCore.GetBackoffTime((IDictionary)runtime_["backoff"], _retryTimes);
if (backoffTime > 0)
{
TeaCore.Sleep(backoffTime);
}
}
_retryTimes = _retryTimes + 1;
try
{
TeaRequest request_ = new TeaRequest();
Dictionary<string, string> systemParams = new Dictionary<string, string>
{
{"method", "alipay.pass.instance.add"},
{"app_id", this._kernel.GetConfig("appId")},
{"timestamp", this._kernel.GetTimestamp()},
{"format", "json"},
{"version", "1.0"},
{"alipay_sdk", this._kernel.GetSdkVersion()},
{"charset", "UTF-8"},
{"sign_type", this._kernel.GetConfig("signType")},
{"app_cert_sn", this._kernel.GetMerchantCertSN()},
{"alipay_root_cert_sn", this._kernel.GetAlipayRootCertSN()},
};
Dictionary<string, object> bizParams = new Dictionary<string, object>
{
{"tpl_id", tplId},
{"tpl_params", tplParams},
{"recognition_type", recognitionType},
{"recognition_info", recognitionInfo},
};
Dictionary<string, string> textParams = new Dictionary<string, string>(){};
request_.Protocol = this._kernel.GetConfig("protocol");
request_.Method = "POST";
request_.Pathname = "/gateway.do";
request_.Headers = new Dictionary<string, string>
{
{"host", this._kernel.GetConfig("gatewayHost")},
{"content-type", "application/x-www-form-urlencoded;charset=utf-8"},
};
request_.Query = this._kernel.SortMap(TeaConverter.merge<string>
(
new Dictionary<string, string>()
{
{"sign", this._kernel.Sign(systemParams, bizParams, textParams, this._kernel.GetConfig("merchantPrivateKey"))},
},
systemParams,
textParams
));
request_.Body = TeaCore.BytesReadable(this._kernel.ToUrlEncodedRequestBody(bizParams));
_lastRequest = request_;
TeaResponse response_ = await TeaCore.DoActionAsync(request_, runtime_);
Dictionary<string, object> respMap = await this._kernel.ReadAsJsonAsync(response_, "alipay.pass.instance.add");
if (this._kernel.IsCertMode())
{
if (this._kernel.Verify(respMap, this._kernel.ExtractAlipayPublicKey(this._kernel.GetAlipayCertSN(respMap))))
{
return TeaModel.ToObject<AlipayPassInstanceAddResponse>(this._kernel.ToRespModel(respMap));
}
}
else
{
if (this._kernel.Verify(respMap, this._kernel.GetConfig("alipayPublicKey")))
{
return TeaModel.ToObject<AlipayPassInstanceAddResponse>(this._kernel.ToRespModel(respMap));
}
}
throw new TeaException(new Dictionary<string, string>
{
{"message", "验签失败,请检查支付宝公钥设置是否正确。"},
});
}
catch (Exception e)
{
if (TeaCore.IsRetryable(e))
{
_lastException = e;
continue;
}
throw e;
}
}
throw new TeaUnretryableException(_lastRequest, _lastException);
}
public AlipayPassInstanceUpdateResponse UpdateInstance(string serialNumber, string channelId, string tplParams, string status, string verifyCode, string verifyType)
{
Dictionary<string, object> runtime_ = new Dictionary<string, object>
{
{"ignoreSSL", this._kernel.GetConfig("ignoreSSL")},
{"httpProxy", this._kernel.GetConfig("httpProxy")},
{"connectTimeout", 15000},
{"readTimeout", 15000},
{"retry", new Dictionary<string, int?>
{
{"maxAttempts", 0},
}},
};
TeaRequest _lastRequest = null;
Exception _lastException = null;
long _now = System.DateTime.Now.Millisecond;
int _retryTimes = 0;
while (TeaCore.AllowRetry((IDictionary) runtime_["retry"], _retryTimes, _now))
{
if (_retryTimes > 0)
{
int backoffTime = TeaCore.GetBackoffTime((IDictionary)runtime_["backoff"], _retryTimes);
if (backoffTime > 0)
{
TeaCore.Sleep(backoffTime);
}
}
_retryTimes = _retryTimes + 1;
try
{
TeaRequest request_ = new TeaRequest();
Dictionary<string, string> systemParams = new Dictionary<string, string>
{
{"method", "alipay.pass.instance.update"},
{"app_id", this._kernel.GetConfig("appId")},
{"timestamp", this._kernel.GetTimestamp()},
{"format", "json"},
{"version", "1.0"},
{"alipay_sdk", this._kernel.GetSdkVersion()},
{"charset", "UTF-8"},
{"sign_type", this._kernel.GetConfig("signType")},
{"app_cert_sn", this._kernel.GetMerchantCertSN()},
{"alipay_root_cert_sn", this._kernel.GetAlipayRootCertSN()},
};
Dictionary<string, object> bizParams = new Dictionary<string, object>
{
{"serial_number", serialNumber},
{"channel_id", channelId},
{"tpl_params", tplParams},
{"status", status},
{"verify_code", verifyCode},
{"verify_type", verifyType},
};
Dictionary<string, string> textParams = new Dictionary<string, string>(){};
request_.Protocol = this._kernel.GetConfig("protocol");
request_.Method = "POST";
request_.Pathname = "/gateway.do";
request_.Headers = new Dictionary<string, string>
{
{"host", this._kernel.GetConfig("gatewayHost")},
{"content-type", "application/x-www-form-urlencoded;charset=utf-8"},
};
request_.Query = this._kernel.SortMap(TeaConverter.merge<string>
(
new Dictionary<string, string>()
{
{"sign", this._kernel.Sign(systemParams, bizParams, textParams, this._kernel.GetConfig("merchantPrivateKey"))},
},
systemParams,
textParams
));
request_.Body = TeaCore.BytesReadable(this._kernel.ToUrlEncodedRequestBody(bizParams));
_lastRequest = request_;
TeaResponse response_ = TeaCore.DoAction(request_, runtime_);
Dictionary<string, object> respMap = this._kernel.ReadAsJson(response_, "alipay.pass.instance.update");
if (this._kernel.IsCertMode())
{
if (this._kernel.Verify(respMap, this._kernel.ExtractAlipayPublicKey(this._kernel.GetAlipayCertSN(respMap))))
{
return TeaModel.ToObject<AlipayPassInstanceUpdateResponse>(this._kernel.ToRespModel(respMap));
}
}
else
{
if (this._kernel.Verify(respMap, this._kernel.GetConfig("alipayPublicKey")))
{
return TeaModel.ToObject<AlipayPassInstanceUpdateResponse>(this._kernel.ToRespModel(respMap));
}
}
throw new TeaException(new Dictionary<string, string>
{
{"message", "验签失败,请检查支付宝公钥设置是否正确。"},
});
}
catch (Exception e)
{
if (TeaCore.IsRetryable(e))
{
_lastException = e;
continue;
}
throw e;
}
}
throw new TeaUnretryableException(_lastRequest, _lastException);
}
public async Task<AlipayPassInstanceUpdateResponse> UpdateInstanceAsync(string serialNumber, string channelId, string tplParams, string status, string verifyCode, string verifyType)
{
Dictionary<string, object> runtime_ = new Dictionary<string, object>
{
{"ignoreSSL", this._kernel.GetConfig("ignoreSSL")},
{"httpProxy", this._kernel.GetConfig("httpProxy")},
{"connectTimeout", 15000},
{"readTimeout", 15000},
{"retry", new Dictionary<string, int?>
{
{"maxAttempts", 0},
}},
};
TeaRequest _lastRequest = null;
Exception _lastException = null;
long _now = System.DateTime.Now.Millisecond;
int _retryTimes = 0;
while (TeaCore.AllowRetry((IDictionary) runtime_["retry"], _retryTimes, _now))
{
if (_retryTimes > 0)
{
int backoffTime = TeaCore.GetBackoffTime((IDictionary)runtime_["backoff"], _retryTimes);
if (backoffTime > 0)
{
TeaCore.Sleep(backoffTime);
}
}
_retryTimes = _retryTimes + 1;
try
{
TeaRequest request_ = new TeaRequest();
Dictionary<string, string> systemParams = new Dictionary<string, string>
{
{"method", "alipay.pass.instance.update"},
{"app_id", this._kernel.GetConfig("appId")},
{"timestamp", this._kernel.GetTimestamp()},
{"format", "json"},
{"version", "1.0"},
{"alipay_sdk", this._kernel.GetSdkVersion()},
{"charset", "UTF-8"},
{"sign_type", this._kernel.GetConfig("signType")},
{"app_cert_sn", this._kernel.GetMerchantCertSN()},
{"alipay_root_cert_sn", this._kernel.GetAlipayRootCertSN()},
};
Dictionary<string, object> bizParams = new Dictionary<string, object>
{
{"serial_number", serialNumber},
{"channel_id", channelId},
{"tpl_params", tplParams},
{"status", status},
{"verify_code", verifyCode},
{"verify_type", verifyType},
};
Dictionary<string, string> textParams = new Dictionary<string, string>(){};
request_.Protocol = this._kernel.GetConfig("protocol");
request_.Method = "POST";
request_.Pathname = "/gateway.do";
request_.Headers = new Dictionary<string, string>
{
{"host", this._kernel.GetConfig("gatewayHost")},
{"content-type", "application/x-www-form-urlencoded;charset=utf-8"},
};
request_.Query = this._kernel.SortMap(TeaConverter.merge<string>
(
new Dictionary<string, string>()
{
{"sign", this._kernel.Sign(systemParams, bizParams, textParams, this._kernel.GetConfig("merchantPrivateKey"))},
},
systemParams,
textParams
));
request_.Body = TeaCore.BytesReadable(this._kernel.ToUrlEncodedRequestBody(bizParams));
_lastRequest = request_;
TeaResponse response_ = await TeaCore.DoActionAsync(request_, runtime_);
Dictionary<string, object> respMap = await this._kernel.ReadAsJsonAsync(response_, "alipay.pass.instance.update");
if (this._kernel.IsCertMode())
{
if (this._kernel.Verify(respMap, this._kernel.ExtractAlipayPublicKey(this._kernel.GetAlipayCertSN(respMap))))
{
return TeaModel.ToObject<AlipayPassInstanceUpdateResponse>(this._kernel.ToRespModel(respMap));
}
}
else
{
if (this._kernel.Verify(respMap, this._kernel.GetConfig("alipayPublicKey")))
{
return TeaModel.ToObject<AlipayPassInstanceUpdateResponse>(this._kernel.ToRespModel(respMap));
}
}
throw new TeaException(new Dictionary<string, string>
{
{"message", "验签失败,请检查支付宝公钥设置是否正确。"},
});
}
catch (Exception e)
{
if (TeaCore.IsRetryable(e))
{
_lastException = e;
continue;
}
throw e;
}
}
throw new TeaUnretryableException(_lastRequest, _lastException);
}
/// <summary>
/// ISV代商户代用指定appAuthToken
/// </summary>
/// <param name="appAuthToken">代调用token</param>
/// <returns>本客户端,便于链式调用</returns>
public Client Agent(string appAuthToken)
{
_kernel.InjectTextParam("app_auth_token", appAuthToken);
return this;
}
/// <summary>
/// 用户授权调用指定authToken
/// </summary>
/// <param name="authToken">用户授权token</param>
/// <returns>本客户端,便于链式调用</returns>
public Client Auth(string authToken)
{
_kernel.InjectTextParam("auth_token", authToken);
return this;
}
/// <summary>
/// 设置异步通知回调地址此处设置将在本调用中覆盖Config中的全局配置
/// </summary>
/// <param name="url">异步通知回调地址例如https://www.test.com/callback </param>
/// <returns>本客户端,便于链式调用</returns>
public Client AsyncNotify(string url)
{
_kernel.InjectTextParam("notify_url", url);
return this;
}
/// <summary>
/// 将本次调用强制路由到后端系统的测试地址上,常用于线下环境内外联调,沙箱与线上环境设置无效
/// </summary>
/// <param name="testUrl">后端系统测试地址</param>
/// <returns>本客户端,便于链式调用</returns>
public Client Route(string testUrl)
{
_kernel.InjectTextParam("ws_service_url", testUrl);
return this;
}
/// <summary>
/// 设置API入参中没有的其他可选业务请求参数(biz_content下的字段)
/// </summary>
/// <param name="key">业务请求参数名称biz_content下的字段名比如timeout_express</param>
/// <param name="value">
/// 业务请求参数的值一个可以序列化成JSON的对象
/// 如果该字段是一个字符串类型String、Price、Date在SDK中都是字符串请使用string储存
/// 如果该字段是一个数值型类型比如Number请使用long储存
/// 如果该字段是一个复杂类型请使用嵌套的Dictionary指定各下级字段的值
/// 如果该字段是一个数组请使用List储存各个值
/// 对于更复杂的情况也支持Dictionary和List的各种组合嵌套比如参数是值是个ListList中的每种类型是一个复杂对象
/// </param>
/// <returns>本客户端,便于链式调用</returns>
public Client Optional(string key, object value)
{
_kernel.InjectBizParam(key, value);
return this;
}
/// <summary>
/// 批量设置API入参中没有的其他可选业务请求参数(biz_content下的字段)
/// optional方法的批量版本
/// </summary>
/// <param name="optionalArgs">可选参数集合每个参数由key和value组成key和value的格式请参见optional方法的注释</param>
/// <returns>本客户端,便于链式调用</returns>
public Client BatchOptional(Dictionary<string, object> optionalArgs)
{
foreach (var pair in optionalArgs)
{
_kernel.InjectBizParam(pair.Key, pair.Value);
}
return this;
}
}
}

View File

@@ -0,0 +1,45 @@
// This file is auto-generated, don't edit it. Thanks.
using System;
using System.Collections.Generic;
using System.IO;
using Tea;
namespace Alipay.EasySDK.Marketing.Pass.Models
{
public class AlipayPassInstanceAddResponse : TeaModel {
/// <summary>
/// 响应原始字符串
/// </summary>
[NameInMap("http_body")]
[Validation(Required=true)]
public string HttpBody { get; set; }
[NameInMap("code")]
[Validation(Required=true)]
public string Code { get; set; }
[NameInMap("msg")]
[Validation(Required=true)]
public string Msg { get; set; }
[NameInMap("sub_code")]
[Validation(Required=true)]
public string SubCode { get; set; }
[NameInMap("sub_msg")]
[Validation(Required=true)]
public string SubMsg { get; set; }
[NameInMap("success")]
[Validation(Required=true)]
public bool? Success { get; set; }
[NameInMap("result")]
[Validation(Required=true)]
public string Result { get; set; }
}
}

View File

@@ -0,0 +1,45 @@
// This file is auto-generated, don't edit it. Thanks.
using System;
using System.Collections.Generic;
using System.IO;
using Tea;
namespace Alipay.EasySDK.Marketing.Pass.Models
{
public class AlipayPassInstanceUpdateResponse : TeaModel {
/// <summary>
/// 响应原始字符串
/// </summary>
[NameInMap("http_body")]
[Validation(Required=true)]
public string HttpBody { get; set; }
[NameInMap("code")]
[Validation(Required=true)]
public string Code { get; set; }
[NameInMap("msg")]
[Validation(Required=true)]
public string Msg { get; set; }
[NameInMap("sub_code")]
[Validation(Required=true)]
public string SubCode { get; set; }
[NameInMap("sub_msg")]
[Validation(Required=true)]
public string SubMsg { get; set; }
[NameInMap("success")]
[Validation(Required=true)]
public bool? Success { get; set; }
[NameInMap("result")]
[Validation(Required=true)]
public string Result { get; set; }
}
}

View File

@@ -0,0 +1,45 @@
// This file is auto-generated, don't edit it. Thanks.
using System;
using System.Collections.Generic;
using System.IO;
using Tea;
namespace Alipay.EasySDK.Marketing.Pass.Models
{
public class AlipayPassTemplateAddResponse : TeaModel {
/// <summary>
/// 响应原始字符串
/// </summary>
[NameInMap("http_body")]
[Validation(Required=true)]
public string HttpBody { get; set; }
[NameInMap("code")]
[Validation(Required=true)]
public string Code { get; set; }
[NameInMap("msg")]
[Validation(Required=true)]
public string Msg { get; set; }
[NameInMap("sub_code")]
[Validation(Required=true)]
public string SubCode { get; set; }
[NameInMap("sub_msg")]
[Validation(Required=true)]
public string SubMsg { get; set; }
[NameInMap("success")]
[Validation(Required=true)]
public bool? Success { get; set; }
[NameInMap("result")]
[Validation(Required=true)]
public string Result { get; set; }
}
}

View File

@@ -0,0 +1,45 @@
// This file is auto-generated, don't edit it. Thanks.
using System;
using System.Collections.Generic;
using System.IO;
using Tea;
namespace Alipay.EasySDK.Marketing.Pass.Models
{
public class AlipayPassTemplateUpdateResponse : TeaModel {
/// <summary>
/// 响应原始字符串
/// </summary>
[NameInMap("http_body")]
[Validation(Required=true)]
public string HttpBody { get; set; }
[NameInMap("code")]
[Validation(Required=true)]
public string Code { get; set; }
[NameInMap("msg")]
[Validation(Required=true)]
public string Msg { get; set; }
[NameInMap("sub_code")]
[Validation(Required=true)]
public string SubCode { get; set; }
[NameInMap("sub_msg")]
[Validation(Required=true)]
public string SubMsg { get; set; }
[NameInMap("success")]
[Validation(Required=true)]
public bool? Success { get; set; }
[NameInMap("result")]
[Validation(Required=true)]
public string Result { get; set; }
}
}

View File

@@ -0,0 +1,322 @@
// This file is auto-generated, don't edit it. Thanks.
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Threading.Tasks;
using Tea;
using Tea.Utils;
using Alipay.EasySDK.Marketing.TemplateMessage.Models;
namespace Alipay.EasySDK.Marketing.TemplateMessage
{
public class Client
{
protected Alipay.EasySDK.Kernel.Client _kernel;
public Client(Alipay.EasySDK.Kernel.Client kernel)
{
this._kernel = kernel;
}
public AlipayOpenAppMiniTemplatemessageSendResponse Send(string toUserId, string formId, string userTemplateId, string page, string data)
{
Dictionary<string, object> runtime_ = new Dictionary<string, object>
{
{"ignoreSSL", this._kernel.GetConfig("ignoreSSL")},
{"httpProxy", this._kernel.GetConfig("httpProxy")},
{"connectTimeout", 15000},
{"readTimeout", 15000},
{"retry", new Dictionary<string, int?>
{
{"maxAttempts", 0},
}},
};
TeaRequest _lastRequest = null;
Exception _lastException = null;
long _now = System.DateTime.Now.Millisecond;
int _retryTimes = 0;
while (TeaCore.AllowRetry((IDictionary) runtime_["retry"], _retryTimes, _now))
{
if (_retryTimes > 0)
{
int backoffTime = TeaCore.GetBackoffTime((IDictionary)runtime_["backoff"], _retryTimes);
if (backoffTime > 0)
{
TeaCore.Sleep(backoffTime);
}
}
_retryTimes = _retryTimes + 1;
try
{
TeaRequest request_ = new TeaRequest();
Dictionary<string, string> systemParams = new Dictionary<string, string>
{
{"method", "alipay.open.app.mini.templatemessage.send"},
{"app_id", this._kernel.GetConfig("appId")},
{"timestamp", this._kernel.GetTimestamp()},
{"format", "json"},
{"version", "1.0"},
{"alipay_sdk", this._kernel.GetSdkVersion()},
{"charset", "UTF-8"},
{"sign_type", this._kernel.GetConfig("signType")},
{"app_cert_sn", this._kernel.GetMerchantCertSN()},
{"alipay_root_cert_sn", this._kernel.GetAlipayRootCertSN()},
};
Dictionary<string, object> bizParams = new Dictionary<string, object>
{
{"to_user_id", toUserId},
{"form_id", formId},
{"user_template_id", userTemplateId},
{"page", page},
{"data", data},
};
Dictionary<string, string> textParams = new Dictionary<string, string>(){};
request_.Protocol = this._kernel.GetConfig("protocol");
request_.Method = "POST";
request_.Pathname = "/gateway.do";
request_.Headers = new Dictionary<string, string>
{
{"host", this._kernel.GetConfig("gatewayHost")},
{"content-type", "application/x-www-form-urlencoded;charset=utf-8"},
};
request_.Query = this._kernel.SortMap(TeaConverter.merge<string>
(
new Dictionary<string, string>()
{
{"sign", this._kernel.Sign(systemParams, bizParams, textParams, this._kernel.GetConfig("merchantPrivateKey"))},
},
systemParams,
textParams
));
request_.Body = TeaCore.BytesReadable(this._kernel.ToUrlEncodedRequestBody(bizParams));
_lastRequest = request_;
TeaResponse response_ = TeaCore.DoAction(request_, runtime_);
Dictionary<string, object> respMap = this._kernel.ReadAsJson(response_, "alipay.open.app.mini.templatemessage.send");
if (this._kernel.IsCertMode())
{
if (this._kernel.Verify(respMap, this._kernel.ExtractAlipayPublicKey(this._kernel.GetAlipayCertSN(respMap))))
{
return TeaModel.ToObject<AlipayOpenAppMiniTemplatemessageSendResponse>(this._kernel.ToRespModel(respMap));
}
}
else
{
if (this._kernel.Verify(respMap, this._kernel.GetConfig("alipayPublicKey")))
{
return TeaModel.ToObject<AlipayOpenAppMiniTemplatemessageSendResponse>(this._kernel.ToRespModel(respMap));
}
}
throw new TeaException(new Dictionary<string, string>
{
{"message", "验签失败,请检查支付宝公钥设置是否正确。"},
});
}
catch (Exception e)
{
if (TeaCore.IsRetryable(e))
{
_lastException = e;
continue;
}
throw e;
}
}
throw new TeaUnretryableException(_lastRequest, _lastException);
}
public async Task<AlipayOpenAppMiniTemplatemessageSendResponse> SendAsync(string toUserId, string formId, string userTemplateId, string page, string data)
{
Dictionary<string, object> runtime_ = new Dictionary<string, object>
{
{"ignoreSSL", this._kernel.GetConfig("ignoreSSL")},
{"httpProxy", this._kernel.GetConfig("httpProxy")},
{"connectTimeout", 15000},
{"readTimeout", 15000},
{"retry", new Dictionary<string, int?>
{
{"maxAttempts", 0},
}},
};
TeaRequest _lastRequest = null;
Exception _lastException = null;
long _now = System.DateTime.Now.Millisecond;
int _retryTimes = 0;
while (TeaCore.AllowRetry((IDictionary) runtime_["retry"], _retryTimes, _now))
{
if (_retryTimes > 0)
{
int backoffTime = TeaCore.GetBackoffTime((IDictionary)runtime_["backoff"], _retryTimes);
if (backoffTime > 0)
{
TeaCore.Sleep(backoffTime);
}
}
_retryTimes = _retryTimes + 1;
try
{
TeaRequest request_ = new TeaRequest();
Dictionary<string, string> systemParams = new Dictionary<string, string>
{
{"method", "alipay.open.app.mini.templatemessage.send"},
{"app_id", this._kernel.GetConfig("appId")},
{"timestamp", this._kernel.GetTimestamp()},
{"format", "json"},
{"version", "1.0"},
{"alipay_sdk", this._kernel.GetSdkVersion()},
{"charset", "UTF-8"},
{"sign_type", this._kernel.GetConfig("signType")},
{"app_cert_sn", this._kernel.GetMerchantCertSN()},
{"alipay_root_cert_sn", this._kernel.GetAlipayRootCertSN()},
};
Dictionary<string, object> bizParams = new Dictionary<string, object>
{
{"to_user_id", toUserId},
{"form_id", formId},
{"user_template_id", userTemplateId},
{"page", page},
{"data", data},
};
Dictionary<string, string> textParams = new Dictionary<string, string>(){};
request_.Protocol = this._kernel.GetConfig("protocol");
request_.Method = "POST";
request_.Pathname = "/gateway.do";
request_.Headers = new Dictionary<string, string>
{
{"host", this._kernel.GetConfig("gatewayHost")},
{"content-type", "application/x-www-form-urlencoded;charset=utf-8"},
};
request_.Query = this._kernel.SortMap(TeaConverter.merge<string>
(
new Dictionary<string, string>()
{
{"sign", this._kernel.Sign(systemParams, bizParams, textParams, this._kernel.GetConfig("merchantPrivateKey"))},
},
systemParams,
textParams
));
request_.Body = TeaCore.BytesReadable(this._kernel.ToUrlEncodedRequestBody(bizParams));
_lastRequest = request_;
TeaResponse response_ = await TeaCore.DoActionAsync(request_, runtime_);
Dictionary<string, object> respMap = await this._kernel.ReadAsJsonAsync(response_, "alipay.open.app.mini.templatemessage.send");
if (this._kernel.IsCertMode())
{
if (this._kernel.Verify(respMap, this._kernel.ExtractAlipayPublicKey(this._kernel.GetAlipayCertSN(respMap))))
{
return TeaModel.ToObject<AlipayOpenAppMiniTemplatemessageSendResponse>(this._kernel.ToRespModel(respMap));
}
}
else
{
if (this._kernel.Verify(respMap, this._kernel.GetConfig("alipayPublicKey")))
{
return TeaModel.ToObject<AlipayOpenAppMiniTemplatemessageSendResponse>(this._kernel.ToRespModel(respMap));
}
}
throw new TeaException(new Dictionary<string, string>
{
{"message", "验签失败,请检查支付宝公钥设置是否正确。"},
});
}
catch (Exception e)
{
if (TeaCore.IsRetryable(e))
{
_lastException = e;
continue;
}
throw e;
}
}
throw new TeaUnretryableException(_lastRequest, _lastException);
}
/// <summary>
/// ISV代商户代用指定appAuthToken
/// </summary>
/// <param name="appAuthToken">代调用token</param>
/// <returns>本客户端,便于链式调用</returns>
public Client Agent(string appAuthToken)
{
_kernel.InjectTextParam("app_auth_token", appAuthToken);
return this;
}
/// <summary>
/// 用户授权调用指定authToken
/// </summary>
/// <param name="authToken">用户授权token</param>
/// <returns>本客户端,便于链式调用</returns>
public Client Auth(string authToken)
{
_kernel.InjectTextParam("auth_token", authToken);
return this;
}
/// <summary>
/// 设置异步通知回调地址此处设置将在本调用中覆盖Config中的全局配置
/// </summary>
/// <param name="url">异步通知回调地址例如https://www.test.com/callback </param>
/// <returns>本客户端,便于链式调用</returns>
public Client AsyncNotify(string url)
{
_kernel.InjectTextParam("notify_url", url);
return this;
}
/// <summary>
/// 将本次调用强制路由到后端系统的测试地址上,常用于线下环境内外联调,沙箱与线上环境设置无效
/// </summary>
/// <param name="testUrl">后端系统测试地址</param>
/// <returns>本客户端,便于链式调用</returns>
public Client Route(string testUrl)
{
_kernel.InjectTextParam("ws_service_url", testUrl);
return this;
}
/// <summary>
/// 设置API入参中没有的其他可选业务请求参数(biz_content下的字段)
/// </summary>
/// <param name="key">业务请求参数名称biz_content下的字段名比如timeout_express</param>
/// <param name="value">
/// 业务请求参数的值一个可以序列化成JSON的对象
/// 如果该字段是一个字符串类型String、Price、Date在SDK中都是字符串请使用string储存
/// 如果该字段是一个数值型类型比如Number请使用long储存
/// 如果该字段是一个复杂类型请使用嵌套的Dictionary指定各下级字段的值
/// 如果该字段是一个数组请使用List储存各个值
/// 对于更复杂的情况也支持Dictionary和List的各种组合嵌套比如参数是值是个ListList中的每种类型是一个复杂对象
/// </param>
/// <returns>本客户端,便于链式调用</returns>
public Client Optional(string key, object value)
{
_kernel.InjectBizParam(key, value);
return this;
}
/// <summary>
/// 批量设置API入参中没有的其他可选业务请求参数(biz_content下的字段)
/// optional方法的批量版本
/// </summary>
/// <param name="optionalArgs">可选参数集合每个参数由key和value组成key和value的格式请参见optional方法的注释</param>
/// <returns>本客户端,便于链式调用</returns>
public Client BatchOptional(Dictionary<string, object> optionalArgs)
{
foreach (var pair in optionalArgs)
{
_kernel.InjectBizParam(pair.Key, pair.Value);
}
return this;
}
}
}

View File

@@ -0,0 +1,37 @@
// This file is auto-generated, don't edit it. Thanks.
using System;
using System.Collections.Generic;
using System.IO;
using Tea;
namespace Alipay.EasySDK.Marketing.TemplateMessage.Models
{
public class AlipayOpenAppMiniTemplatemessageSendResponse : TeaModel {
/// <summary>
/// 响应原始字符串
/// </summary>
[NameInMap("http_body")]
[Validation(Required=true)]
public string HttpBody { get; set; }
[NameInMap("code")]
[Validation(Required=true)]
public string Code { get; set; }
[NameInMap("msg")]
[Validation(Required=true)]
public string Msg { get; set; }
[NameInMap("sub_code")]
[Validation(Required=true)]
public string SubCode { get; set; }
[NameInMap("sub_msg")]
[Validation(Required=true)]
public string SubMsg { get; set; }
}
}

View File

@@ -0,0 +1,562 @@
// This file is auto-generated, don't edit it. Thanks.
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Threading.Tasks;
using Tea;
using Tea.Utils;
using Alipay.EasySDK.Member.Identification.Models;
namespace Alipay.EasySDK.Member.Identification
{
public class Client
{
protected Alipay.EasySDK.Kernel.Client _kernel;
public Client(Alipay.EasySDK.Kernel.Client kernel)
{
this._kernel = kernel;
}
public AlipayUserCertifyOpenInitializeResponse Init(string outerOrderNo, string bizCode, IdentityParam identityParam, MerchantConfig merchantConfig)
{
identityParam.Validate();
merchantConfig.Validate();
Dictionary<string, object> runtime_ = new Dictionary<string, object>
{
{"ignoreSSL", this._kernel.GetConfig("ignoreSSL")},
{"httpProxy", this._kernel.GetConfig("httpProxy")},
{"connectTimeout", 15000},
{"readTimeout", 15000},
{"retry", new Dictionary<string, int?>
{
{"maxAttempts", 0},
}},
};
TeaRequest _lastRequest = null;
Exception _lastException = null;
long _now = System.DateTime.Now.Millisecond;
int _retryTimes = 0;
while (TeaCore.AllowRetry((IDictionary) runtime_["retry"], _retryTimes, _now))
{
if (_retryTimes > 0)
{
int backoffTime = TeaCore.GetBackoffTime((IDictionary)runtime_["backoff"], _retryTimes);
if (backoffTime > 0)
{
TeaCore.Sleep(backoffTime);
}
}
_retryTimes = _retryTimes + 1;
try
{
TeaRequest request_ = new TeaRequest();
Dictionary<string, string> systemParams = new Dictionary<string, string>
{
{"method", "alipay.user.certify.open.initialize"},
{"app_id", this._kernel.GetConfig("appId")},
{"timestamp", this._kernel.GetTimestamp()},
{"format", "json"},
{"version", "1.0"},
{"alipay_sdk", this._kernel.GetSdkVersion()},
{"charset", "UTF-8"},
{"sign_type", this._kernel.GetConfig("signType")},
{"app_cert_sn", this._kernel.GetMerchantCertSN()},
{"alipay_root_cert_sn", this._kernel.GetAlipayRootCertSN()},
};
Dictionary<string, object> bizParams = new Dictionary<string, object>
{
{"outer_order_no", outerOrderNo},
{"biz_code", bizCode},
{"identity_param", identityParam},
{"merchant_config", merchantConfig},
};
Dictionary<string, string> textParams = new Dictionary<string, string>(){};
request_.Protocol = this._kernel.GetConfig("protocol");
request_.Method = "POST";
request_.Pathname = "/gateway.do";
request_.Headers = new Dictionary<string, string>
{
{"host", this._kernel.GetConfig("gatewayHost")},
{"content-type", "application/x-www-form-urlencoded;charset=utf-8"},
};
request_.Query = this._kernel.SortMap(TeaConverter.merge<string>
(
new Dictionary<string, string>()
{
{"sign", this._kernel.Sign(systemParams, bizParams, textParams, this._kernel.GetConfig("merchantPrivateKey"))},
},
systemParams,
textParams
));
request_.Body = TeaCore.BytesReadable(this._kernel.ToUrlEncodedRequestBody(bizParams));
_lastRequest = request_;
TeaResponse response_ = TeaCore.DoAction(request_, runtime_);
Dictionary<string, object> respMap = this._kernel.ReadAsJson(response_, "alipay.user.certify.open.initialize");
if (this._kernel.IsCertMode())
{
if (this._kernel.Verify(respMap, this._kernel.ExtractAlipayPublicKey(this._kernel.GetAlipayCertSN(respMap))))
{
return TeaModel.ToObject<AlipayUserCertifyOpenInitializeResponse>(this._kernel.ToRespModel(respMap));
}
}
else
{
if (this._kernel.Verify(respMap, this._kernel.GetConfig("alipayPublicKey")))
{
return TeaModel.ToObject<AlipayUserCertifyOpenInitializeResponse>(this._kernel.ToRespModel(respMap));
}
}
throw new TeaException(new Dictionary<string, string>
{
{"message", "验签失败,请检查支付宝公钥设置是否正确。"},
});
}
catch (Exception e)
{
if (TeaCore.IsRetryable(e))
{
_lastException = e;
continue;
}
throw e;
}
}
throw new TeaUnretryableException(_lastRequest, _lastException);
}
public async Task<AlipayUserCertifyOpenInitializeResponse> InitAsync(string outerOrderNo, string bizCode, IdentityParam identityParam, MerchantConfig merchantConfig)
{
identityParam.Validate();
merchantConfig.Validate();
Dictionary<string, object> runtime_ = new Dictionary<string, object>
{
{"ignoreSSL", this._kernel.GetConfig("ignoreSSL")},
{"httpProxy", this._kernel.GetConfig("httpProxy")},
{"connectTimeout", 15000},
{"readTimeout", 15000},
{"retry", new Dictionary<string, int?>
{
{"maxAttempts", 0},
}},
};
TeaRequest _lastRequest = null;
Exception _lastException = null;
long _now = System.DateTime.Now.Millisecond;
int _retryTimes = 0;
while (TeaCore.AllowRetry((IDictionary) runtime_["retry"], _retryTimes, _now))
{
if (_retryTimes > 0)
{
int backoffTime = TeaCore.GetBackoffTime((IDictionary)runtime_["backoff"], _retryTimes);
if (backoffTime > 0)
{
TeaCore.Sleep(backoffTime);
}
}
_retryTimes = _retryTimes + 1;
try
{
TeaRequest request_ = new TeaRequest();
Dictionary<string, string> systemParams = new Dictionary<string, string>
{
{"method", "alipay.user.certify.open.initialize"},
{"app_id", this._kernel.GetConfig("appId")},
{"timestamp", this._kernel.GetTimestamp()},
{"format", "json"},
{"version", "1.0"},
{"alipay_sdk", this._kernel.GetSdkVersion()},
{"charset", "UTF-8"},
{"sign_type", this._kernel.GetConfig("signType")},
{"app_cert_sn", this._kernel.GetMerchantCertSN()},
{"alipay_root_cert_sn", this._kernel.GetAlipayRootCertSN()},
};
Dictionary<string, object> bizParams = new Dictionary<string, object>
{
{"outer_order_no", outerOrderNo},
{"biz_code", bizCode},
{"identity_param", identityParam},
{"merchant_config", merchantConfig},
};
Dictionary<string, string> textParams = new Dictionary<string, string>(){};
request_.Protocol = this._kernel.GetConfig("protocol");
request_.Method = "POST";
request_.Pathname = "/gateway.do";
request_.Headers = new Dictionary<string, string>
{
{"host", this._kernel.GetConfig("gatewayHost")},
{"content-type", "application/x-www-form-urlencoded;charset=utf-8"},
};
request_.Query = this._kernel.SortMap(TeaConverter.merge<string>
(
new Dictionary<string, string>()
{
{"sign", this._kernel.Sign(systemParams, bizParams, textParams, this._kernel.GetConfig("merchantPrivateKey"))},
},
systemParams,
textParams
));
request_.Body = TeaCore.BytesReadable(this._kernel.ToUrlEncodedRequestBody(bizParams));
_lastRequest = request_;
TeaResponse response_ = await TeaCore.DoActionAsync(request_, runtime_);
Dictionary<string, object> respMap = await this._kernel.ReadAsJsonAsync(response_, "alipay.user.certify.open.initialize");
if (this._kernel.IsCertMode())
{
if (this._kernel.Verify(respMap, this._kernel.ExtractAlipayPublicKey(this._kernel.GetAlipayCertSN(respMap))))
{
return TeaModel.ToObject<AlipayUserCertifyOpenInitializeResponse>(this._kernel.ToRespModel(respMap));
}
}
else
{
if (this._kernel.Verify(respMap, this._kernel.GetConfig("alipayPublicKey")))
{
return TeaModel.ToObject<AlipayUserCertifyOpenInitializeResponse>(this._kernel.ToRespModel(respMap));
}
}
throw new TeaException(new Dictionary<string, string>
{
{"message", "验签失败,请检查支付宝公钥设置是否正确。"},
});
}
catch (Exception e)
{
if (TeaCore.IsRetryable(e))
{
_lastException = e;
continue;
}
throw e;
}
}
throw new TeaUnretryableException(_lastRequest, _lastException);
}
public AlipayUserCertifyOpenQueryResponse Query(string certifyId)
{
Dictionary<string, object> runtime_ = new Dictionary<string, object>
{
{"ignoreSSL", this._kernel.GetConfig("ignoreSSL")},
{"httpProxy", this._kernel.GetConfig("httpProxy")},
{"connectTimeout", 15000},
{"readTimeout", 15000},
{"retry", new Dictionary<string, int?>
{
{"maxAttempts", 0},
}},
};
TeaRequest _lastRequest = null;
Exception _lastException = null;
long _now = System.DateTime.Now.Millisecond;
int _retryTimes = 0;
while (TeaCore.AllowRetry((IDictionary) runtime_["retry"], _retryTimes, _now))
{
if (_retryTimes > 0)
{
int backoffTime = TeaCore.GetBackoffTime((IDictionary)runtime_["backoff"], _retryTimes);
if (backoffTime > 0)
{
TeaCore.Sleep(backoffTime);
}
}
_retryTimes = _retryTimes + 1;
try
{
TeaRequest request_ = new TeaRequest();
Dictionary<string, string> systemParams = new Dictionary<string, string>
{
{"method", "alipay.user.certify.open.query"},
{"app_id", this._kernel.GetConfig("appId")},
{"timestamp", this._kernel.GetTimestamp()},
{"format", "json"},
{"version", "1.0"},
{"alipay_sdk", this._kernel.GetSdkVersion()},
{"charset", "UTF-8"},
{"sign_type", this._kernel.GetConfig("signType")},
{"app_cert_sn", this._kernel.GetMerchantCertSN()},
{"alipay_root_cert_sn", this._kernel.GetAlipayRootCertSN()},
};
Dictionary<string, object> bizParams = new Dictionary<string, object>
{
{"certify_id", certifyId},
};
Dictionary<string, string> textParams = new Dictionary<string, string>(){};
request_.Protocol = this._kernel.GetConfig("protocol");
request_.Method = "POST";
request_.Pathname = "/gateway.do";
request_.Headers = new Dictionary<string, string>
{
{"host", this._kernel.GetConfig("gatewayHost")},
{"content-type", "application/x-www-form-urlencoded;charset=utf-8"},
};
request_.Query = this._kernel.SortMap(TeaConverter.merge<string>
(
new Dictionary<string, string>()
{
{"sign", this._kernel.Sign(systemParams, bizParams, textParams, this._kernel.GetConfig("merchantPrivateKey"))},
},
systemParams,
textParams
));
request_.Body = TeaCore.BytesReadable(this._kernel.ToUrlEncodedRequestBody(bizParams));
_lastRequest = request_;
TeaResponse response_ = TeaCore.DoAction(request_, runtime_);
Dictionary<string, object> respMap = this._kernel.ReadAsJson(response_, "alipay.user.certify.open.query");
if (this._kernel.IsCertMode())
{
if (this._kernel.Verify(respMap, this._kernel.ExtractAlipayPublicKey(this._kernel.GetAlipayCertSN(respMap))))
{
return TeaModel.ToObject<AlipayUserCertifyOpenQueryResponse>(this._kernel.ToRespModel(respMap));
}
}
else
{
if (this._kernel.Verify(respMap, this._kernel.GetConfig("alipayPublicKey")))
{
return TeaModel.ToObject<AlipayUserCertifyOpenQueryResponse>(this._kernel.ToRespModel(respMap));
}
}
throw new TeaException(new Dictionary<string, string>
{
{"message", "验签失败,请检查支付宝公钥设置是否正确。"},
});
}
catch (Exception e)
{
if (TeaCore.IsRetryable(e))
{
_lastException = e;
continue;
}
throw e;
}
}
throw new TeaUnretryableException(_lastRequest, _lastException);
}
public async Task<AlipayUserCertifyOpenQueryResponse> QueryAsync(string certifyId)
{
Dictionary<string, object> runtime_ = new Dictionary<string, object>
{
{"ignoreSSL", this._kernel.GetConfig("ignoreSSL")},
{"httpProxy", this._kernel.GetConfig("httpProxy")},
{"connectTimeout", 15000},
{"readTimeout", 15000},
{"retry", new Dictionary<string, int?>
{
{"maxAttempts", 0},
}},
};
TeaRequest _lastRequest = null;
Exception _lastException = null;
long _now = System.DateTime.Now.Millisecond;
int _retryTimes = 0;
while (TeaCore.AllowRetry((IDictionary) runtime_["retry"], _retryTimes, _now))
{
if (_retryTimes > 0)
{
int backoffTime = TeaCore.GetBackoffTime((IDictionary)runtime_["backoff"], _retryTimes);
if (backoffTime > 0)
{
TeaCore.Sleep(backoffTime);
}
}
_retryTimes = _retryTimes + 1;
try
{
TeaRequest request_ = new TeaRequest();
Dictionary<string, string> systemParams = new Dictionary<string, string>
{
{"method", "alipay.user.certify.open.query"},
{"app_id", this._kernel.GetConfig("appId")},
{"timestamp", this._kernel.GetTimestamp()},
{"format", "json"},
{"version", "1.0"},
{"alipay_sdk", this._kernel.GetSdkVersion()},
{"charset", "UTF-8"},
{"sign_type", this._kernel.GetConfig("signType")},
{"app_cert_sn", this._kernel.GetMerchantCertSN()},
{"alipay_root_cert_sn", this._kernel.GetAlipayRootCertSN()},
};
Dictionary<string, object> bizParams = new Dictionary<string, object>
{
{"certify_id", certifyId},
};
Dictionary<string, string> textParams = new Dictionary<string, string>(){};
request_.Protocol = this._kernel.GetConfig("protocol");
request_.Method = "POST";
request_.Pathname = "/gateway.do";
request_.Headers = new Dictionary<string, string>
{
{"host", this._kernel.GetConfig("gatewayHost")},
{"content-type", "application/x-www-form-urlencoded;charset=utf-8"},
};
request_.Query = this._kernel.SortMap(TeaConverter.merge<string>
(
new Dictionary<string, string>()
{
{"sign", this._kernel.Sign(systemParams, bizParams, textParams, this._kernel.GetConfig("merchantPrivateKey"))},
},
systemParams,
textParams
));
request_.Body = TeaCore.BytesReadable(this._kernel.ToUrlEncodedRequestBody(bizParams));
_lastRequest = request_;
TeaResponse response_ = await TeaCore.DoActionAsync(request_, runtime_);
Dictionary<string, object> respMap = await this._kernel.ReadAsJsonAsync(response_, "alipay.user.certify.open.query");
if (this._kernel.IsCertMode())
{
if (this._kernel.Verify(respMap, this._kernel.ExtractAlipayPublicKey(this._kernel.GetAlipayCertSN(respMap))))
{
return TeaModel.ToObject<AlipayUserCertifyOpenQueryResponse>(this._kernel.ToRespModel(respMap));
}
}
else
{
if (this._kernel.Verify(respMap, this._kernel.GetConfig("alipayPublicKey")))
{
return TeaModel.ToObject<AlipayUserCertifyOpenQueryResponse>(this._kernel.ToRespModel(respMap));
}
}
throw new TeaException(new Dictionary<string, string>
{
{"message", "验签失败,请检查支付宝公钥设置是否正确。"},
});
}
catch (Exception e)
{
if (TeaCore.IsRetryable(e))
{
_lastException = e;
continue;
}
throw e;
}
}
throw new TeaUnretryableException(_lastRequest, _lastException);
}
public AlipayUserCertifyOpenCertifyResponse Certify(string certifyId)
{
Dictionary<string, string> systemParams = new Dictionary<string, string>
{
{"method", "alipay.user.certify.open.certify"},
{"app_id", this._kernel.GetConfig("appId")},
{"timestamp", this._kernel.GetTimestamp()},
{"format", "json"},
{"version", "1.0"},
{"alipay_sdk", this._kernel.GetSdkVersion()},
{"charset", "UTF-8"},
{"sign_type", this._kernel.GetConfig("signType")},
{"app_cert_sn", this._kernel.GetMerchantCertSN()},
{"alipay_root_cert_sn", this._kernel.GetAlipayRootCertSN()},
};
Dictionary<string, object> bizParams = new Dictionary<string, object>
{
{"certify_id", certifyId},
};
Dictionary<string, string> textParams = new Dictionary<string, string>(){};
string sign = this._kernel.Sign(systemParams, bizParams, textParams, this._kernel.GetConfig("merchantPrivateKey"));
Dictionary<string, string> response = new Dictionary<string, string>
{
{"body", this._kernel.GeneratePage("GET", systemParams, bizParams, textParams, sign)},
};
return TeaModel.ToObject<AlipayUserCertifyOpenCertifyResponse>(response);
}
/// <summary>
/// ISV代商户代用指定appAuthToken
/// </summary>
/// <param name="appAuthToken">代调用token</param>
/// <returns>本客户端,便于链式调用</returns>
public Client Agent(string appAuthToken)
{
_kernel.InjectTextParam("app_auth_token", appAuthToken);
return this;
}
/// <summary>
/// 用户授权调用指定authToken
/// </summary>
/// <param name="authToken">用户授权token</param>
/// <returns>本客户端,便于链式调用</returns>
public Client Auth(string authToken)
{
_kernel.InjectTextParam("auth_token", authToken);
return this;
}
/// <summary>
/// 设置异步通知回调地址此处设置将在本调用中覆盖Config中的全局配置
/// </summary>
/// <param name="url">异步通知回调地址例如https://www.test.com/callback </param>
/// <returns>本客户端,便于链式调用</returns>
public Client AsyncNotify(string url)
{
_kernel.InjectTextParam("notify_url", url);
return this;
}
/// <summary>
/// 将本次调用强制路由到后端系统的测试地址上,常用于线下环境内外联调,沙箱与线上环境设置无效
/// </summary>
/// <param name="testUrl">后端系统测试地址</param>
/// <returns>本客户端,便于链式调用</returns>
public Client Route(string testUrl)
{
_kernel.InjectTextParam("ws_service_url", testUrl);
return this;
}
/// <summary>
/// 设置API入参中没有的其他可选业务请求参数(biz_content下的字段)
/// </summary>
/// <param name="key">业务请求参数名称biz_content下的字段名比如timeout_express</param>
/// <param name="value">
/// 业务请求参数的值一个可以序列化成JSON的对象
/// 如果该字段是一个字符串类型String、Price、Date在SDK中都是字符串请使用string储存
/// 如果该字段是一个数值型类型比如Number请使用long储存
/// 如果该字段是一个复杂类型请使用嵌套的Dictionary指定各下级字段的值
/// 如果该字段是一个数组请使用List储存各个值
/// 对于更复杂的情况也支持Dictionary和List的各种组合嵌套比如参数是值是个ListList中的每种类型是一个复杂对象
/// </param>
/// <returns>本客户端,便于链式调用</returns>
public Client Optional(string key, object value)
{
_kernel.InjectBizParam(key, value);
return this;
}
/// <summary>
/// 批量设置API入参中没有的其他可选业务请求参数(biz_content下的字段)
/// optional方法的批量版本
/// </summary>
/// <param name="optionalArgs">可选参数集合每个参数由key和value组成key和value的格式请参见optional方法的注释</param>
/// <returns>本客户端,便于链式调用</returns>
public Client BatchOptional(Dictionary<string, object> optionalArgs)
{
foreach (var pair in optionalArgs)
{
_kernel.InjectBizParam(pair.Key, pair.Value);
}
return this;
}
}
}

View File

@@ -0,0 +1,21 @@
// This file is auto-generated, don't edit it. Thanks.
using System;
using System.Collections.Generic;
using System.IO;
using Tea;
namespace Alipay.EasySDK.Member.Identification.Models
{
public class AlipayUserCertifyOpenCertifyResponse : TeaModel {
/// <summary>
/// 认证服务请求地址
/// </summary>
[NameInMap("body")]
[Validation(Required=true)]
public string Body { get; set; }
}
}

View File

@@ -0,0 +1,41 @@
// This file is auto-generated, don't edit it. Thanks.
using System;
using System.Collections.Generic;
using System.IO;
using Tea;
namespace Alipay.EasySDK.Member.Identification.Models
{
public class AlipayUserCertifyOpenInitializeResponse : TeaModel {
/// <summary>
/// 响应原始字符串
/// </summary>
[NameInMap("http_body")]
[Validation(Required=true)]
public string HttpBody { get; set; }
[NameInMap("code")]
[Validation(Required=true)]
public string Code { get; set; }
[NameInMap("msg")]
[Validation(Required=true)]
public string Msg { get; set; }
[NameInMap("sub_code")]
[Validation(Required=true)]
public string SubCode { get; set; }
[NameInMap("sub_msg")]
[Validation(Required=true)]
public string SubMsg { get; set; }
[NameInMap("certify_id")]
[Validation(Required=true)]
public string CertifyId { get; set; }
}
}

View File

@@ -0,0 +1,49 @@
// This file is auto-generated, don't edit it. Thanks.
using System;
using System.Collections.Generic;
using System.IO;
using Tea;
namespace Alipay.EasySDK.Member.Identification.Models
{
public class AlipayUserCertifyOpenQueryResponse : TeaModel {
/// <summary>
/// 响应原始字符串
/// </summary>
[NameInMap("http_body")]
[Validation(Required=true)]
public string HttpBody { get; set; }
[NameInMap("code")]
[Validation(Required=true)]
public string Code { get; set; }
[NameInMap("msg")]
[Validation(Required=true)]
public string Msg { get; set; }
[NameInMap("sub_code")]
[Validation(Required=true)]
public string SubCode { get; set; }
[NameInMap("sub_msg")]
[Validation(Required=true)]
public string SubMsg { get; set; }
[NameInMap("passed")]
[Validation(Required=true)]
public string Passed { get; set; }
[NameInMap("identity_info")]
[Validation(Required=true)]
public string IdentityInfo { get; set; }
[NameInMap("material_info")]
[Validation(Required=true)]
public string MaterialInfo { get; set; }
}
}

View File

@@ -0,0 +1,30 @@
// This file is auto-generated, don't edit it. Thanks.
using System;
using System.Collections.Generic;
using System.IO;
using Tea;
namespace Alipay.EasySDK.Member.Identification.Models
{
public class IdentityParam : TeaModel {
[NameInMap("identity_type")]
[Validation(Required=true)]
public string IdentityType { get; set; }
[NameInMap("cert_type")]
[Validation(Required=true)]
public string CertType { get; set; }
[NameInMap("cert_name")]
[Validation(Required=true)]
public string CertName { get; set; }
[NameInMap("cert_no")]
[Validation(Required=true)]
public string CertNo { get; set; }
}
}

View File

@@ -0,0 +1,18 @@
// This file is auto-generated, don't edit it. Thanks.
using System;
using System.Collections.Generic;
using System.IO;
using Tea;
namespace Alipay.EasySDK.Member.Identification.Models
{
public class MerchantConfig : TeaModel {
[NameInMap("return_url")]
[Validation(Required=true)]
public string ReturnUrl { get; set; }
}
}

View File

@@ -0,0 +1,135 @@
// This file is auto-generated, don't edit it. Thanks.
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Threading.Tasks;
using Tea;
using Tea.Utils;
using Alipay.EasySDK.Payment.App.Models;
namespace Alipay.EasySDK.Payment.App
{
public class Client
{
protected Alipay.EasySDK.Kernel.Client _kernel;
public Client(Alipay.EasySDK.Kernel.Client kernel)
{
this._kernel = kernel;
}
public AlipayTradeAppPayResponse Pay(string subject, string outTradeNo, string totalAmount)
{
Dictionary<string, string> systemParams = new Dictionary<string, string>
{
{"method", "alipay.trade.app.pay"},
{"app_id", this._kernel.GetConfig("appId")},
{"timestamp", this._kernel.GetTimestamp()},
{"format", "json"},
{"version", "1.0"},
{"alipay_sdk", this._kernel.GetSdkVersion()},
{"charset", "UTF-8"},
{"sign_type", this._kernel.GetConfig("signType")},
{"app_cert_sn", this._kernel.GetMerchantCertSN()},
{"alipay_root_cert_sn", this._kernel.GetAlipayRootCertSN()},
};
Dictionary<string, object> bizParams = new Dictionary<string, object>
{
{"subject", subject},
{"out_trade_no", outTradeNo},
{"total_amount", totalAmount},
};
Dictionary<string, string> textParams = new Dictionary<string, string>(){};
string sign = this._kernel.Sign(systemParams, bizParams, textParams, this._kernel.GetConfig("merchantPrivateKey"));
Dictionary<string, string> response = new Dictionary<string, string>
{
{"body", this._kernel.GenerateOrderString(systemParams, bizParams, textParams, sign)},
};
return TeaModel.ToObject<AlipayTradeAppPayResponse>(response);
}
/// <summary>
/// ISV代商户代用指定appAuthToken
/// </summary>
/// <param name="appAuthToken">代调用token</param>
/// <returns>本客户端,便于链式调用</returns>
public Client Agent(string appAuthToken)
{
_kernel.InjectTextParam("app_auth_token", appAuthToken);
return this;
}
/// <summary>
/// 用户授权调用指定authToken
/// </summary>
/// <param name="authToken">用户授权token</param>
/// <returns>本客户端,便于链式调用</returns>
public Client Auth(string authToken)
{
_kernel.InjectTextParam("auth_token", authToken);
return this;
}
/// <summary>
/// 设置异步通知回调地址此处设置将在本调用中覆盖Config中的全局配置
/// </summary>
/// <param name="url">异步通知回调地址例如https://www.test.com/callback </param>
/// <returns>本客户端,便于链式调用</returns>
public Client AsyncNotify(string url)
{
_kernel.InjectTextParam("notify_url", url);
return this;
}
/// <summary>
/// 将本次调用强制路由到后端系统的测试地址上,常用于线下环境内外联调,沙箱与线上环境设置无效
/// </summary>
/// <param name="testUrl">后端系统测试地址</param>
/// <returns>本客户端,便于链式调用</returns>
public Client Route(string testUrl)
{
_kernel.InjectTextParam("ws_service_url", testUrl);
return this;
}
/// <summary>
/// 设置API入参中没有的其他可选业务请求参数(biz_content下的字段)
/// </summary>
/// <param name="key">业务请求参数名称biz_content下的字段名比如timeout_express</param>
/// <param name="value">
/// 业务请求参数的值一个可以序列化成JSON的对象
/// 如果该字段是一个字符串类型String、Price、Date在SDK中都是字符串请使用string储存
/// 如果该字段是一个数值型类型比如Number请使用long储存
/// 如果该字段是一个复杂类型请使用嵌套的Dictionary指定各下级字段的值
/// 如果该字段是一个数组请使用List储存各个值
/// 对于更复杂的情况也支持Dictionary和List的各种组合嵌套比如参数是值是个ListList中的每种类型是一个复杂对象
/// </param>
/// <returns>本客户端,便于链式调用</returns>
public Client Optional(string key, object value)
{
_kernel.InjectBizParam(key, value);
return this;
}
/// <summary>
/// 批量设置API入参中没有的其他可选业务请求参数(biz_content下的字段)
/// optional方法的批量版本
/// </summary>
/// <param name="optionalArgs">可选参数集合每个参数由key和value组成key和value的格式请参见optional方法的注释</param>
/// <returns>本客户端,便于链式调用</returns>
public Client BatchOptional(Dictionary<string, object> optionalArgs)
{
foreach (var pair in optionalArgs)
{
_kernel.InjectBizParam(pair.Key, pair.Value);
}
return this;
}
}
}

View File

@@ -0,0 +1,21 @@
// This file is auto-generated, don't edit it. Thanks.
using System;
using System.Collections.Generic;
using System.IO;
using Tea;
namespace Alipay.EasySDK.Payment.App.Models
{
public class AlipayTradeAppPayResponse : TeaModel {
/// <summary>
/// 订单信息,字符串形式
/// </summary>
[NameInMap("body")]
[Validation(Required=true)]
public string Body { get; set; }
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,41 @@
// This file is auto-generated, don't edit it. Thanks.
using System;
using System.Collections.Generic;
using System.IO;
using Tea;
namespace Alipay.EasySDK.Payment.Common.Models
{
public class AlipayDataDataserviceBillDownloadurlQueryResponse : TeaModel {
/// <summary>
/// 响应原始字符串
/// </summary>
[NameInMap("http_body")]
[Validation(Required=true)]
public string HttpBody { get; set; }
[NameInMap("code")]
[Validation(Required=true)]
public string Code { get; set; }
[NameInMap("msg")]
[Validation(Required=true)]
public string Msg { get; set; }
[NameInMap("sub_code")]
[Validation(Required=true)]
public string SubCode { get; set; }
[NameInMap("sub_msg")]
[Validation(Required=true)]
public string SubMsg { get; set; }
[NameInMap("bill_download_url")]
[Validation(Required=true)]
public string BillDownloadUrl { get; set; }
}
}

View File

@@ -0,0 +1,61 @@
// This file is auto-generated, don't edit it. Thanks.
using System;
using System.Collections.Generic;
using System.IO;
using Tea;
namespace Alipay.EasySDK.Payment.Common.Models
{
public class AlipayTradeCancelResponse : TeaModel {
/// <summary>
/// 响应原始字符串
/// </summary>
[NameInMap("http_body")]
[Validation(Required=true)]
public string HttpBody { get; set; }
[NameInMap("code")]
[Validation(Required=true)]
public string Code { get; set; }
[NameInMap("msg")]
[Validation(Required=true)]
public string Msg { get; set; }
[NameInMap("sub_code")]
[Validation(Required=true)]
public string SubCode { get; set; }
[NameInMap("sub_msg")]
[Validation(Required=true)]
public string SubMsg { get; set; }
[NameInMap("trade_no")]
[Validation(Required=true)]
public string TradeNo { get; set; }
[NameInMap("out_trade_no")]
[Validation(Required=true)]
public string OutTradeNo { get; set; }
[NameInMap("retry_flag")]
[Validation(Required=true)]
public string RetryFlag { get; set; }
[NameInMap("action")]
[Validation(Required=true)]
public string Action { get; set; }
[NameInMap("gmt_refund_pay")]
[Validation(Required=true)]
public string GmtRefundPay { get; set; }
[NameInMap("refund_settlement_id")]
[Validation(Required=true)]
public string RefundSettlementId { get; set; }
}
}

View File

@@ -0,0 +1,45 @@
// This file is auto-generated, don't edit it. Thanks.
using System;
using System.Collections.Generic;
using System.IO;
using Tea;
namespace Alipay.EasySDK.Payment.Common.Models
{
public class AlipayTradeCloseResponse : TeaModel {
/// <summary>
/// 响应原始字符串
/// </summary>
[NameInMap("http_body")]
[Validation(Required=true)]
public string HttpBody { get; set; }
[NameInMap("code")]
[Validation(Required=true)]
public string Code { get; set; }
[NameInMap("msg")]
[Validation(Required=true)]
public string Msg { get; set; }
[NameInMap("sub_code")]
[Validation(Required=true)]
public string SubCode { get; set; }
[NameInMap("sub_msg")]
[Validation(Required=true)]
public string SubMsg { get; set; }
[NameInMap("trade_no")]
[Validation(Required=true)]
public string TradeNo { get; set; }
[NameInMap("out_trade_no")]
[Validation(Required=true)]
public string OutTradeNo { get; set; }
}
}

View File

@@ -0,0 +1,45 @@
// This file is auto-generated, don't edit it. Thanks.
using System;
using System.Collections.Generic;
using System.IO;
using Tea;
namespace Alipay.EasySDK.Payment.Common.Models
{
public class AlipayTradeCreateResponse : TeaModel {
/// <summary>
/// 响应原始字符串
/// </summary>
[NameInMap("http_body")]
[Validation(Required=true)]
public string HttpBody { get; set; }
[NameInMap("code")]
[Validation(Required=true)]
public string Code { get; set; }
[NameInMap("msg")]
[Validation(Required=true)]
public string Msg { get; set; }
[NameInMap("sub_code")]
[Validation(Required=true)]
public string SubCode { get; set; }
[NameInMap("sub_msg")]
[Validation(Required=true)]
public string SubMsg { get; set; }
[NameInMap("out_trade_no")]
[Validation(Required=true)]
public string OutTradeNo { get; set; }
[NameInMap("trade_no")]
[Validation(Required=true)]
public string TradeNo { get; set; }
}
}

View File

@@ -0,0 +1,109 @@
// This file is auto-generated, don't edit it. Thanks.
using System;
using System.Collections.Generic;
using System.IO;
using Tea;
namespace Alipay.EasySDK.Payment.Common.Models
{
public class AlipayTradeFastpayRefundQueryResponse : TeaModel {
/// <summary>
/// 响应原始字符串
/// </summary>
[NameInMap("http_body")]
[Validation(Required=true)]
public string HttpBody { get; set; }
[NameInMap("code")]
[Validation(Required=true)]
public string Code { get; set; }
[NameInMap("msg")]
[Validation(Required=true)]
public string Msg { get; set; }
[NameInMap("sub_code")]
[Validation(Required=true)]
public string SubCode { get; set; }
[NameInMap("sub_msg")]
[Validation(Required=true)]
public string SubMsg { get; set; }
[NameInMap("error_code")]
[Validation(Required=true)]
public string ErrorCode { get; set; }
[NameInMap("gmt_refund_pay")]
[Validation(Required=true)]
public string GmtRefundPay { get; set; }
[NameInMap("industry_sepc_detail")]
[Validation(Required=true)]
public string IndustrySepcDetail { get; set; }
[NameInMap("out_request_no")]
[Validation(Required=true)]
public string OutRequestNo { get; set; }
[NameInMap("out_trade_no")]
[Validation(Required=true)]
public string OutTradeNo { get; set; }
[NameInMap("present_refund_buyer_amount")]
[Validation(Required=true)]
public string PresentRefundBuyerAmount { get; set; }
[NameInMap("present_refund_discount_amount")]
[Validation(Required=true)]
public string PresentRefundDiscountAmount { get; set; }
[NameInMap("present_refund_mdiscount_amount")]
[Validation(Required=true)]
public string PresentRefundMdiscountAmount { get; set; }
[NameInMap("refund_amount")]
[Validation(Required=true)]
public string RefundAmount { get; set; }
[NameInMap("refund_charge_amount")]
[Validation(Required=true)]
public string RefundChargeAmount { get; set; }
[NameInMap("refund_detail_item_list")]
[Validation(Required=true)]
public List<TradeFundBill> RefundDetailItemList { get; set; }
[NameInMap("refund_reason")]
[Validation(Required=true)]
public string RefundReason { get; set; }
[NameInMap("refund_royaltys")]
[Validation(Required=true)]
public List<RefundRoyaltyResult> RefundRoyaltys { get; set; }
[NameInMap("refund_settlement_id")]
[Validation(Required=true)]
public string RefundSettlementId { get; set; }
[NameInMap("refund_status")]
[Validation(Required=true)]
public string RefundStatus { get; set; }
[NameInMap("send_back_fee")]
[Validation(Required=true)]
public string SendBackFee { get; set; }
[NameInMap("total_amount")]
[Validation(Required=true)]
public string TotalAmount { get; set; }
[NameInMap("trade_no")]
[Validation(Required=true)]
public string TradeNo { get; set; }
}
}

View File

@@ -0,0 +1,177 @@
// This file is auto-generated, don't edit it. Thanks.
using System;
using System.Collections.Generic;
using System.IO;
using Tea;
namespace Alipay.EasySDK.Payment.Common.Models
{
public class AlipayTradeQueryResponse : TeaModel {
/// <summary>
/// 响应原始字符串
/// </summary>
[NameInMap("http_body")]
[Validation(Required=true)]
public string HttpBody { get; set; }
[NameInMap("code")]
[Validation(Required=true)]
public string Code { get; set; }
[NameInMap("msg")]
[Validation(Required=true)]
public string Msg { get; set; }
[NameInMap("sub_code")]
[Validation(Required=true)]
public string SubCode { get; set; }
[NameInMap("sub_msg")]
[Validation(Required=true)]
public string SubMsg { get; set; }
[NameInMap("trade_no")]
[Validation(Required=true)]
public string TradeNo { get; set; }
[NameInMap("out_trade_no")]
[Validation(Required=true)]
public string OutTradeNo { get; set; }
[NameInMap("buyer_logon_id")]
[Validation(Required=true)]
public string BuyerLogonId { get; set; }
[NameInMap("trade_status")]
[Validation(Required=true)]
public string TradeStatus { get; set; }
[NameInMap("total_amount")]
[Validation(Required=true)]
public string TotalAmount { get; set; }
[NameInMap("trans_currency")]
[Validation(Required=true)]
public string TransCurrency { get; set; }
[NameInMap("settle_currency")]
[Validation(Required=true)]
public string SettleCurrency { get; set; }
[NameInMap("settle_amount")]
[Validation(Required=true)]
public string SettleAmount { get; set; }
[NameInMap("pay_currency")]
[Validation(Required=true)]
public string PayCurrency { get; set; }
[NameInMap("pay_amount")]
[Validation(Required=true)]
public string PayAmount { get; set; }
[NameInMap("settle_trans_rate")]
[Validation(Required=true)]
public string SettleTransRate { get; set; }
[NameInMap("trans_pay_rate")]
[Validation(Required=true)]
public string TransPayRate { get; set; }
[NameInMap("buyer_pay_amount")]
[Validation(Required=true)]
public string BuyerPayAmount { get; set; }
[NameInMap("point_amount")]
[Validation(Required=true)]
public string PointAmount { get; set; }
[NameInMap("invoice_amount")]
[Validation(Required=true)]
public string InvoiceAmount { get; set; }
[NameInMap("send_pay_date")]
[Validation(Required=true)]
public string SendPayDate { get; set; }
[NameInMap("receipt_amount")]
[Validation(Required=true)]
public string ReceiptAmount { get; set; }
[NameInMap("store_id")]
[Validation(Required=true)]
public string StoreId { get; set; }
[NameInMap("terminal_id")]
[Validation(Required=true)]
public string TerminalId { get; set; }
[NameInMap("fund_bill_list")]
[Validation(Required=true)]
public List<TradeFundBill> FundBillList { get; set; }
[NameInMap("store_name")]
[Validation(Required=true)]
public string StoreName { get; set; }
[NameInMap("buyer_user_id")]
[Validation(Required=true)]
public string BuyerUserId { get; set; }
[NameInMap("charge_amount")]
[Validation(Required=true)]
public string ChargeAmount { get; set; }
[NameInMap("charge_flags")]
[Validation(Required=true)]
public string ChargeFlags { get; set; }
[NameInMap("settlement_id")]
[Validation(Required=true)]
public string SettlementId { get; set; }
[NameInMap("trade_settle_info")]
[Validation(Required=true)]
public List<TradeSettleInfo> TradeSettleInfo { get; set; }
[NameInMap("auth_trade_pay_mode")]
[Validation(Required=true)]
public string AuthTradePayMode { get; set; }
[NameInMap("buyer_user_type")]
[Validation(Required=true)]
public string BuyerUserType { get; set; }
[NameInMap("mdiscount_amount")]
[Validation(Required=true)]
public string MdiscountAmount { get; set; }
[NameInMap("discount_amount")]
[Validation(Required=true)]
public string DiscountAmount { get; set; }
[NameInMap("buyer_user_name")]
[Validation(Required=true)]
public string BuyerUserName { get; set; }
[NameInMap("subject")]
[Validation(Required=true)]
public string Subject { get; set; }
[NameInMap("body")]
[Validation(Required=true)]
public string Body { get; set; }
[NameInMap("alipay_sub_merchant_id")]
[Validation(Required=true)]
public string AlipaySubMerchantId { get; set; }
[NameInMap("ext_infos")]
[Validation(Required=true)]
public string ExtInfos { get; set; }
}
}

View File

@@ -0,0 +1,97 @@
// This file is auto-generated, don't edit it. Thanks.
using System;
using System.Collections.Generic;
using System.IO;
using Tea;
namespace Alipay.EasySDK.Payment.Common.Models
{
public class AlipayTradeRefundResponse : TeaModel {
/// <summary>
/// 响应原始字符串
/// </summary>
[NameInMap("http_body")]
[Validation(Required=true)]
public string HttpBody { get; set; }
[NameInMap("code")]
[Validation(Required=true)]
public string Code { get; set; }
[NameInMap("msg")]
[Validation(Required=true)]
public string Msg { get; set; }
[NameInMap("sub_code")]
[Validation(Required=true)]
public string SubCode { get; set; }
[NameInMap("sub_msg")]
[Validation(Required=true)]
public string SubMsg { get; set; }
[NameInMap("trade_no")]
[Validation(Required=true)]
public string TradeNo { get; set; }
[NameInMap("out_trade_no")]
[Validation(Required=true)]
public string OutTradeNo { get; set; }
[NameInMap("buyer_logon_id")]
[Validation(Required=true)]
public string BuyerLogonId { get; set; }
[NameInMap("fund_change")]
[Validation(Required=true)]
public string FundChange { get; set; }
[NameInMap("refund_fee")]
[Validation(Required=true)]
public string RefundFee { get; set; }
[NameInMap("refund_currency")]
[Validation(Required=true)]
public string RefundCurrency { get; set; }
[NameInMap("gmt_refund_pay")]
[Validation(Required=true)]
public string GmtRefundPay { get; set; }
[NameInMap("refund_detail_item_list")]
[Validation(Required=true)]
public List<TradeFundBill> RefundDetailItemList { get; set; }
[NameInMap("store_name")]
[Validation(Required=true)]
public string StoreName { get; set; }
[NameInMap("buyer_user_id")]
[Validation(Required=true)]
public string BuyerUserId { get; set; }
[NameInMap("refund_preset_paytool_list")]
[Validation(Required=true)]
public List<PresetPayToolInfo> RefundPresetPaytoolList { get; set; }
[NameInMap("refund_settlement_id")]
[Validation(Required=true)]
public string RefundSettlementId { get; set; }
[NameInMap("present_refund_buyer_amount")]
[Validation(Required=true)]
public string PresentRefundBuyerAmount { get; set; }
[NameInMap("present_refund_discount_amount")]
[Validation(Required=true)]
public string PresentRefundDiscountAmount { get; set; }
[NameInMap("present_refund_mdiscount_amount")]
[Validation(Required=true)]
public string PresentRefundMdiscountAmount { get; set; }
}
}

View File

@@ -0,0 +1,22 @@
// This file is auto-generated, don't edit it. Thanks.
using System;
using System.Collections.Generic;
using System.IO;
using Tea;
namespace Alipay.EasySDK.Payment.Common.Models
{
public class PresetPayToolInfo : TeaModel {
[NameInMap("amount")]
[Validation(Required=true)]
public List<string> Amount { get; set; }
[NameInMap("assert_type_code")]
[Validation(Required=true)]
public string AssertTypeCode { get; set; }
}
}

View File

@@ -0,0 +1,42 @@
// This file is auto-generated, don't edit it. Thanks.
using System;
using System.Collections.Generic;
using System.IO;
using Tea;
namespace Alipay.EasySDK.Payment.Common.Models
{
public class RefundRoyaltyResult : TeaModel {
[NameInMap("refund_amount")]
[Validation(Required=true)]
public string RefundAmount { get; set; }
[NameInMap("royalty_type")]
[Validation(Required=true)]
public string RoyaltyType { get; set; }
[NameInMap("result_code")]
[Validation(Required=true)]
public string ResultCode { get; set; }
[NameInMap("trans_out")]
[Validation(Required=true)]
public string TransOut { get; set; }
[NameInMap("trans_out_email")]
[Validation(Required=true)]
public string TransOutEmail { get; set; }
[NameInMap("trans_in")]
[Validation(Required=true)]
public string TransIn { get; set; }
[NameInMap("trans_in_email")]
[Validation(Required=true)]
public string TransInEmail { get; set; }
}
}

View File

@@ -0,0 +1,34 @@
// This file is auto-generated, don't edit it. Thanks.
using System;
using System.Collections.Generic;
using System.IO;
using Tea;
namespace Alipay.EasySDK.Payment.Common.Models
{
public class TradeFundBill : TeaModel {
[NameInMap("fund_channel")]
[Validation(Required=true)]
public string FundChannel { get; set; }
[NameInMap("bank_code")]
[Validation(Required=true)]
public string BankCode { get; set; }
[NameInMap("amount")]
[Validation(Required=true)]
public string Amount { get; set; }
[NameInMap("real_amount")]
[Validation(Required=true)]
public string RealAmount { get; set; }
[NameInMap("fund_type")]
[Validation(Required=true)]
public string FundType { get; set; }
}
}

View File

@@ -0,0 +1,38 @@
// This file is auto-generated, don't edit it. Thanks.
using System;
using System.Collections.Generic;
using System.IO;
using Tea;
namespace Alipay.EasySDK.Payment.Common.Models
{
public class TradeSettleDetail : TeaModel {
[NameInMap("operation_type")]
[Validation(Required=true)]
public string OperationType { get; set; }
[NameInMap("operation_serial_no")]
[Validation(Required=true)]
public string OperationSerial_no { get; set; }
[NameInMap("operation_dt")]
[Validation(Required=true)]
public string OperationDt { get; set; }
[NameInMap("trans_out")]
[Validation(Required=true)]
public string TransOut { get; set; }
[NameInMap("trans_in")]
[Validation(Required=true)]
public string TransIn { get; set; }
[NameInMap("amount")]
[Validation(Required=true)]
public string Amount { get; set; }
}
}

View File

@@ -0,0 +1,18 @@
// This file is auto-generated, don't edit it. Thanks.
using System;
using System.Collections.Generic;
using System.IO;
using Tea;
namespace Alipay.EasySDK.Payment.Common.Models
{
public class TradeSettleInfo : TeaModel {
[NameInMap("trade_settle_detail_list")]
[Validation(Required=true)]
public List<TradeSettleDetail> TradeSettleDetailList { get; set; }
}
}

View File

@@ -0,0 +1,536 @@
// This file is auto-generated, don't edit it. Thanks.
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Threading.Tasks;
using Tea;
using Tea.Utils;
using Alipay.EasySDK.Payment.FaceToFace.Models;
namespace Alipay.EasySDK.Payment.FaceToFace
{
public class Client
{
protected Alipay.EasySDK.Kernel.Client _kernel;
public Client(Alipay.EasySDK.Kernel.Client kernel)
{
this._kernel = kernel;
}
public AlipayTradePayResponse Pay(string subject, string outTradeNo, string totalAmount, string authCode)
{
Dictionary<string, object> runtime_ = new Dictionary<string, object>
{
{"ignoreSSL", this._kernel.GetConfig("ignoreSSL")},
{"httpProxy", this._kernel.GetConfig("httpProxy")},
{"connectTimeout", 15000},
{"readTimeout", 15000},
{"retry", new Dictionary<string, int?>
{
{"maxAttempts", 0},
}},
};
TeaRequest _lastRequest = null;
Exception _lastException = null;
long _now = System.DateTime.Now.Millisecond;
int _retryTimes = 0;
while (TeaCore.AllowRetry((IDictionary) runtime_["retry"], _retryTimes, _now))
{
if (_retryTimes > 0)
{
int backoffTime = TeaCore.GetBackoffTime((IDictionary)runtime_["backoff"], _retryTimes);
if (backoffTime > 0)
{
TeaCore.Sleep(backoffTime);
}
}
_retryTimes = _retryTimes + 1;
try
{
TeaRequest request_ = new TeaRequest();
Dictionary<string, string> systemParams = new Dictionary<string, string>
{
{"method", "alipay.trade.pay"},
{"app_id", this._kernel.GetConfig("appId")},
{"timestamp", this._kernel.GetTimestamp()},
{"format", "json"},
{"version", "1.0"},
{"alipay_sdk", this._kernel.GetSdkVersion()},
{"charset", "UTF-8"},
{"sign_type", this._kernel.GetConfig("signType")},
{"app_cert_sn", this._kernel.GetMerchantCertSN()},
{"alipay_root_cert_sn", this._kernel.GetAlipayRootCertSN()},
};
Dictionary<string, object> bizParams = new Dictionary<string, object>
{
{"subject", subject},
{"out_trade_no", outTradeNo},
{"total_amount", totalAmount},
{"auth_code", authCode},
{"scene", "bar_code"},
};
Dictionary<string, string> textParams = new Dictionary<string, string>(){};
request_.Protocol = this._kernel.GetConfig("protocol");
request_.Method = "POST";
request_.Pathname = "/gateway.do";
request_.Headers = new Dictionary<string, string>
{
{"host", this._kernel.GetConfig("gatewayHost")},
{"content-type", "application/x-www-form-urlencoded;charset=utf-8"},
};
request_.Query = this._kernel.SortMap(TeaConverter.merge<string>
(
new Dictionary<string, string>()
{
{"sign", this._kernel.Sign(systemParams, bizParams, textParams, this._kernel.GetConfig("merchantPrivateKey"))},
},
systemParams,
textParams
));
request_.Body = TeaCore.BytesReadable(this._kernel.ToUrlEncodedRequestBody(bizParams));
_lastRequest = request_;
TeaResponse response_ = TeaCore.DoAction(request_, runtime_);
Dictionary<string, object> respMap = this._kernel.ReadAsJson(response_, "alipay.trade.pay");
if (this._kernel.IsCertMode())
{
if (this._kernel.Verify(respMap, this._kernel.ExtractAlipayPublicKey(this._kernel.GetAlipayCertSN(respMap))))
{
return TeaModel.ToObject<AlipayTradePayResponse>(this._kernel.ToRespModel(respMap));
}
}
else
{
if (this._kernel.Verify(respMap, this._kernel.GetConfig("alipayPublicKey")))
{
return TeaModel.ToObject<AlipayTradePayResponse>(this._kernel.ToRespModel(respMap));
}
}
throw new TeaException(new Dictionary<string, string>
{
{"message", "验签失败,请检查支付宝公钥设置是否正确。"},
});
}
catch (Exception e)
{
if (TeaCore.IsRetryable(e))
{
_lastException = e;
continue;
}
throw e;
}
}
throw new TeaUnretryableException(_lastRequest, _lastException);
}
public async Task<AlipayTradePayResponse> PayAsync(string subject, string outTradeNo, string totalAmount, string authCode)
{
Dictionary<string, object> runtime_ = new Dictionary<string, object>
{
{"ignoreSSL", this._kernel.GetConfig("ignoreSSL")},
{"httpProxy", this._kernel.GetConfig("httpProxy")},
{"connectTimeout", 15000},
{"readTimeout", 15000},
{"retry", new Dictionary<string, int?>
{
{"maxAttempts", 0},
}},
};
TeaRequest _lastRequest = null;
Exception _lastException = null;
long _now = System.DateTime.Now.Millisecond;
int _retryTimes = 0;
while (TeaCore.AllowRetry((IDictionary) runtime_["retry"], _retryTimes, _now))
{
if (_retryTimes > 0)
{
int backoffTime = TeaCore.GetBackoffTime((IDictionary)runtime_["backoff"], _retryTimes);
if (backoffTime > 0)
{
TeaCore.Sleep(backoffTime);
}
}
_retryTimes = _retryTimes + 1;
try
{
TeaRequest request_ = new TeaRequest();
Dictionary<string, string> systemParams = new Dictionary<string, string>
{
{"method", "alipay.trade.pay"},
{"app_id", this._kernel.GetConfig("appId")},
{"timestamp", this._kernel.GetTimestamp()},
{"format", "json"},
{"version", "1.0"},
{"alipay_sdk", this._kernel.GetSdkVersion()},
{"charset", "UTF-8"},
{"sign_type", this._kernel.GetConfig("signType")},
{"app_cert_sn", this._kernel.GetMerchantCertSN()},
{"alipay_root_cert_sn", this._kernel.GetAlipayRootCertSN()},
};
Dictionary<string, object> bizParams = new Dictionary<string, object>
{
{"subject", subject},
{"out_trade_no", outTradeNo},
{"total_amount", totalAmount},
{"auth_code", authCode},
{"scene", "bar_code"},
};
Dictionary<string, string> textParams = new Dictionary<string, string>(){};
request_.Protocol = this._kernel.GetConfig("protocol");
request_.Method = "POST";
request_.Pathname = "/gateway.do";
request_.Headers = new Dictionary<string, string>
{
{"host", this._kernel.GetConfig("gatewayHost")},
{"content-type", "application/x-www-form-urlencoded;charset=utf-8"},
};
request_.Query = this._kernel.SortMap(TeaConverter.merge<string>
(
new Dictionary<string, string>()
{
{"sign", this._kernel.Sign(systemParams, bizParams, textParams, this._kernel.GetConfig("merchantPrivateKey"))},
},
systemParams,
textParams
));
request_.Body = TeaCore.BytesReadable(this._kernel.ToUrlEncodedRequestBody(bizParams));
_lastRequest = request_;
TeaResponse response_ = await TeaCore.DoActionAsync(request_, runtime_);
Dictionary<string, object> respMap = await this._kernel.ReadAsJsonAsync(response_, "alipay.trade.pay");
if (this._kernel.IsCertMode())
{
if (this._kernel.Verify(respMap, this._kernel.ExtractAlipayPublicKey(this._kernel.GetAlipayCertSN(respMap))))
{
return TeaModel.ToObject<AlipayTradePayResponse>(this._kernel.ToRespModel(respMap));
}
}
else
{
if (this._kernel.Verify(respMap, this._kernel.GetConfig("alipayPublicKey")))
{
return TeaModel.ToObject<AlipayTradePayResponse>(this._kernel.ToRespModel(respMap));
}
}
throw new TeaException(new Dictionary<string, string>
{
{"message", "验签失败,请检查支付宝公钥设置是否正确。"},
});
}
catch (Exception e)
{
if (TeaCore.IsRetryable(e))
{
_lastException = e;
continue;
}
throw e;
}
}
throw new TeaUnretryableException(_lastRequest, _lastException);
}
public AlipayTradePrecreateResponse PreCreate(string subject, string outTradeNo, string totalAmount)
{
Dictionary<string, object> runtime_ = new Dictionary<string, object>
{
{"ignoreSSL", this._kernel.GetConfig("ignoreSSL")},
{"httpProxy", this._kernel.GetConfig("httpProxy")},
{"connectTimeout", 15000},
{"readTimeout", 15000},
{"retry", new Dictionary<string, int?>
{
{"maxAttempts", 0},
}},
};
TeaRequest _lastRequest = null;
Exception _lastException = null;
long _now = System.DateTime.Now.Millisecond;
int _retryTimes = 0;
while (TeaCore.AllowRetry((IDictionary) runtime_["retry"], _retryTimes, _now))
{
if (_retryTimes > 0)
{
int backoffTime = TeaCore.GetBackoffTime((IDictionary)runtime_["backoff"], _retryTimes);
if (backoffTime > 0)
{
TeaCore.Sleep(backoffTime);
}
}
_retryTimes = _retryTimes + 1;
try
{
TeaRequest request_ = new TeaRequest();
Dictionary<string, string> systemParams = new Dictionary<string, string>
{
{"method", "alipay.trade.precreate"},
{"app_id", this._kernel.GetConfig("appId")},
{"timestamp", this._kernel.GetTimestamp()},
{"format", "json"},
{"version", "1.0"},
{"alipay_sdk", this._kernel.GetSdkVersion()},
{"charset", "UTF-8"},
{"sign_type", this._kernel.GetConfig("signType")},
{"app_cert_sn", this._kernel.GetMerchantCertSN()},
{"alipay_root_cert_sn", this._kernel.GetAlipayRootCertSN()},
};
Dictionary<string, object> bizParams = new Dictionary<string, object>
{
{"subject", subject},
{"out_trade_no", outTradeNo},
{"total_amount", totalAmount},
};
Dictionary<string, string> textParams = new Dictionary<string, string>(){};
request_.Protocol = this._kernel.GetConfig("protocol");
request_.Method = "POST";
request_.Pathname = "/gateway.do";
request_.Headers = new Dictionary<string, string>
{
{"host", this._kernel.GetConfig("gatewayHost")},
{"content-type", "application/x-www-form-urlencoded;charset=utf-8"},
};
request_.Query = this._kernel.SortMap(TeaConverter.merge<string>
(
new Dictionary<string, string>()
{
{"sign", this._kernel.Sign(systemParams, bizParams, textParams, this._kernel.GetConfig("merchantPrivateKey"))},
},
systemParams,
textParams
));
request_.Body = TeaCore.BytesReadable(this._kernel.ToUrlEncodedRequestBody(bizParams));
_lastRequest = request_;
TeaResponse response_ = TeaCore.DoAction(request_, runtime_);
Dictionary<string, object> respMap = this._kernel.ReadAsJson(response_, "alipay.trade.precreate");
if (this._kernel.IsCertMode())
{
if (this._kernel.Verify(respMap, this._kernel.ExtractAlipayPublicKey(this._kernel.GetAlipayCertSN(respMap))))
{
return TeaModel.ToObject<AlipayTradePrecreateResponse>(this._kernel.ToRespModel(respMap));
}
}
else
{
if (this._kernel.Verify(respMap, this._kernel.GetConfig("alipayPublicKey")))
{
return TeaModel.ToObject<AlipayTradePrecreateResponse>(this._kernel.ToRespModel(respMap));
}
}
throw new TeaException(new Dictionary<string, string>
{
{"message", "验签失败,请检查支付宝公钥设置是否正确。"},
});
}
catch (Exception e)
{
if (TeaCore.IsRetryable(e))
{
_lastException = e;
continue;
}
throw e;
}
}
throw new TeaUnretryableException(_lastRequest, _lastException);
}
public async Task<AlipayTradePrecreateResponse> PreCreateAsync(string subject, string outTradeNo, string totalAmount)
{
Dictionary<string, object> runtime_ = new Dictionary<string, object>
{
{"ignoreSSL", this._kernel.GetConfig("ignoreSSL")},
{"httpProxy", this._kernel.GetConfig("httpProxy")},
{"connectTimeout", 15000},
{"readTimeout", 15000},
{"retry", new Dictionary<string, int?>
{
{"maxAttempts", 0},
}},
};
TeaRequest _lastRequest = null;
Exception _lastException = null;
long _now = System.DateTime.Now.Millisecond;
int _retryTimes = 0;
while (TeaCore.AllowRetry((IDictionary) runtime_["retry"], _retryTimes, _now))
{
if (_retryTimes > 0)
{
int backoffTime = TeaCore.GetBackoffTime((IDictionary)runtime_["backoff"], _retryTimes);
if (backoffTime > 0)
{
TeaCore.Sleep(backoffTime);
}
}
_retryTimes = _retryTimes + 1;
try
{
TeaRequest request_ = new TeaRequest();
Dictionary<string, string> systemParams = new Dictionary<string, string>
{
{"method", "alipay.trade.precreate"},
{"app_id", this._kernel.GetConfig("appId")},
{"timestamp", this._kernel.GetTimestamp()},
{"format", "json"},
{"version", "1.0"},
{"alipay_sdk", this._kernel.GetSdkVersion()},
{"charset", "UTF-8"},
{"sign_type", this._kernel.GetConfig("signType")},
{"app_cert_sn", this._kernel.GetMerchantCertSN()},
{"alipay_root_cert_sn", this._kernel.GetAlipayRootCertSN()},
};
Dictionary<string, object> bizParams = new Dictionary<string, object>
{
{"subject", subject},
{"out_trade_no", outTradeNo},
{"total_amount", totalAmount},
};
Dictionary<string, string> textParams = new Dictionary<string, string>(){};
request_.Protocol = this._kernel.GetConfig("protocol");
request_.Method = "POST";
request_.Pathname = "/gateway.do";
request_.Headers = new Dictionary<string, string>
{
{"host", this._kernel.GetConfig("gatewayHost")},
{"content-type", "application/x-www-form-urlencoded;charset=utf-8"},
};
request_.Query = this._kernel.SortMap(TeaConverter.merge<string>
(
new Dictionary<string, string>()
{
{"sign", this._kernel.Sign(systemParams, bizParams, textParams, this._kernel.GetConfig("merchantPrivateKey"))},
},
systemParams,
textParams
));
request_.Body = TeaCore.BytesReadable(this._kernel.ToUrlEncodedRequestBody(bizParams));
_lastRequest = request_;
TeaResponse response_ = await TeaCore.DoActionAsync(request_, runtime_);
Dictionary<string, object> respMap = await this._kernel.ReadAsJsonAsync(response_, "alipay.trade.precreate");
if (this._kernel.IsCertMode())
{
if (this._kernel.Verify(respMap, this._kernel.ExtractAlipayPublicKey(this._kernel.GetAlipayCertSN(respMap))))
{
return TeaModel.ToObject<AlipayTradePrecreateResponse>(this._kernel.ToRespModel(respMap));
}
}
else
{
if (this._kernel.Verify(respMap, this._kernel.GetConfig("alipayPublicKey")))
{
return TeaModel.ToObject<AlipayTradePrecreateResponse>(this._kernel.ToRespModel(respMap));
}
}
throw new TeaException(new Dictionary<string, string>
{
{"message", "验签失败,请检查支付宝公钥设置是否正确。"},
});
}
catch (Exception e)
{
if (TeaCore.IsRetryable(e))
{
_lastException = e;
continue;
}
throw e;
}
}
throw new TeaUnretryableException(_lastRequest, _lastException);
}
/// <summary>
/// ISV代商户代用指定appAuthToken
/// </summary>
/// <param name="appAuthToken">代调用token</param>
/// <returns>本客户端,便于链式调用</returns>
public Client Agent(string appAuthToken)
{
_kernel.InjectTextParam("app_auth_token", appAuthToken);
return this;
}
/// <summary>
/// 用户授权调用指定authToken
/// </summary>
/// <param name="authToken">用户授权token</param>
/// <returns>本客户端,便于链式调用</returns>
public Client Auth(string authToken)
{
_kernel.InjectTextParam("auth_token", authToken);
return this;
}
/// <summary>
/// 设置异步通知回调地址此处设置将在本调用中覆盖Config中的全局配置
/// </summary>
/// <param name="url">异步通知回调地址例如https://www.test.com/callback </param>
/// <returns>本客户端,便于链式调用</returns>
public Client AsyncNotify(string url)
{
_kernel.InjectTextParam("notify_url", url);
return this;
}
/// <summary>
/// 将本次调用强制路由到后端系统的测试地址上,常用于线下环境内外联调,沙箱与线上环境设置无效
/// </summary>
/// <param name="testUrl">后端系统测试地址</param>
/// <returns>本客户端,便于链式调用</returns>
public Client Route(string testUrl)
{
_kernel.InjectTextParam("ws_service_url", testUrl);
return this;
}
/// <summary>
/// 设置API入参中没有的其他可选业务请求参数(biz_content下的字段)
/// </summary>
/// <param name="key">业务请求参数名称biz_content下的字段名比如timeout_express</param>
/// <param name="value">
/// 业务请求参数的值一个可以序列化成JSON的对象
/// 如果该字段是一个字符串类型String、Price、Date在SDK中都是字符串请使用string储存
/// 如果该字段是一个数值型类型比如Number请使用long储存
/// 如果该字段是一个复杂类型请使用嵌套的Dictionary指定各下级字段的值
/// 如果该字段是一个数组请使用List储存各个值
/// 对于更复杂的情况也支持Dictionary和List的各种组合嵌套比如参数是值是个ListList中的每种类型是一个复杂对象
/// </param>
/// <returns>本客户端,便于链式调用</returns>
public Client Optional(string key, object value)
{
_kernel.InjectBizParam(key, value);
return this;
}
/// <summary>
/// 批量设置API入参中没有的其他可选业务请求参数(biz_content下的字段)
/// optional方法的批量版本
/// </summary>
/// <param name="optionalArgs">可选参数集合每个参数由key和value组成key和value的格式请参见optional方法的注释</param>
/// <returns>本客户端,便于链式调用</returns>
public Client BatchOptional(Dictionary<string, object> optionalArgs)
{
foreach (var pair in optionalArgs)
{
_kernel.InjectBizParam(pair.Key, pair.Value);
}
return this;
}
}
}

View File

@@ -0,0 +1,165 @@
// This file is auto-generated, don't edit it. Thanks.
using System;
using System.Collections.Generic;
using System.IO;
using Tea;
namespace Alipay.EasySDK.Payment.FaceToFace.Models
{
public class AlipayTradePayResponse : TeaModel {
/// <summary>
/// 响应原始字符串
/// </summary>
[NameInMap("http_body")]
[Validation(Required=true)]
public string HttpBody { get; set; }
[NameInMap("code")]
[Validation(Required=true)]
public string Code { get; set; }
[NameInMap("msg")]
[Validation(Required=true)]
public string Msg { get; set; }
[NameInMap("sub_code")]
[Validation(Required=true)]
public string SubCode { get; set; }
[NameInMap("sub_msg")]
[Validation(Required=true)]
public string SubMsg { get; set; }
[NameInMap("trade_no")]
[Validation(Required=true)]
public string TradeNo { get; set; }
[NameInMap("out_trade_no")]
[Validation(Required=true)]
public string OutTradeNo { get; set; }
[NameInMap("buyer_logon_id")]
[Validation(Required=true)]
public string BuyerLogonId { get; set; }
[NameInMap("settle_amount")]
[Validation(Required=true)]
public string SettleAmount { get; set; }
[NameInMap("pay_currency")]
[Validation(Required=true)]
public string PayCurrency { get; set; }
[NameInMap("pay_amount")]
[Validation(Required=true)]
public string PayAmount { get; set; }
[NameInMap("settle_trans_rate")]
[Validation(Required=true)]
public string SettleTransRate { get; set; }
[NameInMap("trans_pay_rate")]
[Validation(Required=true)]
public string TransPayRate { get; set; }
[NameInMap("total_amount")]
[Validation(Required=true)]
public string TotalAmount { get; set; }
[NameInMap("trans_currency")]
[Validation(Required=true)]
public string TransCurrency { get; set; }
[NameInMap("settle_currency")]
[Validation(Required=true)]
public string SettleCurrency { get; set; }
[NameInMap("receipt_amount")]
[Validation(Required=true)]
public string ReceiptAmount { get; set; }
[NameInMap("buyer_pay_amount")]
[Validation(Required=true)]
public string BuyerPayAmount { get; set; }
[NameInMap("point_amount")]
[Validation(Required=true)]
public string PointAmount { get; set; }
[NameInMap("invoice_amount")]
[Validation(Required=true)]
public string InvoiceAmount { get; set; }
[NameInMap("gmt_payment")]
[Validation(Required=true)]
public string GmtPayment { get; set; }
[NameInMap("fund_bill_list")]
[Validation(Required=true)]
public List<TradeFundBill> FundBillList { get; set; }
[NameInMap("card_balance")]
[Validation(Required=true)]
public string CardBalance { get; set; }
[NameInMap("store_name")]
[Validation(Required=true)]
public string StoreName { get; set; }
[NameInMap("buyer_user_id")]
[Validation(Required=true)]
public string BuyerUserId { get; set; }
[NameInMap("discount_goods_detail")]
[Validation(Required=true)]
public string DiscountGoodsDetail { get; set; }
[NameInMap("voucher_detail_list")]
[Validation(Required=true)]
public List<VoucherDetail> VoucherDetailList { get; set; }
[NameInMap("advance_amount")]
[Validation(Required=true)]
public string AdvanceAmount { get; set; }
[NameInMap("auth_trade_pay_mode")]
[Validation(Required=true)]
public string AuthTradePayMode { get; set; }
[NameInMap("charge_amount")]
[Validation(Required=true)]
public string ChargeAmount { get; set; }
[NameInMap("charge_flags")]
[Validation(Required=true)]
public string ChargeFlags { get; set; }
[NameInMap("settlement_id")]
[Validation(Required=true)]
public string SettlementId { get; set; }
[NameInMap("business_params")]
[Validation(Required=true)]
public string BusinessParams { get; set; }
[NameInMap("buyer_user_type")]
[Validation(Required=true)]
public string BuyerUserType { get; set; }
[NameInMap("mdiscount_amount")]
[Validation(Required=true)]
public string MdiscountAmount { get; set; }
[NameInMap("discount_amount")]
[Validation(Required=true)]
public string DiscountAmount { get; set; }
[NameInMap("buyer_user_name")]
[Validation(Required=true)]
public string BuyerUserName { get; set; }
}
}

View File

@@ -0,0 +1,45 @@
// This file is auto-generated, don't edit it. Thanks.
using System;
using System.Collections.Generic;
using System.IO;
using Tea;
namespace Alipay.EasySDK.Payment.FaceToFace.Models
{
public class AlipayTradePrecreateResponse : TeaModel {
/// <summary>
/// 响应原始字符串
/// </summary>
[NameInMap("http_body")]
[Validation(Required=true)]
public string HttpBody { get; set; }
[NameInMap("code")]
[Validation(Required=true)]
public string Code { get; set; }
[NameInMap("msg")]
[Validation(Required=true)]
public string Msg { get; set; }
[NameInMap("sub_code")]
[Validation(Required=true)]
public string SubCode { get; set; }
[NameInMap("sub_msg")]
[Validation(Required=true)]
public string SubMsg { get; set; }
[NameInMap("out_trade_no")]
[Validation(Required=true)]
public string OutTradeNo { get; set; }
[NameInMap("qr_code")]
[Validation(Required=true)]
public string QrCode { get; set; }
}
}

View File

@@ -0,0 +1,30 @@
// This file is auto-generated, don't edit it. Thanks.
using System;
using System.Collections.Generic;
using System.IO;
using Tea;
namespace Alipay.EasySDK.Payment.FaceToFace.Models
{
public class TradeFundBill : TeaModel {
[NameInMap("fund_channel")]
[Validation(Required=true)]
public string FundChannel { get; set; }
[NameInMap("bank_code")]
[Validation(Required=true)]
public string BankCode { get; set; }
[NameInMap("amount")]
[Validation(Required=true)]
public string Amount { get; set; }
[NameInMap("real_amount")]
[Validation(Required=true)]
public string RealAmount { get; set; }
}
}

View File

@@ -0,0 +1,58 @@
// This file is auto-generated, don't edit it. Thanks.
using System;
using System.Collections.Generic;
using System.IO;
using Tea;
namespace Alipay.EasySDK.Payment.FaceToFace.Models
{
public class VoucherDetail : TeaModel {
[NameInMap("id")]
[Validation(Required=true)]
public string Id { get; set; }
[NameInMap("name")]
[Validation(Required=true)]
public string Name { get; set; }
[NameInMap("type")]
[Validation(Required=true)]
public string Type { get; set; }
[NameInMap("amount")]
[Validation(Required=true)]
public string Amount { get; set; }
[NameInMap("merchant_contribute")]
[Validation(Required=true)]
public string MerchantContribute { get; set; }
[NameInMap("other_contribute")]
[Validation(Required=true)]
public string OtherContribute { get; set; }
[NameInMap("memo")]
[Validation(Required=true)]
public string Memo { get; set; }
[NameInMap("template_id")]
[Validation(Required=true)]
public string TemplateId { get; set; }
[NameInMap("purchase_buyer_contribute")]
[Validation(Required=true)]
public string PurchaseBuyerContribute { get; set; }
[NameInMap("purchase_merchant_contribute")]
[Validation(Required=true)]
public string PurchaseMerchantContribute { get; set; }
[NameInMap("purchase_ant_contribute")]
[Validation(Required=true)]
public string PurchaseAntContribute { get; set; }
}
}

View File

@@ -0,0 +1,324 @@
// This file is auto-generated, don't edit it. Thanks.
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Threading.Tasks;
using Tea;
using Tea.Utils;
using Alipay.EasySDK.Payment.Huabei.Models;
namespace Alipay.EasySDK.Payment.Huabei
{
public class Client
{
protected Alipay.EasySDK.Kernel.Client _kernel;
public Client(Alipay.EasySDK.Kernel.Client kernel)
{
this._kernel = kernel;
}
public AlipayTradeCreateResponse Create(string subject, string outTradeNo, string totalAmount, string buyerId, HuabeiConfig extendParams)
{
extendParams.Validate();
Dictionary<string, object> runtime_ = new Dictionary<string, object>
{
{"ignoreSSL", this._kernel.GetConfig("ignoreSSL")},
{"httpProxy", this._kernel.GetConfig("httpProxy")},
{"connectTimeout", 15000},
{"readTimeout", 15000},
{"retry", new Dictionary<string, int?>
{
{"maxAttempts", 0},
}},
};
TeaRequest _lastRequest = null;
Exception _lastException = null;
long _now = System.DateTime.Now.Millisecond;
int _retryTimes = 0;
while (TeaCore.AllowRetry((IDictionary) runtime_["retry"], _retryTimes, _now))
{
if (_retryTimes > 0)
{
int backoffTime = TeaCore.GetBackoffTime((IDictionary)runtime_["backoff"], _retryTimes);
if (backoffTime > 0)
{
TeaCore.Sleep(backoffTime);
}
}
_retryTimes = _retryTimes + 1;
try
{
TeaRequest request_ = new TeaRequest();
Dictionary<string, string> systemParams = new Dictionary<string, string>
{
{"method", "alipay.trade.create"},
{"app_id", this._kernel.GetConfig("appId")},
{"timestamp", this._kernel.GetTimestamp()},
{"format", "json"},
{"version", "1.0"},
{"alipay_sdk", this._kernel.GetSdkVersion()},
{"charset", "UTF-8"},
{"sign_type", this._kernel.GetConfig("signType")},
{"app_cert_sn", this._kernel.GetMerchantCertSN()},
{"alipay_root_cert_sn", this._kernel.GetAlipayRootCertSN()},
};
Dictionary<string, object> bizParams = new Dictionary<string, object>
{
{"subject", subject},
{"out_trade_no", outTradeNo},
{"total_amount", totalAmount},
{"buyer_id", buyerId},
{"extend_params", extendParams},
};
Dictionary<string, string> textParams = new Dictionary<string, string>(){};
request_.Protocol = this._kernel.GetConfig("protocol");
request_.Method = "POST";
request_.Pathname = "/gateway.do";
request_.Headers = new Dictionary<string, string>
{
{"host", this._kernel.GetConfig("gatewayHost")},
{"content-type", "application/x-www-form-urlencoded;charset=utf-8"},
};
request_.Query = this._kernel.SortMap(TeaConverter.merge<string>
(
new Dictionary<string, string>()
{
{"sign", this._kernel.Sign(systemParams, bizParams, textParams, this._kernel.GetConfig("merchantPrivateKey"))},
},
systemParams,
textParams
));
request_.Body = TeaCore.BytesReadable(this._kernel.ToUrlEncodedRequestBody(bizParams));
_lastRequest = request_;
TeaResponse response_ = TeaCore.DoAction(request_, runtime_);
Dictionary<string, object> respMap = this._kernel.ReadAsJson(response_, "alipay.trade.create");
if (this._kernel.IsCertMode())
{
if (this._kernel.Verify(respMap, this._kernel.ExtractAlipayPublicKey(this._kernel.GetAlipayCertSN(respMap))))
{
return TeaModel.ToObject<AlipayTradeCreateResponse>(this._kernel.ToRespModel(respMap));
}
}
else
{
if (this._kernel.Verify(respMap, this._kernel.GetConfig("alipayPublicKey")))
{
return TeaModel.ToObject<AlipayTradeCreateResponse>(this._kernel.ToRespModel(respMap));
}
}
throw new TeaException(new Dictionary<string, string>
{
{"message", "验签失败,请检查支付宝公钥设置是否正确。"},
});
}
catch (Exception e)
{
if (TeaCore.IsRetryable(e))
{
_lastException = e;
continue;
}
throw e;
}
}
throw new TeaUnretryableException(_lastRequest, _lastException);
}
public async Task<AlipayTradeCreateResponse> CreateAsync(string subject, string outTradeNo, string totalAmount, string buyerId, HuabeiConfig extendParams)
{
extendParams.Validate();
Dictionary<string, object> runtime_ = new Dictionary<string, object>
{
{"ignoreSSL", this._kernel.GetConfig("ignoreSSL")},
{"httpProxy", this._kernel.GetConfig("httpProxy")},
{"connectTimeout", 15000},
{"readTimeout", 15000},
{"retry", new Dictionary<string, int?>
{
{"maxAttempts", 0},
}},
};
TeaRequest _lastRequest = null;
Exception _lastException = null;
long _now = System.DateTime.Now.Millisecond;
int _retryTimes = 0;
while (TeaCore.AllowRetry((IDictionary) runtime_["retry"], _retryTimes, _now))
{
if (_retryTimes > 0)
{
int backoffTime = TeaCore.GetBackoffTime((IDictionary)runtime_["backoff"], _retryTimes);
if (backoffTime > 0)
{
TeaCore.Sleep(backoffTime);
}
}
_retryTimes = _retryTimes + 1;
try
{
TeaRequest request_ = new TeaRequest();
Dictionary<string, string> systemParams = new Dictionary<string, string>
{
{"method", "alipay.trade.create"},
{"app_id", this._kernel.GetConfig("appId")},
{"timestamp", this._kernel.GetTimestamp()},
{"format", "json"},
{"version", "1.0"},
{"alipay_sdk", this._kernel.GetSdkVersion()},
{"charset", "UTF-8"},
{"sign_type", this._kernel.GetConfig("signType")},
{"app_cert_sn", this._kernel.GetMerchantCertSN()},
{"alipay_root_cert_sn", this._kernel.GetAlipayRootCertSN()},
};
Dictionary<string, object> bizParams = new Dictionary<string, object>
{
{"subject", subject},
{"out_trade_no", outTradeNo},
{"total_amount", totalAmount},
{"buyer_id", buyerId},
{"extend_params", extendParams},
};
Dictionary<string, string> textParams = new Dictionary<string, string>(){};
request_.Protocol = this._kernel.GetConfig("protocol");
request_.Method = "POST";
request_.Pathname = "/gateway.do";
request_.Headers = new Dictionary<string, string>
{
{"host", this._kernel.GetConfig("gatewayHost")},
{"content-type", "application/x-www-form-urlencoded;charset=utf-8"},
};
request_.Query = this._kernel.SortMap(TeaConverter.merge<string>
(
new Dictionary<string, string>()
{
{"sign", this._kernel.Sign(systemParams, bizParams, textParams, this._kernel.GetConfig("merchantPrivateKey"))},
},
systemParams,
textParams
));
request_.Body = TeaCore.BytesReadable(this._kernel.ToUrlEncodedRequestBody(bizParams));
_lastRequest = request_;
TeaResponse response_ = await TeaCore.DoActionAsync(request_, runtime_);
Dictionary<string, object> respMap = await this._kernel.ReadAsJsonAsync(response_, "alipay.trade.create");
if (this._kernel.IsCertMode())
{
if (this._kernel.Verify(respMap, this._kernel.ExtractAlipayPublicKey(this._kernel.GetAlipayCertSN(respMap))))
{
return TeaModel.ToObject<AlipayTradeCreateResponse>(this._kernel.ToRespModel(respMap));
}
}
else
{
if (this._kernel.Verify(respMap, this._kernel.GetConfig("alipayPublicKey")))
{
return TeaModel.ToObject<AlipayTradeCreateResponse>(this._kernel.ToRespModel(respMap));
}
}
throw new TeaException(new Dictionary<string, string>
{
{"message", "验签失败,请检查支付宝公钥设置是否正确。"},
});
}
catch (Exception e)
{
if (TeaCore.IsRetryable(e))
{
_lastException = e;
continue;
}
throw e;
}
}
throw new TeaUnretryableException(_lastRequest, _lastException);
}
/// <summary>
/// ISV代商户代用指定appAuthToken
/// </summary>
/// <param name="appAuthToken">代调用token</param>
/// <returns>本客户端,便于链式调用</returns>
public Client Agent(string appAuthToken)
{
_kernel.InjectTextParam("app_auth_token", appAuthToken);
return this;
}
/// <summary>
/// 用户授权调用指定authToken
/// </summary>
/// <param name="authToken">用户授权token</param>
/// <returns>本客户端,便于链式调用</returns>
public Client Auth(string authToken)
{
_kernel.InjectTextParam("auth_token", authToken);
return this;
}
/// <summary>
/// 设置异步通知回调地址此处设置将在本调用中覆盖Config中的全局配置
/// </summary>
/// <param name="url">异步通知回调地址例如https://www.test.com/callback </param>
/// <returns>本客户端,便于链式调用</returns>
public Client AsyncNotify(string url)
{
_kernel.InjectTextParam("notify_url", url);
return this;
}
/// <summary>
/// 将本次调用强制路由到后端系统的测试地址上,常用于线下环境内外联调,沙箱与线上环境设置无效
/// </summary>
/// <param name="testUrl">后端系统测试地址</param>
/// <returns>本客户端,便于链式调用</returns>
public Client Route(string testUrl)
{
_kernel.InjectTextParam("ws_service_url", testUrl);
return this;
}
/// <summary>
/// 设置API入参中没有的其他可选业务请求参数(biz_content下的字段)
/// </summary>
/// <param name="key">业务请求参数名称biz_content下的字段名比如timeout_express</param>
/// <param name="value">
/// 业务请求参数的值一个可以序列化成JSON的对象
/// 如果该字段是一个字符串类型String、Price、Date在SDK中都是字符串请使用string储存
/// 如果该字段是一个数值型类型比如Number请使用long储存
/// 如果该字段是一个复杂类型请使用嵌套的Dictionary指定各下级字段的值
/// 如果该字段是一个数组请使用List储存各个值
/// 对于更复杂的情况也支持Dictionary和List的各种组合嵌套比如参数是值是个ListList中的每种类型是一个复杂对象
/// </param>
/// <returns>本客户端,便于链式调用</returns>
public Client Optional(string key, object value)
{
_kernel.InjectBizParam(key, value);
return this;
}
/// <summary>
/// 批量设置API入参中没有的其他可选业务请求参数(biz_content下的字段)
/// optional方法的批量版本
/// </summary>
/// <param name="optionalArgs">可选参数集合每个参数由key和value组成key和value的格式请参见optional方法的注释</param>
/// <returns>本客户端,便于链式调用</returns>
public Client BatchOptional(Dictionary<string, object> optionalArgs)
{
foreach (var pair in optionalArgs)
{
_kernel.InjectBizParam(pair.Key, pair.Value);
}
return this;
}
}
}

View File

@@ -0,0 +1,45 @@
// This file is auto-generated, don't edit it. Thanks.
using System;
using System.Collections.Generic;
using System.IO;
using Tea;
namespace Alipay.EasySDK.Payment.Huabei.Models
{
public class AlipayTradeCreateResponse : TeaModel {
/// <summary>
/// 响应原始字符串
/// </summary>
[NameInMap("http_body")]
[Validation(Required=true)]
public string HttpBody { get; set; }
[NameInMap("code")]
[Validation(Required=true)]
public string Code { get; set; }
[NameInMap("msg")]
[Validation(Required=true)]
public string Msg { get; set; }
[NameInMap("sub_code")]
[Validation(Required=true)]
public string SubCode { get; set; }
[NameInMap("sub_msg")]
[Validation(Required=true)]
public string SubMsg { get; set; }
[NameInMap("out_trade_no")]
[Validation(Required=true)]
public string OutTradeNo { get; set; }
[NameInMap("trade_no")]
[Validation(Required=true)]
public string TradeNo { get; set; }
}
}

View File

@@ -0,0 +1,22 @@
// This file is auto-generated, don't edit it. Thanks.
using System;
using System.Collections.Generic;
using System.IO;
using Tea;
namespace Alipay.EasySDK.Payment.Huabei.Models
{
public class HuabeiConfig : TeaModel {
[NameInMap("hb_fq_num")]
[Validation(Required=true)]
public string HbFqNum { get; set; }
[NameInMap("hb_fq_seller_percent")]
[Validation(Required=true)]
public string HbFqSellerPercent { get; set; }
}
}

View File

@@ -0,0 +1,139 @@
// This file is auto-generated, don't edit it. Thanks.
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Threading.Tasks;
using Tea;
using Tea.Utils;
using Alipay.EasySDK.Payment.Page.Models;
namespace Alipay.EasySDK.Payment.Page
{
public class Client
{
protected Alipay.EasySDK.Kernel.Client _kernel;
public Client(Alipay.EasySDK.Kernel.Client kernel)
{
this._kernel = kernel;
}
public AlipayTradePagePayResponse Pay(string subject, string outTradeNo, string totalAmount, string returnUrl)
{
Dictionary<string, string> systemParams = new Dictionary<string, string>
{
{"method", "alipay.trade.page.pay"},
{"app_id", this._kernel.GetConfig("appId")},
{"timestamp", this._kernel.GetTimestamp()},
{"format", "json"},
{"version", "1.0"},
{"alipay_sdk", this._kernel.GetSdkVersion()},
{"charset", "UTF-8"},
{"sign_type", this._kernel.GetConfig("signType")},
{"app_cert_sn", this._kernel.GetMerchantCertSN()},
{"alipay_root_cert_sn", this._kernel.GetAlipayRootCertSN()},
};
Dictionary<string, object> bizParams = new Dictionary<string, object>
{
{"subject", subject},
{"out_trade_no", outTradeNo},
{"total_amount", totalAmount},
{"product_code", "FAST_INSTANT_TRADE_PAY"},
};
Dictionary<string, string> textParams = new Dictionary<string, string>
{
{"return_url", returnUrl},
};
string sign = this._kernel.Sign(systemParams, bizParams, textParams, this._kernel.GetConfig("merchantPrivateKey"));
Dictionary<string, string> response = new Dictionary<string, string>
{
{"body", this._kernel.GeneratePage("POST", systemParams, bizParams, textParams, sign)},
};
return TeaModel.ToObject<AlipayTradePagePayResponse>(response);
}
/// <summary>
/// ISV代商户代用指定appAuthToken
/// </summary>
/// <param name="appAuthToken">代调用token</param>
/// <returns>本客户端,便于链式调用</returns>
public Client Agent(string appAuthToken)
{
_kernel.InjectTextParam("app_auth_token", appAuthToken);
return this;
}
/// <summary>
/// 用户授权调用指定authToken
/// </summary>
/// <param name="authToken">用户授权token</param>
/// <returns>本客户端,便于链式调用</returns>
public Client Auth(string authToken)
{
_kernel.InjectTextParam("auth_token", authToken);
return this;
}
/// <summary>
/// 设置异步通知回调地址此处设置将在本调用中覆盖Config中的全局配置
/// </summary>
/// <param name="url">异步通知回调地址例如https://www.test.com/callback </param>
/// <returns>本客户端,便于链式调用</returns>
public Client AsyncNotify(string url)
{
_kernel.InjectTextParam("notify_url", url);
return this;
}
/// <summary>
/// 将本次调用强制路由到后端系统的测试地址上,常用于线下环境内外联调,沙箱与线上环境设置无效
/// </summary>
/// <param name="testUrl">后端系统测试地址</param>
/// <returns>本客户端,便于链式调用</returns>
public Client Route(string testUrl)
{
_kernel.InjectTextParam("ws_service_url", testUrl);
return this;
}
/// <summary>
/// 设置API入参中没有的其他可选业务请求参数(biz_content下的字段)
/// </summary>
/// <param name="key">业务请求参数名称biz_content下的字段名比如timeout_express</param>
/// <param name="value">
/// 业务请求参数的值一个可以序列化成JSON的对象
/// 如果该字段是一个字符串类型String、Price、Date在SDK中都是字符串请使用string储存
/// 如果该字段是一个数值型类型比如Number请使用long储存
/// 如果该字段是一个复杂类型请使用嵌套的Dictionary指定各下级字段的值
/// 如果该字段是一个数组请使用List储存各个值
/// 对于更复杂的情况也支持Dictionary和List的各种组合嵌套比如参数是值是个ListList中的每种类型是一个复杂对象
/// </param>
/// <returns>本客户端,便于链式调用</returns>
public Client Optional(string key, object value)
{
_kernel.InjectBizParam(key, value);
return this;
}
/// <summary>
/// 批量设置API入参中没有的其他可选业务请求参数(biz_content下的字段)
/// optional方法的批量版本
/// </summary>
/// <param name="optionalArgs">可选参数集合每个参数由key和value组成key和value的格式请参见optional方法的注释</param>
/// <returns>本客户端,便于链式调用</returns>
public Client BatchOptional(Dictionary<string, object> optionalArgs)
{
foreach (var pair in optionalArgs)
{
_kernel.InjectBizParam(pair.Key, pair.Value);
}
return this;
}
}
}

View File

@@ -0,0 +1,21 @@
// This file is auto-generated, don't edit it. Thanks.
using System;
using System.Collections.Generic;
using System.IO;
using Tea;
namespace Alipay.EasySDK.Payment.Page.Models
{
public class AlipayTradePagePayResponse : TeaModel {
/// <summary>
/// 订单信息Form表单形式
/// </summary>
[NameInMap("body")]
[Validation(Required=true)]
public string Body { get; set; }
}
}

View File

@@ -0,0 +1,140 @@
// This file is auto-generated, don't edit it. Thanks.
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Threading.Tasks;
using Tea;
using Tea.Utils;
using Alipay.EasySDK.Payment.Wap.Models;
namespace Alipay.EasySDK.Payment.Wap
{
public class Client
{
protected Alipay.EasySDK.Kernel.Client _kernel;
public Client(Alipay.EasySDK.Kernel.Client kernel)
{
this._kernel = kernel;
}
public AlipayTradeWapPayResponse Pay(string subject, string outTradeNo, string totalAmount, string quitUrl, string returnUrl)
{
Dictionary<string, string> systemParams = new Dictionary<string, string>
{
{"method", "alipay.trade.wap.pay"},
{"app_id", this._kernel.GetConfig("appId")},
{"timestamp", this._kernel.GetTimestamp()},
{"format", "json"},
{"version", "1.0"},
{"alipay_sdk", this._kernel.GetSdkVersion()},
{"charset", "UTF-8"},
{"sign_type", this._kernel.GetConfig("signType")},
{"app_cert_sn", this._kernel.GetMerchantCertSN()},
{"alipay_root_cert_sn", this._kernel.GetAlipayRootCertSN()},
};
Dictionary<string, object> bizParams = new Dictionary<string, object>
{
{"subject", subject},
{"out_trade_no", outTradeNo},
{"total_amount", totalAmount},
{"quit_url", quitUrl},
{"product_code", "QUICK_WAP_WAY"},
};
Dictionary<string, string> textParams = new Dictionary<string, string>
{
{"return_url", returnUrl},
};
string sign = this._kernel.Sign(systemParams, bizParams, textParams, this._kernel.GetConfig("merchantPrivateKey"));
Dictionary<string, string> response = new Dictionary<string, string>
{
{"body", this._kernel.GeneratePage("POST", systemParams, bizParams, textParams, sign)},
};
return TeaModel.ToObject<AlipayTradeWapPayResponse>(response);
}
/// <summary>
/// ISV代商户代用指定appAuthToken
/// </summary>
/// <param name="appAuthToken">代调用token</param>
/// <returns>本客户端,便于链式调用</returns>
public Client Agent(string appAuthToken)
{
_kernel.InjectTextParam("app_auth_token", appAuthToken);
return this;
}
/// <summary>
/// 用户授权调用指定authToken
/// </summary>
/// <param name="authToken">用户授权token</param>
/// <returns>本客户端,便于链式调用</returns>
public Client Auth(string authToken)
{
_kernel.InjectTextParam("auth_token", authToken);
return this;
}
/// <summary>
/// 设置异步通知回调地址此处设置将在本调用中覆盖Config中的全局配置
/// </summary>
/// <param name="url">异步通知回调地址例如https://www.test.com/callback </param>
/// <returns>本客户端,便于链式调用</returns>
public Client AsyncNotify(string url)
{
_kernel.InjectTextParam("notify_url", url);
return this;
}
/// <summary>
/// 将本次调用强制路由到后端系统的测试地址上,常用于线下环境内外联调,沙箱与线上环境设置无效
/// </summary>
/// <param name="testUrl">后端系统测试地址</param>
/// <returns>本客户端,便于链式调用</returns>
public Client Route(string testUrl)
{
_kernel.InjectTextParam("ws_service_url", testUrl);
return this;
}
/// <summary>
/// 设置API入参中没有的其他可选业务请求参数(biz_content下的字段)
/// </summary>
/// <param name="key">业务请求参数名称biz_content下的字段名比如timeout_express</param>
/// <param name="value">
/// 业务请求参数的值一个可以序列化成JSON的对象
/// 如果该字段是一个字符串类型String、Price、Date在SDK中都是字符串请使用string储存
/// 如果该字段是一个数值型类型比如Number请使用long储存
/// 如果该字段是一个复杂类型请使用嵌套的Dictionary指定各下级字段的值
/// 如果该字段是一个数组请使用List储存各个值
/// 对于更复杂的情况也支持Dictionary和List的各种组合嵌套比如参数是值是个ListList中的每种类型是一个复杂对象
/// </param>
/// <returns>本客户端,便于链式调用</returns>
public Client Optional(string key, object value)
{
_kernel.InjectBizParam(key, value);
return this;
}
/// <summary>
/// 批量设置API入参中没有的其他可选业务请求参数(biz_content下的字段)
/// optional方法的批量版本
/// </summary>
/// <param name="optionalArgs">可选参数集合每个参数由key和value组成key和value的格式请参见optional方法的注释</param>
/// <returns>本客户端,便于链式调用</returns>
public Client BatchOptional(Dictionary<string, object> optionalArgs)
{
foreach (var pair in optionalArgs)
{
_kernel.InjectBizParam(pair.Key, pair.Value);
}
return this;
}
}
}

View File

@@ -0,0 +1,21 @@
// This file is auto-generated, don't edit it. Thanks.
using System;
using System.Collections.Generic;
using System.IO;
using Tea;
namespace Alipay.EasySDK.Payment.Wap.Models
{
public class AlipayTradeWapPayResponse : TeaModel {
/// <summary>
/// 订单信息Form表单形式
/// </summary>
[NameInMap("body")]
[Validation(Required=true)]
public string Body { get; set; }
}
}

View File

@@ -0,0 +1,314 @@
// This file is auto-generated, don't edit it. Thanks.
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Threading.Tasks;
using Tea;
using Tea.Utils;
using Alipay.EasySDK.Security.TextRisk.Models;
namespace Alipay.EasySDK.Security.TextRisk
{
public class Client
{
protected Alipay.EasySDK.Kernel.Client _kernel;
public Client(Alipay.EasySDK.Kernel.Client kernel)
{
this._kernel = kernel;
}
public AlipaySecurityRiskContentDetectResponse Detect(string content)
{
Dictionary<string, object> runtime_ = new Dictionary<string, object>
{
{"ignoreSSL", this._kernel.GetConfig("ignoreSSL")},
{"httpProxy", this._kernel.GetConfig("httpProxy")},
{"connectTimeout", 15000},
{"readTimeout", 15000},
{"retry", new Dictionary<string, int?>
{
{"maxAttempts", 0},
}},
};
TeaRequest _lastRequest = null;
Exception _lastException = null;
long _now = System.DateTime.Now.Millisecond;
int _retryTimes = 0;
while (TeaCore.AllowRetry((IDictionary) runtime_["retry"], _retryTimes, _now))
{
if (_retryTimes > 0)
{
int backoffTime = TeaCore.GetBackoffTime((IDictionary)runtime_["backoff"], _retryTimes);
if (backoffTime > 0)
{
TeaCore.Sleep(backoffTime);
}
}
_retryTimes = _retryTimes + 1;
try
{
TeaRequest request_ = new TeaRequest();
Dictionary<string, string> systemParams = new Dictionary<string, string>
{
{"method", "alipay.security.risk.content.detect"},
{"app_id", this._kernel.GetConfig("appId")},
{"timestamp", this._kernel.GetTimestamp()},
{"format", "json"},
{"version", "1.0"},
{"alipay_sdk", this._kernel.GetSdkVersion()},
{"charset", "UTF-8"},
{"sign_type", this._kernel.GetConfig("signType")},
{"app_cert_sn", this._kernel.GetMerchantCertSN()},
{"alipay_root_cert_sn", this._kernel.GetAlipayRootCertSN()},
};
Dictionary<string, object> bizParams = new Dictionary<string, object>
{
{"content", content},
};
Dictionary<string, string> textParams = new Dictionary<string, string>(){};
request_.Protocol = this._kernel.GetConfig("protocol");
request_.Method = "POST";
request_.Pathname = "/gateway.do";
request_.Headers = new Dictionary<string, string>
{
{"host", this._kernel.GetConfig("gatewayHost")},
{"content-type", "application/x-www-form-urlencoded;charset=utf-8"},
};
request_.Query = this._kernel.SortMap(TeaConverter.merge<string>
(
new Dictionary<string, string>()
{
{"sign", this._kernel.Sign(systemParams, bizParams, textParams, this._kernel.GetConfig("merchantPrivateKey"))},
},
systemParams,
textParams
));
request_.Body = TeaCore.BytesReadable(this._kernel.ToUrlEncodedRequestBody(bizParams));
_lastRequest = request_;
TeaResponse response_ = TeaCore.DoAction(request_, runtime_);
Dictionary<string, object> respMap = this._kernel.ReadAsJson(response_, "alipay.security.risk.content.detect");
if (this._kernel.IsCertMode())
{
if (this._kernel.Verify(respMap, this._kernel.ExtractAlipayPublicKey(this._kernel.GetAlipayCertSN(respMap))))
{
return TeaModel.ToObject<AlipaySecurityRiskContentDetectResponse>(this._kernel.ToRespModel(respMap));
}
}
else
{
if (this._kernel.Verify(respMap, this._kernel.GetConfig("alipayPublicKey")))
{
return TeaModel.ToObject<AlipaySecurityRiskContentDetectResponse>(this._kernel.ToRespModel(respMap));
}
}
throw new TeaException(new Dictionary<string, string>
{
{"message", "验签失败,请检查支付宝公钥设置是否正确。"},
});
}
catch (Exception e)
{
if (TeaCore.IsRetryable(e))
{
_lastException = e;
continue;
}
throw e;
}
}
throw new TeaUnretryableException(_lastRequest, _lastException);
}
public async Task<AlipaySecurityRiskContentDetectResponse> DetectAsync(string content)
{
Dictionary<string, object> runtime_ = new Dictionary<string, object>
{
{"ignoreSSL", this._kernel.GetConfig("ignoreSSL")},
{"httpProxy", this._kernel.GetConfig("httpProxy")},
{"connectTimeout", 15000},
{"readTimeout", 15000},
{"retry", new Dictionary<string, int?>
{
{"maxAttempts", 0},
}},
};
TeaRequest _lastRequest = null;
Exception _lastException = null;
long _now = System.DateTime.Now.Millisecond;
int _retryTimes = 0;
while (TeaCore.AllowRetry((IDictionary) runtime_["retry"], _retryTimes, _now))
{
if (_retryTimes > 0)
{
int backoffTime = TeaCore.GetBackoffTime((IDictionary)runtime_["backoff"], _retryTimes);
if (backoffTime > 0)
{
TeaCore.Sleep(backoffTime);
}
}
_retryTimes = _retryTimes + 1;
try
{
TeaRequest request_ = new TeaRequest();
Dictionary<string, string> systemParams = new Dictionary<string, string>
{
{"method", "alipay.security.risk.content.detect"},
{"app_id", this._kernel.GetConfig("appId")},
{"timestamp", this._kernel.GetTimestamp()},
{"format", "json"},
{"version", "1.0"},
{"alipay_sdk", this._kernel.GetSdkVersion()},
{"charset", "UTF-8"},
{"sign_type", this._kernel.GetConfig("signType")},
{"app_cert_sn", this._kernel.GetMerchantCertSN()},
{"alipay_root_cert_sn", this._kernel.GetAlipayRootCertSN()},
};
Dictionary<string, object> bizParams = new Dictionary<string, object>
{
{"content", content},
};
Dictionary<string, string> textParams = new Dictionary<string, string>(){};
request_.Protocol = this._kernel.GetConfig("protocol");
request_.Method = "POST";
request_.Pathname = "/gateway.do";
request_.Headers = new Dictionary<string, string>
{
{"host", this._kernel.GetConfig("gatewayHost")},
{"content-type", "application/x-www-form-urlencoded;charset=utf-8"},
};
request_.Query = this._kernel.SortMap(TeaConverter.merge<string>
(
new Dictionary<string, string>()
{
{"sign", this._kernel.Sign(systemParams, bizParams, textParams, this._kernel.GetConfig("merchantPrivateKey"))},
},
systemParams,
textParams
));
request_.Body = TeaCore.BytesReadable(this._kernel.ToUrlEncodedRequestBody(bizParams));
_lastRequest = request_;
TeaResponse response_ = await TeaCore.DoActionAsync(request_, runtime_);
Dictionary<string, object> respMap = await this._kernel.ReadAsJsonAsync(response_, "alipay.security.risk.content.detect");
if (this._kernel.IsCertMode())
{
if (this._kernel.Verify(respMap, this._kernel.ExtractAlipayPublicKey(this._kernel.GetAlipayCertSN(respMap))))
{
return TeaModel.ToObject<AlipaySecurityRiskContentDetectResponse>(this._kernel.ToRespModel(respMap));
}
}
else
{
if (this._kernel.Verify(respMap, this._kernel.GetConfig("alipayPublicKey")))
{
return TeaModel.ToObject<AlipaySecurityRiskContentDetectResponse>(this._kernel.ToRespModel(respMap));
}
}
throw new TeaException(new Dictionary<string, string>
{
{"message", "验签失败,请检查支付宝公钥设置是否正确。"},
});
}
catch (Exception e)
{
if (TeaCore.IsRetryable(e))
{
_lastException = e;
continue;
}
throw e;
}
}
throw new TeaUnretryableException(_lastRequest, _lastException);
}
/// <summary>
/// ISV代商户代用指定appAuthToken
/// </summary>
/// <param name="appAuthToken">代调用token</param>
/// <returns>本客户端,便于链式调用</returns>
public Client Agent(string appAuthToken)
{
_kernel.InjectTextParam("app_auth_token", appAuthToken);
return this;
}
/// <summary>
/// 用户授权调用指定authToken
/// </summary>
/// <param name="authToken">用户授权token</param>
/// <returns>本客户端,便于链式调用</returns>
public Client Auth(string authToken)
{
_kernel.InjectTextParam("auth_token", authToken);
return this;
}
/// <summary>
/// 设置异步通知回调地址此处设置将在本调用中覆盖Config中的全局配置
/// </summary>
/// <param name="url">异步通知回调地址例如https://www.test.com/callback </param>
/// <returns>本客户端,便于链式调用</returns>
public Client AsyncNotify(string url)
{
_kernel.InjectTextParam("notify_url", url);
return this;
}
/// <summary>
/// 将本次调用强制路由到后端系统的测试地址上,常用于线下环境内外联调,沙箱与线上环境设置无效
/// </summary>
/// <param name="testUrl">后端系统测试地址</param>
/// <returns>本客户端,便于链式调用</returns>
public Client Route(string testUrl)
{
_kernel.InjectTextParam("ws_service_url", testUrl);
return this;
}
/// <summary>
/// 设置API入参中没有的其他可选业务请求参数(biz_content下的字段)
/// </summary>
/// <param name="key">业务请求参数名称biz_content下的字段名比如timeout_express</param>
/// <param name="value">
/// 业务请求参数的值一个可以序列化成JSON的对象
/// 如果该字段是一个字符串类型String、Price、Date在SDK中都是字符串请使用string储存
/// 如果该字段是一个数值型类型比如Number请使用long储存
/// 如果该字段是一个复杂类型请使用嵌套的Dictionary指定各下级字段的值
/// 如果该字段是一个数组请使用List储存各个值
/// 对于更复杂的情况也支持Dictionary和List的各种组合嵌套比如参数是值是个ListList中的每种类型是一个复杂对象
/// </param>
/// <returns>本客户端,便于链式调用</returns>
public Client Optional(string key, object value)
{
_kernel.InjectBizParam(key, value);
return this;
}
/// <summary>
/// 批量设置API入参中没有的其他可选业务请求参数(biz_content下的字段)
/// optional方法的批量版本
/// </summary>
/// <param name="optionalArgs">可选参数集合每个参数由key和value组成key和value的格式请参见optional方法的注释</param>
/// <returns>本客户端,便于链式调用</returns>
public Client BatchOptional(Dictionary<string, object> optionalArgs)
{
foreach (var pair in optionalArgs)
{
_kernel.InjectBizParam(pair.Key, pair.Value);
}
return this;
}
}
}

View File

@@ -0,0 +1,49 @@
// This file is auto-generated, don't edit it. Thanks.
using System;
using System.Collections.Generic;
using System.IO;
using Tea;
namespace Alipay.EasySDK.Security.TextRisk.Models
{
public class AlipaySecurityRiskContentDetectResponse : TeaModel {
/// <summary>
/// 响应原始字符串
/// </summary>
[NameInMap("http_body")]
[Validation(Required=true)]
public string HttpBody { get; set; }
[NameInMap("code")]
[Validation(Required=true)]
public string Code { get; set; }
[NameInMap("msg")]
[Validation(Required=true)]
public string Msg { get; set; }
[NameInMap("sub_code")]
[Validation(Required=true)]
public string SubCode { get; set; }
[NameInMap("sub_msg")]
[Validation(Required=true)]
public string SubMsg { get; set; }
[NameInMap("action")]
[Validation(Required=true)]
public string Action { get; set; }
[NameInMap("keywords")]
[Validation(Required=true)]
public List<string> Keywords { get; set; }
[NameInMap("unique_id")]
[Validation(Required=true)]
public string UniqueId { get; set; }
}
}

View File

@@ -0,0 +1,114 @@
// This file is auto-generated, don't edit it. Thanks.
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Threading.Tasks;
using Tea;
using Tea.Utils;
namespace Alipay.EasySDK.Util.AES
{
public class Client
{
protected Alipay.EasySDK.Kernel.Client _kernel;
public Client(Alipay.EasySDK.Kernel.Client kernel)
{
this._kernel = kernel;
}
public string Decrypt(string cipherText)
{
return this._kernel.AesDecrypt(cipherText, this._kernel.GetConfig("encryptKey"));
}
public string Encrypt(string plainText)
{
return this._kernel.AesEncrypt(plainText, this._kernel.GetConfig("encryptKey"));
}
/// <summary>
/// ISV代商户代用指定appAuthToken
/// </summary>
/// <param name="appAuthToken">代调用token</param>
/// <returns>本客户端,便于链式调用</returns>
public Client Agent(string appAuthToken)
{
_kernel.InjectTextParam("app_auth_token", appAuthToken);
return this;
}
/// <summary>
/// 用户授权调用指定authToken
/// </summary>
/// <param name="authToken">用户授权token</param>
/// <returns>本客户端,便于链式调用</returns>
public Client Auth(string authToken)
{
_kernel.InjectTextParam("auth_token", authToken);
return this;
}
/// <summary>
/// 设置异步通知回调地址此处设置将在本调用中覆盖Config中的全局配置
/// </summary>
/// <param name="url">异步通知回调地址例如https://www.test.com/callback </param>
/// <returns>本客户端,便于链式调用</returns>
public Client AsyncNotify(string url)
{
_kernel.InjectTextParam("notify_url", url);
return this;
}
/// <summary>
/// 将本次调用强制路由到后端系统的测试地址上,常用于线下环境内外联调,沙箱与线上环境设置无效
/// </summary>
/// <param name="testUrl">后端系统测试地址</param>
/// <returns>本客户端,便于链式调用</returns>
public Client Route(string testUrl)
{
_kernel.InjectTextParam("ws_service_url", testUrl);
return this;
}
/// <summary>
/// 设置API入参中没有的其他可选业务请求参数(biz_content下的字段)
/// </summary>
/// <param name="key">业务请求参数名称biz_content下的字段名比如timeout_express</param>
/// <param name="value">
/// 业务请求参数的值一个可以序列化成JSON的对象
/// 如果该字段是一个字符串类型String、Price、Date在SDK中都是字符串请使用string储存
/// 如果该字段是一个数值型类型比如Number请使用long储存
/// 如果该字段是一个复杂类型请使用嵌套的Dictionary指定各下级字段的值
/// 如果该字段是一个数组请使用List储存各个值
/// 对于更复杂的情况也支持Dictionary和List的各种组合嵌套比如参数是值是个ListList中的每种类型是一个复杂对象
/// </param>
/// <returns>本客户端,便于链式调用</returns>
public Client Optional(string key, object value)
{
_kernel.InjectBizParam(key, value);
return this;
}
/// <summary>
/// 批量设置API入参中没有的其他可选业务请求参数(biz_content下的字段)
/// optional方法的批量版本
/// </summary>
/// <param name="optionalArgs">可选参数集合每个参数由key和value组成key和value的格式请参见optional方法的注释</param>
/// <returns>本客户端,便于链式调用</returns>
public Client BatchOptional(Dictionary<string, object> optionalArgs)
{
foreach (var pair in optionalArgs)
{
_kernel.InjectBizParam(pair.Key, pair.Value);
}
return this;
}
}
}

View File

@@ -0,0 +1,304 @@
// This file is auto-generated, don't edit it. Thanks.
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Threading.Tasks;
using Tea;
using Tea.Utils;
using Alipay.EasySDK.Util.Generic.Models;
namespace Alipay.EasySDK.Util.Generic
{
public class Client
{
protected Alipay.EasySDK.Kernel.Client _kernel;
public Client(Alipay.EasySDK.Kernel.Client kernel)
{
this._kernel = kernel;
}
public AlipayOpenApiGenericResponse Execute(string method, Dictionary<string, string> textParams, Dictionary<string, object> bizParams)
{
Dictionary<string, object> runtime_ = new Dictionary<string, object>
{
{"ignoreSSL", this._kernel.GetConfig("ignoreSSL")},
{"httpProxy", this._kernel.GetConfig("httpProxy")},
{"connectTimeout", 15000},
{"readTimeout", 15000},
{"retry", new Dictionary<string, int?>
{
{"maxAttempts", 0},
}},
};
TeaRequest _lastRequest = null;
Exception _lastException = null;
long _now = System.DateTime.Now.Millisecond;
int _retryTimes = 0;
while (TeaCore.AllowRetry((IDictionary) runtime_["retry"], _retryTimes, _now))
{
if (_retryTimes > 0)
{
int backoffTime = TeaCore.GetBackoffTime((IDictionary)runtime_["backoff"], _retryTimes);
if (backoffTime > 0)
{
TeaCore.Sleep(backoffTime);
}
}
_retryTimes = _retryTimes + 1;
try
{
TeaRequest request_ = new TeaRequest();
Dictionary<string, string> systemParams = new Dictionary<string, string>
{
{"method", method},
{"app_id", this._kernel.GetConfig("appId")},
{"timestamp", this._kernel.GetTimestamp()},
{"format", "json"},
{"version", "1.0"},
{"alipay_sdk", this._kernel.GetSdkVersion()},
{"charset", "UTF-8"},
{"sign_type", this._kernel.GetConfig("signType")},
{"app_cert_sn", this._kernel.GetMerchantCertSN()},
{"alipay_root_cert_sn", this._kernel.GetAlipayRootCertSN()},
};
request_.Protocol = this._kernel.GetConfig("protocol");
request_.Method = "POST";
request_.Pathname = "/gateway.do";
request_.Headers = new Dictionary<string, string>
{
{"host", this._kernel.GetConfig("gatewayHost")},
{"content-type", "application/x-www-form-urlencoded;charset=utf-8"},
};
request_.Query = this._kernel.SortMap(TeaConverter.merge<string>
(
new Dictionary<string, string>()
{
{"sign", this._kernel.Sign(systemParams, bizParams, textParams, this._kernel.GetConfig("merchantPrivateKey"))},
},
systemParams,
textParams
));
request_.Body = TeaCore.BytesReadable(this._kernel.ToUrlEncodedRequestBody(bizParams));
_lastRequest = request_;
TeaResponse response_ = TeaCore.DoAction(request_, runtime_);
Dictionary<string, object> respMap = this._kernel.ReadAsJson(response_, method);
if (this._kernel.IsCertMode())
{
if (this._kernel.Verify(respMap, this._kernel.ExtractAlipayPublicKey(this._kernel.GetAlipayCertSN(respMap))))
{
return TeaModel.ToObject<AlipayOpenApiGenericResponse>(this._kernel.ToRespModel(respMap));
}
}
else
{
if (this._kernel.Verify(respMap, this._kernel.GetConfig("alipayPublicKey")))
{
return TeaModel.ToObject<AlipayOpenApiGenericResponse>(this._kernel.ToRespModel(respMap));
}
}
throw new TeaException(new Dictionary<string, string>
{
{"message", "验签失败,请检查支付宝公钥设置是否正确。"},
});
}
catch (Exception e)
{
if (TeaCore.IsRetryable(e))
{
_lastException = e;
continue;
}
throw e;
}
}
throw new TeaUnretryableException(_lastRequest, _lastException);
}
public async Task<AlipayOpenApiGenericResponse> ExecuteAsync(string method, Dictionary<string, string> textParams, Dictionary<string, object> bizParams)
{
Dictionary<string, object> runtime_ = new Dictionary<string, object>
{
{"ignoreSSL", this._kernel.GetConfig("ignoreSSL")},
{"httpProxy", this._kernel.GetConfig("httpProxy")},
{"connectTimeout", 15000},
{"readTimeout", 15000},
{"retry", new Dictionary<string, int?>
{
{"maxAttempts", 0},
}},
};
TeaRequest _lastRequest = null;
Exception _lastException = null;
long _now = System.DateTime.Now.Millisecond;
int _retryTimes = 0;
while (TeaCore.AllowRetry((IDictionary) runtime_["retry"], _retryTimes, _now))
{
if (_retryTimes > 0)
{
int backoffTime = TeaCore.GetBackoffTime((IDictionary)runtime_["backoff"], _retryTimes);
if (backoffTime > 0)
{
TeaCore.Sleep(backoffTime);
}
}
_retryTimes = _retryTimes + 1;
try
{
TeaRequest request_ = new TeaRequest();
Dictionary<string, string> systemParams = new Dictionary<string, string>
{
{"method", method},
{"app_id", this._kernel.GetConfig("appId")},
{"timestamp", this._kernel.GetTimestamp()},
{"format", "json"},
{"version", "1.0"},
{"alipay_sdk", this._kernel.GetSdkVersion()},
{"charset", "UTF-8"},
{"sign_type", this._kernel.GetConfig("signType")},
{"app_cert_sn", this._kernel.GetMerchantCertSN()},
{"alipay_root_cert_sn", this._kernel.GetAlipayRootCertSN()},
};
request_.Protocol = this._kernel.GetConfig("protocol");
request_.Method = "POST";
request_.Pathname = "/gateway.do";
request_.Headers = new Dictionary<string, string>
{
{"host", this._kernel.GetConfig("gatewayHost")},
{"content-type", "application/x-www-form-urlencoded;charset=utf-8"},
};
request_.Query = this._kernel.SortMap(TeaConverter.merge<string>
(
new Dictionary<string, string>()
{
{"sign", this._kernel.Sign(systemParams, bizParams, textParams, this._kernel.GetConfig("merchantPrivateKey"))},
},
systemParams,
textParams
));
request_.Body = TeaCore.BytesReadable(this._kernel.ToUrlEncodedRequestBody(bizParams));
_lastRequest = request_;
TeaResponse response_ = await TeaCore.DoActionAsync(request_, runtime_);
Dictionary<string, object> respMap = await this._kernel.ReadAsJsonAsync(response_, method);
if (this._kernel.IsCertMode())
{
if (this._kernel.Verify(respMap, this._kernel.ExtractAlipayPublicKey(this._kernel.GetAlipayCertSN(respMap))))
{
return TeaModel.ToObject<AlipayOpenApiGenericResponse>(this._kernel.ToRespModel(respMap));
}
}
else
{
if (this._kernel.Verify(respMap, this._kernel.GetConfig("alipayPublicKey")))
{
return TeaModel.ToObject<AlipayOpenApiGenericResponse>(this._kernel.ToRespModel(respMap));
}
}
throw new TeaException(new Dictionary<string, string>
{
{"message", "验签失败,请检查支付宝公钥设置是否正确。"},
});
}
catch (Exception e)
{
if (TeaCore.IsRetryable(e))
{
_lastException = e;
continue;
}
throw e;
}
}
throw new TeaUnretryableException(_lastRequest, _lastException);
}
/// <summary>
/// ISV代商户代用指定appAuthToken
/// </summary>
/// <param name="appAuthToken">代调用token</param>
/// <returns>本客户端,便于链式调用</returns>
public Client Agent(string appAuthToken)
{
_kernel.InjectTextParam("app_auth_token", appAuthToken);
return this;
}
/// <summary>
/// 用户授权调用指定authToken
/// </summary>
/// <param name="authToken">用户授权token</param>
/// <returns>本客户端,便于链式调用</returns>
public Client Auth(string authToken)
{
_kernel.InjectTextParam("auth_token", authToken);
return this;
}
/// <summary>
/// 设置异步通知回调地址此处设置将在本调用中覆盖Config中的全局配置
/// </summary>
/// <param name="url">异步通知回调地址例如https://www.test.com/callback </param>
/// <returns>本客户端,便于链式调用</returns>
public Client AsyncNotify(string url)
{
_kernel.InjectTextParam("notify_url", url);
return this;
}
/// <summary>
/// 将本次调用强制路由到后端系统的测试地址上,常用于线下环境内外联调,沙箱与线上环境设置无效
/// </summary>
/// <param name="testUrl">后端系统测试地址</param>
/// <returns>本客户端,便于链式调用</returns>
public Client Route(string testUrl)
{
_kernel.InjectTextParam("ws_service_url", testUrl);
return this;
}
/// <summary>
/// 设置API入参中没有的其他可选业务请求参数(biz_content下的字段)
/// </summary>
/// <param name="key">业务请求参数名称biz_content下的字段名比如timeout_express</param>
/// <param name="value">
/// 业务请求参数的值一个可以序列化成JSON的对象
/// 如果该字段是一个字符串类型String、Price、Date在SDK中都是字符串请使用string储存
/// 如果该字段是一个数值型类型比如Number请使用long储存
/// 如果该字段是一个复杂类型请使用嵌套的Dictionary指定各下级字段的值
/// 如果该字段是一个数组请使用List储存各个值
/// 对于更复杂的情况也支持Dictionary和List的各种组合嵌套比如参数是值是个ListList中的每种类型是一个复杂对象
/// </param>
/// <returns>本客户端,便于链式调用</returns>
public Client Optional(string key, object value)
{
_kernel.InjectBizParam(key, value);
return this;
}
/// <summary>
/// 批量设置API入参中没有的其他可选业务请求参数(biz_content下的字段)
/// optional方法的批量版本
/// </summary>
/// <param name="optionalArgs">可选参数集合每个参数由key和value组成key和value的格式请参见optional方法的注释</param>
/// <returns>本客户端,便于链式调用</returns>
public Client BatchOptional(Dictionary<string, object> optionalArgs)
{
foreach (var pair in optionalArgs)
{
_kernel.InjectBizParam(pair.Key, pair.Value);
}
return this;
}
}
}

View File

@@ -0,0 +1,37 @@
// This file is auto-generated, don't edit it. Thanks.
using System;
using System.Collections.Generic;
using System.IO;
using Tea;
namespace Alipay.EasySDK.Util.Generic.Models
{
public class AlipayOpenApiGenericResponse : TeaModel {
/// <summary>
/// 响应原始字符串
/// </summary>
[NameInMap("http_body")]
[Validation(Required=true)]
public string HttpBody { get; set; }
[NameInMap("code")]
[Validation(Required=true)]
public string Code { get; set; }
[NameInMap("msg")]
[Validation(Required=true)]
public string Msg { get; set; }
[NameInMap("sub_code")]
[Validation(Required=true)]
public string SubCode { get; set; }
[NameInMap("sub_msg")]
[Validation(Required=true)]
public string SubMsg { get; set; }
}
}

View File

@@ -0,0 +1,248 @@
[![NuGet](https://badge.fury.io/nu/AlipayEasySDK.svg)](https://badge.fury.io/nu/AlipayEasySDK)
[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Falipay%2Falipay-easysdk.svg?type=shield)](https://app.fossa.com/projects/git%2Bgithub.com%2Falipay%2Falipay-easysdk?ref=badge_shield)
欢迎使用 Alipay **Easy** SDK for .NET
Alipay Esay SDK for .NET让您不用复杂编程即可访支付宝开放平台开放的各项常用能力SDK可以自动帮您满足能力调用过程中所需的证书校验加签验签发送HTTP请求等非功能性要求
下面向您介绍Alipay Easy SDK for .NET 的基本设计理念和使用方法
## 设计理念
不同于原有的[Alipay SDK](https://github.com/alipay/alipay-sdk-net-all)通用而全面的设计理念Alipay Easy SDK对开放能力的API进行了更加贴近高频场景的精心设计与裁剪简化了服务端调用方式让调用API像使用语言内置的函数一样简便。
同时您也不必担心面向高频场景提炼的API可能无法完全契合自己的个性化场景Alipay Easy SDK支持灵活的动态扩展方式同样可以满足低频参数低频API的使用需求
Alipay Easy SDK提供了与[能力地图](https://opendocs.alipay.com/mini/00am3f)相对应的代码组织结构让开发者可以快速找到不同能力对应的API。
Alipay Easy SDK主要目标是提升开发者在**服务端**集成支付宝开放平台开放的各类核心能力的效率
## 环境要求
1. Alipay Easy SDK for .NET基于`.Net Standard 2.0`开发支持`.Net Framework 4.6.1`.`Net Core 2.0`及其以上版本
2. 使用 Alipay Easy SDK for .NET 之前 您需要先前往[支付宝开发平台-开发者中心](https://openhome.alipay.com/platform/developerIndex.htm)完成开发者接入的一些准备工作,包括创建应用、为应用添加功能包、设置应用的接口加签方式等。
3. 准备工作完成后注意保存如下信息后续将作为使用SDK的输入
* 加签模式为公钥证书模式时推荐
`AppId``应用的私钥``应用公钥证书文件``支付宝公钥证书文件``支付宝根证书文件`
* 加签模式为公钥模式时
`AppId``应用的私钥``支付宝公钥`
## 安装依赖
### 通过[NuGet](https://www.nuget.org/packages/AlipayEasySDK/)程序包管理器在线安装依赖(推荐)
* `解决方案资源管理器面板` 中右击您的项目选择 `管理 NuGet 程序包` 菜单在打开的 `NuGet 管理面板` 中点击 `浏览` 选项卡输入 `AlipayEasySDK`在下方列表中选择 `Authors` `antopen` 由官方发布的**最新稳定版**NuGet包点击 **安装** 即可
* 或者通过 .NET CLI 工具来安装
> dotnet add package AlipayEasySDK
### 离线安装NuGet包适用于自己修改源码后的本地重新打包安装
1. 使用`Visual Studio`打开本`README.md`所在文件夹下的`AlipayEasySDK.sln`解决方案`生成`菜单栏下执行`全部重新生成`
2. `AlipayEasySDK/bin/Debug``AlipayEasySDK/bin/Release`目录下找到`AlipayEasySDK.[version].nupkg`文件该文件即为本SDK的NuGet离线包
3. 参照[NuGet离线安装程序包使用指南](https://yq.aliyun.com/articles/689227),在您的.NET应用项目工程中引入本SDK的NuGet离线包即可完成SDK的依赖安装。
## 快速开始
### 普通调用
以下这段代码示例向您展示了使用Alipay Easy SDK for .NET调用一个API的3个主要步骤
1. 设置参数全局只需设置一次
2. 发起API调用
3. 处理响应或异常
```charp
using System;
using Alipay.EasySDK.Factory;
using Alipay.EasySDK.Kernel;
using Alipay.EasySDK.Kernel.Util;
using Alipay.EasySDK.Payment.FaceToFace.Models;
namespace SDKDemo
{
class Program
{
static void Main(string[] args)
{
// 1. 设置参数(全局只需设置一次)
Factory.SetOptions(GetConfig());
try
{
// 2. 发起API调用以创建当面付收款二维码为例
AlipayTradePrecreateResponse response = Factory.Payment.FaceToFace()
.PreCreate("Apple iPhone11 128G", "2234567234890", "5799.00");
// 3. 处理响应或异常
if (ResponseChecker.Success(response))
{
Console.WriteLine("调用成功");
}
else
{
Console.WriteLine("调用失败,原因:" + response.Msg + "" + response.SubMsg);
}
}
catch (Exception ex)
{
Console.WriteLine("调用遭遇异常,原因:" + ex.Message);
throw ex;
}
}
static private Config GetConfig()
{
return new Config()
{
Protocol = "https",
GatewayHost = "openapi.alipay.com",
SignType = "RSA2",
AppId = "<-- 请填写您的AppId例如2019091767145019 -->",
// 为避免私钥随源码泄露,推荐从文件中读取私钥字符串而不是写入源码中
MerchantPrivateKey = "<-- 请填写您的应用私钥例如MIIEvQIBADANB ... ... -->",
MerchantCertPath = "<-- 请填写您的应用公钥证书文件路径,例如:/foo/appCertPublicKey_2019051064521003.crt -->",
AlipayCertPath = "<-- 请填写您的支付宝公钥证书文件路径,例如:/foo/alipayCertPublicKey_RSA2.crt -->",
AlipayRootCertPath = "<-- 请填写您的支付宝根证书文件路径,例如:/foo/alipayRootCert.crt -->",
// 如果采用非证书模式,则无需赋值上面的三个证书路径,改为赋值如下的支付宝公钥字符串即可
// AlipayPublicKey = "<-- 请填写您的支付宝公钥例如MIIBIjANBg... -->"
//可设置异步通知接收服务地址(可选)
NotifyUrl = "<-- 请填写您的支付类接口异步通知接收服务地址例如https://www.test.com/callback -->",
//可设置AES密钥调用AES加解密相关接口时需要可选
EncryptKey = "<-- 请填写您的AES密钥例如aa4BtZ4tspm2wnXLb1ThQA== -->"
};
}
}
}
```
### 扩展调用
#### ISV代调用
```csharp
Factory.Payment.FaceToFace()
//调用Agent扩展方法设置app_auth_token完成ISV代调用
.Agent("ca34ea491e7146cc87d25fca24c4cD11")
.PreCreate("Apple iPhone11 128G", "2234567890", "5799.00");
```
#### 设置独立的异步通知地址
```csharp
Factory.Payment.FaceToFace()
// 调用AsyncNotify扩展方法可以为每此API调用设置独立的异步通知地址
// 此处设置的异步通知地址的优先级高于全局Config中配置的异步通知地址
.AsyncNotify("https://www.test.com/callback")
.PreCreate("Apple iPhone11 128G", "2234567890", "5799.00");
```
#### 设置可选业务参数
```csharp
List<object> goodsDetailList = new List<object>();
Dictionary<string, object> goodsDetail = new Dictionary<string, object>
{
{ "goods_id", "apple-01" },
{ "goods_name", "Apple iPhone11 128G" },
{ "quantity", 1 },
{ "price", "5799.00" }
};
goodsDetailList.Add(goodsDetail);
Factory.Payment.FaceToFace()
// 调用Optional扩展方法完成可选业务参数biz_content下的可选字段的设置
.Optional("seller_id", "2088102146225135")
.Optional("discountable_amount", "8.88")
.Optional("goods_detail", goodsDetailList)
.PreCreate("Apple iPhone11 128G", "2234567890", "5799.00");
Dictionary<string, object> optionalArgs = new Dictionary<string, object>
{
{ "seller_id", "2088102146225135" },
{ "discountable_amount", "8.88" },
{ "goods_detail", goodsDetailList }
};
Factory.Payment.FaceToFace()
// 也可以调用BatchOptional扩展方法批量设置可选业务参数biz_content下的可选字段
.BatchOptional(optionalArgs)
.PreCreate("Apple iPhone11 128G", "2234567890", "5799.00");
```
#### 多种扩展灵活组合
```csharp
// 多种扩展方式可灵活组装(对扩展方法的调用顺序没有要求)
Factory.Payment.FaceToFace()
.Agent("ca34ea491e7146cc87d25fca24c4cD11")
.AsyncNotify("https://www.test.com/callback")
.Optional("seller_id", "2088102146225135")
.PreCreate("Apple iPhone11 128G", "2234567890", "5799.00");
```
## API组织规范
在Alipay Easy SDK中API的引用路径与能力地图的组织层次一致遵循如下规则
> Factory.能力名称.场景名称().接口方法名称( ... )
比如如果您想要使用[能力地图](https://opendocs.alipay.com/mini/00am3f)中`营销能力`下的`模板消息`场景中的`小程序发送模板消息`,只需按如下形式编写调用代码即可(不同编程语言的连接符号可能不同)。
`Factory.Marketing.TemplateMessage().send( ... )`
其中接口方法名称通常是对其依赖的OpenAPI功能的一个最简概况接口方法的出入参与OpenAPI中同名参数含义一致可参照OpenAPI相关参数的使用说明
Alipay Easy SDK将致力于保持良好的API命名以符合开发者的编程直觉
## 已支持的API列表
| 能力类别 | 场景类别 | 接口方法名称 | 调用的OpenAPI名称 |
|-----------|-----------------|------------------------|-----------------------------------------------------------|
| Base | OAuth | getToken | alipay\.system\.oauth\.token |
| Base | OAuth | refreshToken | alipay\.system\.oauth\.token |
| Base | Qrcode | create | alipay\.open\.app\.qrcode\.create |
| Base | Image | upload | alipay\.offline\.material\.image\.upload |
| Base | Video | upload | alipay\.offline\.material\.image\.upload |
| Member | Identification | init | alipay\.user\.certify\.open\.initialize |
| Member | Identification | certify | alipay\.user\.certify\.open\.certify |
| Member | Identification | query | alipay\.user\.certify\.open\.query |
| Payment | Common | create | alipay\.trade\.create |
| Payment | Common | query | alipay\.trade\.query |
| Payment | Common | refund | alipay\.trade\.refund |
| Payment | Common | close | alipay\.trade\.close |
| Payment | Common | cancel | alipay\.trade\.cancel |
| Payment | Common | queryRefund | alipay\.trade\.fastpay\.refund\.query |
| Payment | Common | downloadBill | alipay\.data\.dataservice\.bill\.downloadurl\.query |
| Payment | Common | verifyNotify | - |
| Payment | Huabei | create | alipay\.trade\.create |
| Payment | FaceToFace | pay | alipay\.trade\.pay |
| Payment | FaceToFace | precreate | alipay\.trade\.precreate |
| Payment | App | pay | alipay\.trade\.app\.pay |
| Payment | Page | pay | alipay\.trade\.page\.pay |
| Payment | Wap | pay | alipay\.trade\.wap\.pay |
| Security | TextRisk | detect | alipay\.security\.risk\.content\.detect |
| Marketing | Pass | createTemplate | alipay\.pass\.template\.add |
| Marketing | Pass | updateTemplate | alipay\.pass\.template\.update |
| Marketing | Pass | addInstance | alipay\.pass\.instance\.add |
| Marketing | Pass | updateInstance | alipay\.pass\.instance\.update |
| Marketing | TemplateMessage | send | alipay\.open\.app\.mini\.templatemessage\.send |
| Marketing | OpenLife | createImageTextContent | alipay\.open\.public\.message\.content\.create |
| Marketing | OpenLife | modifyImageTextContent | alipay\.open\.public\.message\.content\.modify |
| Marketing | OpenLife | sendText | alipay\.open\.public\.message\.total\.send |
| Marketing | OpenLife | sendImageText | alipay\.open\.public\.message\.total\.send |
| Marketing | OpenLife | sendSingleMessage | alipay\.open\.public\.message\.single\.send |
| Marketing | OpenLife | recallMessage | alipay\.open\.public\.life\.msg\.recall |
| Marketing | OpenLife | setIndustry | alipay\.open\.public\.template\.message\.industry\.modify |
| Marketing | OpenLife | getIndustry | alipay\.open\.public\.setting\.category\.query |
| Util | AES | decrypt | - |
| Util | AES | encrypt | - |
| Util | Generic | execute | - |
> 更多高频场景的API持续更新中敬请期待
## 文档
[API Doc](./../APIDoc.md)
[Alipay Easy SDK](./../README.md)

View File

@@ -0,0 +1,32 @@
using NUnit.Framework;
using Alipay.EasySDK.Factory;
using Alipay.EasySDK.Base.Image.Models;
using Alipay.EasySDK.Kernel.Util;
namespace UnitTest.Base.Image
{
public class ClientTest
{
[SetUp]
public void SetUp()
{
Factory.SetOptions(TestAccount.Mini.CONFIG);
}
[Test]
public void TestUpload()
{
AlipayOfflineMaterialImageUploadResponse response = Factory.Base.Image().Upload(
"测试图片", TestAccount.GetSolutionBasePath() + "/UnitTest/Fixture/sample.png");
Assert.IsTrue(ResponseChecker.Success(response));
Assert.AreEqual(response.Code, "10000");
Assert.AreEqual(response.Msg, "Success");
Assert.IsNull(response.SubCode);
Assert.IsNull(response.SubMsg);
Assert.NotNull(response.HttpBody);
Assert.NotNull(response.ImageId);
Assert.IsTrue(response.ImageUrl.StartsWith("https://"));
}
}
}

View File

@@ -0,0 +1,42 @@
using NUnit.Framework;
using Alipay.EasySDK.Factory;
using Alipay.EasySDK.Base.OAuth.Models;
using Alipay.EasySDK.Kernel.Util;
namespace UnitTest.Base.OAuth
{
public class ClientTest
{
[SetUp]
public void SetUp()
{
Factory.SetOptions(TestAccount.Mini.CONFIG);
}
[Test]
public void TestGetToken()
{
AlipaySystemOauthTokenResponse response = Factory.Base.OAuth().GetToken("1234567890");
Assert.IsFalse(ResponseChecker.Success(response));
Assert.AreEqual(response.Code, "40002");
Assert.AreEqual(response.Msg, "Invalid Arguments");
Assert.AreEqual(response.SubCode, "isv.code-invalid");
Assert.AreEqual(response.SubMsg, "授权码code无效");
Assert.NotNull(response.HttpBody);
}
[Test]
public void TestRefreshToken()
{
AlipaySystemOauthTokenResponse response = Factory.Base.OAuth().RefreshToken("1234567890");
Assert.IsFalse(ResponseChecker.Success(response));
Assert.AreEqual(response.Code, "40002");
Assert.AreEqual(response.Msg, "Invalid Arguments");
Assert.AreEqual(response.SubCode, "isv.refresh-token-invalid");
Assert.AreEqual(response.SubMsg, "刷新令牌refresh_token无效");
Assert.NotNull(response.HttpBody);
}
}
}

View File

@@ -0,0 +1,31 @@
using NUnit.Framework;
using Alipay.EasySDK.Factory;
using Alipay.EasySDK.Base.Qrcode.Models;
using Alipay.EasySDK.Kernel.Util;
namespace UnitTest.Base.Qrcode
{
public class ClientTest
{
[SetUp]
public void SetUp()
{
Factory.SetOptions(TestAccount.Mini.CONFIG);
}
[Test]
public void TestCreate()
{
AlipayOpenAppQrcodeCreateResponse response = Factory.Base.Qrcode().Create(
"https://opendocs.alipay.com", "ageIndex=1", "文档站点");
Assert.IsTrue(ResponseChecker.Success(response));
Assert.AreEqual(response.Code, "10000");
Assert.AreEqual(response.Msg, "Success");
Assert.Null(response.SubCode);
Assert.Null(response.SubMsg);
Assert.NotNull(response.HttpBody);
Assert.NotNull(response.QrCodeUrl);
}
}
}

View File

@@ -0,0 +1,32 @@
using NUnit.Framework;
using Alipay.EasySDK.Factory;
using Alipay.EasySDK.Base.Video.Models;
using Alipay.EasySDK.Kernel.Util;
namespace UnitTest.Base.Video
{
public class ClientTest
{
[SetUp]
public void SetUp()
{
Factory.SetOptions(TestAccount.Mini.CONFIG);
}
[Test]
public void TestUpload()
{
AlipayOfflineMaterialImageUploadResponse response = Factory.Base.Video().Upload(
"测试视频", TestAccount.GetSolutionBasePath() + "/UnitTest/Fixture/sample.mp4");
Assert.IsTrue(ResponseChecker.Success(response));
Assert.AreEqual(response.Code, "10000");
Assert.AreEqual(response.Msg, "Success");
Assert.IsNull(response.SubCode);
Assert.IsNull(response.SubMsg);
Assert.NotNull(response.HttpBody);
Assert.NotNull(response.ImageId);
Assert.IsTrue(response.ImageUrl.StartsWith("https://"));
}
}
}

View File

@@ -0,0 +1,33 @@
using System;
using NUnit.Framework;
using Alipay.EasySDK.Payment.Common.Models;
using Alipay.EasySDK.Factory;
using Alipay.EasySDK.Kernel.Util;
namespace UnitTest.FactoryTest
{
public class FactoryTest
{
[SetUp]
public void SetUp()
{
Factory.SetOptions(TestAccount.Mini.CONFIG);
}
[Test]
public void TestGetClient()
{
AlipayTradeFastpayRefundQueryResponse response = Factory.GetClient<Alipay.EasySDK.Payment.Common.Client>()
.QueryRefund("64628156-f784-4572-9540-485b7c91b850", "64628156-f784-4572-9540-485b7c91b850");
Assert.IsTrue(ResponseChecker.Success(response));
Assert.AreEqual(response.Code, "10000");
Assert.AreEqual(response.Msg, "Success");
Assert.IsNull(response.SubCode);
Assert.IsNull(response.SubMsg);
Assert.NotNull(response.HttpBody);
Assert.AreEqual(response.RefundAmount, "0.01");
Assert.AreEqual(response.TotalAmount, "0.01");
}
}
}

View File

@@ -0,0 +1,22 @@
-----BEGIN CERTIFICATE-----
MIIDkzCCAnugAwIBAgIQIBkJAnXy/rwX3BTZaKNEzjANBgkqhkiG9w0BAQsFADCBgjELMAkGA1UE
BhMCQ04xFjAUBgNVBAoMDUFudCBGaW5hbmNpYWwxIDAeBgNVBAsMF0NlcnRpZmljYXRpb24gQXV0
aG9yaXR5MTkwNwYDVQQDDDBBbnQgRmluYW5jaWFsIENlcnRpZmljYXRpb24gQXV0aG9yaXR5IENs
YXNzIDIgUjEwHhcNMTkwOTAyMTI0NDIyWhcNMjEwOTAxMTI0NDIyWjB0MQswCQYDVQQGEwJDTjEP
MA0GA1UECgwG6ZKf6ZuoMQ8wDQYDVQQLDAZBbGlwYXkxQzBBBgNVBAMMOuaUr+S7mOWunSjkuK3l
m70p572R57uc5oqA5pyv5pyJ6ZmQ5YWs5Y+4LTIwODgwMDI2NTY3MTg5MjAwggEiMA0GCSqGSIb3
DQEBAQUAA4IBDwAwggEKAoIBAQDQxh7MsF7bsPyQlToJWOPlmGfqUerZI2o2725LUqrabGYOaAgx
a8OAm6sFXoq6TykRltIBEmAjYjMYudQelwxSv8NhQ1eLEFrY7o2Z3TQ+y8lvlLmvqWnEMzOqq4Fc
UN6gzd1nissGVtzUkmx9ErB+89g6WAKV1bFCZBQHIjzfMIqcZkddUZ4SiksMKB/ncKFOJPJf2CUI
i31URny3WlIoC44jG1SiX2sPKdbkbsSGQcDfGIpNRQBNJxlXX/8Y8D7RrFCWHtjh4ONSMT29+xjS
8HNM0gSR2y4QKXyRupXrNY9yTTtkPhQIEjfSjsQPnuM+3b7VFd3GSDcDbvskNRNLAgMBAAGjEjAQ
MA4GA1UdDwEB/wQEAwID+DANBgkqhkiG9w0BAQsFAAOCAQEAf8Qx2UsLFqPDTxKk9eT0np75NqJ8
MexTuPJ/gC+Lp20YzEUyYW2rPlDFhDmFztlqk9RdynLRqyjB5dOAdWlxhgDlEqB9E6DvkVKtpIaL
7h7zqJei9gb/STAyf5vTVWR/WTmOhp3vQhaj7+lt14JwK/ELYMdBLD2IdmFis7YdzhCsGo7Y4FPb
BuHCV8Ngfaf2PvDlKaFOVzDg8tGnMBbAOgpe+mhxKUdhNG3eXcO0Z813rNIC15YAvWm68tNAwuZJ
rIVgK+049WUojwUJxOwVyzewob/8Gx7o8ipIV5E/bMrduSvigsj7OmNzwQ5/iSm31dfcXi3fOXXz
BLMb888PlA==
-----END CERTIFICATE-----
-----BEGIN CERTIFICATE-----
MIIE4jCCAsqgAwIBAgIIYsSr5bKAMl8wDQYJKoZIhvcNAQELBQAwejELMAkGA1UEBhMCQ04xFjAUBgNVBAoMDUFudCBGaW5hbmNpYWwxIDAeBgNVBAsMF0NlcnRpZmljYXRpb24gQXV0aG9yaXR5MTEwLwYDVQQDDChBbnQgRmluYW5jaWFsIENlcnRpZmljYXRpb24gQXV0aG9yaXR5IFIxMB4XDTE4MDMyMjE0MzQxNVoXDTM3MTEyNjE0MzQxNVowgYIxCzAJBgNVBAYTAkNOMRYwFAYDVQQKDA1BbnQgRmluYW5jaWFsMSAwHgYDVQQLDBdDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTE5MDcGA1UEAwwwQW50IEZpbmFuY2lhbCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eSBDbGFzcyAyIFIxMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAsLMfYaoRoPRbmDcAfXPCmKf43pWRN5yTXa/KJWO0l+mrgQvs89bANEvbDUxlkGwycwtwi5DgBuBgVhLliXu+R9CYgr2dXs8D8Hx/gsggDcyGPLmVrDOnL+dyeauheARZfA3du60fwEwwbGcVIpIxPa/4n3IS/ElxQa6DNgqxh8J9Xwh7qMGl0JK9+bALuxf7B541Gr4p0WENG8fhgjBV4w4ut9eQLOoa1eddOUSZcy46Z7allwowwgt7b5VFfx/P1iKJ3LzBMgkCK7GZ2kiLrL7RiqV+h482J7hkJD+ardoc6LnrHO/hIZymDxok+VH9fVeUdQa29IZKrIDVj65THQIDAQABo2MwYTAfBgNVHSMEGDAWgBRfdLQEwE8HWurlsdsio4dBspzhATAdBgNVHQ4EFgQUSqHkYINtUSAtDPnS8XoyoP9p7qEwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwDQYJKoZIhvcNAQELBQADggIBAIQ8TzFy4bVIVb8+WhHKCkKNPcJe2EZuIcqvRoi727lZTJOfYy/JzLtckyZYfEI8J0lasZ29wkTta1IjSo+a6XdhudU4ONVBrL70U8Kzntplw/6TBNbLFpp7taRALjUgbCOk4EoBMbeCL0GiYYsTS0mw7xdySzmGQku4GTyqutIGPQwKxSj9iSFw1FCZqr4VP4tyXzMUgc52SzagA6i7AyLedd3tbS6lnR5BL+W9Kx9hwT8L7WANAxQzv/jGldeuSLN8bsTxlOYlsdjmIGu/C9OWblPYGpjQQIRyvs4Cc/mNhrh+14EQgwuemIIFDLOgcD+iISoN8CqegelNcJndFw1PDN6LkVoiHz9p7jzsge8RKay/QW6C03KNDpWZEUCgCUdfHfo8xKeR+LL1cfn24HKJmZt8L/aeRZwZ1jwePXFRVtiXELvgJuM/tJDIFj2KD337iV64fWcKQ/ydDVGqfDZAdcU4hQdsrPWENwPTQPfVPq2NNLMyIH9+WKx9Ed6/WzeZmIy5ZWpX1TtTolo6OJXQFeItMAjHxW/ZSZTok5IS3FuRhExturaInnzjYpx50a6kS34c5+c8hYq7sAtZ/CNLZmBnBCFDaMQqT8xFZJ5uolUaSeXxg7JFY1QsYp5RKvj4SjFwCGKJ2+hPPe9UyyltxOidNtxjaknOCeBHytOr
-----END CERTIFICATE-----

View File

@@ -0,0 +1,88 @@
-----BEGIN CERTIFICATE-----
MIIBszCCAVegAwIBAgIIaeL+wBcKxnswDAYIKoEcz1UBg3UFADAuMQswCQYDVQQG
EwJDTjEOMAwGA1UECgwFTlJDQUMxDzANBgNVBAMMBlJPT1RDQTAeFw0xMjA3MTQw
MzExNTlaFw00MjA3MDcwMzExNTlaMC4xCzAJBgNVBAYTAkNOMQ4wDAYDVQQKDAVO
UkNBQzEPMA0GA1UEAwwGUk9PVENBMFkwEwYHKoZIzj0CAQYIKoEcz1UBgi0DQgAE
MPCca6pmgcchsTf2UnBeL9rtp4nw+itk1Kzrmbnqo05lUwkwlWK+4OIrtFdAqnRT
V7Q9v1htkv42TsIutzd126NdMFswHwYDVR0jBBgwFoAUTDKxl9kzG8SmBcHG5Yti
W/CXdlgwDAYDVR0TBAUwAwEB/zALBgNVHQ8EBAMCAQYwHQYDVR0OBBYEFEwysZfZ
MxvEpgXBxuWLYlvwl3ZYMAwGCCqBHM9VAYN1BQADSAAwRQIgG1bSLeOXp3oB8H7b
53W+CKOPl2PknmWEq/lMhtn25HkCIQDaHDgWxWFtnCrBjH16/W3Ezn7/U/Vjo5xI
pDoiVhsLwg==
-----END CERTIFICATE-----
-----BEGIN CERTIFICATE-----
MIIF0zCCA7ugAwIBAgIIH8+hjWpIDREwDQYJKoZIhvcNAQELBQAwejELMAkGA1UE
BhMCQ04xFjAUBgNVBAoMDUFudCBGaW5hbmNpYWwxIDAeBgNVBAsMF0NlcnRpZmlj
YXRpb24gQXV0aG9yaXR5MTEwLwYDVQQDDChBbnQgRmluYW5jaWFsIENlcnRpZmlj
YXRpb24gQXV0aG9yaXR5IFIxMB4XDTE4MDMyMTEzNDg0MFoXDTM4MDIyODEzNDg0
MFowejELMAkGA1UEBhMCQ04xFjAUBgNVBAoMDUFudCBGaW5hbmNpYWwxIDAeBgNV
BAsMF0NlcnRpZmljYXRpb24gQXV0aG9yaXR5MTEwLwYDVQQDDChBbnQgRmluYW5j
aWFsIENlcnRpZmljYXRpb24gQXV0aG9yaXR5IFIxMIICIjANBgkqhkiG9w0BAQEF
AAOCAg8AMIICCgKCAgEAtytTRcBNuur5h8xuxnlKJetT65cHGemGi8oD+beHFPTk
rUTlFt9Xn7fAVGo6QSsPb9uGLpUFGEdGmbsQ2q9cV4P89qkH04VzIPwT7AywJdt2
xAvMs+MgHFJzOYfL1QkdOOVO7NwKxH8IvlQgFabWomWk2Ei9WfUyxFjVO1LVh0Bp
dRBeWLMkdudx0tl3+21t1apnReFNQ5nfX29xeSxIhesaMHDZFViO/DXDNW2BcTs6
vSWKyJ4YIIIzStumD8K1xMsoaZBMDxg4itjWFaKRgNuPiIn4kjDY3kC66Sl/6yTl
YUz8AybbEsICZzssdZh7jcNb1VRfk79lgAprm/Ktl+mgrU1gaMGP1OE25JCbqli1
Pbw/BpPynyP9+XulE+2mxFwTYhKAwpDIDKuYsFUXuo8t261pCovI1CXFzAQM2w7H
DtA2nOXSW6q0jGDJ5+WauH+K8ZSvA6x4sFo4u0KNCx0ROTBpLif6GTngqo3sj+98
SZiMNLFMQoQkjkdN5Q5g9N6CFZPVZ6QpO0JcIc7S1le/g9z5iBKnifrKxy0TQjtG
PsDwc8ubPnRm/F82RReCoyNyx63indpgFfhN7+KxUIQ9cOwwTvemmor0A+ZQamRe
9LMuiEfEaWUDK+6O0Gl8lO571uI5onYdN1VIgOmwFbe+D8TcuzVjIZ/zvHrAGUcC
AwEAAaNdMFswCwYDVR0PBAQDAgEGMAwGA1UdEwQFMAMBAf8wHQYDVR0OBBYEFF90
tATATwda6uWx2yKjh0GynOEBMB8GA1UdIwQYMBaAFF90tATATwda6uWx2yKjh0Gy
nOEBMA0GCSqGSIb3DQEBCwUAA4ICAQCVYaOtqOLIpsrEikE5lb+UARNSFJg6tpkf
tJ2U8QF/DejemEHx5IClQu6ajxjtu0Aie4/3UnIXop8nH/Q57l+Wyt9T7N2WPiNq
JSlYKYbJpPF8LXbuKYG3BTFTdOVFIeRe2NUyYh/xs6bXGr4WKTXb3qBmzR02FSy3
IODQw5Q6zpXj8prYqFHYsOvGCEc1CwJaSaYwRhTkFedJUxiyhyB5GQwoFfExCVHW
05ZFCAVYFldCJvUzfzrWubN6wX0DD2dwultgmldOn/W/n8at52mpPNvIdbZb2F41
T0YZeoWnCJrYXjq/32oc1cmifIHqySnyMnavi75DxPCdZsCOpSAT4j4lAQRGsfgI
kkLPGQieMfNNkMCKh7qjwdXAVtdqhf0RVtFILH3OyEodlk1HYXqX5iE5wlaKzDop
PKwf2Q3BErq1xChYGGVS+dEvyXc/2nIBlt7uLWKp4XFjqekKbaGaLJdjYP5b2s7N
1dM0MXQ/f8XoXKBkJNzEiM3hfsU6DOREgMc1DIsFKxfuMwX3EkVQM1If8ghb6x5Y
jXayv+NLbidOSzk4vl5QwngO/JYFMkoc6i9LNwEaEtR9PhnrdubxmrtM+RjfBm02
77q3dSWFESFQ4QxYWew4pHE0DpWbWy/iMIKQ6UZ5RLvB8GEcgt8ON7BBJeMc+Dyi
kT9qhqn+lw==
-----END CERTIFICATE-----
-----BEGIN CERTIFICATE-----
MIICiDCCAgygAwIBAgIIQX76UsB/30owDAYIKoZIzj0EAwMFADB6MQswCQYDVQQG
EwJDTjEWMBQGA1UECgwNQW50IEZpbmFuY2lhbDEgMB4GA1UECwwXQ2VydGlmaWNh
dGlvbiBBdXRob3JpdHkxMTAvBgNVBAMMKEFudCBGaW5hbmNpYWwgQ2VydGlmaWNh
dGlvbiBBdXRob3JpdHkgRTEwHhcNMTkwNDI4MTYyMDQ0WhcNNDkwNDIwMTYyMDQ0
WjB6MQswCQYDVQQGEwJDTjEWMBQGA1UECgwNQW50IEZpbmFuY2lhbDEgMB4GA1UE
CwwXQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkxMTAvBgNVBAMMKEFudCBGaW5hbmNp
YWwgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkgRTEwdjAQBgcqhkjOPQIBBgUrgQQA
IgNiAASCCRa94QI0vR5Up9Yr9HEupz6hSoyjySYqo7v837KnmjveUIUNiuC9pWAU
WP3jwLX3HkzeiNdeg22a0IZPoSUCpasufiLAnfXh6NInLiWBrjLJXDSGaY7vaokt
rpZvAdmjXTBbMAsGA1UdDwQEAwIBBjAMBgNVHRMEBTADAQH/MB0GA1UdDgQWBBRZ
4ZTgDpksHL2qcpkFkxD2zVd16TAfBgNVHSMEGDAWgBRZ4ZTgDpksHL2qcpkFkxD2
zVd16TAMBggqhkjOPQQDAwUAA2gAMGUCMQD4IoqT2hTUn0jt7oXLdMJ8q4vLp6sg
wHfPiOr9gxreb+e6Oidwd2LDnC4OUqCWiF8CMAzwKs4SnDJYcMLf2vpkbuVE4dTH
Rglz+HGcTLWsFs4KxLsq7MuU+vJTBUeDJeDjdA==
-----END CERTIFICATE-----
-----BEGIN CERTIFICATE-----
MIIDxTCCAq2gAwIBAgIUEMdk6dVgOEIS2cCP0Q43P90Ps5YwDQYJKoZIhvcNAQEF
BQAwajELMAkGA1UEBhMCQ04xEzARBgNVBAoMCmlUcnVzQ2hpbmExHDAaBgNVBAsM
E0NoaW5hIFRydXN0IE5ldHdvcmsxKDAmBgNVBAMMH2lUcnVzQ2hpbmEgQ2xhc3Mg
MiBSb290IENBIC0gRzMwHhcNMTMwNDE4MDkzNjU2WhcNMzMwNDE4MDkzNjU2WjBq
MQswCQYDVQQGEwJDTjETMBEGA1UECgwKaVRydXNDaGluYTEcMBoGA1UECwwTQ2hp
bmEgVHJ1c3QgTmV0d29yazEoMCYGA1UEAwwfaVRydXNDaGluYSBDbGFzcyAyIFJv
b3QgQ0EgLSBHMzCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAOPPShpV
nJbMqqCw6Bz1kehnoPst9pkr0V9idOwU2oyS47/HjJXk9Rd5a9xfwkPO88trUpz5
4GmmwspDXjVFu9L0eFaRuH3KMha1Ak01citbF7cQLJlS7XI+tpkTGHEY5pt3EsQg
wykfZl/A1jrnSkspMS997r2Gim54cwz+mTMgDRhZsKK/lbOeBPpWtcFizjXYCqhw
WktvQfZBYi6o4sHCshnOswi4yV1p+LuFcQ2ciYdWvULh1eZhLxHbGXyznYHi0dGN
z+I9H8aXxqAQfHVhbdHNzi77hCxFjOy+hHrGsyzjrd2swVQ2iUWP8BfEQqGLqM1g
KgWKYfcTGdbPB1MCAwEAAaNjMGEwHQYDVR0OBBYEFG/oAMxTVe7y0+408CTAK8hA
uTyRMB8GA1UdIwQYMBaAFG/oAMxTVe7y0+408CTAK8hAuTyRMA8GA1UdEwEB/wQF
MAMBAf8wDgYDVR0PAQH/BAQDAgEGMA0GCSqGSIb3DQEBBQUAA4IBAQBLnUTfW7hp
emMbuUGCk7RBswzOT83bDM6824EkUnf+X0iKS95SUNGeeSWK2o/3ALJo5hi7GZr3
U8eLaWAcYizfO99UXMRBPw5PRR+gXGEronGUugLpxsjuynoLQu8GQAeysSXKbN1I
UugDo9u8igJORYA+5ms0s5sCUySqbQ2R5z/GoceyI9LdxIVa1RjVX8pYOj8JFwtn
DJN3ftSFvNMYwRuILKuqUYSHc2GPYiHVflDh5nDymCMOQFcFG3WsEuB+EYQPFgIU
1DHmdZcz7Llx8UOZXX2JupWCYzK1XhJb+r4hK5ncf/w8qGtYlmyJpxk3hr1TfUJX
Yf4Zr0fJsGuv
-----END CERTIFICATE-----

View File

@@ -0,0 +1,23 @@
-----BEGIN CERTIFICATE-----
MIIEkzCCA3ugAwIBAgIQICABI1M0G1IN1Hv7M5NTmjANBgkqhkiG9w0BAQsFADCBgjELMAkGA1UE
BhMCQ04xFjAUBgNVBAoMDUFudCBGaW5hbmNpYWwxIDAeBgNVBAsMF0NlcnRpZmljYXRpb24gQXV0
aG9yaXR5MTkwNwYDVQQDDDBBbnQgRmluYW5jaWFsIENlcnRpZmljYXRpb24gQXV0aG9yaXR5IENs
YXNzIDEgUjEwHhcNMjAwMTIzMDc0NTQ3WhcNMjIwMTIyMDc0NTQ3WjBbMQswCQYDVQQGEwJDTjEP
MA0GA1UECgwG6ZKf6ZuoMQ8wDQYDVQQLDAZBbGlwYXkxKjAoBgNVBAMMITIwODgwMDI2NTY3MTg5
MjAtMjAxOTA1MTA2NDUyMTAwMzCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAIRaW3zN
ZGJY3oOUL41KMZqcoyI9JyDWG/fyb8qShWgH9NGinO6JeGWWX2pU2b5GKCd1CB6imnbD5U3zvErR
Z6h9Kc9pD4M22MNqnpuFontWuFXhq01MIbuolV5zTw94nrMR4aMPgTt7wX6svcQ8cKyg+v7Xz4DH
QCQOPhtFM3aL1UHsEZhLp+F2xNENTGpphmlV7D50ahnAo3A8Jdkt9ZBIzkWk4CoMdeoYk6BlOETG
XZ93Mc1TKR6cLNPj7LIUKb7xUh4ekaRoky2RP7k9NgBLsZLDjMkqZmzvHHhnstddmq5Er49Ger9b
VHnKsWNMWtN0Oi+ZyWTDcwvACdCgLbcCAwEAAaOCASkwggElMB8GA1UdIwQYMBaAFHEH4gRhFuTl
8mXrMQ/J4PQ8mtWRMB0GA1UdDgQWBBSNSXcCsxvjAa3v5QcTyVZ183CMjzBABgNVHSAEOTA3MDUG
B2CBHAFuAQEwKjAoBggrBgEFBQcCARYcaHR0cDovL2NhLmFsaXBheS5jb20vY3BzLnBkZjAOBgNV
HQ8BAf8EBAMCBsAwLwYDVR0fBCgwJjAkoCKgIIYeaHR0cDovL2NhLmFsaXBheS5jb20vY3JsMzcu
Y3JsMGAGCCsGAQUFBwEBBFQwUjAoBggrBgEFBQcwAoYcaHR0cDovL2NhLmFsaXBheS5jb20vY2E2
LmNlcjAmBggrBgEFBQcwAYYaaHR0cDovL2NhLmFsaXBheS5jb206ODM0MC8wDQYJKoZIhvcNAQEL
BQADggEBAA0l9rTtjEl4uqE4RP4Nd+A0KgM8NmWQHLxsubDRMSeYVFMzrpSm8V9zhlxLmKdFxWP/
OuY4SHRe8eOSA++5yJc3ihg9B7/ddK2kNTsnaB7Xtvex685kvDDR8DMZmQYeirDThGVPhUeBgPdk
wY0R5KU6mEh2FzT3QIxDzP6t4ssSyYHhFPssZ4PXHFQ5eHzmdpJ81/85crfques67JxAm4CCfldb
bX0DH1BUrPxcnvz4Kj5lKv1qIvBR71yUnrGFOKAVCx04VYK4dTNDI70W9lLgX1aTfLGUBTYiJe/J
Zq/XlYhQP/T7t8HOAaCQFf2hM9tRq62EaL1UbExV2hcAP/E=
-----END CERTIFICATE-----

View File

@@ -0,0 +1,4 @@
{
"2019022663440152": "<- 已脱敏如想要执行单元测试请开发者自行替换TestAccount中的相关账号并在此重新配置新的APPID与私钥的关联 ->",
"2019051064521003": "<- 已脱敏如想要执行单元测试请开发者自行替换TestAccount中的相关账号并在此重新配置新的APPID与私钥的关联 ->"
}

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 198 KiB

View File

@@ -0,0 +1,205 @@
using NUnit.Framework;
using Alipay.EasySDK.Factory;
using Alipay.EasySDK.Marketing.OpenLife.Models;
using System.Collections.Generic;
using Alipay.EasySDK.Kernel.Util;
namespace UnitTest.Marketing.OpenLife
{
public class ClientTest
{
[SetUp]
public void SetUp()
{
Factory.SetOptions(TestAccount.OpenLife.CONFIG);
}
[Test]
public void TestCreateImageTextContent()
{
AlipayOpenPublicMessageContentCreateResponse response = Factory.Marketing.OpenLife().CreateImageTextContent("标题",
"http://dl.django.t.taobao.com/rest/1.0/image?fileIds=hOTQ1lT1TtOjcxGflvnUXgAAACMAAQED",
"示例", "T", "activity", "满100减10",
"关键,热度", "13434343432,xxx@163.com");
Assert.IsTrue(ResponseChecker.Success(response));
Assert.AreEqual(response.Code, "10000");
Assert.AreEqual(response.Msg, "Success");
Assert.Null(response.SubCode);
Assert.Null(response.SubMsg);
Assert.NotNull(response.HttpBody);
Assert.NotNull(response.ContentId);
Assert.NotNull(response.ContentUrl);
}
[Test]
public void TestModifyImageTextContent()
{
AlipayOpenPublicMessageContentModifyResponse response = Factory.Marketing.OpenLife().ModifyImageTextContent(
"20190510645210035577f788-d6cd-4020-9dba-1a195edb7342", "新标题",
"http://dl.django.t.taobao.com/rest/1.0/image?fileIds=hOTQ1lT1TtOjcxGflvnUXgAAACMAAQED",
"新示例", "T", "activity", "满100减20",
"关键,热度", "13434343432,xxx@163.com");
Assert.IsTrue(ResponseChecker.Success(response));
Assert.AreEqual(response.Code, "10000");
Assert.AreEqual(response.Msg, "Success");
Assert.Null(response.SubCode);
Assert.Null(response.SubMsg);
Assert.NotNull(response.HttpBody);
Assert.AreEqual(response.ContentId, "20190510645210035577f788-d6cd-4020-9dba-1a195edb7342");
Assert.NotNull(response.ContentUrl);
}
[Test]
public void TestSendText()
{
AlipayOpenPublicMessageTotalSendResponse response = Factory.Marketing.OpenLife().SendText("测试");
if (response.Code.Equals("10000"))
{
Assert.IsTrue(ResponseChecker.Success(response));
Assert.AreEqual(response.Code, "10000");
Assert.AreEqual(response.Msg, "Success");
Assert.Null(response.SubCode);
Assert.Null(response.SubMsg);
Assert.NotNull(response.HttpBody);
Assert.NotNull(response.MessageId);
}
else
{
Assert.IsFalse(ResponseChecker.Success(response));
Assert.AreEqual(response.Code, "40004");
Assert.AreEqual(response.Msg, "Business Failed");
Assert.AreEqual(response.SubCode, "PUB.MSG_BATCH_SD_OVER");
Assert.AreEqual(response.SubMsg, "批量发送消息频率超限");
Assert.NotNull(response.HttpBody);
Assert.Null(response.MessageId);
}
}
[Test]
public void TestSendImageText()
{
Article article = new Article
{
ActionName = "测试",
Desc = "测试",
Title = "测试",
ImageUrl = "http://dl.django.t.taobao.com/rest/1.0/image?fileIds=hOTQ1lT1TtOjcxGflvnUXgAAACMAAQED",
Url = "https://docs.open.alipay.com/api_6/alipay.open.public.message.total.send"
};
AlipayOpenPublicMessageTotalSendResponse response = Factory.Marketing.OpenLife().SendImageText(new List<Article> { article });
if (response.Code.Equals("10000"))
{
Assert.IsTrue(ResponseChecker.Success(response));
Assert.AreEqual(response.Code, "10000");
Assert.AreEqual(response.Msg, "Success");
Assert.Null(response.SubCode);
Assert.Null(response.SubMsg);
Assert.NotNull(response.HttpBody);
Assert.NotNull(response.MessageId);
}
else
{
Assert.IsFalse(ResponseChecker.Success(response));
Assert.AreEqual(response.Code, "40004");
Assert.AreEqual(response.Msg, "Business Failed");
Assert.AreEqual(response.SubCode, "PUB.MSG_BATCH_SD_OVER");
Assert.AreEqual(response.SubMsg, "批量发送消息频率超限");
Assert.NotNull(response.HttpBody);
Assert.Null(response.MessageId);
}
}
[Test]
public void TestSendSingleMessage()
{
Keyword keyword = new Keyword
{
Color = "#85be53",
Value = "HU7142"
};
Context context = new Context
{
HeadColor = "#85be53",
Url = "https://docs.open.alipay.com/api_6/alipay.open.public.message.single.send",
ActionName = "查看详情",
Keyword1 = keyword,
Keyword2 = keyword,
First = keyword,
Remark = keyword
};
Alipay.EasySDK.Marketing.OpenLife.Models.Template template = new Alipay.EasySDK.Marketing.OpenLife.Models.Template
{
TemplateId = "e44cd3e52ffa46b1a50afc145f55d1ea",
Context = context
};
AlipayOpenPublicMessageSingleSendResponse response = Factory.Marketing.OpenLife().SendSingleMessage(
"2088002656718920", template);
Assert.IsTrue(ResponseChecker.Success(response));
Assert.AreEqual(response.Code, "10000");
Assert.AreEqual(response.Msg, "Success");
Assert.IsNull(response.SubCode);
Assert.IsNull(response.SubMsg);
Assert.NotNull(response.HttpBody);
}
[Test]
public void TestRecallMessage()
{
AlipayOpenPublicLifeMsgRecallResponse response = Factory.Marketing.OpenLife().RecallMessage("201905106452100327f456f6-8dd2-4a06-8b0e-ec8a3a85c46a");
Assert.IsTrue(ResponseChecker.Success(response));
Assert.AreEqual(response.Code, "10000");
Assert.AreEqual(response.Msg, "Success");
Assert.IsNull(response.SubCode);
Assert.IsNull(response.SubMsg);
Assert.NotNull(response.HttpBody);
}
[Test]
public void TestSetIndustry()
{
AlipayOpenPublicTemplateMessageIndustryModifyResponse response = Factory.Marketing.OpenLife().SetIndustry(
"10001/20102", "IT科技/IT软件与服务",
"10001/20102", "IT科技/IT软件与服务");
if (response.Code.Equals("10000"))
{
Assert.IsTrue(ResponseChecker.Success(response));
Assert.AreEqual(response.Code, "10000");
Assert.AreEqual(response.Msg, "Success");
Assert.Null(response.SubCode);
Assert.Null(response.SubMsg);
Assert.NotNull(response.HttpBody);
}
else
{
Assert.IsFalse(ResponseChecker.Success(response));
Assert.AreEqual(response.Code, "40004");
Assert.AreEqual(response.Msg, "Business Failed");
Assert.AreEqual(response.SubCode, "3002");
Assert.AreEqual(response.SubMsg, ("模板消息行业一月只能修改一次"));
Assert.NotNull(response.HttpBody);
}
}
[Test]
public void TestGetIndustry()
{
AlipayOpenPublicSettingCategoryQueryResponse response = Factory.Marketing.OpenLife().GetIndustry();
Assert.IsTrue(ResponseChecker.Success(response));
Assert.AreEqual(response.Code, "10000");
Assert.AreEqual(response.Msg, "Success");
Assert.Null(response.SubCode);
Assert.Null(response.SubMsg);
Assert.NotNull(response.HttpBody);
Assert.AreEqual(response.PrimaryCategory, "IT科技/IT软件与服务");
Assert.AreEqual(response.SecondaryCategory, "IT科技/IT软件与服务");
}
}
}

View File

@@ -0,0 +1,100 @@
using NUnit.Framework;
using Alipay.EasySDK.Factory;
using Alipay.EasySDK.Marketing.Pass.Models;
using Alipay.EasySDK.Kernel.Util;
namespace UnitTest.Marketing.Pass
{
public class ClientTest
{
[SetUp]
public void SetUp()
{
Factory.SetOptions(TestAccount.Mini.CONFIG);
}
[Test]
public void TestCreateTemplate()
{
AlipayPassTemplateAddResponse response = Factory.Marketing.Pass().CreateTemplate("123456789", GetTplContent());
Assert.IsTrue(ResponseChecker.Success(response));
Assert.AreEqual(response.Code, "10000");
Assert.AreEqual(response.Msg, "Success");
Assert.Null(response.SubCode);
Assert.Null(response.SubMsg);
Assert.NotNull(response.HttpBody);
Assert.True(response.Success);
Assert.True(response.Result.Contains("tpl_id"));
}
[Test]
public void TestUpdateTemplate()
{
AlipayPassTemplateUpdateResponse response = Factory.Marketing.Pass().UpdateTemplate("2020012014534017917956080", GetTplContent());
Assert.IsTrue(ResponseChecker.Success(response));
Assert.AreEqual(response.Code, "10000");
Assert.AreEqual(response.Msg, "Success");
Assert.Null(response.SubCode);
Assert.Null(response.SubMsg);
Assert.NotNull(response.HttpBody);
Assert.True(response.Success);
Assert.True(response.Result.Contains("tpl_id"));
}
[Test]
public void TestAddInstance()
{
AlipayPassInstanceAddResponse response = Factory.Marketing.Pass().AddInstance("2020012014534017917956080", "{}",
"1", "{\"partner_id\":\"2088102114633762\",\"out_trade_no\":\"1234567\"}");
Assert.IsFalse(ResponseChecker.Success(response));
Assert.AreEqual(response.Code, "40004");
Assert.AreEqual(response.Msg, "Business Failed");
Assert.AreEqual(response.SubCode, "KP.AE_ALIPASS_APPID_NOSUPPORT");
Assert.AreEqual(response.SubMsg, "该AppId不支持");
Assert.NotNull(response.HttpBody);
Assert.False(response.Success);
Assert.True(response.Result.Contains("该AppId不支持"));
}
[Test]
public void TestUpdateInstance()
{
AlipayPassInstanceUpdateResponse response = Factory.Marketing.Pass().UpdateInstance("209919213",
"2088918273", "{}", "USED", "8612231273", "wave");
Assert.IsFalse(ResponseChecker.Success(response));
Assert.AreEqual(response.Code, "40004");
Assert.AreEqual(response.Msg, "Business Failed");
Assert.AreEqual(response.SubCode, "KP.AE_ALIPASS_NOTEXIST");
Assert.AreEqual(response.SubMsg, "卡券不存在");
Assert.NotNull(response.HttpBody);
Assert.False(response.Success);
Assert.True(response.Result.Contains("{\"operate\":\"UPDATE\"}"));
}
private string GetTplContent()
{
return "{\"logo\":\"http://img01.taobaocdn.com/top/i1/LB1NDJuQpXXXXbYXFXXXXXXXXXX\",\"strip\":null,\"icon\":null,"
+ "\"content\":{\"evoucherInfo\":{\"goodsId\":\"\",\"title\":\"test\",\"type\":\"boardingPass\","
+ "\"product\":\"air\",\"startDate\":\"2020-01-20 13:45:56\",\"endDate\":\"2020-01-25 13:45:56\","
+ "\"operation\":[{\"message\":{\"img\":\"http://img01.taobaocdn.com/top/i1/LB1NDJuQpXXXXbYXFXXXXXXXXXX\","
+ "\"target\":\"\"},\"format\":\"img\",\"messageEncoding\":\"utf-8\",\"altText\":\"\"}],"
+ "\"einfo\":{\"logoText\":\"test\",\"headFields\":[{\"key\":\"test\",\"label\":\"测试\",\"value\":\"\","
+ "\"type\":\"text\"}],\"primaryFields\":[{\"key\":\"from\",\"label\":\"测试\",\"value\":\"\",\"type\":\"text\"},"
+ "{\"key\":\"to\",\"label\":\"测试\",\"value\":\"\",\"type\":\"text\"}],\"secondaryFields\":[{\"key\":\"fltNo\","
+ "\"label\":\"航班号\",\"value\":\"CA123\",\"type\":\"text\"}],\"auxiliaryFields\":[{\"key\":\"test\","
+ "\"label\":\"测试\",\"value\":\"\",\"type\":\"text\"}],\"backFields\":[]},\"locations\":[]},"
+ "\"merchant\":{\"mname\":\"钟雨\",\"mtel\":\"\",\"minfo\":\"\"},\"platform\":{\"channelID\":\"2088201564809153\","
+ "\"webServiceUrl\":\"https://alipass.alipay.com/builder/syncRecord.htm?tempId=2020012013442621326446216\"},"
+ "\"style\":{\"backgroundColor\":\"RGB(26,150,219)\"},\"fileInfo\":{\"formatVersion\":\"2\",\"canShare\":true,"
+ "\"canBuy\":false,\"canPresent\":true,\"serialNumber\":\"2020012013520759738677158\",\"supportTaxi\":\"true\","
+ "\"taxiSchemaUrl\":\"alipays://platformapi/startapp?appId=20000778&bizid=260&channel=71322\"},"
+ "\"appInfo\":{\"app\":{\"android_appid\":\"\",\"ios_appid\":\"\",\"android_launch\":\"\",\"ios_launch\":\"\","
+ "\"android_download\":\"\",\"ios_download\":\"\"},\"label\":\"测试\",\"message\":\"\"},"
+ "\"source\":\"alipassprod\",\"alipayVerify\":[\"qrcode\"]}}";
}
}
}

View File

@@ -0,0 +1,34 @@
using NUnit.Framework;
using Alipay.EasySDK.Factory;
using Alipay.EasySDK.Marketing.TemplateMessage.Models;
using Alipay.EasySDK.Kernel.Util;
namespace UnitTest.Marketing.TemplateMessage
{
public class ClientTest
{
[SetUp]
public void SetUp()
{
Factory.SetOptions(TestAccount.Mini.CONFIG);
}
[Test]
public void TestSend()
{
AlipayOpenAppMiniTemplatemessageSendResponse response = Factory.Marketing.TemplateMessage().Send(
"2088102122458832",
"2017010100000000580012345678",
"MDI4YzIxMDE2M2I5YTQzYjUxNWE4MjA4NmU1MTIyYmM=",
"page/component/index",
"{\"keyword1\": {\"value\" : \"12:00\"},\"keyword2\": {\"value\" : \"20180808\"},\"keyword3\": {\"value\" : \"支付宝\"}}");
Assert.IsFalse(ResponseChecker.Success(response));
Assert.AreEqual(response.Code, "40004");
Assert.AreEqual(response.Msg, "Business Failed");
Assert.AreEqual(response.SubCode, "USER_TEMPLATE_ILLEGAL");
Assert.AreEqual(response.SubMsg, "模板非法");
Assert.NotNull(response.HttpBody);
}
}
}

View File

@@ -0,0 +1,72 @@
using System;
using NUnit.Framework;
using Alipay.EasySDK.Factory;
using Alipay.EasySDK.Member.Identification.Models;
using Alipay.EasySDK.Kernel.Util;
namespace UnitTest.Member.Identification
{
public class ClientTest
{
[SetUp]
public void SetUp()
{
Factory.SetOptions(TestAccount.Mini.CONFIG);
}
[Test]
public void TestInit()
{
IdentityParam identityParam = new IdentityParam()
{
IdentityType = "CERT_INFO",
CertType = "IDENTITY_CARD",
CertName = "张三",
CertNo = "513901198008089876"
};
MerchantConfig merchantConfig = new MerchantConfig()
{
ReturnUrl = "www.taobao.com"
};
AlipayUserCertifyOpenInitializeResponse response = Factory.Member.Identification().Init(
Guid.NewGuid().ToString(), "FACE", identityParam, merchantConfig);
Assert.IsTrue(ResponseChecker.Success(response));
Assert.AreEqual(response.Code, "10000");
Assert.AreEqual(response.Msg, "Success");
Assert.IsNull(response.SubCode);
Assert.IsNull(response.SubMsg);
Assert.NotNull(response.HttpBody);
Assert.NotNull(response.CertifyId);
}
[Test]
public void TestCertify()
{
AlipayUserCertifyOpenCertifyResponse response = Factory.Member.Identification().Certify("bbdb57e87211279e2c22de5846d85161");
Assert.IsTrue(ResponseChecker.Success(response));
Assert.IsTrue(response.Body.Contains("https://openapi.alipay.com/gateway.do?alipay_sdk=alipay-easysdk-net"));
Assert.IsTrue(response.Body.Contains("sign"));
}
[Test]
public void TestQuery()
{
AlipayUserCertifyOpenQueryResponse response = Factory.Member.Identification().Query("89ad1f1b8171d9741c3e5620fd77f9de");
Assert.IsFalse(ResponseChecker.Success(response));
Assert.AreEqual(response.Code, "40004");
Assert.AreEqual(response.Msg, "Business Failed");
Assert.AreEqual(response.SubCode, "CERTIFY_ID_EXPIRED");
Assert.AreEqual(response.SubMsg, "认证已失效");
Assert.NotNull(response.HttpBody);
Assert.IsNull(response.Passed);
Assert.IsNull(response.IdentityInfo);
Assert.IsNull(response.MaterialInfo);
}
}
}

View File

@@ -0,0 +1,54 @@
using NUnit.Framework;
using Alipay.EasySDK.Factory;
using Alipay.EasySDK.Payment.App.Models;
using System.Collections.Generic;
using Alipay.EasySDK.Kernel.Util;
namespace UnitTest.Payment.App
{
public class ClientTest
{
[SetUp]
public void SetUp()
{
Factory.SetOptions(TestAccount.Mini.CONFIG);
}
[Test]
public void TestPay()
{
AlipayTradeAppPayResponse response = Factory.Payment.App().Pay("iPhone6 16G",
"f4833085-0c46-4bb0-8e5f-622a02a4cffc", "0.10");
Assert.IsTrue(ResponseChecker.Success(response));
Assert.IsTrue(response.Body.Contains("app_id=2019022663440152&biz_content=%7b%22subject%22%3a%22iPhone6+16G%22%2c%22" +
"out_trade_no%22%3a%22f4833085-0c46-4bb0-8e5f-622a02a4cffc%22%2c%22total_amount%22%3a%220.10%22%7d&charset=UTF-8&" +
"format=json&method=alipay.trade.app.pay&notify_url=https%3a%2f%2fwww.test.com%2fcallback&sign="));
}
[Test]
public void TestPayWithOptional()
{
AlipayTradeAppPayResponse response = Factory.Payment.App()
.Agent("ca34ea491e7146cc87d25fca24c4cD11")
.Optional("extend_params", GetHuabeiConfig())
.Pay("iPhone6 16G", "f4833085-0c46-4bb0-8e5f-622a02a4cffc", "0.10");
Assert.IsTrue(ResponseChecker.Success(response));
Assert.IsTrue(response.Body.Contains("app_auth_token=ca34ea491e7146cc87d25fca24c4cD11&app_id=2019022663440152&biz_content=%7b%22subject%22%3a%22iPhone6+16G%22%2c"
+ "%22out_trade_no%22%3a%22f4833085-0c46-4bb0-8e5f-622a02a4cffc%22%2c%22total_amount%22%3a%220"
+ ".10%22%2c%22extend_params%22%3a%7b%22hb_fq_num%22%3a%223%22%2c%22hb_fq_seller_percent%22%3a%22100%22%7d%7d&charset=UTF"
+ "-8&format=json&method=alipay.trade.app.pay&notify_url=https%3a%2f%2fwww.test.com%2fcallback&sign="));
}
private Dictionary<string, string> GetHuabeiConfig()
{
Dictionary<string, string> extendParams = new Dictionary<string, string>
{
{ "hb_fq_num", "3" },
{ "hb_fq_seller_percent", "100" }
};
return extendParams;
}
}
}

View File

@@ -0,0 +1,154 @@
using NUnit.Framework;
using Alipay.EasySDK.Factory;
using Alipay.EasySDK.Payment.Common.Models;
using System;
using System.Collections.Generic;
using Alipay.EasySDK.Kernel.Util;
namespace UnitTest.Payment.Common
{
public class ClientTest
{
[SetUp]
public void SetUp()
{
Factory.SetOptions(TestAccount.Mini.CONFIG);
}
[Test]
public void TestCreate()
{
string outTradeNo = Guid.NewGuid().ToString();
AlipayTradeCreateResponse response = Factory.Payment.Common().Create("iPhone6 16G",
outTradeNo, "88.88", "2088002656718920");
Assert.IsTrue(ResponseChecker.Success(response));
Assert.AreEqual(response.Code, "10000");
Assert.AreEqual(response.Msg, "Success");
Assert.Null(response.SubCode);
Assert.Null(response.SubMsg);
Assert.NotNull(response.HttpBody);
Assert.AreEqual(response.OutTradeNo, outTradeNo);
Assert.True(response.TradeNo.StartsWith("202"));
}
[Test]
public void TestCreateWithOptional()
{
string outTradeNo = Guid.NewGuid().ToString();
AlipayTradeCreateResponse response = Factory.Payment.Common().Optional("goods_detail", GetGoodsDetail())
.Create("iPhone6 16G", outTradeNo, "0.01", "2088002656718920");
Assert.IsTrue(ResponseChecker.Success(response));
Assert.AreEqual(response.Code, "10000");
Assert.AreEqual(response.Msg, "Success");
Assert.Null(response.SubCode);
Assert.Null(response.SubMsg);
Assert.NotNull(response.HttpBody);
Assert.AreEqual(response.OutTradeNo, outTradeNo);
Assert.True(response.TradeNo.StartsWith("202"));
}
private List<object> GetGoodsDetail()
{
List<object> goodsDetail = new List<object>();
Dictionary<string, object> goodDetail = new Dictionary<string, object>();
goodDetail.Add("goods_id", "apple-01");
goodDetail.Add("goods_name", "iPhone6 16G");
goodDetail.Add("quantity", 1);
goodDetail.Add("price", "0.01");
goodsDetail.Add(goodDetail);
return goodsDetail;
}
[Test]
public void TestQuery()
{
AlipayTradeQueryResponse response = Factory.Payment.Common().Query("6f149ddb-ab8c-4546-81fb-5880b4aaa318");
Assert.IsTrue(ResponseChecker.Success(response));
Assert.AreEqual(response.Code, "10000");
Assert.AreEqual(response.Msg, "Success");
Assert.Null(response.SubCode);
Assert.Null(response.SubMsg);
Assert.NotNull(response.HttpBody);
Assert.AreEqual(response.OutTradeNo, "6f149ddb-ab8c-4546-81fb-5880b4aaa318");
}
[Test]
public void TestCancel()
{
AlipayTradeCancelResponse response = Factory.Payment.Common().Cancel(CreateNewAndReturnOutTradeNo());
Assert.IsTrue(ResponseChecker.Success(response));
Assert.AreEqual(response.Code, "10000");
Assert.AreEqual(response.Msg, "Success");
Assert.Null(response.SubCode);
Assert.Null(response.SubMsg);
Assert.NotNull(response.HttpBody);
Assert.AreEqual(response.Action, "close");
}
[Test]
public void TestClose()
{
AlipayTradeCloseResponse response = Factory.Payment.Common().Close(CreateNewAndReturnOutTradeNo());
Assert.IsTrue(ResponseChecker.Success(response));
Assert.AreEqual(response.Code, "10000");
Assert.AreEqual(response.Msg, "Success");
Assert.Null(response.SubCode);
Assert.Null(response.SubMsg);
Assert.NotNull(response.HttpBody);
}
[Test]
public void TestRefund()
{
AlipayTradeRefundResponse response = Factory.Payment.Common().Refund(CreateNewAndReturnOutTradeNo(), "0.01");
Assert.IsFalse(ResponseChecker.Success(response));
Assert.AreEqual(response.Code, "40004");
Assert.AreEqual(response.Msg, "Business Failed");
Assert.AreEqual(response.SubCode, "ACQ.TRADE_STATUS_ERROR");
Assert.AreEqual(response.SubMsg, "交易状态不合法");
Assert.NotNull(response.HttpBody);
}
[Test]
public void TestQueryRefund()
{
AlipayTradeFastpayRefundQueryResponse response = Factory.Payment.Common().QueryRefund(
"64628156-f784-4572-9540-485b7c91b850", "64628156-f784-4572-9540-485b7c91b850");
Assert.IsTrue(ResponseChecker.Success(response));
Assert.AreEqual(response.Code, "10000");
Assert.AreEqual(response.Msg, "Success");
Assert.IsNull(response.SubCode);
Assert.IsNull(response.SubMsg);
Assert.NotNull(response.HttpBody);
Assert.AreEqual(response.RefundAmount, "0.01");
Assert.AreEqual(response.TotalAmount, "0.01");
}
[Test]
public void TestDownloadBill()
{
AlipayDataDataserviceBillDownloadurlQueryResponse response = Factory.Payment.Common().DownloadBill("trade", "2020-01");
Assert.IsTrue(ResponseChecker.Success(response));
Assert.AreEqual(response.Code, "10000");
Assert.AreEqual(response.Msg, "Success");
Assert.IsNull(response.SubCode);
Assert.IsNull(response.SubMsg);
Assert.NotNull(response.HttpBody);
Assert.IsTrue(response.BillDownloadUrl.StartsWith("http://dwbillcenter.alipay.com/"));
}
private string CreateNewAndReturnOutTradeNo()
{
return Factory.Payment.Common().Create("iPhone6 16G", Guid.NewGuid().ToString(),
"88.88", "2088002656718920").OutTradeNo;
}
}
}

View File

@@ -0,0 +1,51 @@
using NUnit.Framework;
using Alipay.EasySDK.Factory;
using Alipay.EasySDK.Payment.FaceToFace.Models;
using System;
using Alipay.EasySDK.Kernel.Util;
namespace UnitTest.Payment.FaceToFace
{
public class ClientTest
{
[SetUp]
public void SetUp()
{
Factory.SetOptions(TestAccount.Mini.CONFIG);
}
[Test]
public void TestPay()
{
AlipayTradePayResponse response = Factory.Payment.FaceToFace().Pay("Iphone6 16G", CreateNewAndReturnOutTradeNo(), "0.01", "1234567890");
Assert.IsFalse(ResponseChecker.Success(response));
Assert.AreEqual(response.Code, "40004");
Assert.AreEqual(response.Msg, "Business Failed");
Assert.AreEqual(response.SubCode, "ACQ.PAYMENT_AUTH_CODE_INVALID");
Assert.AreEqual(response.SubMsg, "支付失败,获取顾客账户信息失败,请顾客刷新付款码后重新收款,如再次收款失败,请联系管理员处理。[SOUNDWAVE_PARSER_FAIL]");
Assert.NotNull(response.HttpBody);
}
[Test]
public void TestPreCreate()
{
AlipayTradePrecreateResponse response = Factory.Payment.FaceToFace().PreCreate("iPhone6 16G",
CreateNewAndReturnOutTradeNo(), "0.10");
Assert.IsTrue(ResponseChecker.Success(response));
Assert.AreEqual(response.Code, "10000");
Assert.AreEqual(response.Msg, "Success");
Assert.IsNull(response.SubCode);
Assert.IsNull(response.SubMsg);
Assert.NotNull(response.HttpBody);
Assert.IsTrue(response.QrCode.StartsWith("https://qr.alipay.com/"));
}
private string CreateNewAndReturnOutTradeNo()
{
return Factory.Payment.Common().Create("Iphone6 16G", Guid.NewGuid().ToString(),
"88.88", "2088002656718920").OutTradeNo;
}
}
}

View File

@@ -0,0 +1,39 @@
using NUnit.Framework;
using Alipay.EasySDK.Factory;
using Alipay.EasySDK.Payment.Huabei.Models;
using System;
using Alipay.EasySDK.Kernel.Util;
namespace UnitTest.Payment.HuaBei
{
public class ClientTest
{
[SetUp]
public void SetUp()
{
Factory.SetOptions(TestAccount.Mini.CONFIG);
}
[Test]
public void TestCrate()
{
string outTradeNo = Guid.NewGuid().ToString();
HuabeiConfig config = new HuabeiConfig()
{
HbFqNum = "3",
HbFqSellerPercent = "0"
};
AlipayTradeCreateResponse response = Factory.Payment.Huabei().Create("Iphone6 16G",
outTradeNo, "88.88", "2088002656718920", config);
Assert.IsTrue(ResponseChecker.Success(response));
Assert.AreEqual(response.Code, "10000");
Assert.AreEqual(response.Msg, "Success");
Assert.Null(response.SubCode);
Assert.Null(response.SubMsg);
Assert.NotNull(response.HttpBody);
Assert.AreEqual(response.OutTradeNo, outTradeNo);
Assert.True(response.TradeNo.StartsWith("202"));
}
}
}

View File

@@ -0,0 +1,50 @@
using NUnit.Framework;
using Alipay.EasySDK.Factory;
using Alipay.EasySDK.Payment.Page.Models;
using Alipay.EasySDK.Kernel.Util;
namespace UnitTest.Payment.Page
{
public class ClientTest
{
[SetUp]
public void SetUp()
{
Factory.SetOptions(TestAccount.Mini.CONFIG);
}
[Test]
public void TestPay()
{
AlipayTradePagePayResponse response = Factory.Payment.Page().Pay("iPhone6 16G",
"e5b5bd79-8310-447d-b63b-0fe3a393324d", "0.10", "https://www.taobao.com");
Assert.IsTrue(ResponseChecker.Success(response));
Assert.IsTrue(response.Body.Contains("<form name=\"punchout_form\" method=\"post\" action=\"https://openapi.alipay.com/gateway.do?"));
Assert.IsTrue(response.Body.Contains("notify_url"));
Assert.IsTrue(response.Body.Contains("return_url"));
Assert.IsTrue(response.Body.Contains("<input type=\"hidden\" name=\"biz_content\" value=\"{&quot;subject&quot;:&quot;iPhone6 16G&quot;,&quot;"
+ "out_trade_no&quot;:&quot;e5b5bd79-8310-447d-b63b-0fe3a393324d&quot;,&quot;total_amount&quot;:&quot;0.10&quot;,&quot;"
+ "product_code&quot;:&quot;FAST_INSTANT_TRADE_PAY&quot;}\">"));
Assert.IsTrue(response.Body.Contains("<input type=\"submit\" value=\"立即支付\" style=\"display:none\" >"));
Assert.IsTrue(response.Body.Contains("<script>document.forms[0].submit();</script>"));
}
[Test]
public void TestPayWithOptionalNotify()
{
AlipayTradePagePayResponse response = Factory.Payment.Page().AsyncNotify("https://www.test2.com/newCallback")
.Pay("iPhone6 16G", "e5b5bd79-8310-447d-b63b-0fe3a393324d", "0.10", "https://www.taobao.com");
Assert.IsTrue(ResponseChecker.Success(response));
Assert.IsTrue(response.Body.Contains("<form name=\"punchout_form\" method=\"post\" action=\"https://openapi.alipay.com/gateway.do?"));
Assert.IsTrue(response.Body.Contains("notify_url=https%3a%2f%2fwww.test2.com%2fnewCallback"));
Assert.IsTrue(response.Body.Contains("return_url"));
Assert.IsTrue(response.Body.Contains("<input type=\"hidden\" name=\"biz_content\" value=\"{&quot;subject&quot;:&quot;iPhone6 16G&quot;,&quot;out_trade_no&quot;:&quot;"
+ "e5b5bd79-8310-447d-b63b-0fe3a393324d&quot;,&quot;total_amount&quot;:&quot;0.10&quot;,&quot;product_code&quot;:&quot;"
+ "FAST_INSTANT_TRADE_PAY&quot;}\">"));
Assert.IsTrue(response.Body.Contains("<input type=\"submit\" value=\"立即支付\" style=\"display:none\" >"));
Assert.IsTrue(response.Body.Contains("<script>document.forms[0].submit();</script>"));
}
}
}

View File

@@ -0,0 +1,65 @@
using NUnit.Framework;
using Alipay.EasySDK.Factory;
using Alipay.EasySDK.Payment.Wap.Models;
using Alipay.EasySDK.Kernel.Util;
using System.Collections.Generic;
namespace UnitTest.Payment.Wap
{
public class ClientTest
{
[SetUp]
public void SetUp()
{
Factory.SetOptions(TestAccount.Mini.CONFIG);
}
[Test]
public void TestPay()
{
AlipayTradeWapPayResponse response = Factory.Payment.Wap().Pay("iPhone6 16G",
"b7f4bc7d-ea4b-4efd-9072-d8ea913c8946", "0.10",
"https://www.taobao.com", "https://www.taobao.com");
Assert.IsTrue(ResponseChecker.Success(response));
Assert.IsTrue(response.Body.Contains("<form name=\"punchout_form\" method=\"post\" action=\"https://openapi.alipay.com/gateway.do?"));
Assert.IsTrue(response.Body.Contains("notify_url"));
Assert.IsTrue(response.Body.Contains("return_url"));
Assert.IsTrue(response.Body.Contains("<input type=\"hidden\" name=\"biz_content\" value=\"{&quot;subject&quot;:&quot;iPhone6 16G&quot;,&quot;"
+ "out_trade_no&quot;:&quot;b7f4bc7d-ea4b-4efd-9072-d8ea913c8946&quot;,&quot;"
+ "total_amount&quot;:&quot;0.10&quot;,&quot;quit_url&quot;:&quot;https://www.taobao.com&quot;,&quot;"
+ "product_code&quot;:&quot;QUICK_WAP_WAY&quot;}\">"));
Assert.IsTrue(response.Body.Contains("<input type=\"submit\" value=\"立即支付\" style=\"display:none\" >"));
Assert.IsTrue(response.Body.Contains("<script>document.forms[0].submit();</script>"));
}
[Test]
public void TestPayWithOptional()
{
Dictionary<string, object> optionalArgs = new Dictionary<string, object>
{
{ "timeout_express", "10m" },
{ "body", "iPhone6 16G"}
};
AlipayTradeWapPayResponse response = Factory.Payment.Wap()
.Agent("ca34ea491e7146cc87d25fca24c4cD11").BatchOptional(optionalArgs)
.Pay("iPhone6 16G", "b7f4bc7d-ea4b-4efd-9072-d8ea913c8946", "0.10",
"https://www.taobao.com", "https://www.taobao.com");
Assert.IsTrue(ResponseChecker.Success(response));
Assert.IsTrue(response.Body.Contains("<form name=\"punchout_form\" method=\"post\" "
+ "action=\"https://openapi.alipay.com/gateway.do?"));
Assert.IsTrue(response.Body.Contains("notify_url"));
Assert.IsTrue(response.Body.Contains("return_url"));
Assert.IsTrue(response.Body.Contains("app_auth_token"));
Assert.IsTrue(response.Body.Contains("timeout_express"));
Assert.IsTrue(response.Body.Contains("body"));
Assert.IsTrue(response.Body.Contains("<input type=\"hidden\" name=\"biz_content\" value=\"{&quot;subject&quot;:&quot;iPhone6 16G&quot;,&quot;out_trade_no&quot;:&quot;"
+ "b7f4bc7d-ea4b-4efd-9072-d8ea913c8946&quot;,&quot;total_amount&quot;:&quot;0.10&quot;,&quot;quit_url&quot;:&quot;"
+ "https://www.taobao.com&quot;,&quot;product_code&quot;:&quot;QUICK_WAP_WAY&quot;,&quot;timeout_express&quot;:&quot;"
+ "10m&quot;,&quot;body&quot;:&quot;iPhone6 16G&quot;}\">"));
Assert.IsTrue(response.Body.Contains("<input type=\"submit\" value=\"立即支付\" style=\"display:none\" >"));
Assert.IsTrue(response.Body.Contains("<script>document.forms[0].submit();</script>"));
}
}
}

View File

@@ -0,0 +1,31 @@
using NUnit.Framework;
using Alipay.EasySDK.Factory;
using Alipay.EasySDK.Security.TextRisk.Models;
using Alipay.EasySDK.Kernel.Util;
namespace UnitTest.Security.TextRisk
{
public class ClientTest
{
[SetUp]
public void SetUp()
{
Factory.SetOptions(TestAccount.Mini.CONFIG);
}
[Test]
public void TestDetect()
{
AlipaySecurityRiskContentDetectResponse response = Factory.Security.TextRisk().Detect("test");
Assert.IsTrue(ResponseChecker.Success(response));
Assert.AreEqual(response.Code, "10000");
Assert.AreEqual(response.Msg, "Success");
Assert.Null(response.SubCode);
Assert.Null(response.SubMsg);
Assert.NotNull(response.HttpBody);
Assert.AreEqual(response.Action, "PASSED");
Assert.NotNull(response.UniqueId);
}
}
}

View File

@@ -0,0 +1,87 @@
using System.Collections.Generic;
using System.IO;
using System;
using Alipay.EasySDK.Kernel;
using Newtonsoft.Json;
namespace UnitTest
{
public static class TestAccount
{
/// <summary>
/// 从文件中读取私钥
///
/// 注意:实际开发过程中,请务必注意不要将私钥信息配置在源码中(比如配置为常量或储存在配置文件的某个字段中等),因为私钥的保密等级往往比源码高得多,将会增加私钥泄露的风险。
/// 推荐将私钥信息储存在专用的私钥文件中,将私钥文件通过安全的流程分发到服务器的安全储存区域上,仅供自己的应用运行时读取。
/// </summary>
/// <param name="appId">私钥对应的APP_ID</param>
/// <returns>私钥字符串</returns>
private static string GetPrivateKey(string appId)
{
IDictionary<string, string> json = JsonConvert.DeserializeObject<IDictionary<string, string>>(
File.ReadAllText(GetSolutionBasePath() + "/UnitTest/Fixture/privateKey.json"));
return json[appId];
}
/// <summary>
/// 获取解决方案所在路径
/// </summary>
/// <returns>解决方案所在绝对路径</returns>
public static string GetSolutionBasePath()
{
string current = Directory.GetCurrentDirectory();
do
{
current = Directory.GetParent(current).ToString();
}
while (!current.EndsWith("bin", StringComparison.Ordinal));
return current + "/../..";
}
/// <summary>
/// 线上小程序测试账号
/// </summary>
public static class Mini
{
public static Config CONFIG = GetConfig();
public static Config GetConfig()
{
return new Config
{
Protocol = "https",
GatewayHost = "openapi.alipay.com",
AppId = "<-- 请填写您的AppId例如2019022663440152 -->",
SignType = "RSA2",
AlipayPublicKey = "<-- 请填写您的支付宝公钥例如MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAumX1EaLM4ddn1Pia4SxTRb62aVYxU8I2mHMqrc"
+ "pQU6F01mIO/DjY7R4xUWcLi0I2oH/BK/WhckEDCFsGrT7mO+JX8K4sfaWZx1aDGs0m25wOCNjp+DCVBXotXSCurqgGI/9UrY+"
+ "QydYDnsl4jB65M3p8VilF93MfS01omEDjUW+1MM4o3FP0khmcKsoHnYGs21btEeh0LK1gnnTDlou6Jwv3Ew36CbCNY2cYkuyP"
+ "AW0j47XqzhWJ7awAx60fwgNBq6ZOEPJnODqH20TAdTLNxPSl4qGxamjBO+RuInBy+Bc2hFHq3pNv6hTAfktggRKkKzDlDEUwg"
+ "SLE7d2eL7P6rwIDAQAB -->",
MerchantPrivateKey = GetPrivateKey("<-- 请填写您的AppId例如2019022663440152 -->"),
NotifyUrl = "<-- 请填写您的异步通知接收服务器地址例如https://www.test.com/callback"
};
}
}
/// <summary>
/// 线上生活号测试账号
/// </summary>
public static class OpenLife
{
public static Config CONFIG = new Config
{
Protocol = "https",
GatewayHost = "openapi.alipay.com",
AppId = "<-- 请填写您的AppId例如2019051064521003 -->",
SignType = "RSA2",
AlipayCertPath = "<-- 请填写您的支付宝公钥证书文件路径例如GetSolutionBasePath() + \"/UnitTest/Fixture/alipayCertPublicKey_RSA2.crt\" -->",
AlipayRootCertPath = "<-- 请填写您的支付宝根证书文件路径例如GetSolutionBasePath() + \"/UnitTest/Fixture/alipayRootCert.crt\" -->",
MerchantCertPath = "<-- 请填写您的应用公钥证书文件路径例如GetSolutionBasePath() + \"/UnitTest/Fixture/appCertPublicKey_2019051064521003.crt\" -->",
MerchantPrivateKey = GetPrivateKey("<-- 请填写您的AppId例如2019051064521003 -->")
};
}
}
}

Some files were not shown because too many files have changed in this diff Show More