@@ -1,48 +0,0 @@ | |||
# This workflow will build a golang project | |||
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go | |||
name: Run Tests | |||
on: | |||
push: | |||
branches: [ "main" ] | |||
pull_request: | |||
branches: [ "main" ] | |||
jobs: | |||
lint: | |||
runs-on: ubuntu-latest | |||
steps: | |||
- name: Checkout repository | |||
uses: actions/checkout@v4 | |||
- name: Set up Go | |||
uses: actions/setup-go@v5 | |||
with: | |||
go-version: '1.21' | |||
- name: Setup golangci-lint | |||
uses: golangci/golangci-lint-action@v6 | |||
with: | |||
version: latest | |||
args: -v --disable=unused | |||
test: | |||
needs: lint | |||
strategy: | |||
matrix: | |||
os: [ ubuntu-latest, macos-latest ] | |||
go: [ '1.21', '1.22' , '1.23' ] | |||
runs-on: ${{ matrix.os }} | |||
steps: | |||
- name: Checkout Code | |||
uses: actions/checkout@v4 | |||
- name: Set up Go ${{ matrix.go }} | |||
uses: actions/setup-go@v5 | |||
with: | |||
go-version: ${{ matrix.go }} | |||
- name: Test | |||
run: go test -v |
@@ -1,20 +0,0 @@ | |||
# idea ignore | |||
.idea/ | |||
.vscode/ | |||
.vendor/ | |||
*.ipr | |||
*.iml | |||
*.iws | |||
# system ignore | |||
.DS_Store | |||
Thumbs.db | |||
# temp ignore | |||
*.log | |||
*.cache | |||
*.diff | |||
*.exe | |||
*.patch | |||
*.tmp | |||
main |
@@ -1,201 +0,0 @@ | |||
Apache License | |||
Version 2.0, January 2004 | |||
http://www.apache.org/licenses/ | |||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION | |||
1. Definitions. | |||
"License" shall mean the terms and conditions for use, reproduction, | |||
and distribution as defined by Sections 1 through 9 of this document. | |||
"Licensor" shall mean the copyright owner or entity authorized by | |||
the copyright owner that is granting the License. | |||
"Legal Entity" shall mean the union of the acting entity and all | |||
other entities that control, are controlled by, or are under common | |||
control with that entity. For the purposes of this definition, | |||
"control" means (i) the power, direct or indirect, to cause the | |||
direction or management of such entity, whether by contract or | |||
otherwise, or (ii) ownership of fifty percent (50%) or more of the | |||
outstanding shares, or (iii) beneficial ownership of such entity. | |||
"You" (or "Your") shall mean an individual or Legal Entity | |||
exercising permissions granted by this License. | |||
"Source" form shall mean the preferred form for making modifications, | |||
including but not limited to software source code, documentation | |||
source, and configuration files. | |||
"Object" form shall mean any form resulting from mechanical | |||
transformation or translation of a Source form, including but | |||
not limited to compiled object code, generated documentation, | |||
and conversions to other media types. | |||
"Work" shall mean the work of authorship, whether in Source or | |||
Object form, made available under the License, as indicated by a | |||
copyright notice that is included in or attached to the work | |||
(an example is provided in the Appendix below). | |||
"Derivative Works" shall mean any work, whether in Source or Object | |||
form, that is based on (or derived from) the Work and for which the | |||
editorial revisions, annotations, elaborations, or other modifications | |||
represent, as a whole, an original work of authorship. For the purposes | |||
of this License, Derivative Works shall not include works that remain | |||
separable from, or merely link (or bind by name) to the interfaces of, | |||
the Work and Derivative Works thereof. | |||
"Contribution" shall mean any work of authorship, including | |||
the original version of the Work and any modifications or additions | |||
to that Work or Derivative Works thereof, that is intentionally | |||
submitted to Licensor for inclusion in the Work by the copyright owner | |||
or by an individual or Legal Entity authorized to submit on behalf of | |||
the copyright owner. For the purposes of this definition, "submitted" | |||
means any form of electronic, verbal, or written communication sent | |||
to the Licensor or its representatives, including but not limited to | |||
communication on electronic mailing lists, source code control systems, | |||
and issue tracking systems that are managed by, or on behalf of, the | |||
Licensor for the purpose of discussing and improving the Work, but | |||
excluding communication that is conspicuously marked or otherwise | |||
designated in writing by the copyright owner as "Not a Contribution." | |||
"Contributor" shall mean Licensor and any individual or Legal Entity | |||
on behalf of whom a Contribution has been received by Licensor and | |||
subsequently incorporated within the Work. | |||
2. Grant of Copyright License. Subject to the terms and conditions of | |||
this License, each Contributor hereby grants to You a perpetual, | |||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable | |||
copyright license to reproduce, prepare Derivative Works of, | |||
publicly display, publicly perform, sublicense, and distribute the | |||
Work and such Derivative Works in Source or Object form. | |||
3. Grant of Patent License. Subject to the terms and conditions of | |||
this License, each Contributor hereby grants to You a perpetual, | |||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable | |||
(except as stated in this section) patent license to make, have made, | |||
use, offer to sell, sell, import, and otherwise transfer the Work, | |||
where such license applies only to those patent claims licensable | |||
by such Contributor that are necessarily infringed by their | |||
Contribution(s) alone or by combination of their Contribution(s) | |||
with the Work to which such Contribution(s) was submitted. If You | |||
institute patent litigation against any entity (including a | |||
cross-claim or counterclaim in a lawsuit) alleging that the Work | |||
or a Contribution incorporated within the Work constitutes direct | |||
or contributory patent infringement, then any patent licenses | |||
granted to You under this License for that Work shall terminate | |||
as of the date such litigation is filed. | |||
4. Redistribution. You may reproduce and distribute copies of the | |||
Work or Derivative Works thereof in any medium, with or without | |||
modifications, and in Source or Object form, provided that You | |||
meet the following conditions: | |||
(a) You must give any other recipients of the Work or | |||
Derivative Works a copy of this License; and | |||
(b) You must cause any modified files to carry prominent notices | |||
stating that You changed the files; and | |||
(c) You must retain, in the Source form of any Derivative Works | |||
that You distribute, all copyright, patent, trademark, and | |||
attribution notices from the Source form of the Work, | |||
excluding those notices that do not pertain to any part of | |||
the Derivative Works; and | |||
(d) If the Work includes a "NOTICE" text file as part of its | |||
distribution, then any Derivative Works that You distribute must | |||
include a readable copy of the attribution notices contained | |||
within such NOTICE file, excluding those notices that do not | |||
pertain to any part of the Derivative Works, in at least one | |||
of the following places: within a NOTICE text file distributed | |||
as part of the Derivative Works; within the Source form or | |||
documentation, if provided along with the Derivative Works; or, | |||
within a display generated by the Derivative Works, if and | |||
wherever such third-party notices normally appear. The contents | |||
of the NOTICE file are for informational purposes only and | |||
do not modify the License. You may add Your own attribution | |||
notices within Derivative Works that You distribute, alongside | |||
or as an addendum to the NOTICE text from the Work, provided | |||
that such additional attribution notices cannot be construed | |||
as modifying the License. | |||
You may add Your own copyright statement to Your modifications and | |||
may provide additional or different license terms and conditions | |||
for use, reproduction, or distribution of Your modifications, or | |||
for any such Derivative Works as a whole, provided Your use, | |||
reproduction, and distribution of the Work otherwise complies with | |||
the conditions stated in this License. | |||
5. Submission of Contributions. Unless You explicitly state otherwise, | |||
any Contribution intentionally submitted for inclusion in the Work | |||
by You to the Licensor shall be under the terms and conditions of | |||
this License, without any additional terms or conditions. | |||
Notwithstanding the above, nothing herein shall supersede or modify | |||
the terms of any separate license agreement you may have executed | |||
with Licensor regarding such Contributions. | |||
6. Trademarks. This License does not grant permission to use the trade | |||
names, trademarks, service marks, or product names of the Licensor, | |||
except as required for reasonable and customary use in describing the | |||
origin of the Work and reproducing the content of the NOTICE file. | |||
7. Disclaimer of Warranty. Unless required by applicable law or | |||
agreed to in writing, Licensor provides the Work (and each | |||
Contributor provides its Contributions) on an "AS IS" BASIS, | |||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or | |||
implied, including, without limitation, any warranties or conditions | |||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A | |||
PARTICULAR PURPOSE. You are solely responsible for determining the | |||
appropriateness of using or redistributing the Work and assume any | |||
risks associated with Your exercise of permissions under this License. | |||
8. Limitation of Liability. In no event and under no legal theory, | |||
whether in tort (including negligence), contract, or otherwise, | |||
unless required by applicable law (such as deliberate and grossly | |||
negligent acts) or agreed to in writing, shall any Contributor be | |||
liable to You for damages, including any direct, indirect, special, | |||
incidental, or consequential damages of any character arising as a | |||
result of this License or out of the use or inability to use the | |||
Work (including but not limited to damages for loss of goodwill, | |||
work stoppage, computer failure or malfunction, or any and all | |||
other commercial damages or losses), even if such Contributor | |||
has been advised of the possibility of such damages. | |||
9. Accepting Warranty or Additional Liability. While redistributing | |||
the Work or Derivative Works thereof, You may choose to offer, | |||
and charge a fee for, acceptance of support, warranty, indemnity, | |||
or other liability obligations and/or rights consistent with this | |||
License. However, in accepting such obligations, You may act only | |||
on Your own behalf and on Your sole responsibility, not on behalf | |||
of any other Contributor, and only if You agree to indemnify, | |||
defend, and hold each Contributor harmless for any liability | |||
incurred by, or claims asserted against, such Contributor by reason | |||
of your accepting any such warranty or additional liability. | |||
END OF TERMS AND CONDITIONS | |||
APPENDIX: How to apply the Apache License to your work. | |||
To apply the Apache License to your work, attach the following | |||
boilerplate notice, with the fields enclosed by brackets "[]" | |||
replaced with your own identifying information. (Don't include | |||
the brackets!) The text should be enclosed in the appropriate | |||
comment syntax for the file format. We also recommend that a | |||
file or class name and description of purpose be included on the | |||
same "printed page" as the copyright notice for easier | |||
identification within third-party archives. | |||
Copyright 2019 Jerry | |||
Licensed under the Apache License, Version 2.0 (the "License"); | |||
you may not use this file except in compliance with the License. | |||
You may obtain a copy of the License at | |||
http://www.apache.org/licenses/LICENSE-2.0 | |||
Unless required by applicable law or agreed to in writing, software | |||
distributed under the License is distributed on an "AS IS" BASIS, | |||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||
See the License for the specific language governing permissions and | |||
limitations under the License. |
@@ -1,113 +0,0 @@ | |||
<div align=center><img width="240" height="240" alt="Logo was Loading Faild!" src="logo.png"/></div> | |||
# GoPay | |||
### 微信、支付宝、QQ、通联支付、拉卡拉、PayPal 的 Golang 版本SDK | |||
[![Github](https://img.shields.io/github/followers/iGoogle-ink?label=Follow&style=social)](https://github.com/iGoogle-ink) | |||
[![Github](https://img.shields.io/github/forks/go-pay/gopay?label=Fork&style=social)](https://github.com/go-pay/gopay/fork) | |||
[![Golang](https://img.shields.io/badge/golang-1.21-brightgreen.svg)](https://golang.google.cn) | |||
[![GoDoc](https://img.shields.io/badge/doc-pkg.go.dev-informational.svg)](https://pkg.go.dev/github.com/go-pay/gopay) | |||
[![Go](https://github.com/go-pay/gopay/actions/workflows/go.yml/badge.svg)](https://github.com/go-pay/gopay/actions/workflows/go.yml) | |||
[![GitHub Release](https://img.shields.io/github/v/release/go-pay/gopay)](https://github.com/go-pay/gopay/releases) | |||
[![License](https://img.shields.io/github/license/go-pay/gopay)](https://www.apache.org/licenses/LICENSE-2.0) | |||
[![Go Report Card](https://goreportcard.com/badge/github.com/go-pay/gopay)](https://goreportcard.com/report/github.com/go-pay/gopay) | |||
# 一、安装 | |||
```bash | |||
go get -u github.com/go-pay/gopay | |||
``` | |||
#### 查看 GoPay 版本 | |||
[版本更新记录](https://github.com/go-pay/gopay/blob/main/release_note.txt) | |||
```go | |||
import ( | |||
"github.com/go-pay/gopay" | |||
"github.com/go-pay/xlog" | |||
) | |||
func main() { | |||
xlog.Info("GoPay Version: ", gopay.Version) | |||
} | |||
``` | |||
<br> | |||
# 二、文档目录 | |||
> ### 点击查看不同支付方式的使用文档。方便的话,请留下您认可的小星星,十分感谢! | |||
* #### [支付宝支付(V3版)](https://github.com/go-pay/gopay/blob/main/doc/alipay_v3.md) | |||
* #### [支付宝支付](https://github.com/go-pay/gopay/blob/main/doc/alipay.md) | |||
* #### [微信支付(V3版)](https://github.com/go-pay/gopay/blob/main/doc/wechat_v3.md) | |||
* #### [微信支付(V2版,不推荐)](https://github.com/go-pay/gopay/blob/main/doc/wechat_v2.md) | |||
* #### [QQ支付](https://github.com/go-pay/gopay/blob/main/doc/qq.md) | |||
* #### [通联支付](https://github.com/go-pay/gopay/blob/main/doc/allinpay.md) | |||
* #### [拉卡拉支付](https://github.com/go-pay/gopay/blob/main/doc/lakala.md) | |||
* #### [Paypal支付](https://github.com/go-pay/gopay/blob/main/doc/paypal.md) | |||
* #### [Apple支付校验](https://github.com/go-pay/gopay/blob/main/doc/apple.md) | |||
* #### [扫呗支付](https://github.com/go-pay/gopay/blob/main/doc/saobei.md) | |||
<br> | |||
# 三、其他说明 | |||
* 如需自定义Log输出,New Client 后,调用 `client.SetLogger()` 方法设置自定义Logger,自定义Logger实现 `xlog.XLogger` interface即可。 | |||
* 各支付方式接入,请仔细查看 `xxx_test.go` 使用方式 | |||
* `gopay/wechat/v3/client_test.go` | |||
* `gopay/alipay/v3/client_test.go` | |||
* `gopay/alipay/client_test.go` | |||
* `gopay/qq/client_test.go` | |||
* `gopay/allinpay/client_test.go` | |||
* `gopay/lakala/client_test.go` | |||
* `gopay/paypal/client_test.go` | |||
* `gopay/apple/verify_test.go` | |||
* 或 examples | |||
* 接入gopay示例项目(可参考接入使用方式):[gopay-platform](https://github.com/go-pay/gopay-platform) | |||
* 有问题请加微信群 或 抖音关注并私信拉微信群。在此,非常感谢提出宝贵意见和反馈问题的同志们! | |||
* 开发过程中,请尽量使用正式环境,1分钱测试法! | |||
* 有偿承接技术咨询、开发,如需要加微信联系。 | |||
<br> | |||
## 赞赏多少是您的心意,感谢支持! | |||
微信赞赏码: <img width="200" height="200" src=".github/zanshang.png"/> | |||
支付宝赞助码: <img width="200" height="200" src=".github/zanshang_zfb.png"/> | |||
## 讨论群 | |||
> 抖音关注(需要1000+粉丝量)私信获取微信群二维码 | |||
抖音关注私信拉群: | |||
<img width="240" height="240" src=".github/douyin_jerry.png"/> | |||
微信群: | |||
<img width="240" height="240" src=".github/wx_gopay.png"/> | |||
<br> | |||
## 鸣谢 | |||
> [GoLand](https://www.jetbrains.com/go/?from=gopay) A Go IDE with extended support for JavaScript, TypeScript, and Databases。 | |||
特别感谢 [JetBrains](https://www.jetbrains.com/?from=gopay) 为开源项目提供免费的 [GoLand](https://www.jetbrains.com/go/?from=gopay) 等 IDE 的授权 | |||
<br> | |||
[<img src=".github/jetbrains.png" width="300"/>](https://www.jetbrains.com/?from=gopay) | |||
> Copyright © 2000-2024 JetBrains s.r.o. JetBrains and the JetBrains logo are registered trademarks of JetBrains s.r.o. |
@@ -1,225 +0,0 @@ | |||
package alipay | |||
import ( | |||
"context" | |||
"encoding/json" | |||
"fmt" | |||
"github.com/go-pay/gopay" | |||
) | |||
// ant.merchant.expand.shop.modify(修改蚂蚁店铺) | |||
// 文档地址:https://opendocs.alipay.com/apis/014tmb | |||
func (a *Client) AntMerchantShopModify(ctx context.Context, bm gopay.BodyMap) (aliRsp *AntMerchantShopModifyRsp, err error) { | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "ant.merchant.expand.shop.modify"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(AntMerchantShopModifyRsp) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// ant.merchant.expand.shop.create(蚂蚁店铺创建) | |||
// 文档地址:https://opendocs.alipay.com/apis/api_1/ant.merchant.expand.shop.create | |||
func (a *Client) AntMerchantShopCreate(ctx context.Context, bm gopay.BodyMap) (aliRsp *AntMerchantShopCreateRsp, err error) { | |||
err = bm.CheckEmptyError("business_address", "shop_category", "store_id", "shop_type", "ip_role_id", "shop_name") | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "ant.merchant.expand.shop.create"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(AntMerchantShopCreateRsp) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// ant.merchant.expand.shop.consult(蚂蚁店铺创建咨询) | |||
// 文档地址:https://opendocs.alipay.com/apis/014yig | |||
func (a *Client) AntMerchantShopConsult(ctx context.Context, bm gopay.BodyMap) (aliRsp *AntMerchantShopConsultRsp, err error) { | |||
err = bm.CheckEmptyError("business_address", "shop_category", "store_id", "shop_type", "ip_role_id", "shop_name") | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "ant.merchant.expand.shop.consult"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(AntMerchantShopConsultRsp) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// ant.merchant.expand.order.query(商户申请单查询) | |||
// 文档地址:https://opendocs.alipay.com/apis/api_1/ant.merchant.expand.order.query | |||
func (a *Client) AntMerchantOrderQuery(ctx context.Context, bm gopay.BodyMap) (aliRsp *AntMerchantOrderQueryRsp, err error) { | |||
err = bm.CheckEmptyError("order_id") | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "ant.merchant.expand.order.query"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(AntMerchantOrderQueryRsp) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// ant.merchant.expand.shop.query(店铺查询接口) | |||
// 文档地址:https://opendocs.alipay.com/apis/api_1/ant.merchant.expand.shop.query | |||
func (a *Client) AntMerchantShopQuery(ctx context.Context, bm gopay.BodyMap) (aliRsp *AntMerchantShopQueryRsp, err error) { | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "ant.merchant.expand.shop.query"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(AntMerchantShopQueryRsp) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// ant.merchant.expand.shop.page.query(店铺分页查询接口) | |||
// 文档地址:https://opendocs.alipay.com/open/04fgwq | |||
func (a *Client) AntMerchantShopPageQuery(ctx context.Context, bm gopay.BodyMap) (aliRsp *AntMerchantShopPageQueryRsp, err error) { | |||
err = bm.CheckEmptyError("ip_role_id", "page_num", "page_size") | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "ant.merchant.expand.shop.page.query"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(AntMerchantShopPageQueryRsp) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// ant.merchant.expand.shop.close(蚂蚁店铺关闭) | |||
// 文档地址:https://opendocs.alipay.com/apis/api_1/ant.merchant.expand.shop.close | |||
func (a *Client) AntMerchantShopClose(ctx context.Context, bm gopay.BodyMap) (aliRsp *AntMerchantShopCloseRsp, err error) { | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "ant.merchant.expand.shop.close"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(AntMerchantShopCloseRsp) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// ant.merchant.expand.indirect.image.upload(图片上传) | |||
// bm参数中 image_content 可不传,file为必传参数 | |||
// 文档地址:https://opendocs.alipay.com/open/04fgwt | |||
func (a *Client) AntMerchantExpandIndirectImageUpload(ctx context.Context, bm gopay.BodyMap) (aliRsp *AntMerchantExpandIndirectImageUploadRsp, err error) { | |||
err = bm.CheckEmptyError("image_type", "image_content") | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = a.FileUploadRequest(ctx, bm, "ant.merchant.expand.indirect.image.upload"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(AntMerchantExpandIndirectImageUploadRsp) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil { | |||
return nil, err | |||
} | |||
if aliRsp.Response != nil && aliRsp.Response.Code != "10000" { | |||
info := aliRsp.Response | |||
return aliRsp, fmt.Errorf(`{"code":"%s","msg":"%s","sub_code":"%s","sub_msg":"%s"}`, info.Code, info.Msg, info.SubCode, info.SubMsg) | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// ant.merchant.expand.mcc.query(商户mcc信息查询) | |||
// 文档地址:https://opendocs.alipay.com/open/04fgwu | |||
func (a *Client) AntMerchantExpandMccQuery(ctx context.Context, bm gopay.BodyMap) (aliRsp *AntMerchantExpandMccQueryRsp, err error) { | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "ant.merchant.expand.mcc.query"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(AntMerchantExpandMccQueryRsp) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// ant.merchant.expand.shop.receiptaccount.save(店铺增加收单账号) | |||
// 文档地址:https://opendocs.alipay.com/open/54b69b89_ant.merchant.expand.shop.receiptaccount.save | |||
func (a *Client) AntMerchantExpandShopReceiptAccountSave(ctx context.Context, bm gopay.BodyMap) (aliRsp *AntMerchantExpandShopReceiptAccountSaveRsp, err error) { | |||
err = bm.CheckEmptyError("shop_id", "receipt_account_id") | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "ant.merchant.expand.shop.receiptaccount.save"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(AntMerchantExpandShopReceiptAccountSaveRsp) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} |
@@ -1,144 +0,0 @@ | |||
package alipay | |||
import ( | |||
"io" | |||
"os" | |||
"testing" | |||
"github.com/go-pay/gopay" | |||
"github.com/go-pay/xlog" | |||
) | |||
func TestAntMerchantShopModify(t *testing.T) { | |||
// 请求参数 | |||
bm := make(gopay.BodyMap) | |||
aliRsp, err := client.AntMerchantShopModify(ctx, bm) | |||
if err != nil { | |||
xlog.Errorf("client.AntMerchantShopModify(%+v),error:%+v", bm, err) | |||
return | |||
} | |||
xlog.Debug("aliRsp:", *aliRsp) | |||
} | |||
func TestAntMerchantShopCreate(t *testing.T) { | |||
// 请求参数 | |||
bm := make(gopay.BodyMap) | |||
bm.SetBodyMap("business_address", func(bm gopay.BodyMap) { | |||
bm.Set("city_code", "37100") | |||
bm.Set("district_code", "371002") | |||
bm.Set("address", "万塘路18号黄龙时代广场B座") | |||
bm.Set("province_code", "310000") | |||
}) | |||
bm.Set("shop_category", "B0001") | |||
bm.Set("store_id", "NO0001") | |||
bm.Set("shop_type", "01") | |||
bm.Set("ip_role_id", "2088301155943087") | |||
bm.Set("shop_name", "肯德基中关村店") | |||
aliRsp, err := client.AntMerchantShopCreate(ctx, bm) | |||
if err != nil { | |||
if bizErr, ok := IsBizError(err); ok { | |||
xlog.Errorf("%+v", bizErr) | |||
// do something | |||
return | |||
} | |||
xlog.Errorf("client.AntMerchantShopCreate(%+v),error:%+v", bm, err) | |||
return | |||
} | |||
xlog.Debug("aliRsp:", *aliRsp) | |||
} | |||
func TestAntMerchantShopConsult(t *testing.T) { | |||
// 请求参数 | |||
bm := make(gopay.BodyMap) | |||
bm.SetBodyMap("business_address", func(bm gopay.BodyMap) { | |||
bm.Set("city_code", "37100") | |||
bm.Set("district_code", "371002") | |||
bm.Set("address", "万塘路18号黄龙时代广场B座") | |||
bm.Set("province_code", "310000") | |||
}) | |||
bm.Set("shop_category", "B0001") | |||
bm.Set("store_id", "NO0001") | |||
bm.Set("shop_type", "01") | |||
bm.Set("ip_role_id", "2088301155943087") | |||
bm.Set("shop_name", "肯德基中关村店") | |||
aliRsp, err := client.AntMerchantShopConsult(ctx, bm) | |||
if err != nil { | |||
xlog.Errorf("client.AntMerchantShopConsult(%+v),error:%+v", bm, err) | |||
return | |||
} | |||
xlog.Debug("aliRsp:", *aliRsp) | |||
} | |||
func TestAntMerchantOrderQuery(t *testing.T) { | |||
// 请求参数 | |||
bm := make(gopay.BodyMap) | |||
bm.Set("order_id", "2017112200502000000004754299") | |||
aliRsp, err := client.AntMerchantOrderQuery(ctx, bm) | |||
if err != nil { | |||
xlog.Errorf("client.AntMerchantOrderQuery(%+v),error:%+v", bm, err) | |||
return | |||
} | |||
xlog.Debug("aliRsp:", *aliRsp) | |||
} | |||
func TestAntMerchantShopQuery(t *testing.T) { | |||
// 请求参数 | |||
bm := make(gopay.BodyMap) | |||
bm.Set("shop_id", "2018011900502000000005124744") | |||
bm.Set("store_id", "NO0001") | |||
bm.Set("ip_role_id", "2088301155943087") | |||
aliRsp, err := client.AntMerchantShopQuery(ctx, bm) | |||
if err != nil { | |||
xlog.Errorf("client.AntMerchantShopQuery(%+v),error:%+v", bm, err) | |||
return | |||
} | |||
xlog.Debug("aliRsp:", *aliRsp) | |||
} | |||
func TestAntMerchantShopClose(t *testing.T) { | |||
// 请求参数 | |||
bm := make(gopay.BodyMap) | |||
bm.Set("shop_id", "2018011900502000000005124744") | |||
bm.Set("store_id", "NO0001") | |||
bm.Set("ip_role_id", "2088301155943087") | |||
aliRsp, err := client.AntMerchantShopClose(ctx, bm) | |||
if err != nil { | |||
xlog.Errorf("client.AntMerchantShopClose(%+v),error:%+v", bm, err) | |||
return | |||
} | |||
xlog.Debug("aliRsp:", *aliRsp) | |||
} | |||
func TestAntMerchantExpandIndirectImageUpload(t *testing.T) { | |||
// 请求参数 | |||
logo, err := os.Open("../logo.png") | |||
if err != nil { | |||
xlog.Errorf("os.Open(%s),error:%+v", "../logo.png", err) | |||
return | |||
} | |||
xlog.Warnf("fileName: %s", logo.Name()) | |||
allBs, err := io.ReadAll(logo) | |||
if err != nil { | |||
xlog.Errorf("io.ReadAll(%s),error:%+v", logo.Name(), err) | |||
return | |||
} | |||
f := &gopay.File{ | |||
Name: "logo.png", | |||
Content: allBs, | |||
} | |||
bm := make(gopay.BodyMap) | |||
bm.Set("image_type", "png") | |||
bm.SetFormFile("image_content", f) | |||
aliRsp, err := client.AntMerchantExpandIndirectImageUpload(ctx, bm) | |||
if err != nil { | |||
xlog.Errorf("client.AntMerchantExpandIndirectImageUpload(),error:%+v", err) | |||
return | |||
} | |||
xlog.Debug("aliRsp:", *aliRsp) | |||
} |
@@ -1,38 +0,0 @@ | |||
MIIDszCCApugAwIBAgIQICMGCYNKwsloIKi8XMlUgzANBgkqhkiG9w0BAQsFADCBkTELMAkGA1UE | |||
BhMCQ04xGzAZBgNVBAoMEkFudCBGaW5hbmNpYWwgdGVzdDElMCMGA1UECwwcQ2VydGlmaWNhdGlv | |||
biBBdXRob3JpdHkgdGVzdDE+MDwGA1UEAww1QW50IEZpbmFuY2lhbCBDZXJ0aWZpY2F0aW9uIEF1 | |||
dGhvcml0eSBDbGFzcyAyIFIxIHRlc3QwHhcNMjMwNjA5MTI1MjAzWhcNMjQwNjA4MTI1MjAzWjCB | |||
hDELMAkGA1UEBhMCQ04xHzAdBgNVBAoMFmxhZ21pczYyNTRAc2FuZGJveC5jb20xDzANBgNVBAsM | |||
BkFsaXBheTFDMEEGA1UEAww65pSv5LuY5a6dKOS4reWbvSnnvZHnu5zmioDmnK/mnInpmZDlhazl | |||
j7gtMjA4ODcyMTAwMzIzNjQ0MjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAJN/z9yl | |||
+66sFRDJG2ZWPND6gSsTR7DAeKucCm6SlNimX3w4opVd2z6Rz5tcB2iRyh7nZoq1Vo5+uZSLKaiD | |||
IAOEaFNwn9LBLPDH/WgM79BeOygFm9qAYQ8kHGBrR37Sxu6tphgWpVyu0yVlgNvgwdlALX2RCwUW | |||
lYbGhe2wpBndxo00lwWXMlwEoYJx/eAu8k69iEW7/kp8HnU3Qih8V76D0bwAcpTvSq8fDIsiRAgQ | |||
X0EnAOu0rC/hNTCojFXTKJs5UxEO1tFBALc5huGkTM0qd9C4IIrdcR+xysjloEhN18tC0+/FSm6h | |||
kbggE+iE+QAPY6kgGzgX7e4oCRZM/bMCAwEAAaMSMBAwDgYDVR0PAQH/BAQDAgTwMA0GCSqGSIb3 | |||
DQEBCwUAA4IBAQCcCBpLhvl+6fO21kJvL+FIaWgAoCpLuQGQYS1cX9pn+BNHNL8Ur2i0Se7IkL4z | |||
USM4ETULw6RtzoARgIlpSbpSQkZOvyUysOv+ou5rmhUZGtSA2BHwoTHoNWdpmlbps61v7AjQeZTX | |||
rhzdJ7ipLutSNsFiQf0TRjshq79wpIFPwsDO68hrDx6QTMlFqW0/uXv7dERDac9uemCBvePeJVrt | |||
xhqFXuzE5ZvgtuFXW9pIeXwq7B4xNuwfpXQWdxAPyo2Up//0wJdy90gtfESfO8fCYATPtptnB4lP | |||
KHqoqQsuV3xw2P4o/+pmMBgj6hhhoZILLNUJ2Il9PgLEkvkCwRXR | |||
MIIDszCCApugAwIBAgIQIBkIGbgVxq210KxLJ+YA/TANBgkqhkiG9w0BAQsFADCBhDELMAkGA1UE | |||
BhMCQ04xFjAUBgNVBAoMDUFudCBGaW5hbmNpYWwxJTAjBgNVBAsMHENlcnRpZmljYXRpb24gQXV0 | |||
aG9yaXR5IHRlc3QxNjA0BgNVBAMMLUFudCBGaW5hbmNpYWwgQ2VydGlmaWNhdGlvbiBBdXRob3Jp | |||
dHkgUjEgdGVzdDAeFw0xOTA4MTkxMTE2MDBaFw0yNDA4MDExMTE2MDBaMIGRMQswCQYDVQQGEwJD | |||
TjEbMBkGA1UECgwSQW50IEZpbmFuY2lhbCB0ZXN0MSUwIwYDVQQLDBxDZXJ0aWZpY2F0aW9uIEF1 | |||
dGhvcml0eSB0ZXN0MT4wPAYDVQQDDDVBbnQgRmluYW5jaWFsIENlcnRpZmljYXRpb24gQXV0aG9y | |||
aXR5IENsYXNzIDIgUjEgdGVzdDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAMh4FKYO | |||
ZyRQHD6eFbPKZeSAnrfjfU7xmS9Yoozuu+iuqZlb6Z0SPLUqqTZAFZejOcmr07ln/pwZxluqplxC | |||
5+B48End4nclDMlT5HPrDr3W0frs6Xsa2ZNcyil/iKNB5MbGll8LRAxntsKvZZj6vUTMb705gYgm | |||
VUMILwi/ZxKTQqBtkT/kQQ5y6nOZsj7XI5rYdz6qqOROrpvS/d7iypdHOMIM9Iz9DlL1mrCykbBi | |||
t25y+gTeXmuisHUwqaRpwtCGK4BayCqxRGbNipe6W73EK9lBrrzNtTr9NaysesT/v+l25JHCL9tG | |||
wpNr1oWFzk4IHVOg0ORiQ6SUgxZUTYcCAwEAAaMSMBAwDgYDVR0PAQH/BAQDAgTwMA0GCSqGSIb3 | |||
DQEBCwUAA4IBAQBWThEoIaQoBX2YeRY/I8gu6TYnFXtyuCljANnXnM38ft+ikhE5mMNgKmJYLHvT | |||
yWWWgwHoSAWEuml7EGbE/2AK2h3k0MdfiWLzdmpPCRG/RJHk6UB1pMHPilI+c0MVu16OPpKbg5Vf | |||
LTv7dsAB40AzKsvyYw88/Ezi1osTXo6QQwda7uefvudirtb8FcQM9R66cJxl3kt1FXbpYwheIm/p | |||
j1mq64swCoIYu4NrsUYtn6CV542DTQMI5QdXkn+PzUUly8F6kDp+KpMNd0avfWNL5+O++z+F5Szy | |||
1CPta1D7EQ/eYmMP+mOQ35oifWIoFCpN6qQVBS/Hob1J/UUyg7BW |
@@ -1,88 +0,0 @@ | |||
MIIBszCCAVegAwIBAgIIaeL+wBcKxnswDAYIKoEcz1UBg3UFADAuMQswCQYDVQQG | |||
EwJDTjEOMAwGA1UECgwFTlJDQUMxDzANBgNVBAMMBlJPT1RDQTAeFw0xMjA3MTQw | |||
MzExNTlaFw00MjA3MDcwMzExNTlaMC4xCzAJBgNVBAYTAkNOMQ4wDAYDVQQKDAVO | |||
UkNBQzEPMA0GA1UEAwwGUk9PVENBMFkwEwYHKoZIzj0CAQYIKoEcz1UBgi0DQgAE | |||
MPCca6pmgcchsTf2UnBeL9rtp4nw+itk1Kzrmbnqo05lUwkwlWK+4OIrtFdAqnRT | |||
V7Q9v1htkv42TsIutzd126NdMFswHwYDVR0jBBgwFoAUTDKxl9kzG8SmBcHG5Yti | |||
W/CXdlgwDAYDVR0TBAUwAwEB/zALBgNVHQ8EBAMCAQYwHQYDVR0OBBYEFEwysZfZ | |||
MxvEpgXBxuWLYlvwl3ZYMAwGCCqBHM9VAYN1BQADSAAwRQIgG1bSLeOXp3oB8H7b | |||
53W+CKOPl2PknmWEq/lMhtn25HkCIQDaHDgWxWFtnCrBjH16/W3Ezn7/U/Vjo5xI | |||
pDoiVhsLwg== | |||
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== | |||
MIICiDCCAgygAwIBAgIIQX76UsB/30owDAYIKoZIzj0EAwMFADB6MQswCQYDVQQG | |||
EwJDTjEWMBQGA1UECgwNQW50IEZpbmFuY2lhbDEgMB4GA1UECwwXQ2VydGlmaWNh | |||
dGlvbiBBdXRob3JpdHkxMTAvBgNVBAMMKEFudCBGaW5hbmNpYWwgQ2VydGlmaWNh | |||
dGlvbiBBdXRob3JpdHkgRTEwHhcNMTkwNDI4MTYyMDQ0WhcNNDkwNDIwMTYyMDQ0 | |||
WjB6MQswCQYDVQQGEwJDTjEWMBQGA1UECgwNQW50IEZpbmFuY2lhbDEgMB4GA1UE | |||
CwwXQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkxMTAvBgNVBAMMKEFudCBGaW5hbmNp | |||
YWwgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkgRTEwdjAQBgcqhkjOPQIBBgUrgQQA | |||
IgNiAASCCRa94QI0vR5Up9Yr9HEupz6hSoyjySYqo7v837KnmjveUIUNiuC9pWAU | |||
WP3jwLX3HkzeiNdeg22a0IZPoSUCpasufiLAnfXh6NInLiWBrjLJXDSGaY7vaokt | |||
rpZvAdmjXTBbMAsGA1UdDwQEAwIBBjAMBgNVHRMEBTADAQH/MB0GA1UdDgQWBBRZ | |||
4ZTgDpksHL2qcpkFkxD2zVd16TAfBgNVHSMEGDAWgBRZ4ZTgDpksHL2qcpkFkxD2 | |||
zVd16TAMBggqhkjOPQQDAwUAA2gAMGUCMQD4IoqT2hTUn0jt7oXLdMJ8q4vLp6sg | |||
wHfPiOr9gxreb+e6Oidwd2LDnC4OUqCWiF8CMAzwKs4SnDJYcMLf2vpkbuVE4dTH | |||
Rglz+HGcTLWsFs4KxLsq7MuU+vJTBUeDJeDjdA== | |||
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 |
@@ -1,19 +0,0 @@ | |||
MIIDmTCCAoGgAwIBAgIQICMGCXK2Am4QGbc/5Yi2QjANBgkqhkiG9w0BAQsFADCBkTELMAkGA1UE | |||
BhMCQ04xGzAZBgNVBAoMEkFudCBGaW5hbmNpYWwgdGVzdDElMCMGA1UECwwcQ2VydGlmaWNhdGlv | |||
biBBdXRob3JpdHkgdGVzdDE+MDwGA1UEAww1QW50IEZpbmFuY2lhbCBDZXJ0aWZpY2F0aW9uIEF1 | |||
dGhvcml0eSBDbGFzcyAyIFIxIHRlc3QwHhcNMjMwNjA5MTI1MjAyWhcNMjQwNjEzMTI1MjAyWjBr | |||
MQswCQYDVQQGEwJDTjEfMB0GA1UECgwWbGFnbWlzNjI1NEBzYW5kYm94LmNvbTEPMA0GA1UECwwG | |||
QWxpcGF5MSowKAYDVQQDDCEyMDg4NzIxMDAzMjM2NDQyLTIwMjEwMDAxMjI2NzIzODgwggEiMA0G | |||
CSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDDTHpBfR55b5dE2Hi78EbVGzK5hiweap6eTgas9XwS | |||
WtQQ3qctHBJcZIgi4i7IKjS3izAI2n1DniD4BSakB114EJiEcqsBgbifXUyddRiiwR7jfDNSF3s9 | |||
penFy0WVIqEWBgGJftxCD87xOEcknQfRDL6T000naAyd8/KmT3/jcOy0eYoRVC+BClyCeGVsrxfi | |||
2EgrjNbTHAeAOFIB5m71Au9/9xzY90qZ3nGJRQzsns+3BPtW9sojbt9g4F7WHHGu+ljq9wYYZqXz | |||
GE04oP56KpcCA+AhFi5eouk+Bpg4iaOecf2UinOOsI7SextrVPi2icOOnmO/QVpIrA5MCM7pAgMB | |||
AAGjEjAQMA4GA1UdDwEB/wQEAwIE8DANBgkqhkiG9w0BAQsFAAOCAQEAZc2RyiGKftnKi/0zIUUl | |||
xKDPyUdVBBYDagcraHROKXafsZEnhO/cdBPC3VAJEiygNvddB51l088cGb8pGS2VqTQqR/Ehmd1x | |||
kLMleWlUocX0Mwctz/J6jNp9/JKcVe1jk492HR7Csqjf+hvsajIVliIWzuhzB7C0eNEb46Js/G8T | |||
QmsX92eHI0r2pcmsVr+PmDioLu4H4miKrDRhXNXLQ2AQfxPOCOtxt0tSNrB97bDNSwB1O4OItmr/ | |||
Cimb7l1nqxY3BOY5o8iAWLv4wG4giYu9LSrEJW0nWa2JG059kMlWLSVe7Afx0GzMVQUP6NJNdulP | |||
ddebveu2CNZcJ7ipbA== |
@@ -1,162 +0,0 @@ | |||
package cert | |||
var ( | |||
Appid = "2021000122672388" | |||
// 应用私钥 | |||
PrivateKey = "MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQC3DCgphWsp4OyB5pxF7ImUHHC7luATNfACFiK9qCvMRX1Ot0j4Ll64HUwVWaTfYbS00QyWPZLxwmGIAvh0y+9odu699oAb047p1XG1Q5eQa4qYrlxKGDeGUdWjK0C8qqeVHMAa8FK3xGukPYNersUbQ5E/eQqD7o6m51xR8AzhZ1lwWdW6PPAN51sH9o/MSvGZTmYAOWsErhSKZ0Eb613oG/rfxrvuBH3tFAqHva/cjNPznukieWCHrD5OUXlM48MEK2Ht8rFXs2HG6ZDdMNUMJuz15H5HQ3Plt1KYLy6b6Y6a7NtE1VWGvlmhT1Quzeudkb4lyYMC7DBCE4cZtMBlAgMBAAECggEAAfjNjfTz/JWBtryHPnGX4dKUnFC5xTs1hLA8W5KuNhshiHGNBa9qMc2O/kPi9M0Wp0QBQLUVGimf51kw2AFCaPuvArjfFG2pAnfcK7m4rkOaUJ7AO8QbBQVoqcNThTTJbV/L6f5gxb4F8tT+z0xOr0aBEA/7vwQY4U9ovTE60krIDbd3hE2Eh8RdrKebLrUvvGZ2LPFF3suuGbHHhQwRIzF8Enfa5TjyEJxGz3C3cdCEDjhA/tbMh05egeDhu1qu+Nx1FXzcyc/bFTKF2qPXeE27rclw8U07wggiegHPntJJ9Fgso918f0n8URlzhwpRQ5EjbBNOiVjkKGxQD0rLGQKBgQDl81Jk1iw2WWMuBxZKtxy43sXKjWY8umhrhK0gDjfRXokppCf91+tC3t/7BEc+X8HuAEYCuPs+tnv0XYdhfOeBpy/GHB7NQqYqCiu3Ptm3KnIm/q+CnnPA1HY7222Sa/9NptbfOfrPIlINnglAwjpZ2tn5h0uNvZfMP4Yh+x6aTwKBgQDLyKADd6Iw5jshwVF2SIlv/qHH5w8UKFmkLDT5l6RAqIg0mqY5tPpOEm5JohfYRmp9+ny4U8+V0CNNehN7FLreLJm5ksDvcOuIlEXPCzuEzyO8tkHFuW1pXLcdNnzZmdQ3S8o0mDllegEbwV0OK10RcJ96NRJnngNYp7rohrUxCwKBgHAvHmJtjpJRV66r7Hc1EIEsxehExb0Y4DqcNu4toZO2gEpdeNlBztgH7dQDyVIn22/mmEFZx9FXq++S9apdCoDZdNg8/dX8Dx7xaVR0CDlxLtHRbQTXkvdfb/NR4QoPQDW9EJVFLxSA1PEpya/bUiZmO/OdywFynq0ZzLGlVs/HAoGBALyLV2Fd4vaTTcqhbpmd62tvkIfARLdFzgqTzD/SCeq5A6yIGZvy0lRBwUDndGBqZkVA6PwyrzHRbZhVhoiuWWcOpPyJx3DCbWnkpeI2Zk8ux8Xma1xhf9WoLtQcgc9jAHJY8TFQVmqJQ1VGxq5BeM6WATe0ut6b2ETCi7BwUlyZAoGAV4kL7eiV2rcHa8IROWh8oo+8fgPMb5MSmbU78n/o4tXRTdUmg/6ghE1t9dWK867/PEubVFEvO8F15oQvwLHYdD+SPeLmp/CLf20jzNSjkImFxMG7xmnpre5+sfgIGjioI1rFkwrVk7II7GfvmGpDTbOSLWeiymdFsmmPnjs8I5Q=" | |||
PublicKey = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAtwwoKYVrKeDsgeacReyJlBxwu5bgEzXwAhYivagrzEV9TrdI+C5euB1MFVmk32G0tNEMlj2S8cJhiAL4dMvvaHbuvfaAG9OO6dVxtUOXkGuKmK5cShg3hlHVoytAvKqnlRzAGvBSt8RrpD2DXq7FG0ORP3kKg+6OpudcUfAM4WdZcFnVujzwDedbB/aPzErxmU5mADlrBK4UimdBG+td6Bv638a77gR97RQKh72v3IzT857pInlgh6w+TlF5TOPDBCth7fKxV7NhxumQ3TDVDCbs9eR+R0Nz5bdSmC8um+mOmuzbRNVVhr5ZoU9ULs3rnZG+JcmDAuwwQhOHGbTAZQIDAQAB" | |||
// 支付宝公钥证书 | |||
AlipayPublicContentRSA2 = []byte(`-----BEGIN CERTIFICATE----- | |||
MIIDszCCApugAwIBAgIQICMGCYNKwsloIKi8XMlUgzANBgkqhkiG9w0BAQsFADCBkTELMAkGA1UE | |||
BhMCQ04xGzAZBgNVBAoMEkFudCBGaW5hbmNpYWwgdGVzdDElMCMGA1UECwwcQ2VydGlmaWNhdGlv | |||
biBBdXRob3JpdHkgdGVzdDE+MDwGA1UEAww1QW50IEZpbmFuY2lhbCBDZXJ0aWZpY2F0aW9uIEF1 | |||
dGhvcml0eSBDbGFzcyAyIFIxIHRlc3QwHhcNMjMwNjA5MTI1MjAzWhcNMjQwNjA4MTI1MjAzWjCB | |||
hDELMAkGA1UEBhMCQ04xHzAdBgNVBAoMFmxhZ21pczYyNTRAc2FuZGJveC5jb20xDzANBgNVBAsM | |||
BkFsaXBheTFDMEEGA1UEAww65pSv5LuY5a6dKOS4reWbvSnnvZHnu5zmioDmnK/mnInpmZDlhazl | |||
j7gtMjA4ODcyMTAwMzIzNjQ0MjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAJN/z9yl | |||
+66sFRDJG2ZWPND6gSsTR7DAeKucCm6SlNimX3w4opVd2z6Rz5tcB2iRyh7nZoq1Vo5+uZSLKaiD | |||
IAOEaFNwn9LBLPDH/WgM79BeOygFm9qAYQ8kHGBrR37Sxu6tphgWpVyu0yVlgNvgwdlALX2RCwUW | |||
lYbGhe2wpBndxo00lwWXMlwEoYJx/eAu8k69iEW7/kp8HnU3Qih8V76D0bwAcpTvSq8fDIsiRAgQ | |||
X0EnAOu0rC/hNTCojFXTKJs5UxEO1tFBALc5huGkTM0qd9C4IIrdcR+xysjloEhN18tC0+/FSm6h | |||
kbggE+iE+QAPY6kgGzgX7e4oCRZM/bMCAwEAAaMSMBAwDgYDVR0PAQH/BAQDAgTwMA0GCSqGSIb3 | |||
DQEBCwUAA4IBAQCcCBpLhvl+6fO21kJvL+FIaWgAoCpLuQGQYS1cX9pn+BNHNL8Ur2i0Se7IkL4z | |||
USM4ETULw6RtzoARgIlpSbpSQkZOvyUysOv+ou5rmhUZGtSA2BHwoTHoNWdpmlbps61v7AjQeZTX | |||
rhzdJ7ipLutSNsFiQf0TRjshq79wpIFPwsDO68hrDx6QTMlFqW0/uXv7dERDac9uemCBvePeJVrt | |||
xhqFXuzE5ZvgtuFXW9pIeXwq7B4xNuwfpXQWdxAPyo2Up//0wJdy90gtfESfO8fCYATPtptnB4lP | |||
KHqoqQsuV3xw2P4o/+pmMBgj6hhhoZILLNUJ2Il9PgLEkvkCwRXR | |||
MIIDszCCApugAwIBAgIQIBkIGbgVxq210KxLJ+YA/TANBgkqhkiG9w0BAQsFADCBhDELMAkGA1UE | |||
BhMCQ04xFjAUBgNVBAoMDUFudCBGaW5hbmNpYWwxJTAjBgNVBAsMHENlcnRpZmljYXRpb24gQXV0 | |||
aG9yaXR5IHRlc3QxNjA0BgNVBAMMLUFudCBGaW5hbmNpYWwgQ2VydGlmaWNhdGlvbiBBdXRob3Jp | |||
dHkgUjEgdGVzdDAeFw0xOTA4MTkxMTE2MDBaFw0yNDA4MDExMTE2MDBaMIGRMQswCQYDVQQGEwJD | |||
TjEbMBkGA1UECgwSQW50IEZpbmFuY2lhbCB0ZXN0MSUwIwYDVQQLDBxDZXJ0aWZpY2F0aW9uIEF1 | |||
dGhvcml0eSB0ZXN0MT4wPAYDVQQDDDVBbnQgRmluYW5jaWFsIENlcnRpZmljYXRpb24gQXV0aG9y | |||
aXR5IENsYXNzIDIgUjEgdGVzdDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAMh4FKYO | |||
ZyRQHD6eFbPKZeSAnrfjfU7xmS9Yoozuu+iuqZlb6Z0SPLUqqTZAFZejOcmr07ln/pwZxluqplxC | |||
5+B48End4nclDMlT5HPrDr3W0frs6Xsa2ZNcyil/iKNB5MbGll8LRAxntsKvZZj6vUTMb705gYgm | |||
VUMILwi/ZxKTQqBtkT/kQQ5y6nOZsj7XI5rYdz6qqOROrpvS/d7iypdHOMIM9Iz9DlL1mrCykbBi | |||
t25y+gTeXmuisHUwqaRpwtCGK4BayCqxRGbNipe6W73EK9lBrrzNtTr9NaysesT/v+l25JHCL9tG | |||
wpNr1oWFzk4IHVOg0ORiQ6SUgxZUTYcCAwEAAaMSMBAwDgYDVR0PAQH/BAQDAgTwMA0GCSqGSIb3 | |||
DQEBCwUAA4IBAQBWThEoIaQoBX2YeRY/I8gu6TYnFXtyuCljANnXnM38ft+ikhE5mMNgKmJYLHvT | |||
yWWWgwHoSAWEuml7EGbE/2AK2h3k0MdfiWLzdmpPCRG/RJHk6UB1pMHPilI+c0MVu16OPpKbg5Vf | |||
LTv7dsAB40AzKsvyYw88/Ezi1osTXo6QQwda7uefvudirtb8FcQM9R66cJxl3kt1FXbpYwheIm/p | |||
j1mq64swCoIYu4NrsUYtn6CV542DTQMI5QdXkn+PzUUly8F6kDp+KpMNd0avfWNL5+O++z+F5Szy | |||
1CPta1D7EQ/eYmMP+mOQ35oifWIoFCpN6qQVBS/Hob1J/UUyg7BW | |||
`) | |||
// 支付宝根证书 | |||
AlipayRootContent = []byte(`-----BEGIN CERTIFICATE----- | |||
MIIBszCCAVegAwIBAgIIaeL+wBcKxnswDAYIKoEcz1UBg3UFADAuMQswCQYDVQQG | |||
EwJDTjEOMAwGA1UECgwFTlJDQUMxDzANBgNVBAMMBlJPT1RDQTAeFw0xMjA3MTQw | |||
MzExNTlaFw00MjA3MDcwMzExNTlaMC4xCzAJBgNVBAYTAkNOMQ4wDAYDVQQKDAVO | |||
UkNBQzEPMA0GA1UEAwwGUk9PVENBMFkwEwYHKoZIzj0CAQYIKoEcz1UBgi0DQgAE | |||
MPCca6pmgcchsTf2UnBeL9rtp4nw+itk1Kzrmbnqo05lUwkwlWK+4OIrtFdAqnRT | |||
V7Q9v1htkv42TsIutzd126NdMFswHwYDVR0jBBgwFoAUTDKxl9kzG8SmBcHG5Yti | |||
W/CXdlgwDAYDVR0TBAUwAwEB/zALBgNVHQ8EBAMCAQYwHQYDVR0OBBYEFEwysZfZ | |||
MxvEpgXBxuWLYlvwl3ZYMAwGCCqBHM9VAYN1BQADSAAwRQIgG1bSLeOXp3oB8H7b | |||
53W+CKOPl2PknmWEq/lMhtn25HkCIQDaHDgWxWFtnCrBjH16/W3Ezn7/U/Vjo5xI | |||
pDoiVhsLwg== | |||
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== | |||
MIICiDCCAgygAwIBAgIIQX76UsB/30owDAYIKoZIzj0EAwMFADB6MQswCQYDVQQG | |||
EwJDTjEWMBQGA1UECgwNQW50IEZpbmFuY2lhbDEgMB4GA1UECwwXQ2VydGlmaWNh | |||
dGlvbiBBdXRob3JpdHkxMTAvBgNVBAMMKEFudCBGaW5hbmNpYWwgQ2VydGlmaWNh | |||
dGlvbiBBdXRob3JpdHkgRTEwHhcNMTkwNDI4MTYyMDQ0WhcNNDkwNDIwMTYyMDQ0 | |||
WjB6MQswCQYDVQQGEwJDTjEWMBQGA1UECgwNQW50IEZpbmFuY2lhbDEgMB4GA1UE | |||
CwwXQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkxMTAvBgNVBAMMKEFudCBGaW5hbmNp | |||
YWwgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkgRTEwdjAQBgcqhkjOPQIBBgUrgQQA | |||
IgNiAASCCRa94QI0vR5Up9Yr9HEupz6hSoyjySYqo7v837KnmjveUIUNiuC9pWAU | |||
WP3jwLX3HkzeiNdeg22a0IZPoSUCpasufiLAnfXh6NInLiWBrjLJXDSGaY7vaokt | |||
rpZvAdmjXTBbMAsGA1UdDwQEAwIBBjAMBgNVHRMEBTADAQH/MB0GA1UdDgQWBBRZ | |||
4ZTgDpksHL2qcpkFkxD2zVd16TAfBgNVHSMEGDAWgBRZ4ZTgDpksHL2qcpkFkxD2 | |||
zVd16TAMBggqhkjOPQQDAwUAA2gAMGUCMQD4IoqT2hTUn0jt7oXLdMJ8q4vLp6sg | |||
wHfPiOr9gxreb+e6Oidwd2LDnC4OUqCWiF8CMAzwKs4SnDJYcMLf2vpkbuVE4dTH | |||
Rglz+HGcTLWsFs4KxLsq7MuU+vJTBUeDJeDjdA== | |||
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 | |||
// 应用公钥证书 | |||
AppPublicContent = []byte(`-----BEGIN CERTIFICATE----- | |||
MIIDmTCCAoGgAwIBAgIQICQJJiIfTmxJDlWhVlLYPjANBgkqhkiG9w0BAQsFADCBkTELMAkGA1UE | |||
BhMCQ04xGzAZBgNVBAoMEkFudCBGaW5hbmNpYWwgdGVzdDElMCMGA1UECwwcQ2VydGlmaWNhdGlv | |||
biBBdXRob3JpdHkgdGVzdDE+MDwGA1UEAww1QW50IEZpbmFuY2lhbCBDZXJ0aWZpY2F0aW9uIEF1 | |||
dGhvcml0eSBDbGFzcyAyIFIxIHRlc3QwHhcNMjQwOTI2MTU0ODExWhcNMjUxMDAxMTU0ODExWjBr | |||
MQswCQYDVQQGEwJDTjEfMB0GA1UECgwWbGFnbWlzNjI1NEBzYW5kYm94LmNvbTEPMA0GA1UECwwG | |||
QWxpcGF5MSowKAYDVQQDDCEyMDg4NzIxMDAzMjM2NDQyLTIwMjEwMDAxMjI2NzIzODgwggEiMA0G | |||
CSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQC3DCgphWsp4OyB5pxF7ImUHHC7luATNfACFiK9qCvM | |||
RX1Ot0j4Ll64HUwVWaTfYbS00QyWPZLxwmGIAvh0y+9odu699oAb047p1XG1Q5eQa4qYrlxKGDeG | |||
UdWjK0C8qqeVHMAa8FK3xGukPYNersUbQ5E/eQqD7o6m51xR8AzhZ1lwWdW6PPAN51sH9o/MSvGZ | |||
TmYAOWsErhSKZ0Eb613oG/rfxrvuBH3tFAqHva/cjNPznukieWCHrD5OUXlM48MEK2Ht8rFXs2HG | |||
6ZDdMNUMJuz15H5HQ3Plt1KYLy6b6Y6a7NtE1VWGvlmhT1Quzeudkb4lyYMC7DBCE4cZtMBlAgMB | |||
AAGjEjAQMA4GA1UdDwEB/wQEAwIE8DANBgkqhkiG9w0BAQsFAAOCAQEAeMqluNI07JunRvkeOdN3 | |||
u4l1EicBtaMA63h6Ico92YanIgAzvZY9etwBiCP9ULmqckw+jo6+taXERe3fXSoUqyCH+3Hnb30f | |||
MHp+oHlmpxCG93GLYBe9QcugrbEKg7RJ1l8ikyXMt3nkxBcQochCuNxdhGGYM4rxlGtwU1j0v+CV | |||
Ne4IsK8fbpMF8wfYGOwDb+P1Mqx2Hv1D0qLu4S2ztz+br8Opg5leGY8wMt9+mW5aKwEKX3FVDi5J | |||
ijiKYWzTm718zrmMJ+sN2VrapDvtj92bibOt0PKXUtQ5I++RtjG//dRpjAg9aS5pjvui80tNtwAc | |||
xaEqw58KZ41dIaw3Zw== | |||
) |
@@ -1,75 +0,0 @@ | |||
// Java SDK 获取Root证书SN AntCertificationUtil.getRootCertSN(); | |||
/** | |||
* 从公钥证书中提取公钥序列号 | |||
* | |||
* @param certPath 公钥证书存放路径,例如:/home/admin/cert.crt | |||
* @return 公钥证书序列号 | |||
* @throws AlipayApiException | |||
*/ | |||
public static String getCertSN(String certPath) throws AlipayApiException { | |||
InputStream inputStream = null; | |||
try { | |||
inputStream = new FileInputStream(certPath); | |||
CertificateFactory cf = CertificateFactory.getInstance("X.509"); | |||
X509Certificate cert = (X509Certificate) cf.generateCertificate(inputStream); | |||
MessageDigest md = MessageDigest.getInstance("MD5"); | |||
md.update((cert.getIssuerX500Principal().getName() + cert.getSerialNumber()).getBytes()); | |||
String certSN = new BigInteger(1, md.digest()).toString(16); | |||
//BigInteger会把0省略掉,需补全至32位 | |||
certSN = fillMD5(certSN); | |||
return certSN; | |||
} catch (NoSuchAlgorithmException e) { | |||
throw new AlipayApiException(e); | |||
} catch (IOException e) { | |||
throw new AlipayApiException(e); | |||
} catch (CertificateException e) { | |||
throw new AlipayApiException(e); | |||
} finally { | |||
try { | |||
if (inputStream != null) { | |||
inputStream.close(); | |||
} | |||
} catch (IOException e) { | |||
throw new AlipayApiException(e); | |||
} | |||
} | |||
} | |||
// Java SDK 获取证书SN AlipaySignature.getCertSN(); | |||
/** | |||
* 获取根证书序列号 | |||
* | |||
* @param rootCertContent | |||
* @return | |||
*/ | |||
public static String getRootCertSN(String rootCertContent) { | |||
String rootCertSN = null; | |||
try { | |||
X509Certificate[] x509Certificates = readPemCertChain(rootCertContent); | |||
MessageDigest md = MessageDigest.getInstance("MD5"); | |||
for (X509Certificate c : x509Certificates) { | |||
if (c.getSigAlgOID().startsWith("1.2.840.113549.1.1")) { | |||
md.update((c.getIssuerX500Principal().getName() + c.getSerialNumber()).getBytes()); | |||
String certSN = new BigInteger(1, md.digest()).toString(16); | |||
//BigInteger会把0省略掉,需补全至32位 | |||
certSN = fillMD5(certSN); | |||
if (StringUtils.isEmpty(rootCertSN)) { | |||
rootCertSN = certSN; | |||
} else { | |||
rootCertSN = rootCertSN + "_" + certSN; | |||
} | |||
} | |||
} | |||
} catch (Exception e) { | |||
AlipayLogger.logBizError(("提取根证书失败")); | |||
} | |||
return rootCertSN; | |||
} | |||
private static String fillMD5(String md5) { | |||
return md5.length() == 32 ? md5 : fillMD5("0" + md5); | |||
} |
@@ -1,274 +0,0 @@ | |||
package alipay | |||
import ( | |||
"crypto/rsa" | |||
"encoding/base64" | |||
"encoding/json" | |||
"fmt" | |||
"time" | |||
"github.com/go-pay/crypto/aes" | |||
"github.com/go-pay/crypto/xpem" | |||
"github.com/go-pay/crypto/xrsa" | |||
"github.com/go-pay/gopay" | |||
"github.com/go-pay/gopay/pkg/xhttp" | |||
"github.com/go-pay/xlog" | |||
"github.com/go-pay/xtime" | |||
) | |||
type Client struct { | |||
AppId string | |||
AppCertSN string | |||
AliPayPublicCertSN string | |||
AliPayRootCertSN string | |||
ReturnUrl string | |||
NotifyUrl string | |||
Charset string | |||
SignType string | |||
AppAuthToken string | |||
IsProd bool | |||
aesKey string // biz_content 加密的 AES KEY | |||
ivKey []byte | |||
privateKey *rsa.PrivateKey | |||
aliPayPublicKey *rsa.PublicKey // 支付宝证书公钥内容 alipayPublicCert.crt | |||
autoSign bool | |||
DebugSwitch gopay.DebugSwitch | |||
logger xlog.XLogger | |||
location *time.Location | |||
hc *xhttp.Client | |||
} | |||
// 初始化支付宝客户端 | |||
// 注意:如果使用支付宝公钥证书验签,请使用 client.SetCertSnByContent() 或 client.SetCertSnByPath() 设置 应用公钥证书、支付宝公钥证书、支付宝根证书 | |||
// appid:应用ID | |||
// privateKey:应用私钥,支持PKCS1和PKCS8 | |||
// isProd:是否是正式环境,沙箱环境请选择新版沙箱应用。 | |||
func NewClient(appid, privateKey string, isProd bool) (client *Client, err error) { | |||
if appid == gopay.NULL || privateKey == gopay.NULL { | |||
return nil, gopay.MissAlipayInitParamErr | |||
} | |||
key := xrsa.FormatAlipayPrivateKey(privateKey) | |||
priKey, err := xpem.DecodePrivateKey([]byte(key)) | |||
if err != nil { | |||
return nil, err | |||
} | |||
logger := xlog.NewLogger() | |||
logger.SetLevel(xlog.DebugLevel) | |||
client = &Client{ | |||
AppId: appid, | |||
Charset: UTF8, | |||
SignType: RSA2, | |||
IsProd: isProd, | |||
privateKey: priKey, | |||
DebugSwitch: gopay.DebugOff, | |||
logger: logger, | |||
hc: xhttp.NewClient(), | |||
} | |||
return client, nil | |||
} | |||
// 开启请求完自动验签功能(默认不开启,推荐开启,只支持证书模式) | |||
// 注意:只支持证书模式 | |||
// alipayPublicKeyContent:支付宝公钥证书文件内容[]byte | |||
func (a *Client) AutoVerifySign(alipayPublicKeyContent []byte) { | |||
pubKey, err := xpem.DecodePublicKey(alipayPublicKeyContent) | |||
if err != nil { | |||
a.logger.Errorf("AutoVerifySign(%s),err:%+v", alipayPublicKeyContent, err) | |||
} | |||
if pubKey != nil { | |||
a.aliPayPublicKey = pubKey | |||
a.autoSign = true | |||
} | |||
} | |||
// SetBodySize 设置http response body size(MB) | |||
func (a *Client) SetBodySize(sizeMB int) { | |||
if sizeMB > 0 { | |||
a.hc.SetBodySize(sizeMB) | |||
} | |||
} | |||
// SetHttpClient 设置自定义的xhttp.Client | |||
func (a *Client) SetHttpClient(client *xhttp.Client) { | |||
if client != nil { | |||
a.hc = client | |||
} | |||
} | |||
// SetLogger 设置自定义的logger | |||
func (a *Client) SetLogger(logger xlog.XLogger) { | |||
if logger != nil { | |||
a.logger = logger | |||
} | |||
} | |||
// SetAESKey 设置 biz_content 的AES加密key,设置此参数默认开启 biz_content 参数加密 | |||
// 注意:目前不可用,设置后会报错 | |||
func (a *Client) SetAESKey(aesKey string) { | |||
a.aesKey = aesKey | |||
a.ivKey = []byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} | |||
} | |||
// Deprecated | |||
// 推荐使用 RequestParam() | |||
func (a *Client) GetRequestSignParam(bm gopay.BodyMap, method string) (string, error) { | |||
return a.RequestParam(bm, method) | |||
} | |||
// RequestParam 获取支付宝完整请求参数包含签名 | |||
// 注意:biz_content 需要自行通过bm.SetBodyMap()设置,不设置则没有此参数 | |||
func (a *Client) RequestParam(bm gopay.BodyMap, method string) (string, error) { | |||
var ( | |||
bodyBs []byte | |||
err error | |||
sign string | |||
) | |||
if bm == nil { | |||
return "", gopay.BodyMapNilErr | |||
} | |||
// check if there is biz_content | |||
bz := bm.GetAny("biz_content") | |||
if bzBody, ok := bz.(gopay.BodyMap); ok { | |||
if bodyBs, err = json.Marshal(bzBody); err != nil { | |||
return "", fmt.Errorf("json.Marshal(%v):%w", bzBody, err) | |||
} | |||
bm.Set("biz_content", string(bodyBs)) | |||
} | |||
bm.Set("method", method) | |||
// check public parameter | |||
a.checkPublicParam(bm) | |||
// check sign | |||
if bm.GetString("sign") == "" { | |||
sign, err = a.getRsaSign(bm, bm.GetString("sign_type")) | |||
if err != nil { | |||
return "", fmt.Errorf("GetRsaSign Error: %w", err) | |||
} | |||
bm.Set("sign", sign) | |||
} | |||
if a.DebugSwitch == gopay.DebugOn { | |||
a.logger.Debugf("Alipay_Request: %s", bm.JsonBody()) | |||
} | |||
return bm.EncodeURLParams(), nil | |||
} | |||
// 公共参数处理 | |||
func (a *Client) pubParamsHandle(bm gopay.BodyMap, method, bizContent string, authToken ...string) (param string, err error) { | |||
pubBody := make(gopay.BodyMap) | |||
pubBody.Set("app_id", a.AppId). | |||
Set("method", method). | |||
Set("format", "JSON"). | |||
Set("charset", a.Charset). | |||
Set("sign_type", a.SignType). | |||
Set("version", "1.0"). | |||
Set("timestamp", time.Now().Format(xtime.TimeLayout)) | |||
if bm != nil { | |||
// version | |||
if version := bm.GetString("version"); version != gopay.NULL { | |||
pubBody.Set("version", version) | |||
} | |||
if a.AppCertSN != gopay.NULL { | |||
pubBody.Set("app_cert_sn", a.AppCertSN) | |||
} | |||
if a.AliPayRootCertSN != gopay.NULL { | |||
pubBody.Set("alipay_root_cert_sn", a.AliPayRootCertSN) | |||
} | |||
// return_url | |||
if a.ReturnUrl != gopay.NULL { | |||
pubBody.Set("return_url", a.ReturnUrl) | |||
} | |||
if returnUrl := bm.GetString("return_url"); returnUrl != gopay.NULL { | |||
pubBody.Set("return_url", returnUrl) | |||
} | |||
if a.location != nil { | |||
pubBody.Set("timestamp", time.Now().In(a.location).Format(xtime.TimeLayout)) | |||
} | |||
// notify_url | |||
if a.NotifyUrl != gopay.NULL { | |||
pubBody.Set("notify_url", a.NotifyUrl) | |||
} | |||
if notifyUrl := bm.GetString("notify_url"); notifyUrl != gopay.NULL { | |||
pubBody.Set("notify_url", notifyUrl) | |||
} | |||
// default use app_auth_token | |||
if a.AppAuthToken != gopay.NULL { | |||
pubBody.Set("app_auth_token", a.AppAuthToken) | |||
} | |||
// if user set app_auth_token in body_map, use this | |||
if aat := bm.GetString("app_auth_token"); aat != gopay.NULL { | |||
pubBody.Set("app_auth_token", aat) | |||
} | |||
} | |||
if len(authToken) > 0 { | |||
pubBody.Set("auth_token", authToken[0]) | |||
} | |||
if bizContent != gopay.NULL { | |||
if a.aesKey == gopay.NULL { | |||
pubBody.Set("biz_content", bizContent) | |||
} else { | |||
// AES Encrypt biz_content | |||
encryptBizContent, err := a.encryptBizContent(bizContent) | |||
if err != nil { | |||
return "", fmt.Errorf("EncryptBizContent Error: %w", err) | |||
} | |||
if a.DebugSwitch == gopay.DebugOn { | |||
a.logger.Debugf("Alipay_Origin_BizContent: %s", bizContent) | |||
a.logger.Debugf("Alipay_Encrypt_BizContent: %s", encryptBizContent) | |||
} | |||
pubBody.Set("biz_content", encryptBizContent) | |||
} | |||
} | |||
// sign | |||
sign, err := a.getRsaSign(pubBody, pubBody.GetString("sign_type")) | |||
if err != nil { | |||
return "", fmt.Errorf("GetRsaSign Error: %w", err) | |||
} | |||
pubBody.Set("sign", sign) | |||
if a.DebugSwitch == gopay.DebugOn { | |||
a.logger.Debugf("Alipay_Request: %s", pubBody.JsonBody()) | |||
} | |||
param = pubBody.EncodeURLParams() | |||
return | |||
} | |||
// 公共参数检查 | |||
func (a *Client) checkPublicParam(bm gopay.BodyMap) { | |||
bm.Set("format", "JSON"). | |||
Set("charset", a.Charset). | |||
Set("sign_type", a.SignType). | |||
Set("version", "1.0"). | |||
Set("timestamp", time.Now().Format(xtime.TimeLayout)) | |||
if bm.GetString("app_id") == "" && a.AppId != gopay.NULL { | |||
bm.Set("app_id", a.AppId) | |||
} | |||
if bm.GetString("app_cert_sn") == "" && a.AppCertSN != gopay.NULL { | |||
bm.Set("app_cert_sn", a.AppCertSN) | |||
} | |||
if bm.GetString("alipay_root_cert_sn") == "" && a.AliPayRootCertSN != gopay.NULL { | |||
bm.Set("alipay_root_cert_sn", a.AliPayRootCertSN) | |||
} | |||
if bm.GetString("return_url") == "" && a.ReturnUrl != gopay.NULL { | |||
bm.Set("return_url", a.ReturnUrl) | |||
} | |||
if a.location != nil { | |||
bm.Set("timestamp", time.Now().In(a.location).Format(xtime.TimeLayout)) | |||
} | |||
if bm.GetString("notify_url") == "" && a.NotifyUrl != gopay.NULL { | |||
bm.Set("notify_url", a.NotifyUrl) | |||
} | |||
if bm.GetString("app_auth_token") == "" && a.AppAuthToken != gopay.NULL { | |||
bm.Set("app_auth_token", a.AppAuthToken) | |||
} | |||
} | |||
func (a *Client) encryptBizContent(originData string) (string, error) { | |||
encryptData, err := aes.CBCEncrypt([]byte(originData), []byte(a.aesKey), a.ivKey) | |||
if err != nil { | |||
return "", err | |||
} | |||
return base64.StdEncoding.EncodeToString(encryptData), nil | |||
} |
@@ -1,357 +0,0 @@ | |||
package alipay | |||
import ( | |||
"context" | |||
"encoding/json" | |||
"fmt" | |||
"time" | |||
"github.com/go-pay/gopay" | |||
"github.com/go-pay/gopay/pkg/xhttp" | |||
"github.com/go-pay/xtime" | |||
) | |||
// PostAliPayAPISelfV2 支付宝接口自行实现方法 | |||
// 注意:biz_content 需要自行通过bm.SetBodyMap()设置,不设置则没有此参数 | |||
// 示例:请参考 client_test.go 的 TestClient_PostAliPayAPISelfV2() 方法 | |||
func (a *Client) PostAliPayAPISelfV2(ctx context.Context, bodyMap gopay.BodyMap, method string, aliRsp any) (err error) { | |||
var ( | |||
bs, bodyBs []byte | |||
) | |||
// check if there is biz_content | |||
bz := bodyMap.GetAny("biz_content") | |||
if bzBody, ok := bz.(gopay.BodyMap); ok { | |||
if bodyBs, err = json.Marshal(bzBody); err != nil { | |||
return fmt.Errorf("json.Marshal(%v):%w", bzBody, err) | |||
} | |||
bodyMap.Set("biz_content", string(bodyBs)) | |||
} | |||
if bs, err = a.doAliPaySelf(ctx, bodyMap, method); err != nil { | |||
return err | |||
} | |||
if err = json.Unmarshal(bs, aliRsp); err != nil { | |||
return err | |||
} | |||
return nil | |||
} | |||
// PostFileAliPayAPISelfV2 用于支付宝带有文件上传的接口自行实现方法 | |||
// 注意:最新版本的支付宝接口,对于文件的上传已统一改为通过formData上传 | |||
// 请求form格式如下: {file: "fileData", "data": BodyMap{"key": "value"}} | |||
// 其中file为file请求字段名称,data为其他请求参数(key为文件名,value为文件内容) | |||
func (a *Client) PostFileAliPayAPISelfV2(ctx context.Context, bm gopay.BodyMap, method string, aliRsp any) (err error) { | |||
var ( | |||
url string | |||
sign string | |||
) | |||
fm := make(gopay.BodyMap) | |||
for k, v := range bm { | |||
if _, ok := v.(*gopay.File); ok { | |||
fm.Set(k, v) | |||
bm.Remove(k) | |||
continue | |||
} | |||
} | |||
bm.Set("method", method) | |||
// check public parameter | |||
a.checkPublicParam(bm) | |||
// check sign, 需要先移除文件字段 | |||
if bm.GetString("sign") == "" { | |||
sign, err = a.getRsaSign(bm, bm.GetString("sign_type")) | |||
if err != nil { | |||
return fmt.Errorf("GetRsaSign Error: %w", err) | |||
} | |||
bm.Set("sign", sign) | |||
} | |||
// 增加文件字段 | |||
for k, v := range fm { | |||
bm.Set(k, v) | |||
} | |||
if a.DebugSwitch == gopay.DebugOn { | |||
a.logger.Debugf("Alipay_Request: %s", bm.JsonBody()) | |||
} | |||
if a.IsProd { | |||
url = baseUrlUtf8 | |||
} else { | |||
url = sandboxBaseUrlUtf8 | |||
} | |||
res, bs, err := a.hc.Req(xhttp.TypeMultipartFormData).Post(url). | |||
SendMultipartBodyMap(bm).EndBytes(ctx) | |||
if err != nil { | |||
return nil | |||
} | |||
if a.DebugSwitch == gopay.DebugOn { | |||
a.logger.Debugf("Alipay_Response: %d, %s", res.StatusCode, string(bs)) | |||
} | |||
if res.StatusCode != 200 { | |||
return fmt.Errorf("HTTP Request Error, StatusCode = %d", res.StatusCode) | |||
} | |||
if err = json.Unmarshal(bs, aliRsp); err != nil { | |||
return err | |||
} | |||
return nil | |||
} | |||
// 向支付宝发送自定义请求 | |||
func (a *Client) doAliPaySelf(ctx context.Context, bm gopay.BodyMap, method string) (bs []byte, err error) { | |||
var ( | |||
url, sign string | |||
) | |||
bm.Set("method", method) | |||
// check public parameter | |||
a.checkPublicParam(bm) | |||
// check sign | |||
if bm.GetString("sign") == "" { | |||
sign, err = a.getRsaSign(bm, bm.GetString("sign_type")) | |||
if err != nil { | |||
return nil, fmt.Errorf("GetRsaSign Error: %w", err) | |||
} | |||
bm.Set("sign", sign) | |||
} | |||
if a.DebugSwitch == gopay.DebugOn { | |||
a.logger.Debugf("Alipay_Request: %s", bm.JsonBody()) | |||
} | |||
if a.IsProd { | |||
url = baseUrlUtf8 | |||
} else { | |||
url = sandboxBaseUrlUtf8 | |||
} | |||
res, bs, err := a.hc.Req(xhttp.TypeFormData).Post(url).SendString(bm.EncodeURLParams()).EndBytes(ctx) | |||
if err != nil { | |||
return nil, err | |||
} | |||
if a.DebugSwitch == gopay.DebugOn { | |||
a.logger.Debugf("Alipay_Response: %d, %s", res.StatusCode, string(bs)) | |||
} | |||
if res.StatusCode != 200 { | |||
return nil, fmt.Errorf("HTTP Request Error, StatusCode = %d", res.StatusCode) | |||
} | |||
return bs, nil | |||
} | |||
// 向支付宝发送请求 | |||
func (a *Client) doAliPay(ctx context.Context, bm gopay.BodyMap, method string, authToken ...string) (bs []byte, err error) { | |||
var ( | |||
bizContent, url string | |||
bodyBs []byte | |||
) | |||
if bm != nil { | |||
_, has := appAuthTokenInBizContent[method] | |||
if !has { | |||
aat := bm.GetString("app_auth_token") | |||
bm.Remove("app_auth_token") | |||
if bodyBs, err = json.Marshal(bm); err != nil { | |||
return nil, fmt.Errorf("json.Marshal:%w", err) | |||
} | |||
bizContent = string(bodyBs) | |||
if aat != "" { | |||
bm.Set("app_auth_token", aat) | |||
} | |||
} else { | |||
if bodyBs, err = json.Marshal(bm); err != nil { | |||
return nil, fmt.Errorf("json.Marshal:%w", err) | |||
} | |||
bizContent = string(bodyBs) | |||
bm.Remove("app_auth_token") | |||
} | |||
} | |||
// 处理公共参数 | |||
param, err := a.pubParamsHandle(bm, method, bizContent, authToken...) | |||
if err != nil { | |||
return nil, err | |||
} | |||
switch method { | |||
case "alipay.trade.app.pay", "alipay.fund.auth.order.app.freeze", "zhima.credit.pe.zmgo.sign.apply", "zhima.credit.payafteruse.creditagreement.sign": | |||
return []byte(param), nil | |||
case "alipay.trade.wap.pay", "alipay.trade.page.pay", "alipay.user.certify.open.certify": | |||
if !a.IsProd { | |||
return []byte(sandboxBaseUrl + "?" + param), nil | |||
} | |||
return []byte(baseUrl + "?" + param), nil | |||
default: | |||
url = baseUrlUtf8 | |||
if !a.IsProd { | |||
url = sandboxBaseUrlUtf8 | |||
} | |||
res, bs, err := a.hc.Req(xhttp.TypeFormData).Post(url).SendString(param).EndBytes(ctx) | |||
if err != nil { | |||
return nil, err | |||
} | |||
if a.DebugSwitch == gopay.DebugOn { | |||
a.logger.Debugf("Alipay_Response: %d, %s", res.StatusCode, string(bs)) | |||
} | |||
if res.StatusCode != 200 { | |||
return nil, fmt.Errorf("HTTP Request Error, StatusCode = %d", res.StatusCode) | |||
} | |||
return bs, nil | |||
} | |||
} | |||
// 向支付宝发送请求 | |||
func (a *Client) DoAliPay(ctx context.Context, bm gopay.BodyMap, method string, authToken ...string) (bs []byte, err error) { | |||
var ( | |||
bizContent, url string | |||
bodyBs []byte | |||
) | |||
if bm != nil { | |||
_, has := appAuthTokenInBizContent[method] | |||
if !has { | |||
aat := bm.GetString("app_auth_token") | |||
bm.Remove("app_auth_token") | |||
if bodyBs, err = json.Marshal(bm); err != nil { | |||
return nil, fmt.Errorf("json.Marshal:%w", err) | |||
} | |||
bizContent = string(bodyBs) | |||
bm.Set("app_auth_token", aat) | |||
} else { | |||
if bodyBs, err = json.Marshal(bm); err != nil { | |||
return nil, fmt.Errorf("json.Marshal:%w", err) | |||
} | |||
bizContent = string(bodyBs) | |||
bm.Remove("app_auth_token") | |||
} | |||
} | |||
// 处理公共参数 | |||
param, err := a.pubParamsHandle(bm, method, bizContent, authToken...) | |||
if err != nil { | |||
return nil, err | |||
} | |||
switch method { | |||
case "alipay.trade.app.pay", "alipay.fund.auth.order.app.freeze": | |||
return []byte(param), nil | |||
case "alipay.trade.wap.pay", "alipay.trade.page.pay", "alipay.user.certify.open.certify": | |||
if !a.IsProd { | |||
return []byte(sandboxBaseUrl + "?" + param), nil | |||
} | |||
return []byte(baseUrl + "?" + param), nil | |||
default: | |||
url = baseUrlUtf8 | |||
if !a.IsProd { | |||
url = sandboxBaseUrlUtf8 | |||
} | |||
res, bs, err := a.hc.Req(xhttp.TypeFormData).Post(url).SendString(param).EndBytes(ctx) | |||
if err != nil { | |||
return nil, err | |||
} | |||
if a.DebugSwitch == gopay.DebugOn { | |||
a.logger.Debugf("Alipay_Response: %d, %s", res.StatusCode, string(bs)) | |||
} | |||
if res.StatusCode != 200 { | |||
return nil, fmt.Errorf("HTTP Request Error, StatusCode = %d", res.StatusCode) | |||
} | |||
return bs, nil | |||
} | |||
} | |||
// 保持和官方 SDK 命名方式一致 | |||
func (a *Client) PageExecute(ctx context.Context, bm gopay.BodyMap, method string, authToken ...string) (url string, err error) { | |||
var ( | |||
bizContent string | |||
bodyBs []byte | |||
) | |||
if bm != nil { | |||
_, has := appAuthTokenInBizContent[method] | |||
if !has { | |||
aat := bm.GetString("app_auth_token") | |||
bm.Remove("app_auth_token") | |||
if bodyBs, err = json.Marshal(bm); err != nil { | |||
return "", fmt.Errorf("json.Marshal:%w", err) | |||
} | |||
bizContent = string(bodyBs) | |||
bm.Set("app_auth_token", aat) | |||
} else { | |||
if bodyBs, err = json.Marshal(bm); err != nil { | |||
return "", fmt.Errorf("json.Marshal:%w", err) | |||
} | |||
bizContent = string(bodyBs) | |||
bm.Remove("app_auth_token") | |||
} | |||
} | |||
// 处理公共参数 | |||
param, err := a.pubParamsHandle(bm, method, bizContent, authToken...) | |||
if err != nil { | |||
return "", err | |||
} | |||
if !a.IsProd { | |||
return sandboxBaseUrl + "?" + param, nil | |||
} | |||
return baseUrl + "?" + param, nil | |||
} | |||
// 文件上传 | |||
func (a *Client) FileUploadRequest(ctx context.Context, bm gopay.BodyMap, method string) (bs []byte, err error) { | |||
var ( | |||
aat string | |||
) | |||
if bm != nil { | |||
aat = bm.GetString("app_auth_token") | |||
bm.Remove("app_auth_token") | |||
} | |||
pubBody := make(gopay.BodyMap) | |||
pubBody.Set("app_id", a.AppId). | |||
Set("method", method). | |||
Set("format", "JSON"). | |||
Set("charset", a.Charset). | |||
Set("sign_type", a.SignType). | |||
Set("version", "1.0"). | |||
Set("timestamp", time.Now().Format(xtime.TimeLayout)) | |||
if a.AppCertSN != gopay.NULL { | |||
pubBody.Set("app_cert_sn", a.AppCertSN) | |||
} | |||
if a.AliPayRootCertSN != gopay.NULL { | |||
pubBody.Set("alipay_root_cert_sn", a.AliPayRootCertSN) | |||
} | |||
if a.ReturnUrl != gopay.NULL { | |||
pubBody.Set("return_url", a.ReturnUrl) | |||
} | |||
if a.location != nil { | |||
pubBody.Set("timestamp", time.Now().In(a.location).Format(xtime.TimeLayout)) | |||
} | |||
if a.NotifyUrl != gopay.NULL { | |||
pubBody.Set("notify_url", a.NotifyUrl) | |||
} | |||
// default use app_auth_token | |||
if a.AppAuthToken != gopay.NULL { | |||
pubBody.Set("app_auth_token", a.AppAuthToken) | |||
} | |||
// if user set app_auth_token in body_map, use this | |||
if aat != gopay.NULL { | |||
pubBody.Set("app_auth_token", aat) | |||
} | |||
// 文件上传除文件外其他参数也需要签名 | |||
for k, v := range bm { | |||
if _, ok := v.(*gopay.File); !ok { | |||
pubBody.Set(k, v) | |||
} | |||
} | |||
// sign | |||
sign, err := a.getRsaSign(pubBody, pubBody.GetString("sign_type")) | |||
if err != nil { | |||
return nil, fmt.Errorf("GetRsaSign Error: %w", err) | |||
} | |||
// 文件签名完移除query params | |||
for k := range bm { | |||
pubBody.Remove(k) | |||
} | |||
pubBody.Set("sign", sign) | |||
if a.DebugSwitch == gopay.DebugOn { | |||
a.logger.Debugf("Alipay_Query_Request: %s", pubBody.JsonBody()) | |||
} | |||
url := baseUrlUtf8 + "&" + pubBody.EncodeURLParams() | |||
res, bs, err := a.hc.Req(xhttp.TypeMultipartFormData).Post(url). | |||
SendMultipartBodyMap(bm).EndBytes(ctx) | |||
if err != nil { | |||
return nil, err | |||
} | |||
if a.DebugSwitch == gopay.DebugOn { | |||
a.logger.Debugf("Alipay_Response: %d, %s", res.StatusCode, string(bs)) | |||
} | |||
if res.StatusCode != 200 { | |||
return nil, fmt.Errorf("HTTP Request Error, StatusCode = %d", res.StatusCode) | |||
} | |||
return bs, nil | |||
} |
@@ -1,94 +0,0 @@ | |||
package alipay | |||
import ( | |||
"context" | |||
"os" | |||
"testing" | |||
"github.com/go-pay/gopay" | |||
"github.com/go-pay/gopay/alipay/cert" | |||
"github.com/go-pay/util" | |||
"github.com/go-pay/xlog" | |||
) | |||
var ( | |||
ctx = context.Background() | |||
client *Client | |||
err error | |||
) | |||
func TestMain(m *testing.M) { | |||
xlog.SetLevel(xlog.DebugLevel) | |||
// 初始化支付宝客户端 | |||
// appid:应用ID | |||
// privateKey:应用私钥,支持PKCS1和PKCS8 | |||
// isProd:是否是正式环境,沙箱环境请选择新版沙箱应用。 | |||
client, err = NewClient(cert.Appid, cert.PrivateKey, false) | |||
if err != nil { | |||
xlog.Error(err) | |||
return | |||
} | |||
// Debug开关,输出/关闭日志 | |||
client.DebugSwitch = gopay.DebugOff | |||
// 配置公共参数 | |||
client.SetCharset("utf-8"). | |||
SetSignType(RSA2). | |||
// SetAppAuthToken("") | |||
SetReturnUrl("https://www.fmm.ink"). | |||
SetNotifyUrl("https://www.fmm.ink") | |||
// 设置biz_content加密KEY,设置此参数默认开启加密(目前不可用,设置后会报错) | |||
//client.SetAESKey("KvKUTqSVZX2fUgmxnFyMaQ==") | |||
// 自动同步验签(只支持证书模式) | |||
// 传入 支付宝公钥证书 alipayPublicCert.crt 内容 | |||
client.AutoVerifySign(cert.AlipayPublicContentRSA2) | |||
// 传入证书内容 | |||
err := client.SetCertSnByContent(cert.AppPublicContent, cert.AlipayRootContent, cert.AlipayPublicContentRSA2) | |||
// 传入证书文件路径 | |||
//err := client.SetCertSnByPath("cert/appPublicCert.crt", "cert/alipayRootCert.crt", "cert/alipayPublicCert.crt") | |||
if err != nil { | |||
xlog.Debug("SetCertSn:", err) | |||
return | |||
} | |||
os.Exit(m.Run()) | |||
} | |||
func TestClient_PostAliPayAPISelfV2(t *testing.T) { | |||
bm := make(gopay.BodyMap) | |||
// 自定义公共参数(根据自己需求,需要独立设置的自行设置,不需要单独设置的,共享client的配置) | |||
bm.Set("app_id", "appid") | |||
bm.Set("app_auth_token", "app_auth_token") | |||
bm.Set("auth_token", "auth_token") | |||
// biz_content | |||
bm.SetBodyMap("biz_content", func(bz gopay.BodyMap) { | |||
bz.Set("subject", "预创建创建订单") | |||
bz.Set("out_trade_no", util.RandomString(32)) | |||
bz.Set("total_amount", "100") | |||
}) | |||
aliPsp := new(TradePrecreateResponse) | |||
err := client.PostAliPayAPISelfV2(ctx, bm, "alipay.trade.precreate", aliPsp) | |||
if err != nil { | |||
xlog.Error(err) | |||
return | |||
} | |||
xlog.Debug(aliPsp.Response) | |||
} | |||
// ================================================= | |||
func TestDecryptOpenDataToBodyMap(t *testing.T) { | |||
data := "MkvuiIZsGOC8S038cu/JIpoRKnF+ZFjoIRGf5d/K4+ctYjCtb/eEkwgrdB5TeH/93bxff1Ylb+SE+UGStlpvcg==" | |||
key := "TDftre9FpItr46e9BVNJcw==" | |||
bm, err := DecryptOpenDataToBodyMap(data, key) | |||
if err != nil { | |||
xlog.Errorf("DecryptOpenDataToBodyMap(%s,%s),error:%+v", data, key, err) | |||
return | |||
} | |||
xlog.Info("bm:", bm) | |||
} |
@@ -1,101 +0,0 @@ | |||
package alipay | |||
import ( | |||
"context" | |||
"encoding/json" | |||
"fmt" | |||
"github.com/go-pay/gopay" | |||
) | |||
// alipay.commerce.transport.nfccard.send(NFC用户卡信息同步) | |||
// 文档地址:https://opendocs.alipay.com/apis/api_1/alipay.commerce.transport.nfccard.send | |||
func (a *Client) CommerceTransportNfccardSend(ctx context.Context, bm gopay.BodyMap) (aliRsp *CommerceTransportNfccardSendRsp, err error) { | |||
err = bm.CheckEmptyError("issue_org_no", "card_no", "card_status") | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "alipay.commerce.transport.nfccard.send"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(CommerceTransportNfccardSendRsp) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// alipay.commerce.air.callcenter.trade.apply(航司电话订票待申请接口) | |||
// 文档地址:https://opendocs.alipay.com/apis/api_1/alipay.commerce.air.callcenter.trade.apply | |||
func (a *Client) CommerceAirCallcenterTradeApply(ctx context.Context, bm gopay.BodyMap) (aliRsp *CommerceAirCallcenterTradeApplyRsp, err error) { | |||
err = bm.CheckEmptyError("scene_code", "op_code", "channel", "target_id", "target_id_type", "trade_apply_params") | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "alipay.commerce.air.callcenter.trade.apply"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(CommerceAirCallcenterTradeApplyRsp) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// alipay.commerce.operation.gamemarketing.benefit.apply(申请权益发放) | |||
// 文档地址:https://opendocs.alipay.com/apis/api_1/alipay.commerce.operation.gamemarketing.benefit.apply | |||
func (a *Client) CommerceBenefitApply(ctx context.Context, bm gopay.BodyMap) (aliRsp *CommerceBenefitApplyRsp, err error) { | |||
err = bm.CheckEmptyError("activity_code", "trade_no", "user_account", "platform") | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "alipay.commerce.operation.gamemarketing.benefit.apply"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(CommerceBenefitApplyRsp) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// alipay.commerce.operation.gamemarketing.benefit.verify(权益核销) | |||
// 文档地址:https://opendocs.alipay.com/apis/api_1/alipay.commerce.operation.gamemarketing.benefit.verify | |||
func (a *Client) CommerceBenefitVerify(ctx context.Context, bm gopay.BodyMap) (aliRsp *CommerceBenefitVerifyRsp, err error) { | |||
err = bm.CheckEmptyError("activity_code", "voucher_code", "user_account", "trade_no") | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "alipay.commerce.operation.gamemarketing.benefit.verify"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(CommerceBenefitVerifyRsp) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} |
@@ -1,233 +0,0 @@ | |||
package alipay | |||
import ( | |||
"context" | |||
"crypto/aes" | |||
"crypto/cipher" | |||
"crypto/rsa" | |||
"encoding/base64" | |||
"encoding/json" | |||
"errors" | |||
"fmt" | |||
"net/url" | |||
"reflect" | |||
"time" | |||
xaes "github.com/go-pay/crypto/aes" | |||
"github.com/go-pay/crypto/xpem" | |||
"github.com/go-pay/crypto/xrsa" | |||
"github.com/go-pay/gopay" | |||
"github.com/go-pay/gopay/pkg/xhttp" | |||
"github.com/go-pay/xtime" | |||
) | |||
// 格式化请求URL参数 | |||
func FormatURLParam(body gopay.BodyMap) (urlParam string) { | |||
v := url.Values{} | |||
for key, value := range body { | |||
v.Add(key, value.(string)) | |||
} | |||
return v.Encode() | |||
} | |||
// DecryptOpenDataToStruct 解密支付宝开放数据到 结构体 | |||
// encryptedData:包括敏感数据在内的完整用户信息的加密数据 | |||
// secretKey:AES密钥,支付宝管理平台配置 | |||
// beanPtr:需要解析到的结构体指针 | |||
// 文档:https://opendocs.alipay.com/common/02mse3 | |||
func DecryptOpenDataToStruct(encryptedData, secretKey string, beanPtr any) (err error) { | |||
if encryptedData == gopay.NULL || secretKey == gopay.NULL { | |||
return errors.New("encryptedData or secretKey is null") | |||
} | |||
beanValue := reflect.ValueOf(beanPtr) | |||
if beanValue.Kind() != reflect.Ptr { | |||
return errors.New("传入参数类型必须是以指针形式") | |||
} | |||
if beanValue.Elem().Kind() != reflect.Struct { | |||
return errors.New("传入any必须是结构体") | |||
} | |||
var ( | |||
block cipher.Block | |||
blockMode cipher.BlockMode | |||
originData []byte | |||
) | |||
aesKey, _ := base64.StdEncoding.DecodeString(secretKey) | |||
ivKey := []byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} | |||
secretData, _ := base64.StdEncoding.DecodeString(encryptedData) | |||
if block, err = aes.NewCipher(aesKey); err != nil { | |||
return fmt.Errorf("aes.NewCipher:%w", err) | |||
} | |||
if len(secretData)%len(aesKey) != 0 { | |||
return errors.New("encryptedData is error") | |||
} | |||
blockMode = cipher.NewCBCDecrypter(block, ivKey) | |||
originData = make([]byte, len(secretData)) | |||
blockMode.CryptBlocks(originData, secretData) | |||
if len(originData) > 0 { | |||
originData = xaes.PKCS5UnPadding(originData) | |||
} | |||
if err = json.Unmarshal(originData, beanPtr); err != nil { | |||
return fmt.Errorf("json.Unmarshal(%s):%w", string(originData), err) | |||
} | |||
return nil | |||
} | |||
// DecryptOpenDataToBodyMap 解密支付宝开放数据到 BodyMap | |||
// encryptedData:包括敏感数据在内的完整用户信息的加密数据 | |||
// secretKey:AES密钥,支付宝管理平台配置 | |||
// 文档:https://opendocs.alipay.com/common/02mse3 | |||
func DecryptOpenDataToBodyMap(encryptedData, secretKey string) (bm gopay.BodyMap, err error) { | |||
if encryptedData == gopay.NULL || secretKey == gopay.NULL { | |||
return nil, errors.New("encryptedData or secretKey is null") | |||
} | |||
var ( | |||
aesKey, originData []byte | |||
ivKey = []byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} | |||
block cipher.Block | |||
blockMode cipher.BlockMode | |||
) | |||
aesKey, _ = base64.StdEncoding.DecodeString(secretKey) | |||
secretData, _ := base64.StdEncoding.DecodeString(encryptedData) | |||
if block, err = aes.NewCipher(aesKey); err != nil { | |||
return nil, fmt.Errorf("aes.NewCipher:%w", err) | |||
} | |||
if len(secretData)%len(aesKey) != 0 { | |||
return nil, errors.New("encryptedData is error") | |||
} | |||
blockMode = cipher.NewCBCDecrypter(block, ivKey) | |||
originData = make([]byte, len(secretData)) | |||
blockMode.CryptBlocks(originData, secretData) | |||
if len(originData) > 0 { | |||
originData = xaes.PKCS5UnPadding(originData) | |||
} | |||
bm = make(gopay.BodyMap) | |||
if err = json.Unmarshal(originData, &bm); err != nil { | |||
return nil, fmt.Errorf("json.Unmarshal(%s):%w", string(originData), err) | |||
} | |||
return | |||
} | |||
// SystemOauthToken 换取授权访问令牌(默认使用utf-8,RSA2) | |||
// appId:应用ID | |||
// privateKey:应用私钥 | |||
// grantType:值为 authorization_code 时,代表用code换取;值为 refresh_token 时,代表用refresh_token换取,传空默认code换取 | |||
// codeOrToken:支付宝授权码或refresh_token | |||
// signType:签名方式 RSA 或 RSA2,默认 RSA2 | |||
// appAuthToken:可选参数,三方授权令牌 | |||
// 文档:https://opendocs.alipay.com/apis/api_9/alipay.system.oauth.token | |||
func SystemOauthToken(ctx context.Context, appId string, privateKey, grantType, codeOrToken, signType string, appAuthToken ...string) (rsp *SystemOauthTokenResponse, err error) { | |||
key := xrsa.FormatAlipayPrivateKey(privateKey) | |||
aat := "" | |||
if len(appAuthToken) > 0 { | |||
aat = appAuthToken[0] | |||
} | |||
priKey, err := xpem.DecodePrivateKey([]byte(key)) | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
bm := make(gopay.BodyMap) | |||
switch grantType { | |||
case "authorization_code": | |||
bm.Set("grant_type", "authorization_code") | |||
bm.Set("code", codeOrToken) | |||
case "refresh_token": | |||
bm.Set("grant_type", "refresh_token") | |||
bm.Set("refresh_token", codeOrToken) | |||
default: | |||
bm.Set("grant_type", "authorization_code") | |||
bm.Set("code", codeOrToken) | |||
} | |||
if bs, err = systemOauthToken(ctx, appId, priKey, bm, "alipay.system.oauth.token", true, signType, aat); err != nil { | |||
return | |||
} | |||
rsp = new(SystemOauthTokenResponse) | |||
if err = json.Unmarshal(bs, rsp); err != nil { | |||
return nil, fmt.Errorf("json.Unmarshal(%s):%w", string(bs), err) | |||
} | |||
if (rsp.Response == nil) || (rsp.Response != nil && rsp.Response.AccessToken == "") { | |||
return nil, errors.New("response is nil or access_token is NULL") | |||
} | |||
return | |||
} | |||
// systemOauthToken 向支付宝发送请求 | |||
func systemOauthToken(ctx context.Context, appId string, privateKey *rsa.PrivateKey, bm gopay.BodyMap, method string, isProd bool, signType, appAuthToken string) (bs []byte, err error) { | |||
bm.Set("app_id", appId) | |||
bm.Set("method", method) | |||
bm.Set("format", "JSON") | |||
bm.Set("charset", "utf-8") | |||
if signType == gopay.NULL { | |||
bm.Set("sign_type", RSA2) | |||
} else { | |||
bm.Set("sign_type", signType) | |||
} | |||
bm.Set("timestamp", time.Now().Format(xtime.TimeLayout)) | |||
bm.Set("version", "1.0") | |||
if appAuthToken != gopay.NULL { | |||
bm.Set("app_auth_token", appAuthToken) | |||
} | |||
var ( | |||
sign string | |||
baseUrl = baseUrlUtf8 | |||
) | |||
if sign, err = GetRsaSign(bm, bm.GetString("sign_type"), privateKey); err != nil { | |||
return nil, err | |||
} | |||
bm.Set("sign", sign) | |||
if !isProd { | |||
baseUrl = sandboxBaseUrlUtf8 | |||
} | |||
_, bs, err = xhttp.NewClient().Req(xhttp.TypeFormData).Post(baseUrl).SendString(bm.EncodeURLParams()).EndBytes(ctx) | |||
if err != nil { | |||
return nil, err | |||
} | |||
return bs, nil | |||
} | |||
// monitor.heartbeat.syn(验签接口) | |||
// appId:应用ID | |||
// privateKey:应用私钥,支持PKCS1和PKCS8 | |||
// signType:签名方式 alipay.RSA 或 alipay.RSA2,默认 RSA2 | |||
// bizContent:验签时该参数不做任何处理,{任意值},此参数具体看文档 | |||
// 文档:https://opendocs.alipay.com/apis/api_9/monitor.heartbeat.syn | |||
func MonitorHeartbeatSyn(ctx context.Context, appId string, privateKey, signType, bizContent string) (aliRsp *MonitorHeartbeatSynResponse, err error) { | |||
key := xrsa.FormatAlipayPrivateKey(privateKey) | |||
priKey, err := xpem.DecodePrivateKey([]byte(key)) | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
bm := make(gopay.BodyMap) | |||
bm.Set("biz_content", bizContent) | |||
bm.Set("app_id", appId) | |||
bm.Set("method", "monitor.heartbeat.syn") | |||
bm.Set("format", "JSON") | |||
bm.Set("charset", "utf-8") | |||
if signType == gopay.NULL { | |||
bm.Set("sign_type", RSA2) | |||
} else { | |||
bm.Set("sign_type", signType) | |||
} | |||
bm.Set("timestamp", time.Now().Format(xtime.TimeLayout)) | |||
bm.Set("version", "1.0") | |||
sign, err := GetRsaSign(bm, bm.GetString("sign_type"), priKey) | |||
if err != nil { | |||
return nil, err | |||
} | |||
bm.Set("sign", sign) | |||
_, bs, err = xhttp.NewClient().Req(xhttp.TypeFormData).Post(baseUrlUtf8).SendString(bm.EncodeURLParams()).EndBytes(ctx) | |||
if err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(MonitorHeartbeatSynResponse) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
return aliRsp, nil | |||
} |
@@ -1,20 +0,0 @@ | |||
package alipay | |||
import ( | |||
"testing" | |||
"github.com/go-pay/xlog" | |||
) | |||
func TestMonitorHeartbeatSyn(t *testing.T) { | |||
appid := "2016091200494382" | |||
privateKey := "MIIEogIBAAKCAQEAy+CRzKw4krA2RzCDTqg5KJg92XkOY0RN3pW4sYInPqnGtHV7YDHu5nMuxY6un+dLfo91OFOEg+RI+WTOPoM4xJtsOaJwQ1lpjycoeLq1OyetGW5Q8wO+iLWJASaMQM/t/aXR/JHaguycJyqlHSlxANvKKs/tOHx9AhW3LqumaCwz71CDF/+70scYuZG/7wxSjmrbRBswxd1Sz9KHdcdjqT8pmieyPqnM24EKBexHDmQ0ySXvLJJy6eu1dJsPIz+ivX6HEfDXmSmJ71AZVqZyCI1MhK813R5E7XCv5NOtskTe3y8uiIhgGpZSdB77DOyPLcmVayzFVLAQ3AOBDmsY6wIDAQABAoIBAHjsNq31zAw9FcR9orQJlPVd7vlJEt6Pybvmg8hNESfanO+16rpwg2kOEkS8zxgqoJ1tSzJgXu23fgzl3Go5fHcoVDWPAhUAOFre9+M7onh2nPXDd6Hbq6v8OEmFapSaf2b9biHnBHq5Chk08v/r74l501w3PVVOiPqulJrK1oVb+0/YmCvVFpGatBcNaefKUEcA+vekWPL7Yl46k6XeUvRfTwomCD6jpYLUhsAKqZiQJhMGoaLglZvkokQMF/4G78K7FbbVLMM1+JDh8zJ/DDVdY2vHREUcCGhl4mCVQtkzIbpxG++vFg7/g/fDI+PquG22hFILTDdtt2g2fV/4wmkCgYEA6goRQYSiM03y8Tt/M4u1Mm7OWYCksqAsU7rzQllHekIN3WjD41Xrjv6uklsX3sTG1syo7Jr9PGE1xQgjDEIyO8h/3lDQyLyycYnyUPGNNMX8ZjmGwcM51DQ/QfIrY/CXjnnW+MVpmNclAva3L33KXCWjw20VsROV1EA8LCL94BUCgYEA3wH4ANpzo7NqXf+2WlPPMuyRrF0QPIRGlFBNtaKFy0mvoclkREPmK7+N4NIGtMf5JNODS5HkFRgmU4YNdupA2I8lIYpD+TsIobZxGUKUkYzRZYZ1m1ttL69YYvCVz9Xosw/VoQ+RrW0scS5yUKqFMIUOV2R/Imi//c5TdKx6VP8CgYAnJ1ADugC4vI2sNdvt7618pnT3HEJxb8J6r4gKzYzbszlGlURQQAuMfKcP7RVtO1ZYkRyhmLxM4aZxNA9I+boVrlFWDAchzg+8VuunBwIslgLHx0/4EoUWLzd1/OGtco6oU1HXhI9J9pRGjqfO1iiIifN/ujwqx7AFNknayG/YkQKBgD6yNgA/ak12rovYzXKdp14Axn+39k2dPp6J6R8MnyLlB3yruwW6NSbNhtzTD1GZ+wCQepQvYvlPPc8zm+t3tl1r+Rtx3ORf5XBZc3iPkGdPOLubTssrrAnA+U9vph61W+OjqwLJ9sHUNK9pSHhHSIS4k6ycM2YAHyIC9NGTgB0PAoGAJjwd1DgMaQldtWnuXjvohPOo8cQudxXYcs6zVRbx6vtjKe2v7e+eK1SSVrR5qFV9AqxDfGwq8THenRa0LC3vNNplqostuehLhkWCKE7Y75vXMR7N6KU1kdoVWgN4BhXSwuRxmHMQfSY7q3HG3rDGz7mzXo1FVMr/uE4iDGm0IXY=" | |||
bizContent := "{任意值}" | |||
rsp, err := MonitorHeartbeatSyn(ctx, appid, privateKey, RSA2, bizContent) | |||
if err != nil { | |||
xlog.Errorf("MonitorHeartbeatSyn(),error:%+v", err) | |||
return | |||
} | |||
xlog.Info("rsp.Response:", *rsp.Response) | |||
} |
@@ -1,92 +0,0 @@ | |||
package alipay | |||
import ( | |||
"context" | |||
"encoding/json" | |||
"fmt" | |||
"github.com/go-pay/gopay" | |||
"github.com/go-pay/gopay/pkg/xhttp" | |||
) | |||
// alipay.trade.customs.declare(统一收单报关接口) | |||
// 文档地址:https://opendocs.alipay.com/apis/api_29/alipay.trade.customs.declare | |||
func (a *Client) TradeCustomsDeclare(ctx context.Context, bm gopay.BodyMap) (aliRsp *TradeCustomsDeclareRsp, err error) { | |||
err = bm.CheckEmptyError("out_request_no", "trade_no", "merchant_customs_code", "merchant_customs_name", "amount", "customs_place") | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "alipay.trade.customs.declare"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(TradeCustomsDeclareRsp) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// alipay.acquire.customs(报关接口) | |||
// 文档地址:https://opendocs.alipay.com/pre-open/01x3kh | |||
func (a *Client) AcquireCustoms(ctx context.Context, bm gopay.BodyMap) (aliRspBs []byte, err error) { | |||
err = bm.CheckEmptyError("partner", "out_request_no", "trade_no", "merchant_customs_code", "amount", "customs_place", "merchant_customs_name") | |||
if err != nil { | |||
return nil, err | |||
} | |||
bs, err := a.doAliPayCustoms(ctx, bm, "alipay.acquire.customs") | |||
if err != nil { | |||
return nil, err | |||
} | |||
return bs, nil | |||
} | |||
// alipay.overseas.acquire.customs.query(报关查询接口) | |||
// 文档地址:https://opendocs.alipay.com/pre-open/01x3ki | |||
func (a *Client) AcquireCustomsQuery(ctx context.Context, bm gopay.BodyMap) (aliRspBs []byte, err error) { | |||
err = bm.CheckEmptyError("partner", "out_request_nos") | |||
if err != nil { | |||
return nil, err | |||
} | |||
bs, err := a.doAliPayCustoms(ctx, bm, "alipay.overseas.acquire.customs.query") | |||
if err != nil { | |||
return nil, err | |||
} | |||
return bs, nil | |||
} | |||
// 向支付宝发送请求 | |||
func (a *Client) doAliPayCustoms(ctx context.Context, bm gopay.BodyMap, service string) (bs []byte, err error) { | |||
bm.Set("service", service). | |||
Set("_input_charset", "utf-8") | |||
bm.Remove("sign_type") | |||
bm.Remove("sign") | |||
sign, err := a.getRsaSign(bm, RSA) | |||
if err != nil { | |||
return nil, fmt.Errorf("GetRsaSign Error: %v", err) | |||
} | |||
bm.Set("sign_type", RSA).Set("sign", sign) | |||
if a.DebugSwitch == gopay.DebugOn { | |||
a.logger.Debugf("Alipay_Request: %s", bm.JsonBody()) | |||
} | |||
// request | |||
res, bs, err := a.hc.Req(xhttp.TypeFormData).Post("https://mapi.alipay.com/gateway.do").SendString(bm.EncodeURLParams()).EndBytes(ctx) | |||
if err != nil { | |||
return nil, err | |||
} | |||
if a.DebugSwitch == gopay.DebugOn { | |||
a.logger.Debugf("Alipay_Response: %d, %s", res.StatusCode, string(bs)) | |||
} | |||
if res.StatusCode != 200 { | |||
return nil, fmt.Errorf("HTTP Request Error, StatusCode = %d", res.StatusCode) | |||
} | |||
return bs, nil | |||
} |
@@ -1,116 +0,0 @@ | |||
package alipay | |||
import ( | |||
"context" | |||
"encoding/json" | |||
"fmt" | |||
"github.com/go-pay/gopay" | |||
) | |||
// alipay.data.bill.balance.query(支付宝商家账户当前余额查询) | |||
// 文档地址:https://opendocs.alipay.com/open/2acb3c34_alipay.data.bill.balance.query | |||
func (a *Client) DataBillBalanceQuery(ctx context.Context, bm gopay.BodyMap) (aliRsp *DataBillBalanceQueryResponse, err error) { | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "alipay.data.bill.balance.query"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(DataBillBalanceQueryResponse) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// alipay.data.bill.accountlog.query(支付宝商家账户账务明细查询) | |||
// 文档地址:https://opendocs.alipay.com/open/dae3ac99_alipay.data.bill.accountlog.query | |||
func (a *Client) DataBillAccountLogQuery(ctx context.Context, bm gopay.BodyMap) (aliRsp *DataBillAccountLogQueryResponse, err error) { | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "alipay.data.bill.accountlog.query"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(DataBillAccountLogQueryResponse) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// alipay.data.bill.ereceipt.apply(申请电子回单(incubating)) | |||
// 文档地址:https://opendocs.alipay.com/open/1aad1956_alipay.data.bill.ereceipt.apply | |||
func (a *Client) DataBillEreceiptApply(ctx context.Context, bm gopay.BodyMap) (aliRsp *DataBillEreceiptApplyRsp, err error) { | |||
err = bm.CheckEmptyError("type", "key") | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "alipay.data.bill.ereceipt.apply"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(DataBillEreceiptApplyRsp) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// alipay.data.bill.ereceipt.query(查询电子回单状态(incubating)) | |||
// 文档地址:https://opendocs.alipay.com/open/30b94a2f_alipay.data.bill.ereceipt.query | |||
func (a *Client) DataBillEreceiptQuery(ctx context.Context, bm gopay.BodyMap) (aliRsp *DataBillEreceiptQueryRsp, err error) { | |||
err = bm.CheckEmptyError("file_id") | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "alipay.data.bill.ereceipt.query"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(DataBillEreceiptQueryRsp) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// alipay.data.dataservice.bill.downloadurl.query(查询对账单下载地址) | |||
// 文档地址:https://opendocs.alipay.com/open/02e7gr | |||
func (a *Client) DataBillDownloadUrlQuery(ctx context.Context, bm gopay.BodyMap) (aliRsp *DataBillDownloadUrlQueryResponse, err error) { | |||
err = bm.CheckEmptyError("bill_type", "bill_date") | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "alipay.data.dataservice.bill.downloadurl.query"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(DataBillDownloadUrlQueryResponse) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} |
@@ -1,20 +0,0 @@ | |||
package alipay | |||
import ( | |||
"testing" | |||
"github.com/go-pay/gopay" | |||
"github.com/go-pay/xlog" | |||
) | |||
func TestClient_DataBillDownloadUrlQuery(t *testing.T) { | |||
bm := make(gopay.BodyMap) | |||
bm.Set("bill_type", "trade"). | |||
Set("bill_date", "2016-04-05") | |||
rsp, err := client.DataBillDownloadUrlQuery(ctx, bm) | |||
if err != nil { | |||
xlog.Error(err) | |||
return | |||
} | |||
xlog.Debug("rsp:", rsp) | |||
} |
@@ -1,50 +0,0 @@ | |||
package alipay | |||
import ( | |||
"fmt" | |||
) | |||
// BizErr 用于判断支付宝的业务逻辑是否有错误 | |||
type BizErr struct { | |||
Code string `json:"code"` | |||
Msg string `json:"msg"` | |||
SubCode string `json:"sub_code"` | |||
SubMsg string `json:"sub_msg"` | |||
} | |||
// bizErrCheck 检查业务码是否为10000 否则返回一个BizErr | |||
func bizErrCheck(errRsp ErrorResponse) error { | |||
if errRsp.Code != "10000" { | |||
return &BizErr{ | |||
Code: errRsp.Code, | |||
Msg: errRsp.Msg, | |||
SubCode: errRsp.SubCode, | |||
SubMsg: errRsp.SubMsg, | |||
} | |||
} | |||
return nil | |||
} | |||
// bizErrCheckTradePay 检查业务码是否为10000、10003,否则返回一个BizErr | |||
func bizErrCheckTradePay(errRsp ErrorResponse) error { | |||
if errRsp.Code != "10000" && errRsp.Code != "10003" { | |||
return &BizErr{ | |||
Code: errRsp.Code, | |||
Msg: errRsp.Msg, | |||
SubCode: errRsp.SubCode, | |||
SubMsg: errRsp.SubMsg, | |||
} | |||
} | |||
return nil | |||
} | |||
func (e *BizErr) Error() string { | |||
return fmt.Sprintf(`{"code":"%s","msg":"%s","sub_code":"%s","sub_msg":"%s"}`, e.Code, e.Msg, e.SubCode, e.SubMsg) | |||
} | |||
func IsBizError(err error) (*BizErr, bool) { | |||
if bizErr, ok := err.(*BizErr); ok { | |||
return bizErr, true | |||
} | |||
return nil, false | |||
} |
@@ -1,45 +0,0 @@ | |||
package alipay | |||
import ( | |||
"testing" | |||
) | |||
func TestBizErr_BizErrCheck(t *testing.T) { | |||
bizErrRsp := ErrorResponse{ | |||
Code: "40004", | |||
Msg: "NOT_FOUND", | |||
} | |||
if bizErrCheck(bizErrRsp) == nil { | |||
t.Fail() | |||
} | |||
noBizErrRsp := ErrorResponse{ | |||
Code: "10000", | |||
Msg: "SUCCEED", | |||
} | |||
if bizErrCheck(noBizErrRsp) != nil { | |||
t.Fail() | |||
} | |||
} | |||
func TestBizErr_AsBizError(t *testing.T) { | |||
bizErrRsp := ErrorResponse{ | |||
Code: "40004", | |||
Msg: "NOT_FOUND", | |||
} | |||
noBizErrRsp := ErrorResponse{ | |||
Code: "10000", | |||
Msg: "SUCCEED", | |||
} | |||
var err error | |||
err = bizErrCheck(bizErrRsp) | |||
if _, ok := IsBizError(err); !ok { | |||
t.Fail() | |||
} | |||
err = bizErrCheck(noBizErrRsp) | |||
if _, ok := IsBizError(err); !ok { | |||
t.Fail() | |||
} | |||
} |
@@ -1,193 +0,0 @@ | |||
package alipay | |||
import ( | |||
"context" | |||
"encoding/json" | |||
"fmt" | |||
"github.com/go-pay/gopay" | |||
) | |||
// datadigital.fincloud.generalsaas.face.verification.initialize(人脸核身初始化) | |||
// 文档地址:https://opendocs.alipay.com/open/04jg6r | |||
func (a *Client) FaceVerificationInitialize(ctx context.Context, bm gopay.BodyMap) (aliRsp *FaceVerificationInitializeRsp, err error) { | |||
err = bm.CheckEmptyError("outer_order_no", "biz_code", "identity_type", "cert_type", "cert_name", "cert_no") | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "datadigital.fincloud.generalsaas.face.verification.initialize"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(FaceVerificationInitializeRsp) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// datadigital.fincloud.generalsaas.face.verification.query(人脸核身结果查询) | |||
// 文档地址:https://opendocs.alipay.com/open/04jg6s | |||
func (a *Client) FaceVerificationQuery(ctx context.Context, bm gopay.BodyMap) (aliRsp *FaceVerificationQueryRsp, err error) { | |||
err = bm.CheckEmptyError("certify_id") | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "datadigital.fincloud.generalsaas.face.verification.query"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(FaceVerificationQueryRsp) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// datadigital.fincloud.generalsaas.face.certify.initialize(H5人脸核身初始化) | |||
// 文档地址:https://opendocs.alipay.com/open/02zloa | |||
func (a *Client) FaceCertifyInitialize(ctx context.Context, bm gopay.BodyMap) (aliRsp *FaceCertifyInitializeRsp, err error) { | |||
err = bm.CheckEmptyError("outer_order_no", "biz_code", "identity_param", "merchant_config") | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "datadigital.fincloud.generalsaas.face.certify.initialize"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(FaceCertifyInitializeRsp) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// datadigital.fincloud.generalsaas.face.certify.verify(H5人脸核身开始认证) | |||
// 文档地址:https://opendocs.alipay.com/open/02zlob | |||
func (a *Client) FaceCertifyVerify(ctx context.Context, bm gopay.BodyMap) (aliRsp *FaceCertifyVerifyRsp, err error) { | |||
err = bm.CheckEmptyError("certify_id") | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "datadigital.fincloud.generalsaas.face.certify.verify"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(FaceCertifyVerifyRsp) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// datadigital.fincloud.generalsaas.face.certify.query(H5人脸核身查询记录) | |||
// 文档地址:https://opendocs.alipay.com/open/02zloc | |||
func (a *Client) FaceCertifyQuery(ctx context.Context, bm gopay.BodyMap) (aliRsp *FaceCertifyQueryRsp, err error) { | |||
err = bm.CheckEmptyError("certify_id") | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "datadigital.fincloud.generalsaas.face.certify.query"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(FaceCertifyQueryRsp) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// datadigital.fincloud.generalsaas.face.source.certify(纯服务端人脸核身) | |||
// 文档地址:https://opendocs.alipay.com/open/04pxq6 | |||
func (a *Client) FaceSourceCertify(ctx context.Context, bm gopay.BodyMap) (aliRsp *FaceSourceCertifyRsp, err error) { | |||
err = bm.CheckEmptyError("outer_biz_no", "cert_type", "cert_no", "cert_name") | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "datadigital.fincloud.generalsaas.face.source.certify"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(FaceSourceCertifyRsp) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// datadigital.fincloud.generalsaas.face.check.initialize(活体检测初始化) | |||
// 文档地址:https://opendocs.alipay.com/open/03nisu | |||
func (a *Client) FaceCheckInitialize(ctx context.Context, bm gopay.BodyMap) (aliRsp *FaceCheckInitializeRsp, err error) { | |||
err = bm.CheckEmptyError("outer_order_no", "biz_code") | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "datadigital.fincloud.generalsaas.face.check.initialize"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(FaceCheckInitializeRsp) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// datadigital.fincloud.generalsaas.face.check.query(活体检测结果查询) | |||
// 文档地址:https://opendocs.alipay.com/open/03nisv | |||
func (a *Client) FaceCheckQuery(ctx context.Context, bm gopay.BodyMap) (aliRsp *FaceCheckQueryRsp, err error) { | |||
err = bm.CheckEmptyError("certify_id") | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "datadigital.fincloud.generalsaas.face.check.query"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(FaceCheckQueryRsp) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} |
@@ -1,388 +0,0 @@ | |||
package alipay | |||
import ( | |||
"context" | |||
"encoding/json" | |||
"fmt" | |||
"github.com/go-pay/gopay" | |||
) | |||
// alipay.fund.trans.uni.transfer(单笔转账接口) | |||
// 文档地址:https://opendocs.alipay.com/open/02byuo | |||
func (a *Client) FundTransUniTransfer(ctx context.Context, bm gopay.BodyMap) (aliRsp *FundTransUniTransferResponse, err error) { | |||
err = bm.CheckEmptyError("out_biz_no", "trans_amount", "product_code", "payee_info") | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "alipay.fund.trans.uni.transfer"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(FundTransUniTransferResponse) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// alipay.fund.account.query(支付宝资金账户资产查询接口) | |||
// 文档地址:https://opendocs.alipay.com/open/02byuq | |||
func (a *Client) FundAccountQuery(ctx context.Context, bm gopay.BodyMap) (aliRsp *FundAccountQueryResponse, err error) { | |||
err = bm.CheckEmptyError("alipay_user_id") | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "alipay.fund.account.query"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(FundAccountQueryResponse) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// alipay.fund.trans.common.query(转账业务单据查询接口) | |||
// 文档地址:https://opendocs.alipay.com/open/02byup | |||
func (a *Client) FundTransCommonQuery(ctx context.Context, bm gopay.BodyMap) (aliRsp *FundTransCommonQueryResponse, err error) { | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "alipay.fund.trans.common.query"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(FundTransCommonQueryResponse) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// alipay.fund.trans.order.query(查询转账订单接口) | |||
// 文档地址: https://opendocs.alipay.com/apis/api_28/alipay.fund.trans.order.query | |||
func (a *Client) FundTransOrderQuery(ctx context.Context, bm gopay.BodyMap) (aliRsp *FundTransOrderQueryResponse, err error) { | |||
// 两个请求参数不能同时为空 | |||
err1 := bm.CheckEmptyError("out_biz_no") | |||
err2 := bm.CheckEmptyError("order_id") | |||
if err1 != nil && err2 != nil { | |||
return nil, fmt.Errorf("out_biz_no,order_id : Both cannot be empty at some time") | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "alipay.fund.trans.order.query"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(FundTransOrderQueryResponse) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// alipay.fund.trans.refund(资金退回接口) | |||
// 文档地址: https://opendocs.alipay.com/open/02byvd | |||
func (a *Client) FundTransRefund(ctx context.Context, bm gopay.BodyMap) (aliRsp *FundTransRefundResponse, err error) { | |||
err = bm.CheckEmptyError("order_id", "out_request_no", "refund_amount") | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "alipay.fund.trans.refund"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(FundTransRefundResponse) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// alipay.fund.auth.order.freeze(资金授权冻结接口) | |||
// 文档地址: https://opendocs.alipay.com/open/02fkb9 | |||
func (a *Client) FundAuthOrderFreeze(ctx context.Context, bm gopay.BodyMap) (aliRsp *FundAuthOrderFreezeResponse, err error) { | |||
err = bm.CheckEmptyError("auth_code", "auth_code_type", "out_order_no", "out_request_no", "order_title", "amount") | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "alipay.fund.auth.order.freeze"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(FundAuthOrderFreezeResponse) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// alipay.fund.auth.order.voucher.create(资金授权发码接口) | |||
// 文档地址: https://opendocs.alipay.com/open/02fit5 | |||
func (a *Client) FundAuthOrderVoucherCreate(ctx context.Context, bm gopay.BodyMap) (aliRsp *FundAuthOrderVoucherCreateResponse, err error) { | |||
err = bm.CheckEmptyError("out_order_no", "out_request_no", "order_title", "amount", "product_code") | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "alipay.fund.auth.order.voucher.create"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(FundAuthOrderVoucherCreateResponse) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// alipay.fund.auth.order.app.freeze(线上资金授权冻结接口) | |||
// 文档地址: https://opendocs.alipay.com/open/02f912 | |||
func (a *Client) FundAuthOrderAppFreeze(ctx context.Context, bm gopay.BodyMap) (payParam string, err error) { | |||
err = bm.CheckEmptyError("out_order_no", "out_request_no", "order_title", "amount", "product_code") | |||
if err != nil { | |||
return gopay.NULL, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "alipay.fund.auth.order.app.freeze"); err != nil { | |||
return "", err | |||
} | |||
payParam = string(bs) | |||
return payParam, nil | |||
} | |||
// alipay.fund.auth.order.unfreeze(资金授权解冻接口) | |||
// 文档地址: https://opendocs.alipay.com/open/02fkbc | |||
func (a *Client) FundAuthOrderUnfreeze(ctx context.Context, bm gopay.BodyMap) (aliRsp *FundAuthOrderUnfreezeResponse, err error) { | |||
err = bm.CheckEmptyError("auth_no", "out_request_no", "amount", "remark") | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "alipay.fund.auth.order.unfreeze"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(FundAuthOrderUnfreezeResponse) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// alipay.fund.auth.operation.detail.query(资金授权操作查询接口) | |||
// 文档地址: https://opendocs.alipay.com/open/02fkbd | |||
func (a *Client) FundAuthOperationDetailQuery(ctx context.Context, bm gopay.BodyMap) (aliRsp *FundAuthOperationDetailQueryResponse, err error) { | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "alipay.fund.auth.operation.detail.query"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(FundAuthOperationDetailQueryResponse) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// alipay.fund.auth.operation.cancel(资金授权撤销接口) | |||
// 文档地址: https://opendocs.alipay.com/open/02fkbb | |||
func (a *Client) FundAuthOperationCancel(ctx context.Context, bm gopay.BodyMap) (aliRsp *FundAuthOperationCancelResponse, err error) { | |||
err = bm.CheckEmptyError("remark") | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "alipay.fund.auth.operation.cancel"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(FundAuthOperationCancelResponse) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// alipay.fund.batch.create(批次下单接口) | |||
// 文档地址: https://opendocs.alipay.com/apis/api_28/alipay.fund.batch.create | |||
func (a *Client) FundBatchCreate(ctx context.Context, bm gopay.BodyMap) (aliRsp *FundBatchCreateResponse, err error) { | |||
err = bm.CheckEmptyError("out_batch_no", "product_code", "biz_scene", "order_title", "total_trans_amount", "total_count", "trans_order_list") | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "alipay.fund.batch.create"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(FundBatchCreateResponse) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// alipay.fund.batch.close(批量转账关单接口) | |||
// 文档地址: https://opendocs.alipay.com/apis/api_28/alipay.fund.batch.close | |||
func (a *Client) FundBatchClose(ctx context.Context, bm gopay.BodyMap) (aliRsp *FundBatchCloseResponse, err error) { | |||
err = bm.CheckEmptyError("biz_scene") | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "alipay.fund.batch.close"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(FundBatchCloseResponse) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// alipay.fund.batch.detail.query(批量转账明细查询接口) | |||
// 文档地址: https://opendocs.alipay.com/apis/api_28/alipay.fund.batch.detail.query | |||
func (a *Client) FundBatchDetailQuery(ctx context.Context, bm gopay.BodyMap) (aliRsp *FundBatchDetailQueryResponse, err error) { | |||
err = bm.CheckEmptyError("biz_scene") | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "alipay.fund.batch.detail.query"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(FundBatchDetailQueryResponse) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// alipay.fund.trans.app.pay(现金红包无线支付接口) | |||
// 文档地址: https://opendocs.alipay.com/open/03rbyf | |||
func (a *Client) FundTransAppPay(ctx context.Context, bm gopay.BodyMap) (aliRsp *FundTransAppPayResponse, err error) { | |||
err = bm.CheckEmptyError("out_biz_no", "trans_amount", "product_code", "biz_scene") | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "alipay.fund.trans.app.pay"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(FundTransAppPayResponse) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// alipay.fund.trans.payee.bind.query(资金收款账号绑定关系查询) | |||
// 文档地址: https://opendocs.alipay.com/apis/020tl1 | |||
func (a *Client) FundTransPayeeBindQuery(ctx context.Context, bm gopay.BodyMap) (aliRsp *FundTransPayeeBindQueryRsp, err error) { | |||
err = bm.CheckEmptyError("identity", "identity_type") | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "alipay.fund.trans.payee.bind.query"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(FundTransPayeeBindQueryRsp) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// alipay.fund.trans.page.pay(资金转账页面支付接口) | |||
// 文档地址: https://opendocs.alipay.com/open/03rbye | |||
func (a *Client) FundTransPagePay(ctx context.Context, bm gopay.BodyMap) (aliRsp *FundTransPagePayRsp, err error) { | |||
err = bm.CheckEmptyError("out_biz_no", "trans_amount", "product_code", "biz_scene") | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "alipay.fund.trans.page.pay"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(FundTransPagePayRsp) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} |
@@ -1,105 +0,0 @@ | |||
package alipay | |||
import ( | |||
"testing" | |||
"github.com/go-pay/gopay" | |||
"github.com/go-pay/xlog" | |||
) | |||
func TestFundTransUniTransfer(t *testing.T) { | |||
bm := make(gopay.BodyMap) | |||
bm.Set("out_biz_no", "201806300011232301"). | |||
Set("trans_amount", "0.01"). | |||
Set("biz_scene", "DIRECT_TRANSFER"). | |||
Set("product_code", "TRANS_ACCOUNT_NO_PWD"). | |||
SetBodyMap("payee_info", func(bm gopay.BodyMap) { | |||
bm.Set("identity", "85411418@qq.com") | |||
bm.Set("identity_type", "ALIPAY_LOGON_ID") | |||
}) | |||
aliRsp, err := client.FundTransUniTransfer(ctx, bm) | |||
if err != nil { | |||
xlog.Error(err) | |||
return | |||
} | |||
xlog.Debug("aliRsp:", *aliRsp) | |||
xlog.Debug("aliRsp.Response:", aliRsp.Response) | |||
} | |||
func TestFundAccountQuery(t *testing.T) { | |||
bm := make(gopay.BodyMap) | |||
bm.Set("alipay_user_id", "2088301409188095") /*.Set("account_type", "ACCTRANS_ACCOUNT")*/ | |||
aliRsp, err := client.FundAccountQuery(ctx, bm) | |||
if err != nil { | |||
xlog.Error(err) | |||
return | |||
} | |||
xlog.Debug("aliRsp:", *aliRsp) | |||
xlog.Debug("aliRsp.Response:", aliRsp.Response) | |||
} | |||
func TestFundTransCommonQuery(t *testing.T) { | |||
bm := make(gopay.BodyMap) | |||
bm.Set("product_code", "TRANS_ACCOUNT_NO_PWD"). | |||
Set("biz_scene", "DIRECT_TRANSFER"). | |||
Set("order_id", "20190801110070000006380000250621") | |||
aliRsp, err := client.FundTransCommonQuery(ctx, bm) | |||
if err != nil { | |||
xlog.Error(err) | |||
return | |||
} | |||
xlog.Debug("aliRsp:", *aliRsp) | |||
xlog.Debug("aliRsp.Response:", aliRsp.Response) | |||
} | |||
func TestFundTransOrderQuery(t *testing.T) { | |||
bm := make(gopay.BodyMap) | |||
bm.Set("out_biz_no", "201806300011232301") | |||
aliRsp, err := client.FundTransOrderQuery(ctx, bm) | |||
if err != nil { | |||
xlog.Error(err) | |||
return | |||
} | |||
xlog.Debug("aliRsp:", *aliRsp) | |||
xlog.Debug("aliRsp.Response:", aliRsp.Response) | |||
} | |||
func TestFundAuthOrderAppFreeze(t *testing.T) { | |||
bm := make(gopay.BodyMap) | |||
bm.Set("out_order_no", "8077735255938023"). | |||
Set("out_request_no", "8077735255938032"). | |||
Set("order_title", "预授权冻结"). | |||
Set("amount", "0.01"). | |||
Set("product_code", "PRE_AUTH_ONLINE") | |||
aliRsp, err := client.FundAuthOrderAppFreeze(ctx, bm) | |||
if err != nil { | |||
xlog.Error(err) | |||
return | |||
} | |||
xlog.Debug("aliRsp:", aliRsp) | |||
} | |||
func TestClient_FundTransPagePay(t *testing.T) { | |||
bm := make(gopay.BodyMap) | |||
bm.Set("out_biz_no", "2018062800001"). | |||
Set("trans_amount", "8.88"). | |||
Set("product_code", "STD_APP_TRANSFER"). | |||
Set("biz_scene", "PARTY_MEMBERSHIP_DUES"). | |||
SetBodyMap("payee_info", func(b gopay.BodyMap) { | |||
b.Set("identity", "208812*****41234"). | |||
Set("identity_type", "ALIPAY_USER_ID"). | |||
Set("name", "黄龙国际有限公司") | |||
}) | |||
aliRsp, err := client.FundTransPagePay(ctx, bm) | |||
if err != nil { | |||
//xlog.Errorf("client.FundTransPagePay(%+v),error:%+v", bm, err) | |||
return | |||
} | |||
xlog.Debug("aliRsp:", *aliRsp) | |||
} |
@@ -1,33 +0,0 @@ | |||
package alipay | |||
import ( | |||
"context" | |||
"encoding/json" | |||
"fmt" | |||
"github.com/go-pay/gopay" | |||
) | |||
// alipay.merchant.item.file.upload(商品文件上传接口) | |||
// 文档地址:https://opendocs.alipay.com/apis/api_4/alipay.merchant.item.file.upload | |||
func (a *Client) MerchantItemFileUpload(ctx context.Context, bm gopay.BodyMap) (aliRsp *MerchantItemFileUploadRsp, err error) { | |||
err = bm.CheckEmptyError("scene", "file_content") | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = a.FileUploadRequest(ctx, bm, "alipay.merchant.item.file.upload"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(MerchantItemFileUploadRsp) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil { | |||
return nil, err | |||
} | |||
if aliRsp.Response != nil && aliRsp.Response.Code != "10000" { | |||
info := aliRsp.Response | |||
return aliRsp, fmt.Errorf(`{"code":"%s","msg":"%s","sub_code":"%s","sub_msg":"%s"}`, info.Code, info.Msg, info.SubCode, info.SubMsg) | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} |
@@ -1,38 +0,0 @@ | |||
package alipay | |||
import ( | |||
"io" | |||
"os" | |||
"testing" | |||
"github.com/go-pay/gopay" | |||
"github.com/go-pay/xlog" | |||
) | |||
func TestMerchantItemFileUpload(t *testing.T) { | |||
// 请求参数 | |||
logo, err := os.Open("../logo.png") | |||
if err != nil { | |||
xlog.Errorf("os.Open(%s),error:%+v", "../logo.png", err) | |||
return | |||
} | |||
xlog.Warnf("fileName: %s", logo.Name()) | |||
allBs, err := io.ReadAll(logo) | |||
if err != nil { | |||
xlog.Errorf("io.ReadAll(%s),error:%+v", logo.Name(), err) | |||
return | |||
} | |||
f := &gopay.File{ | |||
Name: "logo.png", | |||
Content: allBs, | |||
} | |||
bm := make(gopay.BodyMap) | |||
bm.Set("scene", "SYNC_ORDER") // 素材固定值 | |||
bm.SetFormFile("file_content", f) | |||
aliRsp, err := client.MerchantItemFileUpload(ctx, bm) | |||
if err != nil { | |||
xlog.Errorf("client.MerchantItemFileUpload(),error:%+v", err) | |||
return | |||
} | |||
xlog.Debug("aliRsp:", *aliRsp) | |||
} |
@@ -1,239 +0,0 @@ | |||
package alipay | |||
import ( | |||
"context" | |||
"encoding/json" | |||
"fmt" | |||
"github.com/go-pay/gopay" | |||
) | |||
// koubei.trade.order.aggregate.consult(聚合支付订单咨询服务) | |||
// 文档地址:https://opendocs.alipay.com/apis/api_1/koubei.trade.order.aggregate.consult | |||
func (a *Client) KoubeiTradeOrderAggregateConsult(ctx context.Context, bm gopay.BodyMap) (aliRsp *KoubeiTradeOrderAggregateConsultRsp, err error) { | |||
err = bm.CheckEmptyError("shop_id", "total_amount") | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "koubei.trade.order.aggregate.consult"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(KoubeiTradeOrderAggregateConsultRsp) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// koubei.trade.order.precreate(口碑订单预下单) | |||
// 文档地址:https://opendocs.alipay.com/apis/api_1/koubei.trade.order.precreate | |||
func (a *Client) KoubeiTradeOrderPrecreate(ctx context.Context, bm gopay.BodyMap) (aliRsp *KoubeiTradeOrderPrecreateRsp, err error) { | |||
err = bm.CheckEmptyError("request_id", "biz_type") | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "koubei.trade.order.precreate"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(KoubeiTradeOrderPrecreateRsp) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// koubei.trade.itemorder.buy(口碑商品交易购买接口) | |||
// 文档地址:https://opendocs.alipay.com/apis/api_1/koubei.trade.itemorder.buy | |||
func (a *Client) KoubeiTradeItemorderBuy(ctx context.Context, bm gopay.BodyMap) (aliRsp *KoubeiTradeItemorderBuyRsp, err error) { | |||
err = bm.CheckEmptyError("out_order_no", "subject", "biz_product", "biz_scene", "shop_id", "buyer_id", "total_amount", "item_order_details") | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "koubei.trade.itemorder.buy"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(KoubeiTradeItemorderBuyRsp) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// koubei.trade.order.consult(口碑订单预咨询) | |||
// 文档地址:https://opendocs.alipay.com/apis/api_1/koubei.trade.order.consult | |||
func (a *Client) KoubeiTradeOrderConsult(ctx context.Context, bm gopay.BodyMap) (aliRsp *KoubeiTradeOrderConsultRsp, err error) { | |||
err = bm.CheckEmptyError("request_id", "user_id", "total_amount", "shop_id") | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "koubei.trade.order.consult"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(KoubeiTradeOrderConsultRsp) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// koubei.trade.itemorder.refund(口碑商品交易退货接口) | |||
// 文档地址:https://opendocs.alipay.com/apis/api_1/koubei.trade.itemorder.refund | |||
func (a *Client) KoubeiTradeItemorderRefund(ctx context.Context, bm gopay.BodyMap) (aliRsp *KoubeiTradeItemorderRefundRsp, err error) { | |||
err = bm.CheckEmptyError("order_no", "out_request_no", "refund_infos") | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "koubei.trade.itemorder.refund"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(KoubeiTradeItemorderRefundRsp) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// koubei.trade.itemorder.query(口碑商品交易查询接口) | |||
// 文档地址:https://opendocs.alipay.com/apis/api_1/koubei.trade.itemorder.query | |||
func (a *Client) KoubeiTradeItemorderQuery(ctx context.Context, bm gopay.BodyMap) (aliRsp *KoubeiTradeItemorderQueryRsp, err error) { | |||
err = bm.CheckEmptyError("order_no") | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "koubei.trade.itemorder.query"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(KoubeiTradeItemorderQueryRsp) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// koubei.trade.ticket.ticketcode.send(码商发码成功回调接口) | |||
// 文档地址:https://opendocs.alipay.com/apis/api_1/koubei.trade.ticket.ticketcode.send | |||
func (a *Client) KoubeiTradeTicketTicketcodeSend(ctx context.Context, bm gopay.BodyMap) (aliRsp *KoubeiTradeTicketTicketcodeSendRsp, err error) { | |||
err = bm.CheckEmptyError("request_id", "isv_ma_list", "send_order_no", "send_token", "order_no") | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "koubei.trade.ticket.ticketcode.send"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(KoubeiTradeTicketTicketcodeSendRsp) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// koubei.trade.ticket.ticketcode.delay(口碑凭证延期接口) | |||
// 文档地址:https://opendocs.alipay.com/apis/api_1/koubei.trade.ticket.ticketcode.delay | |||
func (a *Client) KoubeiTradeTicketTicketcodeDelay(ctx context.Context, bm gopay.BodyMap) (aliRsp *KoubeiTradeTicketTicketcodeDelayRsp, err error) { | |||
err = bm.CheckEmptyError("request_id", "end_date", "ticket_code", "code_type", "order_no") | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "koubei.trade.ticket.ticketcode.delay"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(KoubeiTradeTicketTicketcodeDelayRsp) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// koubei.trade.ticket.ticketcode.query(口碑凭证码查询) | |||
// 文档地址:https://opendocs.alipay.com/apis/api_1/koubei.trade.ticket.ticketcode.query | |||
func (a *Client) KoubeiTradeTicketTicketcodeQuery(ctx context.Context, bm gopay.BodyMap) (aliRsp *KoubeiTradeTicketTicketcodeQueryRsp, err error) { | |||
err = bm.CheckEmptyError("ticket_code", "shop_id") | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "koubei.trade.ticket.ticketcode.query"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(KoubeiTradeTicketTicketcodeQueryRsp) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// koubei.trade.ticket.ticketcode.cancel(口碑凭证码撤销核销) | |||
// 文档地址:https://opendocs.alipay.com/apis/api_1/koubei.trade.ticket.ticketcode.cancel | |||
func (a *Client) KoubeiTradeTicketTicketcodeCancel(ctx context.Context, bm gopay.BodyMap) (aliRsp *KoubeiTradeTicketTicketcodeCancelRsp, err error) { | |||
err = bm.CheckEmptyError("request_id", "request_biz_no", "ticket_code") | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "koubei.trade.ticket.ticketcode.cancel"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(KoubeiTradeTicketTicketcodeCancelRsp) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} |
@@ -1,178 +0,0 @@ | |||
package alipay | |||
import ( | |||
"testing" | |||
"github.com/go-pay/gopay" | |||
"github.com/go-pay/xlog" | |||
) | |||
func TestKoubeiTradeOrderPrecreate(t *testing.T) { | |||
// 请求参数 | |||
bm := make(gopay.BodyMap) | |||
bm.Set("request_id", "20181120111040030100030100002400") | |||
bm.Set("biz_type", "POST_ORDER_PAY") | |||
aliRsp, err := client.KoubeiTradeOrderPrecreate(ctx, bm) | |||
if err != nil { | |||
xlog.Errorf("client.KoubeiTradeOrderPrecreate(%+v),error:%+v", bm, err) | |||
return | |||
} | |||
xlog.Debug("aliRsp:", *aliRsp) | |||
} | |||
func TestKoubeiTradeItemorderBuy(t *testing.T) { | |||
// 请求参数 | |||
bm := make(gopay.BodyMap) | |||
bm.Set("out_order_no", "A2018011200000001") | |||
bm.Set("subject", "星巴克礼品卡") | |||
bm.Set("biz_product", "ONLINE_PURCHASE") | |||
bm.Set("biz_scene", "giftCard") | |||
bm.Set("shop_id", "2015051100077000000000000300") | |||
bm.Set("buyer_id", "2088102015433735") | |||
bm.Set("total_amount", "100.00") | |||
bm.SetBodyMap("item_order_details", func(bm gopay.BodyMap) { | |||
bm.Set("sku_id", "2015060400076000000000012100") | |||
bm.Set("original_price", "50.00") | |||
bm.Set("price", "10.00") | |||
bm.Set("quantity", "10") | |||
}) | |||
aliRsp, err := client.KoubeiTradeItemorderBuy(ctx, bm) | |||
if err != nil { | |||
xlog.Errorf("client.KoubeiTradeItemorderBuy(%+v),error:%+v", bm, err) | |||
return | |||
} | |||
xlog.Debug("aliRsp:", *aliRsp) | |||
} | |||
func TestKoubeiTradeOrderConsult(t *testing.T) { | |||
// 请求参数 | |||
bm := make(gopay.BodyMap) | |||
bm.Set("request_id", "0ad1e47b1500473065347103327127") | |||
bm.Set("user_id", "2088212151390950") | |||
bm.Set("total_amount", "88.88") | |||
bm.Set("shop_id", "2015051100077000000000000300") | |||
aliRsp, err := client.KoubeiTradeOrderConsult(ctx, bm) | |||
if err != nil { | |||
xlog.Errorf("client.KoubeiTradeOrderConsult(%+v),error:%+v", bm, err) | |||
return | |||
} | |||
xlog.Debug("aliRsp:", *aliRsp) | |||
} | |||
func TestKoubeiTradeItemorderRefund(t *testing.T) { | |||
// 请求参数 | |||
bm := make(gopay.BodyMap) | |||
bm.Set("order_no", "20171114111040030100030100002400") | |||
bm.Set("out_request_no", "B201701180000002") | |||
bm.Set("total_amount", "88.88") | |||
bm.SetBodyMap("refund_infos", func(bm gopay.BodyMap) { | |||
bm.Set("item_order_no", "201701220000008000000001") | |||
bm.Set("amount", "10.00") | |||
}) | |||
aliRsp, err := client.KoubeiTradeItemorderRefund(ctx, bm) | |||
if err != nil { | |||
xlog.Errorf("client.KoubeiTradeItemorderRefund(%+v),error:%+v", bm, err) | |||
return | |||
} | |||
xlog.Debug("aliRsp:", *aliRsp) | |||
} | |||
func TestKoubeiTradeItemorderQuery(t *testing.T) { | |||
// 请求参数 | |||
bm := make(gopay.BodyMap) | |||
bm.Set("order_no", "20160831001040010900010000000001") | |||
bm.Set("out_request_no", "20160831001040010900010000000001") | |||
bm.Set("partner_id", "20180000000001") | |||
bm.Set("status", "CLOSE") | |||
bm.Set("buyer_id", "2088102164040745") | |||
bm.Set("biz_product", "ONLINE_TRADE_PAY") | |||
bm.Set("gmt_create", "2016-09-29 00:00:00") | |||
bm.Set("gmt_modified", "2016-09-29 00:00:00") | |||
bm.Set("total_amount", "25.00") | |||
bm.Set("real_pay_amount", "20.00") | |||
bm.Set("deliver_seller_real_amount", "5.00") | |||
bm.SetBodyMap("item_order_vo", func(bm gopay.BodyMap) { | |||
bm.Set("item_order_no", "2015060400076000000000000000") | |||
bm.Set("sku_id", "2015060400076000000000012100") | |||
bm.Set("quantity", "2") | |||
bm.Set("price", "10.00") | |||
bm.Set("status", "SUCCESS") | |||
}) | |||
aliRsp, err := client.KoubeiTradeItemorderQuery(ctx, bm) | |||
if err != nil { | |||
xlog.Errorf("client.KoubeiTradeItemorderQuery(%+v),error:%+v", bm, err) | |||
return | |||
} | |||
xlog.Debug("aliRsp:", *aliRsp) | |||
} | |||
func TestKoubeiTradeTicketTicketcodeSend(t *testing.T) { | |||
// 请求参数 | |||
bm := make(gopay.BodyMap) | |||
bm.Set("request_id", "20161029032144700000000001467823") | |||
bm.Set("send_order_no", "20170428001640010400000000006800") | |||
bm.Set("send_token", "eed3206686d349d2a22c3d9ada35c0f8") | |||
bm.Set("order_no", "20180404111040030100130500594477") | |||
bm.SetBodyMap("isv_ma_list", func(bm gopay.BodyMap) { | |||
bm.Set("code", "GAL358309629") | |||
bm.Set("num", "2") | |||
}) | |||
aliRsp, err := client.KoubeiTradeTicketTicketcodeSend(ctx, bm) | |||
if err != nil { | |||
xlog.Errorf("client.KoubeiTradeTicketTicketcodeSend(%+v),error:%+v", bm, err) | |||
return | |||
} | |||
xlog.Debug("aliRsp:", *aliRsp) | |||
} | |||
func TestKoubeiTradeTicketTicketcodeDelay(t *testing.T) { | |||
// 请求参数 | |||
bm := make(gopay.BodyMap) | |||
bm.Set("request_id", "20161029032144700000000001467823") | |||
bm.Set("end_date", "2017-09-09 12:12:12") | |||
bm.Set("ticket_code", "358309629059") | |||
bm.Set("code_type", "INTERNAL_CODE") | |||
bm.Set("order_no", "20180404111040030100130500594477") | |||
aliRsp, err := client.KoubeiTradeTicketTicketcodeDelay(ctx, bm) | |||
if err != nil { | |||
xlog.Errorf("client.KoubeiTradeTicketTicketcodeDelay(%+v),error:%+v", bm, err) | |||
return | |||
} | |||
xlog.Debug("aliRsp:", *aliRsp) | |||
} | |||
func TestKoubeiTradeTicketTicketcodeQuery(t *testing.T) { | |||
// 请求参数 | |||
bm := make(gopay.BodyMap) | |||
bm.Set("ticket_code", "016569843362") | |||
bm.Set("shop_id", "2017071200077000000039734370") | |||
aliRsp, err := client.KoubeiTradeTicketTicketcodeQuery(ctx, bm) | |||
if err != nil { | |||
xlog.Errorf("client.KoubeiTradeTicketTicketcodeQuery(%+v),error:%+v", bm, err) | |||
return | |||
} | |||
xlog.Debug("aliRsp:", *aliRsp) | |||
} | |||
func TestKoubeiTradeTicketTicketcodeCancel(t *testing.T) { | |||
// 请求参数 | |||
bm := make(gopay.BodyMap) | |||
bm.Set("request_id", "2016102903214476899999999") | |||
bm.Set("request_biz_no", "2016102903214476899999999") | |||
bm.Set("ticket_code", "016569843362") | |||
aliRsp, err := client.KoubeiTradeTicketTicketcodeCancel(ctx, bm) | |||
if err != nil { | |||
xlog.Errorf("client.KoubeiTradeTicketTicketcodeCancel(%+v),error:%+v", bm, err) | |||
return | |||
} | |||
xlog.Debug("aliRsp:", *aliRsp) | |||
} |
@@ -1,212 +0,0 @@ | |||
package alipay | |||
import ( | |||
"context" | |||
"encoding/json" | |||
"fmt" | |||
"github.com/go-pay/gopay" | |||
) | |||
// alipay.marketing.activity.batchquery(条件查询活动列表) | |||
// 文档地址:https://opendocs.alipay.com/open/04fgw9 | |||
func (a *Client) MarketingActivityBatchQuery(ctx context.Context, bm gopay.BodyMap) (aliRsp *MarketingActivityBatchQueryRsp, err error) { | |||
err = bm.CheckEmptyError("page_num", "page_size", "merchant_access_mode") | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "alipay.marketing.activity.batchquery"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(MarketingActivityBatchQueryRsp) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// alipay.marketing.activity.consult(活动领取咨询接口) | |||
// 文档地址:https://opendocs.alipay.com/open/04fgwa | |||
func (a *Client) MarketingActivityConsult(ctx context.Context, bm gopay.BodyMap) (aliRsp *MarketingActivityConsultRsp, err error) { | |||
err = bm.CheckEmptyError("consult_activity_info_list", "merchant_access_mode") | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "alipay.marketing.activity.consult"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(MarketingActivityConsultRsp) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// alipay.marketing.activity.query(查询活动详情) | |||
// 文档地址:https://opendocs.alipay.com/open/04fgwb | |||
func (a *Client) MarketingActivityQuery(ctx context.Context, bm gopay.BodyMap) (aliRsp *MarketingActivityQueryRsp, err error) { | |||
err = bm.CheckEmptyError("activity_id", "merchant_access_mode") | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "alipay.marketing.activity.query"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(MarketingActivityQueryRsp) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// alipay.marketing.activity.merchant.batchquery(查询活动可用商户) | |||
// 文档地址:https://opendocs.alipay.com/open/04fgwc | |||
func (a *Client) MarketingActivityQueryMerchantBatchQuery(ctx context.Context, bm gopay.BodyMap) (aliRsp *MarketingActivityQueryMerchantBatchQueryRsp, err error) { | |||
err = bm.CheckEmptyError("activity_id", "page_num", "page_size") | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "alipay.marketing.activity.merchant.batchquery"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(MarketingActivityQueryMerchantBatchQueryRsp) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// alipay.marketing.activity.app.batchquery(查询活动可用小程序) | |||
// 文档地址:https://opendocs.alipay.com/open/04fgwd | |||
func (a *Client) MarketingActivityQueryAppBatchQuery(ctx context.Context, bm gopay.BodyMap) (aliRsp *MarketingActivityQueryAppBatchQueryRsp, err error) { | |||
err = bm.CheckEmptyError("activity_id", "page_num", "page_size", "merchant_access_mode") | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "alipay.marketing.activity.app.batchquery"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(MarketingActivityQueryAppBatchQueryRsp) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// alipay.marketing.activity.shop.batchquery(查询活动可用门店) | |||
// 文档地址:https://opendocs.alipay.com/open/04fgwe | |||
func (a *Client) MarketingActivityQueryShopBatchQuery(ctx context.Context, bm gopay.BodyMap) (aliRsp *MarketingActivityQueryShopBatchQueryRsp, err error) { | |||
err = bm.CheckEmptyError("activity_id", "page_num", "page_size") | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "alipay.marketing.activity.shop.batchquery"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(MarketingActivityQueryShopBatchQueryRsp) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// alipay.marketing.activity.goods.batchquery(查询活动适用商品) | |||
// 文档地址:https://opendocs.alipay.com/open/04fgwf | |||
func (a *Client) MarketingActivityQueryGoodsBatchQuery(ctx context.Context, bm gopay.BodyMap) (aliRsp *MarketingActivityQueryGoodsBatchQueryRsp, err error) { | |||
err = bm.CheckEmptyError("activity_id", "page_num", "page_size") | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "alipay.marketing.activity.goods.batchquery"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(MarketingActivityQueryGoodsBatchQueryRsp) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// alipay.marketing.activity.user.batchqueryvoucher(条件查询用户券) | |||
// 文档地址:https://opendocs.alipay.com/open/04fgwg | |||
func (a *Client) MarketingActivityQueryUserBatchQueryVoucher(ctx context.Context, bm gopay.BodyMap) (aliRsp *MarketingActivityQueryUserBatchQueryVoucherRsp, err error) { | |||
err = bm.CheckEmptyError("merchant_access_mode", "page_num", "page_size") | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "alipay.marketing.activity.user.batchqueryvoucher"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(MarketingActivityQueryUserBatchQueryVoucherRsp) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// alipay.marketing.activity.user.queryvoucher(查询用户券详情) | |||
// 文档地址:https://opendocs.alipay.com/open/04fgwh | |||
func (a *Client) MarketingActivityQueryUserQueryVoucher(ctx context.Context, bm gopay.BodyMap) (aliRsp *MarketingActivityQueryUserQueryVoucherRsp, err error) { | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "alipay.marketing.activity.user.queryvoucher"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(MarketingActivityQueryUserQueryVoucherRsp) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} |
@@ -1,257 +0,0 @@ | |||
package alipay | |||
import ( | |||
"context" | |||
"encoding/json" | |||
"fmt" | |||
"strings" | |||
"github.com/go-pay/gopay" | |||
) | |||
// alipay.open.app.qrcode.create(小程序生成推广二维码接口) | |||
// 文档地址:https://opendocs.alipay.com/apis/009zva | |||
func (a *Client) OpenAppQrcodeCreate(ctx context.Context, bm gopay.BodyMap) (aliRsp *OpenAppQrcodeCreateRsp, err error) { | |||
err = bm.CheckEmptyError("url_param", "query_param", "describe") | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "alipay.open.app.qrcode.create"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(OpenAppQrcodeCreateRsp) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// alipay.marketing.campaign.cash.create(创建现金活动接口) | |||
// 文档地址:https://opendocs.alipay.com/open/029yy9 | |||
func (a *Client) MarketingCampaignCashCreate(ctx context.Context, bm gopay.BodyMap) (aliRsp *MarketingCampaignCashCreateRsp, err error) { | |||
err = bm.CheckEmptyError("coupon_name", "prize_type", "total_money", "total_num", "prize_msg", "start_time", "end_time", "merchant_link") | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "alipay.marketing.campaign.cash.create"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(MarketingCampaignCashCreateRsp) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// alipay.marketing.campaign.cash.trigger(触发现金红包活动) | |||
// 文档地址:https://opendocs.alipay.com/open/029yya | |||
func (a *Client) MarketingCampaignCashTrigger(ctx context.Context, bm gopay.BodyMap) (aliRsp *MarketingCampaignCashTriggerRsp, err error) { | |||
err = bm.CheckEmptyError("user_id", "crowd_no", "login_id", "order_price", "out_biz_no") | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "alipay.marketing.campaign.cash.trigger"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(MarketingCampaignCashTriggerRsp) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// alipay.marketing.campaign.cash.status.modify(更改现金活动状态接口) | |||
// 文档地址:https://opendocs.alipay.com/open/029yyb | |||
func (a *Client) MarketingCampaignCashStatusModify(ctx context.Context, bm gopay.BodyMap) (aliRsp *MarketingCampaignCashStatusModifyRsp, err error) { | |||
err = bm.CheckEmptyError("crowd_no", "camp_status") | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "alipay.marketing.campaign.cash.status.modify"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(MarketingCampaignCashStatusModifyRsp) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// alipay.marketing.campaign.cash.list.query(现金活动列表查询接口) | |||
// 文档地址:https://opendocs.alipay.com/open/02a1f9 | |||
func (a *Client) MarketingCampaignCashListQuery(ctx context.Context, bm gopay.BodyMap) (aliRsp *MarketingCampaignCashListQueryRsp, err error) { | |||
err = bm.CheckEmptyError("camp_status", "page_size", "page_index") | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "alipay.marketing.campaign.cash.list.query"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(MarketingCampaignCashListQueryRsp) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// alipay.marketing.campaign.cash.detail.query(现金活动详情查询) | |||
// 文档地址:https://opendocs.alipay.com/open/02a1fa | |||
func (a *Client) MarketingCampaignCashDetailQuery(ctx context.Context, bm gopay.BodyMap) (aliRsp *MarketingCampaignCashDetailQueryRsp, err error) { | |||
err = bm.CheckEmptyError("crowd_no") | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "alipay.marketing.campaign.cash.detail.query"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(MarketingCampaignCashDetailQueryRsp) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// alipay.marketing.campaign.order.voucher.consult(订单优惠前置咨询) | |||
// 文档地址:https://opendocs.alipay.com/open/04fgwi | |||
func (a *Client) MarketingCampaignOrderVoucherConsult(ctx context.Context, bm gopay.BodyMap) (aliRsp *MarketingCampaignOrderVoucherConsultRsp, err error) { | |||
err = bm.CheckEmptyError("scene_code", "order_amount") | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "alipay.marketing.campaign.order.voucher.consult"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(MarketingCampaignOrderVoucherConsultRsp) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// alipay.marketing.activity.delivery.changed(推广计划状态变更消息) | |||
// 文档地址:https://opendocs.alipay.com/open/85544608_alipay.marketing.activity.delivery.changed | |||
func (a *Client) MarketingActivityDeliveryChanged(ctx context.Context, bm gopay.BodyMap) (success bool, err error) { | |||
err = bm.CheckEmptyError("event_time", "delivery_id", "delivery_status", "delivery_error_msg", "delivery_booth_code") | |||
if err != nil { | |||
return false, err | |||
} | |||
bs, err := a.doAliPay(ctx, bm, "alipay.marketing.activity.delivery.changed") | |||
if err != nil { | |||
return false, err | |||
} | |||
if strings.Contains(string(bs), "success") { | |||
return true, nil | |||
} | |||
return | |||
} | |||
// alipay.marketing.activity.delivery.stop(停止推广计划) | |||
// 文档地址:https://opendocs.alipay.com/open/39c69f03_alipay.marketing.activity.delivery.stop | |||
func (a *Client) MarketingActivityDeliveryStop(ctx context.Context, bm gopay.BodyMap) (aliRsp *MarketingActivityDeliveryStopRsp, err error) { | |||
err = bm.CheckEmptyError("delivery_id", "out_biz_no", "merchant_access_mode") | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "alipay.marketing.activity.delivery.stop"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(MarketingActivityDeliveryStopRsp) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// alipay.marketing.activity.delivery.query(查询推广计划) | |||
// 文档地址:https://opendocs.alipay.com/open/69c6d6c2_alipay.marketing.activity.delivery.query | |||
func (a *Client) MarketingActivityDeliveryQuery(ctx context.Context, bm gopay.BodyMap) (aliRsp *MarketingActivityDeliveryQueryRsp, err error) { | |||
err = bm.CheckEmptyError("delivery_id", "merchant_access_mode") | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "alipay.marketing.activity.delivery.query"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(MarketingActivityDeliveryQueryRsp) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// alipay.marketing.activity.delivery.create(创建推广计划) | |||
// 文档地址:https://opendocs.alipay.com/open/47498bf2_alipay.marketing.activity.delivery.create | |||
func (a *Client) MarketingActivityDeliveryCreate(ctx context.Context, bm gopay.BodyMap) (aliRsp *MarketingActivityDeliveryCreateRsp, err error) { | |||
err = bm.CheckEmptyError("delivery_booth_code", "out_biz_no", "delivery_base_info", "delivery_play_config", "delivery_target_rule", "merchant_access_mode") | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "alipay.marketing.activity.delivery.create"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(MarketingActivityDeliveryCreateRsp) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} |
@@ -1,136 +0,0 @@ | |||
package alipay | |||
import ( | |||
"io" | |||
"os" | |||
"testing" | |||
"github.com/go-pay/gopay" | |||
"github.com/go-pay/xlog" | |||
) | |||
func TestOpenAppQrcodeCreate(t *testing.T) { | |||
// 请求参数 | |||
bm := make(gopay.BodyMap) | |||
bm.Set("url_param", "page/component/component-pages/view/view"). | |||
Set("query_param", "x=1"). | |||
Set("describe", "二维码描述") | |||
// 发起请求 | |||
aliRsp, err := client.OpenAppQrcodeCreate(ctx, bm) | |||
if err != nil { | |||
xlog.Error(err) | |||
return | |||
} | |||
xlog.Debug("aliRsp.Response:", aliRsp.Response) | |||
} | |||
func TestMarketingCampaignCashCreate(t *testing.T) { | |||
// 请求参数 | |||
bm := make(gopay.BodyMap) | |||
bm.Set("coupon_name", "test_name"). | |||
Set("prize_type", "0"). | |||
Set("total_money", "0.1"). | |||
Set("total_num", "1"). | |||
Set("prize_msg", "test_prize_msg"). | |||
Set("start_time", "0"). | |||
Set("end_time", "0"). | |||
Set("merchant_link", "0") | |||
// 发起请求 | |||
aliRsp, err := client.MarketingCampaignCashCreate(ctx, bm) | |||
if err != nil { | |||
xlog.Error(err) | |||
return | |||
} | |||
xlog.Debug("aliRsp.Response:", aliRsp.Response) | |||
} | |||
func TestMarketingCampaignCashTrigger(t *testing.T) { | |||
// 请求参数 | |||
bm := make(gopay.BodyMap) | |||
bm.Set("user_id", "1"). | |||
Set("crowd_no", "1"). | |||
Set("login_id", "1"). | |||
Set("order_price", "0"). | |||
Set("out_biz_no", "1") | |||
// 发起请求 | |||
aliRsp, err := client.MarketingCampaignCashTrigger(ctx, bm) | |||
if err != nil { | |||
xlog.Error(err) | |||
return | |||
} | |||
xlog.Debug("aliRsp.Response:", aliRsp.Response) | |||
} | |||
func TestMarketingCampaignCashStatusModify(t *testing.T) { | |||
// 请求参数 | |||
bm := make(gopay.BodyMap) | |||
bm.Set("crowd_no", "1"). | |||
Set("camp_status", "1") | |||
// 发起请求 | |||
aliRsp, err := client.MarketingCampaignCashStatusModify(ctx, bm) | |||
if err != nil { | |||
xlog.Error(err) | |||
return | |||
} | |||
xlog.Debug("aliRsp.Response:", aliRsp.Response) | |||
} | |||
func TestMarketingCampaignCashListQuery(t *testing.T) { | |||
// 请求参数 | |||
bm := make(gopay.BodyMap) | |||
bm.Set("camp_status", "1"). | |||
Set("page_size", "1"). | |||
Set("page_index", "1") | |||
// 发起请求 | |||
aliRsp, err := client.MarketingCampaignCashListQuery(ctx, bm) | |||
if err != nil { | |||
xlog.Error(err) | |||
return | |||
} | |||
xlog.Debug("aliRsp.Response:", aliRsp.Response) | |||
} | |||
func TestMarketingCampaignCashDetailQuery(t *testing.T) { | |||
// 请求参数 | |||
bm := make(gopay.BodyMap) | |||
bm.Set("crowd_no", "POYb84lfiKVdIfERAYsqPL_KQRIpfQbl47xfRmmPBlDMnSZ96O-zxUfKlHp5cxmx") | |||
// 发起请求 | |||
aliRsp, err := client.MarketingCampaignCashDetailQuery(ctx, bm) | |||
if err != nil { | |||
xlog.Error(err) | |||
return | |||
} | |||
xlog.Debug("aliRsp.Response:", aliRsp.Response) | |||
} | |||
func TestMarketingMaterialImageUpload(t *testing.T) { | |||
// 请求参数 | |||
logo, err := os.Open("../logo.png") | |||
if err != nil { | |||
xlog.Errorf("os.Open(%s),error:%+v", "../logo.png", err) | |||
return | |||
} | |||
xlog.Warnf("fileName: %s", logo.Name()) | |||
allBs, err := io.ReadAll(logo) | |||
if err != nil { | |||
xlog.Errorf("io.ReadAll(%s),error:%+v", logo.Name(), err) | |||
return | |||
} | |||
f := &gopay.File{ | |||
Name: "logo.png", | |||
Content: allBs, | |||
} | |||
bm := make(gopay.BodyMap) | |||
bm.Set("file_key", "PROMO_VOUCHER_IMAGE"). | |||
SetFormFile("file_content", f) | |||
aliRsp, err := client.MarketingMaterialImageUpload(ctx, bm) | |||
if err != nil { | |||
xlog.Errorf("client.MarketingMaterialImageUpload(),error:%+v", err) | |||
return | |||
} | |||
xlog.Debug("aliRsp:", *aliRsp) | |||
} |
@@ -1,217 +0,0 @@ | |||
package alipay | |||
import ( | |||
"context" | |||
"encoding/json" | |||
"fmt" | |||
"github.com/go-pay/gopay" | |||
) | |||
// alipay.marketing.card.template.create(会员卡模板创建) | |||
// 文档地址:https://opendocs.alipay.com/open/b2854ad3_alipay.marketing.card.template.create | |||
func (a *Client) MarketingCardTemplateCreate(ctx context.Context, bm gopay.BodyMap) (aliRsp *MarketingCardTemplateCreateRsp, err error) { | |||
err = bm.CheckEmptyError("request_id", "template_style_info") | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "alipay.marketing.card.template.create"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(MarketingCardTemplateCreateRsp) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// alipay.marketing.card.template.modify(会员卡模板修改) | |||
// 文档地址:https://opendocs.alipay.com/open/e3227c82_alipay.marketing.card.template.modify | |||
func (a *Client) MarketingCardTemplateModify(ctx context.Context, bm gopay.BodyMap) (aliRsp *MarketingCardTemplateModifyRsp, err error) { | |||
err = bm.CheckEmptyError("request_id", "template_id", "template_style_info") | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "alipay.marketing.card.template.modify"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(MarketingCardTemplateModifyRsp) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// alipay.marketing.card.template.query(会员卡模板查询接口) | |||
// 文档地址:https://opendocs.alipay.com/open/690f3d16_alipay.marketing.card.template.query | |||
func (a *Client) MarketingCardTemplateQuery(ctx context.Context, bm gopay.BodyMap) (aliRsp *MarketingCardTemplateQueryRsp, err error) { | |||
err = bm.CheckEmptyError("template_id") | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "alipay.marketing.card.template.query"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(MarketingCardTemplateQueryRsp) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// alipay.marketing.card.update(会员卡更新) | |||
// 文档地址:https://opendocs.alipay.com/open/89b55b6d_alipay.marketing.card.update | |||
func (a *Client) MarketingCardUpdate(ctx context.Context, bm gopay.BodyMap) (aliRsp *MarketingCardUpdateRsp, err error) { | |||
err = bm.CheckEmptyError("target_card_no", "target_card_no_type", "occur_time", "card_info") | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "alipay.marketing.card.update"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(MarketingCardUpdateRsp) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// alipay.marketing.card.query(会员卡查询) | |||
// 文档地址:https://opendocs.alipay.com/open/023c20c1_alipay.marketing.card.query | |||
func (a *Client) MarketingCardQuery(ctx context.Context, bm gopay.BodyMap) (aliRsp *MarketingCardQueryRsp, err error) { | |||
err = bm.CheckEmptyError("target_card_no", "target_card_no_type") | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "alipay.marketing.card.query"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(MarketingCardQueryRsp) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// alipay.marketing.card.delete(会员卡删卡) | |||
// 文档地址:https://opendocs.alipay.com/open/8efddab3_alipay.marketing.card.delete | |||
func (a *Client) MarketingCardDelete(ctx context.Context, bm gopay.BodyMap) (aliRsp *MarketingCardDeleteRsp, err error) { | |||
err = bm.CheckEmptyError("out_serial_no", "target_card_no", "target_card_no_type", "reason_code") | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "alipay.marketing.card.delete"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(MarketingCardDeleteRsp) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// alipay.marketing.card.message.notify(会员卡消息通知) | |||
// 文档地址:https://opendocs.alipay.com/open/4c052993_alipay.marketing.card.message.notify | |||
func (a *Client) MarketingCardMessageNotify(ctx context.Context, bm gopay.BodyMap) (aliRsp *MarketingCardMessageNotifyRsp, err error) { | |||
err = bm.CheckEmptyError("target_card_no", "target_card_no_type", "occur_time") | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "alipay.marketing.card.message.notify"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(MarketingCardMessageNotifyRsp) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// alipay.marketing.card.formtemplate.set(会员卡开卡表单模板配置) | |||
// 文档地址:https://opendocs.alipay.com/open/78c84d3f_alipay.marketing.card.formtemplate.set | |||
func (a *Client) MarketingCardFormTemplateSet(ctx context.Context, bm gopay.BodyMap) (aliRsp *MarketingCardFormTemplateSetRsp, err error) { | |||
err = bm.CheckEmptyError("template_id", "fields") | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "alipay.marketing.card.formtemplate.set"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(MarketingCardFormTemplateSetRsp) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// alipay.offline.material.image.upload(上传门店照片和视频接口) | |||
// 文档地址:https://opendocs.alipay.com/open/0af852ff_alipay.offline.material.image.upload | |||
func (a *Client) OfflineMaterialImageUpload(ctx context.Context, bm gopay.BodyMap) (aliRsp *OfflineMaterialImageUploadRsp, err error) { | |||
err = bm.CheckEmptyError("image_type", "image_name", "image_content") | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = a.FileUploadRequest(ctx, bm, "alipay.marketing.material.image.upload"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(OfflineMaterialImageUploadRsp) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil { | |||
return nil, err | |||
} | |||
if aliRsp.Response != nil && aliRsp.Response.Code != "10000" { | |||
info := aliRsp.Response | |||
return aliRsp, fmt.Errorf(`{"code":"%s","msg":"%s","sub_code":"%s","sub_msg":"%s"}`, info.Code, info.Msg, info.SubCode, info.SubMsg) | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} |
@@ -1,380 +0,0 @@ | |||
package alipay | |||
import ( | |||
"context" | |||
"encoding/json" | |||
"fmt" | |||
"github.com/go-pay/gopay" | |||
) | |||
// alipay.marketing.material.image.upload(营销图片资源上传接口) | |||
// bm参数中 file_content 可不传,file为必传参数 | |||
// 文档地址:https://opendocs.alipay.com/open/389b24b6_alipay.marketing.material.image.upload | |||
func (a *Client) MarketingMaterialImageUpload(ctx context.Context, bm gopay.BodyMap) (aliRsp *MarketingMaterialImageUploadRsp, err error) { | |||
if err = bm.CheckEmptyError("file_key", "file_content"); err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = a.FileUploadRequest(ctx, bm, "alipay.marketing.material.image.upload"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(MarketingMaterialImageUploadRsp) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil { | |||
return nil, err | |||
} | |||
if aliRsp.Response != nil && aliRsp.Response.Code != "10000" { | |||
info := aliRsp.Response | |||
return aliRsp, fmt.Errorf(`{"code":"%s","msg":"%s","sub_code":"%s","sub_msg":"%s"}`, info.Code, info.Msg, info.SubCode, info.SubMsg) | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// alipay.marketing.activity.voucher.create(创建支付券) | |||
// 文档地址:https://opendocs.alipay.com/open/049d65 | |||
func (a *Client) MarketingActivityVoucherCreate(ctx context.Context, bm gopay.BodyMap) (aliRsp *MarketingActivityVoucherCreateRsp, err error) { | |||
err = bm.CheckEmptyError("out_biz_no", "activity_base_info", "voucher_send_mode_info", "voucher_deduct_info", "merchant_access_mode", | |||
"voucher_available_scope_info", "voucher_use_rule_info", "voucher_customer_guide_info", "voucher_display_pattern_info", "voucher_budget_supply_info") | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "alipay.marketing.activity.voucher.create"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(MarketingActivityVoucherCreateRsp) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// alipay.marketing.activity.voucher.publish(激活支付券) | |||
// 文档地址:https://opendocs.alipay.com/open/049d66 | |||
func (a *Client) MarketingActivityVoucherPublish(ctx context.Context, bm gopay.BodyMap) (aliRsp *MarketingActivityVoucherPublishRsp, err error) { | |||
err = bm.CheckEmptyError("activity_id", "out_biz_no", "merchant_access_mode") | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "alipay.marketing.activity.voucher.publish"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(MarketingActivityVoucherPublishRsp) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// alipay.marketing.activity.voucher.query(查询支付券详情) | |||
// 文档地址:https://opendocs.alipay.com/open/049d6g | |||
func (a *Client) MarketingActivityVoucherQuery(ctx context.Context, bm gopay.BodyMap) (aliRsp *MarketingActivityVoucherQueryRsp, err error) { | |||
err = bm.CheckEmptyError("activity_id", "merchant_access_mode") | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "alipay.marketing.activity.voucher.query"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(MarketingActivityVoucherQueryRsp) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// alipay.marketing.activity.voucher.modify(修改支付券基本信息) | |||
// 文档地址:https://opendocs.alipay.com/open/049d67 | |||
func (a *Client) MarketingActivityVoucherModify(ctx context.Context, bm gopay.BodyMap) (aliRsp *MarketingActivityVoucherModifyRsp, err error) { | |||
err = bm.CheckEmptyError("out_biz_no", "merchant_access_mode", "activity_base_info") | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "alipay.marketing.activity.voucher.modify"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(MarketingActivityVoucherModifyRsp) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// alipay.marketing.activity.voucher.append(追加支付券预算) | |||
// 文档地址:https://opendocs.alipay.com/open/049d68 | |||
func (a *Client) MarketingActivityVoucherAppend(ctx context.Context, bm gopay.BodyMap) (aliRsp *MarketingActivityVoucherAppendRsp, err error) { | |||
err = bm.CheckEmptyError("activity_id", "voucher_quantity", "out_biz_no", "merchant_access_mode") | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "alipay.marketing.activity.voucher.append"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(MarketingActivityVoucherAppendRsp) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// alipay.marketing.activity.voucher.stop(停止支付券) | |||
// 文档地址:https://opendocs.alipay.com/open/049d69 | |||
func (a *Client) MarketingActivityVoucherStop(ctx context.Context, bm gopay.BodyMap) (aliRsp *MarketingActivityVoucherStopRsp, err error) { | |||
err = bm.CheckEmptyError("activity_id", "out_biz_no", "merchant_access_mode") | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "alipay.marketing.activity.voucher.stop"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(MarketingActivityVoucherStopRsp) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// alipay.marketing.activity.ordervoucher.create(创建商家券活动) | |||
// 文档地址:https://opendocs.alipay.com/open/7ad3a7bf_alipay.marketing.activity.ordervoucher.create | |||
func (a *Client) MarketingActivityOrderVoucherCreate(ctx context.Context, bm gopay.BodyMap) (aliRsp *MarketingActivityOrderVoucherCreateRsp, err error) { | |||
err = bm.CheckEmptyError("out_biz_no", "activity_base_info", "merchant_access_mode", "voucher_send_mode_info", | |||
"voucher_deduct_info", "voucher_available_scope_info", "voucher_use_rule_info", "voucher_customer_guide_info", "voucher_display_pattern_info") | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "alipay.marketing.activity.ordervoucher.create"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(MarketingActivityOrderVoucherCreateRsp) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// alipay.marketing.activity.ordervoucher.codedeposit(同步商家券券码) | |||
// 文档地址:https://opendocs.alipay.com/open/7ed0450d_alipay.marketing.activity.ordervoucher.codedeposit | |||
func (a *Client) MarketingActivityOrderVoucherCodeDeposit(ctx context.Context, bm gopay.BodyMap) (aliRsp *MarketingActivityOrderVoucherCodeDepositRsp, err error) { | |||
err = bm.CheckEmptyError("out_biz_no", "activity_id", "merchant_access_mode", "voucher_codes") | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "alipay.marketing.activity.ordervoucher.codedeposit"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(MarketingActivityOrderVoucherCodeDepositRsp) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// alipay.marketing.activity.ordervoucher.modify(修改商家券活动基本信息) | |||
// 文档地址:https://opendocs.alipay.com/open/528f83f6_alipay.marketing.activity.ordervoucher.modify | |||
func (a *Client) MarketingActivityOrderVoucherModify(ctx context.Context, bm gopay.BodyMap) (aliRsp *MarketingActivityOrderVoucherModifyRsp, err error) { | |||
err = bm.CheckEmptyError("out_biz_no", "activity_id", "merchant_access_mode", "activity_base_info") | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "alipay.marketing.activity.ordervoucher.modify"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(MarketingActivityOrderVoucherModifyRsp) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// alipay.marketing.activity.ordervoucher.stop(停止商家券活动) | |||
// 文档地址:https://opendocs.alipay.com/open/16803efe_alipay.marketing.activity.ordervoucher.stop | |||
func (a *Client) MarketingActivityOrderVoucherStop(ctx context.Context, bm gopay.BodyMap) (aliRsp *MarketingActivityOrderVoucherStopRsp, err error) { | |||
err = bm.CheckEmptyError("out_biz_no", "activity_id", "merchant_access_mode") | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "alipay.marketing.activity.ordervoucher.stop"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(MarketingActivityOrderVoucherStopRsp) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// alipay.marketing.activity.ordervoucher.append(修改商家券活动发券数量上限) | |||
// 文档地址:https://opendocs.alipay.com/open/4e2acff5_alipay.marketing.activity.ordervoucher.append | |||
func (a *Client) MarketingActivityOrderVoucherAppend(ctx context.Context, bm gopay.BodyMap) (aliRsp *MarketingActivityOrderVoucherAppendRsp, err error) { | |||
err = bm.CheckEmptyError("out_biz_no", "activity_id", "merchant_access_mode", "voucher_quantity") | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "alipay.marketing.activity.ordervoucher.append"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(MarketingActivityOrderVoucherAppendRsp) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// alipay.marketing.activity.ordervoucher.use(同步券核销状态) | |||
// 文档地址:https://opendocs.alipay.com/open/3ffce87f_alipay.marketing.activity.ordervoucher.use | |||
func (a *Client) MarketingActivityOrderVoucherUse(ctx context.Context, bm gopay.BodyMap) (aliRsp *MarketingActivityOrderVoucherUseRsp, err error) { | |||
err = bm.CheckEmptyError("biz_dt", "activity_id", "voucher_code", "trade_channel", "total_fee", "out_biz_no") | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "alipay.marketing.activity.ordervoucher.use"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(MarketingActivityOrderVoucherUseRsp) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// alipay.marketing.activity.ordervoucher.refund(取消券核销状态) | |||
// 文档地址:https://opendocs.alipay.com/open/4682759b_alipay.marketing.activity.ordervoucher.refund?scene=common | |||
func (a *Client) MarketingActivityOrderVoucherRefund(ctx context.Context, bm gopay.BodyMap) (aliRsp *MarketingActivityOrderVoucherRefundRsp, err error) { | |||
err = bm.CheckEmptyError("biz_dt", "activity_id", "voucher_code", "out_biz_no") | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "alipay.marketing.activity.ordervoucher.refund"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(MarketingActivityOrderVoucherRefundRsp) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// alipay.marketing.activity.ordervoucher.query(查询商家券活动) | |||
// 文档地址:https://opendocs.alipay.com/open/51f5946e_alipay.marketing.activity.ordervoucher.query | |||
func (a *Client) MarketingActivityOrderVoucherQuery(ctx context.Context, bm gopay.BodyMap) (aliRsp *MarketingActivityOrderVoucherQueryRsp, err error) { | |||
err = bm.CheckEmptyError("activity_id", "merchant_access_mode") | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "alipay.marketing.activity.ordervoucher.query"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(MarketingActivityOrderVoucherQueryRsp) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// alipay.marketing.activity.ordervoucher.codecount(统计商家券券码数量) | |||
// 文档地址:https://opendocs.alipay.com/open/f6e49e82_alipay.marketing.activity.ordervoucher.codecount | |||
func (a *Client) MarketingActivityOrderVoucherCodeCount(ctx context.Context, bm gopay.BodyMap) (aliRsp *MarketingActivityOrderVoucherCodeCountRsp, err error) { | |||
err = bm.CheckEmptyError("activity_id", "merchant_access_mode") | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "alipay.marketing.activity.ordervoucher.codecount"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(MarketingActivityOrderVoucherCodeCountRsp) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} |
@@ -1,606 +0,0 @@ | |||
package alipay | |||
import ( | |||
"context" | |||
"encoding/json" | |||
"errors" | |||
"fmt" | |||
"net/url" | |||
"strings" | |||
"github.com/go-pay/gopay" | |||
) | |||
// alipay.system.oauth.token(换取授权访问令牌) | |||
// 文档地址:https://opendocs.alipay.com/open/02ailc | |||
func (a *Client) SystemOauthToken(ctx context.Context, bm gopay.BodyMap) (aliRsp *SystemOauthTokenResponse, err error) { | |||
if bm.GetString("code") == gopay.NULL && bm.GetString("refresh_token") == gopay.NULL { | |||
return nil, errors.New("code and refresh_token are not allowed to be null at the same time") | |||
} | |||
if err = bm.CheckEmptyError("grant_type"); err != nil { | |||
return nil, err | |||
} | |||
var ( | |||
bs []byte | |||
aat string | |||
) | |||
if a.AppCertSN != gopay.NULL { | |||
bm.Set("app_cert_sn", a.AppCertSN) | |||
} | |||
if a.AliPayRootCertSN != gopay.NULL { | |||
bm.Set("alipay_root_cert_sn", a.AliPayRootCertSN) | |||
} | |||
// default use app_auth_token | |||
if a.AppAuthToken != gopay.NULL { | |||
aat = a.AppAuthToken | |||
} | |||
// if user set app_auth_token in body_map, use this | |||
if bmAt := bm.GetString("app_auth_token"); bmAt != gopay.NULL { | |||
aat = bmAt | |||
} | |||
if bs, err = systemOauthToken(ctx, a.AppId, a.privateKey, bm, "alipay.system.oauth.token", a.IsProd, a.SignType, aat); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(SystemOauthTokenResponse) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if aliRsp.ErrorResponse != nil { | |||
info := aliRsp.ErrorResponse | |||
return aliRsp, fmt.Errorf(`{"code":"%s","msg":"%s","sub_code":"%s","sub_msg":"%s"}`, info.Code, info.Msg, info.SubCode, info.SubMsg) | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// alipay.open.auth.userauth.relationship.query(用户授权关系查询) | |||
// 文档地址:https://opendocs.alipay.com/open/6b97edd1_alipay.open.auth.userauth.relationship.query | |||
func (a *Client) UserAuthRelationshipQuery(ctx context.Context, bm gopay.BodyMap) (aliRsp *UserAuthRelationshipQueryRsp, err error) { | |||
err = bm.CheckEmptyError("scopes") | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "alipay.open.auth.userauth.relationship.query"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(UserAuthRelationshipQueryRsp) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// alipay.user.deloauth.detail.query(查询解除授权明细) | |||
// 文档地址:https://opendocs.alipay.com/open/77e7fec5_alipay.user.deloauth.detail.query | |||
func (a *Client) UserDelOAuthDetailQuery(ctx context.Context, bm gopay.BodyMap) (aliRsp *UserDelOAuthDetailQueryRsp, err error) { | |||
err = bm.CheckEmptyError("date", "limit", "offset") | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "alipay.user.deloauth.detail.query"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(UserDelOAuthDetailQueryRsp) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// alipay.user.info.share(支付宝会员授权信息查询接口) | |||
// body:此接口无需body参数 | |||
// 文档地址:https://opendocs.alipay.com/open/02aild | |||
func (a *Client) UserInfoShare(ctx context.Context, authToken string) (aliRsp *UserInfoShareResponse, err error) { | |||
if authToken == "" { | |||
return nil, errors.New("auth_token can not be null") | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, nil, "alipay.user.info.share", authToken); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(UserInfoShareResponse) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if aliRsp.ErrorResponse != nil { | |||
info := aliRsp.ErrorResponse | |||
return aliRsp, fmt.Errorf(`{"code":"%s","msg":"%s","sub_code":"%s","sub_msg":"%s"}`, info.Code, info.Msg, info.SubCode, info.SubMsg) | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// alipay.user.info.auth(用户登陆授权) | |||
// 注意:不支持自动验签 | |||
// 文档地址:https://opendocs.alipay.com/open/02aile | |||
func (a *Client) UserInfoAuth(ctx context.Context, bm gopay.BodyMap) (html []byte, err error) { | |||
err = bm.CheckEmptyError("scopes", "state") | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "alipay.user.info.auth"); err != nil { | |||
return nil, err | |||
} | |||
if strings.Contains(string(bs), "<head>") { | |||
return bs, nil | |||
} | |||
uiaErr := new(UserInfoAuthResponse) | |||
if err = json.Unmarshal(bs, uiaErr); err != nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
return nil, bizErrCheck(*uiaErr.Response) | |||
} | |||
// alipay.user.certify.open.initialize(身份认证初始化服务) | |||
// 文档地址:https://opendocs.alipay.com/open/02ahjy | |||
func (a *Client) UserCertifyOpenInit(ctx context.Context, bm gopay.BodyMap) (aliRsp *UserCertifyOpenInitResponse, err error) { | |||
err = bm.CheckEmptyError("outer_order_no", "biz_code", "identity_param", "merchant_config") | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "alipay.user.certify.open.initialize"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(UserCertifyOpenInitResponse) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// alipay.user.certify.open.certify(身份认证开始认证) | |||
// API文档地址:https://opendocs.alipay.com/open/02ahk0 | |||
func (a *Client) UserCertifyOpenCertify(ctx context.Context, bm gopay.BodyMap) (certifyUrl string, err error) { | |||
err = bm.CheckEmptyError("certify_id") | |||
if err != nil { | |||
return gopay.NULL, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "alipay.user.certify.open.certify"); err != nil { | |||
return gopay.NULL, err | |||
} | |||
certifyUrl = string(bs) | |||
return certifyUrl, nil | |||
} | |||
// alipay.user.certify.open.query(身份认证记录查询) | |||
// 文档地址:https://opendocs.alipay.com/open/02ahjw | |||
func (a *Client) UserCertifyOpenQuery(ctx context.Context, bm gopay.BodyMap) (aliRsp *UserCertifyOpenQueryResponse, err error) { | |||
err = bm.CheckEmptyError("certify_id") | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "alipay.user.certify.open.query"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(UserCertifyOpenQueryResponse) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// alipay.user.agreement.page.sign(支付宝个人协议页面签约接口) | |||
// 文档地址:https://opendocs.alipay.com/open/8bccfa0b_alipay.user.agreement.page.sign | |||
func (a *Client) UserAgreementPageSign(ctx context.Context, bm gopay.BodyMap) (ret string, err error) { | |||
err = bm.CheckEmptyError("personal_product_code") | |||
if err != nil { | |||
return gopay.NULL, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "alipay.user.agreement.page.sign"); err != nil { | |||
return "", err | |||
} | |||
return string(bs), nil | |||
} | |||
// alipay.user.agreement.page.sign(APP 支付宝个人协议页面签约接口) | |||
// 文档地址:https://opendocs.alipay.com/open/00a05b 通过 App 唤起支付宝的签约页面 | |||
func (a *Client) UserAgreementPageSignInApp(ctx context.Context, bm gopay.BodyMap) (ret string, err error) { | |||
err = bm.CheckEmptyError("personal_product_code") | |||
if err != nil { | |||
return gopay.NULL, err | |||
} | |||
var bs string | |||
// 参考官方示例 | |||
// PageExecute get方式,生成url | |||
if bs, err = a.PageExecute(ctx, bm, "alipay.user.agreement.page.sign"); err != nil { | |||
return "", err | |||
} | |||
// / 生成的url地址去除 http://openapi.alipay.com/gateway.do | |||
replaceUrl := baseUrl + "?" | |||
if !a.IsProd { | |||
replaceUrl = sandboxBaseUrl + "?" | |||
} | |||
signParams := strings.Replace(bs, replaceUrl, "", 1) | |||
// 该链接里面的 APPID 为固定值,不可修改) | |||
// 生成唤起客户端。把signParams使用 UTF-8 字符集整体做一次 encode | |||
link := "alipays://platformapi/startapp?appId=60000157&appClearTop=false&startMultApp=YES&sign_params=" + url.QueryEscape(signParams) | |||
return link, nil | |||
} | |||
// alipay.user.agreement.unsign(支付宝个人代扣协议解约接口) | |||
// 文档地址:https://opendocs.alipay.com/open/b841da1f_alipay.user.agreement.unsign | |||
func (a *Client) UserAgreementPageUnSign(ctx context.Context, bm gopay.BodyMap) (aliRsp *UserAgreementPageUnSignRsp, err error) { | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "alipay.user.agreement.unsign"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(UserAgreementPageUnSignRsp) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(*aliRsp.Response); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// alipay.user.agreement.query(支付宝个人代扣协议查询接口) | |||
// 文档地址:https://opendocs.alipay.com/open/3dab71bc_alipay.user.agreement.query | |||
func (a *Client) UserAgreementQuery(ctx context.Context, bm gopay.BodyMap) (aliRsp *UserAgreementQueryRsp, err error) { | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "alipay.user.agreement.query"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(UserAgreementQueryRsp) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// alipay.user.agreement.executionplan.modify(周期性扣款协议执行计划修改接口) | |||
// 文档地址:https://opendocs.alipay.com/apis/api_2/alipay.user.agreement.executionplan.modify | |||
func (a *Client) UserAgreementExecutionplanModify(ctx context.Context, bm gopay.BodyMap) (aliRsp *UserAgreementExecutionplanModifyRsp, err error) { | |||
err = bm.CheckEmptyError("agreement_no", "deduct_time") | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "alipay.user.agreement.executionplan.modify"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(UserAgreementExecutionplanModifyRsp) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// alipay.user.agreement.transfer(协议由普通通用代扣协议产品转移到周期扣协议产品) | |||
// 文档地址:https://opendocs.alipay.com/apis/api_2/alipay.user.agreement.transfer | |||
func (a *Client) UserAgreementTransfer(ctx context.Context, bm gopay.BodyMap) (aliRsp *UserAgreementTransferRsp, err error) { | |||
err = bm.CheckEmptyError("agreement_no", "target_product_code", "period_rule_params") | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "alipay.user.agreement.transfer"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(UserAgreementTransferRsp) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// alipay.user.twostage.common.use(通用当面付二阶段接口) | |||
// 文档地址:https://opendocs.alipay.com/apis/api_2/alipay.user.twostage.common.use | |||
func (a *Client) UserTwostageCommonUse(ctx context.Context, bm gopay.BodyMap) (aliRsp *UserTwostageCommonUseRsp, err error) { | |||
err = bm.CheckEmptyError("dynamic_id", "sence_no", "pay_pid") | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "alipay.user.twostage.common.use"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(UserTwostageCommonUseRsp) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// alipay.user.auth.zhimaorg.identity.apply(芝麻企业征信基于身份的协议授权) | |||
// 文档地址:https://opendocs.alipay.com/apis/api_2/alipay.user.auth.zhimaorg.identity.apply | |||
func (a *Client) UserAuthZhimaorgIdentityApply(ctx context.Context, bm gopay.BodyMap) (aliRsp *UserAuthZhimaorgIdentityApplyRsp, err error) { | |||
err = bm.CheckEmptyError("cert_type", "cert_no", "name") | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "alipay.user.auth.zhimaorg.identity.apply"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(UserAuthZhimaorgIdentityApplyRsp) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// alipay.user.charity.recordexist.query(查询是否在支付宝公益捐赠的接口) | |||
// 文档地址:https://opendocs.alipay.com/apis/api_2/alipay.user.charity.recordexist.query | |||
func (a *Client) UserCharityRecordexistQuery(ctx context.Context, bm gopay.BodyMap) (aliRsp *UserCharityRecordexistQueryRsp, err error) { | |||
err = bm.CheckEmptyError("partner_id", "user_id") | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "alipay.user.charity.recordexist.query"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(UserCharityRecordexistQueryRsp) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// alipay.user.alipaypoint.send(集分宝发放接口) | |||
// 文档地址:https://opendocs.alipay.com/apis/api_2/alipay.user.alipaypoint.send | |||
func (a *Client) UserAlipaypointSend(ctx context.Context, bm gopay.BodyMap) (aliRsp *UserAlipaypointSendRsp, err error) { | |||
err = bm.CheckEmptyError("budget_code", "partner_biz_no", "point_amount") | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "alipay.user.alipaypoint.send"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(UserAlipaypointSendRsp) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// koubei.member.data.isv.create(isv 会员CRM数据回流) | |||
// 文档地址:https://opendocs.alipay.com/apis/api_2/koubei.member.data.isv.create | |||
func (a *Client) MemberDataIsvCreate(ctx context.Context, bm gopay.BodyMap) (aliRsp *MemberDataIsvCreateRsp, err error) { | |||
err = bm.CheckEmptyError("member_card_id", "member_source", "member_status", "gmt_merber_card_create", "parter_id") | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "koubei.member.data.isv.create"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(MemberDataIsvCreateRsp) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// alipay.user.family.archive.query(查询家人信息档案(选人授权)组件已选的家人档案信息) | |||
// 文档地址:https://opendocs.alipay.com/apis/api_2/alipay.user.family.archive.query | |||
func (a *Client) UserFamilyArchiveQuery(ctx context.Context, bm gopay.BodyMap) (aliRsp *UserFamilyArchiveQueryRsp, err error) { | |||
err = bm.CheckEmptyError("archive_token") | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "alipay.user.family.archive.query"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(UserFamilyArchiveQueryRsp) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// alipay.user.family.archive.initialize(初始化家人信息档案(选人授权)组件) | |||
// 文档地址:https://opendocs.alipay.com/apis/api_2/alipay.user.family.archive.initialize | |||
func (a *Client) UserFamilyArchiveInitialize(ctx context.Context, bm gopay.BodyMap) (aliRsp *UserFamilyArchiveInitializeRsp, err error) { | |||
err = bm.CheckEmptyError("out_biz_no", "template_id", "redirect_uri") | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "alipay.user.family.archive.initialize"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(UserFamilyArchiveInitializeRsp) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// alipay.user.certdoc.certverify.preconsult(实名证件信息比对验证预咨询) | |||
// 文档地址:https://opendocs.alipay.com/apis/api_2/alipay.user.certdoc.certverify.preconsult | |||
func (a *Client) UserCertdocCertverifyPreconsult(ctx context.Context, bm gopay.BodyMap) (aliRsp *UserCertdocCertverifyPreconsultRsp, err error) { | |||
err = bm.CheckEmptyError("user_name", "cert_type", "cert_no") | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "alipay.user.certdoc.certverify.preconsult"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(UserCertdocCertverifyPreconsultRsp) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// alipay.user.certdoc.certverify.consult(实名证件信息比对验证咨询) | |||
// 文档地址:https://opendocs.alipay.com/apis/api_2/alipay.user.certdoc.certverify.consult | |||
func (a *Client) UserCertdocCertverifyConsult(ctx context.Context, bm gopay.BodyMap, authToken string) (aliRsp *UserCertdocCertverifyConsultRsp, err error) { | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "alipay.user.certdoc.certverify.consult", authToken); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(UserCertdocCertverifyConsultRsp) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// alipay.user.family.share.zmgo.initialize(初始化家庭芝麻GO共享组件) | |||
// 文档地址:https://opendocs.alipay.com/apis/01n4yx | |||
func (a *Client) UserFamilyShareZmgoInitialize(ctx context.Context, bm gopay.BodyMap) (aliRsp *UserFamilyShareZmgoInitializeRsp, err error) { | |||
err = bm.CheckEmptyError("user_id", "scene_id", "template_id", "out_request_no") | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "alipay.user.family.share.zmgo.initialize"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(UserFamilyShareZmgoInitializeRsp) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// alipay.user.dtbank.qrcodedata.query(数字分行银行码明细数据查询) | |||
// 文档地址:https://opendocs.alipay.com/apis/01ozks | |||
func (a *Client) UserDtbankQrcodedataQuery(ctx context.Context, bm gopay.BodyMap) (aliRsp *UserDtbankQrcodedataQueryRsp, err error) { | |||
err = bm.CheckEmptyError("data_date", "qrcode_id", "qrcode_out_id") | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "alipay.user.dtbank.qrcodedata.query"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(UserDtbankQrcodedataQueryRsp) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// alipay.user.alipaypoint.budgetlib.query(查询集分宝预算库详情) | |||
// 文档地址:https://opendocs.alipay.com/apis/01zrby | |||
func (a *Client) UserAlipaypointBudgetlibQuery(ctx context.Context, bm gopay.BodyMap) (aliRsp *UserAlipaypointBudgetlibQueryRsp, err error) { | |||
err = bm.CheckEmptyError("budget_code") | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "alipay.user.alipaypoint.budgetlib.query"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(UserAlipaypointBudgetlibQueryRsp) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} |
@@ -1,390 +0,0 @@ | |||
package alipay | |||
import ( | |||
"testing" | |||
"github.com/go-pay/gopay" | |||
"github.com/go-pay/xlog" | |||
) | |||
func TestClient_UserCertifyOpenInit(t *testing.T) { | |||
// 请求参数 | |||
bm := make(gopay.BodyMap) | |||
bm.Set("outer_order_no", "ZGYD201809132323000001234") | |||
// 认证场景码:FACE:多因子人脸认证,CERT_PHOTO:多因子证照认证,CERT_PHOTO_FACE :多因子证照和人脸认证,SMART_FACE:多因子快捷认证 | |||
bm.Set("biz_code", "FACE") | |||
// 需要验证的身份信息参数,格式为json | |||
identity := make(map[string]string) | |||
identity["identity_type"] = "CERT_INFO" | |||
identity["cert_type"] = "IDENTITY_CARD" | |||
identity["cert_name"] = "张三" | |||
identity["cert_no"] = "310123199012301234" | |||
bm.Set("identity_param", identity) | |||
// 商户个性化配置,格式为json | |||
merchant := make(map[string]string) | |||
merchant["return_url"] = "https://www.fmm.ink" | |||
bm.Set("merchant_config", merchant) | |||
// 发起请求 | |||
aliRsp, err := client.UserCertifyOpenInit(ctx, bm) | |||
if err != nil { | |||
if bizErr, ok := IsBizError(err); ok { | |||
xlog.Errorf("%+v", bizErr) | |||
// do something | |||
return | |||
} | |||
return | |||
} | |||
xlog.Debug("aliRsp:", *aliRsp) | |||
} | |||
func TestClient_UserCertifyOpenCertify(t *testing.T) { | |||
// 请求参数 | |||
bm := make(gopay.BodyMap) | |||
// 本次申请操作的唯一标识,由开放认证初始化接口调用后生成,后续的操作都需要用到 | |||
bm.Set("certify_id", "53827f9d085b3ce43938c6e5915b4729") | |||
// 发起请求 | |||
certifyUrl, err := client.UserCertifyOpenCertify(ctx, bm) | |||
if err != nil { | |||
if bizErr, ok := IsBizError(err); ok { | |||
xlog.Errorf("%+v", bizErr) | |||
// do something | |||
return | |||
} | |||
return | |||
} | |||
xlog.Debug("certifyUrl:", certifyUrl) | |||
} | |||
func TestClient_UserCertifyOpenQuery(t *testing.T) { | |||
// 请求参数 | |||
bm := make(gopay.BodyMap) | |||
// 本次申请操作的唯一标识,由开放认证初始化接口调用后生成,后续的操作都需要用到 | |||
bm.Set("certify_id", "OC201809253000000393900404029253") | |||
// 发起请求 | |||
aliRsp, err := client.UserCertifyOpenQuery(ctx, bm) | |||
if err != nil { | |||
if bizErr, ok := IsBizError(err); ok { | |||
xlog.Errorf("%+v", bizErr) | |||
// do something | |||
return | |||
} | |||
return | |||
} | |||
xlog.Debug("aliRsp:", *aliRsp) | |||
xlog.Debug("aliRsp.Response.Passed:", aliRsp.Response.Passed) | |||
} | |||
func TestUserAgreementExecutionplanModify(t *testing.T) { | |||
// 请求参数 | |||
bm := make(gopay.BodyMap) | |||
bm.Set("agreement_no", "20185909000458725113") | |||
bm.Set("deduct_time", "2019-05-12") | |||
bm.Set("memo", "用户已购买半年包,需延期扣款时间") | |||
// 发起请求 | |||
aliRsp, err := client.UserAgreementExecutionplanModify(ctx, bm) | |||
if err != nil { | |||
if bizErr, ok := IsBizError(err); ok { | |||
xlog.Errorf("%+v", bizErr) | |||
// do something | |||
return | |||
} | |||
return | |||
} | |||
xlog.Debug("aliRsp:", *aliRsp) | |||
} | |||
func TestUserAgreementTransfer(t *testing.T) { | |||
// 请求参数 | |||
bm := make(gopay.BodyMap) | |||
bm.Set("agreement_no", "20170322450983769228") | |||
bm.Set("target_product_code", "CYCLE_PAY_AUTH_P") | |||
bm.SetBodyMap("period_rule_params", func(bm gopay.BodyMap) { | |||
bm.Set("period_type", "DAY") | |||
bm.Set("period", "3") | |||
bm.Set("execute_time", "20190-01-23") | |||
bm.Set("single_amount", "10.99") | |||
}) | |||
// 发起请求 | |||
aliRsp, err := client.UserAgreementTransfer(ctx, bm) | |||
if err != nil { | |||
if bizErr, ok := IsBizError(err); ok { | |||
xlog.Errorf("%+v", bizErr) | |||
// do something | |||
return | |||
} | |||
return | |||
} | |||
xlog.Debug("aliRsp:", *aliRsp) | |||
} | |||
func TestUserAgreementPageSignInApp(t *testing.T) { | |||
// 请求参数 | |||
bm := make(gopay.BodyMap) | |||
bm.Set("personal_product_code", "CYCLE_PAY_AUTH_P") | |||
bm.Set("product_code", "CYCLE_PAY_AUTH") | |||
bm.Set("sign_scene", "INDUSTRY|EDU") | |||
bm.Set("agreement_effect_type", "DIRECT") | |||
bm.Set("notify_url", "https://yt-api.t.ergedd.com/api/v1/sign_notify/alipay") | |||
bm.Set("external_agreement_no", "9bAduAd8uvkkU9GrCCw4jYCi64GOYiPI") | |||
bm.SetBodyMap("period_rule_params", func(bm gopay.BodyMap) { | |||
bm.Set("period_type", "MONTH") | |||
bm.Set("period", 1) | |||
bm.Set("execute_time", "2023-01-01") | |||
bm.Set("single_amount", 0.01) | |||
}) | |||
bm.SetBodyMap("access_params", func(ab gopay.BodyMap) { | |||
ab.Set("channel", "ALIPAYAPP") | |||
}) | |||
// 发起请求 | |||
link, err := client.UserAgreementPageSignInApp(ctx, bm) | |||
xlog.Info(err) | |||
if err != nil { | |||
if bizErr, ok := IsBizError(err); ok { | |||
xlog.Errorf("%+v", bizErr) | |||
// do something | |||
return | |||
} | |||
return | |||
} | |||
xlog.Debug("aliRsp:", link) | |||
} | |||
func TestUserTwostageCommonUse(t *testing.T) { | |||
// 请求参数 | |||
bm := make(gopay.BodyMap) | |||
bm.Set("dynamic_id", "286861260475412123") | |||
bm.Set("sence_no", "20170718xxxxxxxx") | |||
bm.Set("pay_pid", "2088702093900999") | |||
// 发起请求 | |||
aliRsp, err := client.UserTwostageCommonUse(ctx, bm) | |||
if err != nil { | |||
if bizErr, ok := IsBizError(err); ok { | |||
xlog.Errorf("%+v", bizErr) | |||
// do something | |||
return | |||
} | |||
return | |||
} | |||
xlog.Debug("aliRsp:", *aliRsp) | |||
} | |||
func TestUserAuthZhimaorgIdentityApply(t *testing.T) { | |||
// 请求参数 | |||
bm := make(gopay.BodyMap) | |||
bm.Set("cert_type", "NATIONAL_LEGAL") | |||
bm.Set("cert_no", "330701199901011311") | |||
bm.Set("name", "中国移动有限公司") | |||
// 发起请求 | |||
aliRsp, err := client.UserAuthZhimaorgIdentityApply(ctx, bm) | |||
if err != nil { | |||
if bizErr, ok := IsBizError(err); ok { | |||
xlog.Errorf("%+v", bizErr) | |||
// do something | |||
return | |||
} | |||
return | |||
} | |||
xlog.Debug("aliRsp:", *aliRsp) | |||
} | |||
func TestUserCharityRecordexistQuery(t *testing.T) { | |||
// 请求参数 | |||
bm := make(gopay.BodyMap) | |||
bm.Set("partner_id", "2088111122223333") | |||
bm.Set("user_id", "2088111122223333") | |||
// 发起请求 | |||
aliRsp, err := client.UserCharityRecordexistQuery(ctx, bm) | |||
if err != nil { | |||
if bizErr, ok := IsBizError(err); ok { | |||
xlog.Errorf("%+v", bizErr) | |||
// do something | |||
return | |||
} | |||
return | |||
} | |||
xlog.Debug("aliRsp:", *aliRsp) | |||
} | |||
func TestUserAlipaypointSend(t *testing.T) { | |||
// 请求参数 | |||
bm := make(gopay.BodyMap) | |||
bm.Set("budget_code", "02559A591572") | |||
bm.Set("partner_biz_no", "011022222222212") | |||
bm.Set("point_amount", "1") | |||
// 发起请求 | |||
aliRsp, err := client.UserAlipaypointSend(ctx, bm) | |||
if err != nil { | |||
if bizErr, ok := IsBizError(err); ok { | |||
xlog.Errorf("%+v", bizErr) | |||
// do something | |||
return | |||
} | |||
return | |||
} | |||
xlog.Debug("aliRsp:", *aliRsp) | |||
} | |||
func TestMemberDataIsvCreate(t *testing.T) { | |||
// 请求参数 | |||
bm := make(gopay.BodyMap) | |||
bm.Set("member_card_id", "2014323100009") | |||
bm.Set("member_source", "alipay") | |||
bm.Set("member_status", "1") | |||
bm.Set("gmt_merber_card_create", "2017-02-17 20:11:54") | |||
bm.Set("parter_id", "2088902248579233") | |||
// 发起请求 | |||
aliRsp, err := client.MemberDataIsvCreate(ctx, bm) | |||
if err != nil { | |||
if bizErr, ok := IsBizError(err); ok { | |||
xlog.Errorf("%+v", bizErr) | |||
// do something | |||
return | |||
} | |||
return | |||
} | |||
xlog.Debug("aliRsp:", *aliRsp) | |||
} | |||
func TestUserFamilyArchiveQuery(t *testing.T) { | |||
// 请求参数 | |||
bm := make(gopay.BodyMap) | |||
bm.Set("archive_token", "2020050200286001170017000004861") | |||
// 发起请求 | |||
aliRsp, err := client.UserFamilyArchiveQuery(ctx, bm) | |||
if err != nil { | |||
if bizErr, ok := IsBizError(err); ok { | |||
xlog.Errorf("%+v", bizErr) | |||
// do something | |||
return | |||
} | |||
return | |||
} | |||
xlog.Debug("aliRsp:", *aliRsp) | |||
} | |||
func TestUserFamilyArchiveInitialize(t *testing.T) { | |||
// 请求参数 | |||
bm := make(gopay.BodyMap) | |||
bm.Set("out_biz_no", "d0f003fdf57b4983bae5a0d1af2e7744") | |||
bm.Set("template_id", "2020050200286001170017000004861") | |||
bm.Set("redirect_uri", "https://www.alipay.com") | |||
// 发起请求 | |||
aliRsp, err := client.UserFamilyArchiveInitialize(ctx, bm) | |||
if err != nil { | |||
if bizErr, ok := IsBizError(err); ok { | |||
xlog.Errorf("%+v", bizErr) | |||
// do something | |||
return | |||
} | |||
return | |||
} | |||
xlog.Debug("aliRsp:", *aliRsp) | |||
} | |||
func TestUserCertdocCertverifyPreconsult(t *testing.T) { | |||
// 请求参数 | |||
bm := make(gopay.BodyMap) | |||
bm.Set("user_name", "张三") | |||
bm.Set("cert_type", "IDENTITY_CARD") | |||
bm.Set("cert_no", "230100199901010001") | |||
// 发起请求 | |||
aliRsp, err := client.UserCertdocCertverifyPreconsult(ctx, bm) | |||
if err != nil { | |||
if bizErr, ok := IsBizError(err); ok { | |||
xlog.Errorf("%+v", bizErr) | |||
// do something | |||
return | |||
} | |||
return | |||
} | |||
xlog.Debug("aliRsp:", *aliRsp) | |||
} | |||
func TestUserCertdocCertverifyConsult(t *testing.T) { | |||
// 请求参数 | |||
bm := make(gopay.BodyMap) | |||
bm.Set("verify_id", "671ffcda5447bc87e9ed2f669eb143d4") | |||
// 发起请求 | |||
aliRsp, err := client.UserCertdocCertverifyConsult(ctx, bm, "auth_token") | |||
if err != nil { | |||
if bizErr, ok := IsBizError(err); ok { | |||
xlog.Errorf("%+v", bizErr) | |||
// do something | |||
return | |||
} | |||
return | |||
} | |||
xlog.Debug("aliRsp:", *aliRsp) | |||
} | |||
func TestUserFamilyShareZmgoInitialize(t *testing.T) { | |||
// 请求参数 | |||
bm := make(gopay.BodyMap) | |||
bm.Set("user_id", "2088161820676973") | |||
bm.Set("scene_id", "family_health_card") | |||
bm.Set("template_id", "2019112500020903940000454087") | |||
bm.Set("out_request_no", "d0f003fdf57b4983bae5a0d1af2e7744") | |||
// 发起请求 | |||
aliRsp, err := client.UserFamilyShareZmgoInitialize(ctx, bm) | |||
if err != nil { | |||
if bizErr, ok := IsBizError(err); ok { | |||
xlog.Errorf("%+v", bizErr) | |||
// do something | |||
return | |||
} | |||
return | |||
} | |||
xlog.Debug("aliRsp:", *aliRsp) | |||
} | |||
func TestUserDtbankQrcodedataQuery(t *testing.T) { | |||
// 请求参数 | |||
bm := make(gopay.BodyMap) | |||
bm.Set("data_date", "20210106") | |||
bm.Set("qrcode_id", "QRC884QRC00014990") | |||
bm.Set("qrcode_out_id", "18448-000006") | |||
// 发起请求 | |||
aliRsp, err := client.UserDtbankQrcodedataQuery(ctx, bm) | |||
if err != nil { | |||
if bizErr, ok := IsBizError(err); ok { | |||
xlog.Errorf("%+v", bizErr) | |||
// do something | |||
return | |||
} | |||
return | |||
} | |||
xlog.Debug("aliRsp:", *aliRsp) | |||
} | |||
func TestUserAlipaypointBudgetlibQuery(t *testing.T) { | |||
// 请求参数 | |||
bm := make(gopay.BodyMap) | |||
bm.Set("budget_code", "20201107050844") | |||
// 发起请求 | |||
aliRsp, err := client.UserAlipaypointBudgetlibQuery(ctx, bm) | |||
if err != nil { | |||
if bizErr, ok := IsBizError(err); ok { | |||
xlog.Errorf("%+v", bizErr) | |||
// do something | |||
return | |||
} | |||
return | |||
} | |||
xlog.Debug("aliRsp:", *aliRsp) | |||
} |
@@ -1,239 +0,0 @@ | |||
package alipay | |||
import ( | |||
"context" | |||
"encoding/json" | |||
"fmt" | |||
"github.com/go-pay/gopay" | |||
) | |||
// alipay.trade.royalty.relation.bind(分账关系绑定) | |||
// 文档地址:https://opendocs.alipay.com/open/c21931d6_alipay.trade.royalty.relation.bind | |||
func (a *Client) TradeRelationBind(ctx context.Context, bm gopay.BodyMap) (aliRsp *TradeRelationBindResponse, err error) { | |||
err = bm.CheckEmptyError("receiver_list", "out_request_no") | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "alipay.trade.royalty.relation.bind"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(TradeRelationBindResponse) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// alipay.trade.royalty.relation.unbind(分账关系解绑) | |||
// 文档地址:https://opendocs.alipay.com/open/3613f4e1_alipay.trade.royalty.relation.unbind | |||
func (a *Client) TradeRelationUnbind(ctx context.Context, bm gopay.BodyMap) (aliRsp *TradeRelationUnbindResponse, err error) { | |||
err = bm.CheckEmptyError("receiver_list", "out_request_no") | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "alipay.trade.royalty.relation.unbind"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(TradeRelationUnbindResponse) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// alipay.trade.royalty.relation.batchquery(分账关系查询) | |||
// 文档地址:https://opendocs.alipay.com/open/1860be54_alipay.trade.royalty.relation.batchquery | |||
func (a *Client) TradeRelationBatchQuery(ctx context.Context, bm gopay.BodyMap) (aliRsp *TradeRelationBatchQueryResponse, err error) { | |||
err = bm.CheckEmptyError("out_request_no") | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "alipay.trade.royalty.relation.batchquery"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(TradeRelationBatchQueryResponse) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// alipay.trade.settle.confirm(统一收单确认结算接口) | |||
// 文档地址:https://opendocs.alipay.com/open/028xqy | |||
func (a *Client) TradeSettleConfirm(ctx context.Context, bm gopay.BodyMap) (aliRsp *TradeSettleConfirmResponse, err error) { | |||
err = bm.CheckEmptyError("out_request_no", "trade_no") | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "alipay.trade.settle.confirm"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(TradeSettleConfirmResponse) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// alipay.trade.order.settle(统一收单交易结算接口) | |||
// 文档地址:https://opendocs.alipay.com/open/c3b24498_alipay.trade.order.settle | |||
func (a *Client) TradeOrderSettle(ctx context.Context, bm gopay.BodyMap) (aliRsp *TradeOrderSettleResponse, err error) { | |||
err = bm.CheckEmptyError("out_request_no", "trade_no", "royalty_parameters") | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "alipay.trade.order.settle"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(TradeOrderSettleResponse) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// alipay.trade.order.settle.query(交易分账查询接口) | |||
// 文档地址:https://opendocs.alipay.com/open/02pj6l | |||
func (a *Client) TradeOrderSettleQuery(ctx context.Context, bm gopay.BodyMap) (aliRsp *TradeOrderSettleQueryResponse, err error) { | |||
err = bm.CheckEmptyError("settle_no") | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "alipay.trade.order.settle.query"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(TradeOrderSettleQueryResponse) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// alipay.trade.order.onsettle.query(分账剩余金额查询) | |||
// 文档地址:https://opendocs.alipay.com/open/d87dc009_alipay.trade.order.onsettle.query | |||
func (a *Client) TradeOrderOnSettleQuery(ctx context.Context, bm gopay.BodyMap) (aliRsp *TradeOrderOnSettleQueryResponse, err error) { | |||
err = bm.CheckEmptyError("trade_no") | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "alipay.trade.order.onsettle.query"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(TradeOrderOnSettleQueryResponse) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// alipay.trade.royalty.rate.query(分账比例查询) | |||
// 文档地址:https://opendocs.alipay.com/open/6f314ee9_alipay.trade.royalty.rate.query | |||
func (a *Client) TradeRoyaltyRateQuery(ctx context.Context, bm gopay.BodyMap) (aliRsp *TradeRoyaltyRateQueryResponse, err error) { | |||
err = bm.CheckEmptyError("out_request_no") | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "alipay.trade.royalty.rate.query"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(TradeRoyaltyRateQueryResponse) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// alipay.security.risk.customerrisk.send(商户数据同步) | |||
// 文档地址:https://opendocs.alipay.com/open/02qth4 | |||
func (a *Client) SecurityCustomerRiskSend(ctx context.Context, bm gopay.BodyMap) (aliRsp *SecurityCustomerRiskSendRsp, err error) { | |||
err = bm.CheckEmptyError("process_code", "trade_no") | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "alipay.security.risk.customerrisk.send"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(SecurityCustomerRiskSendRsp) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// alipay.pay.app.marketing.consult(商户前置内容咨询接口) | |||
// 文档地址:https://opendocs.alipay.com/pre-open/296d225f_alipay.pay.app.marketing.consult | |||
func (a *Client) PayAppMarketingConsult(ctx context.Context, bm gopay.BodyMap) (aliRsp *PayAppMarketingConsultRsp, err error) { | |||
err = bm.CheckEmptyError("biz_scene", "total_amount", "product_code") | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "alipay.pay.app.marketing.consult"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(PayAppMarketingConsultRsp) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} |
@@ -1,376 +0,0 @@ | |||
package alipay | |||
import ( | |||
"context" | |||
"encoding/json" | |||
"fmt" | |||
"github.com/go-pay/gopay" | |||
) | |||
// alipay.merchant.qipan.crowd.create(上传创建人群) | |||
// 文档地址:https://opendocs.alipay.com/open/e93d9a54_alipay.merchant.qipan.crowd.create | |||
func (a *Client) MerchantQipanCrowdCreate(ctx context.Context, bm gopay.BodyMap) (aliRsp *MerchantQipanCrowdCreateRsp, err error) { | |||
err = bm.CheckEmptyError("crowd_name", "external_crowd_code", "user_list") | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "alipay.merchant.qipan.crowd.create"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(MerchantQipanCrowdCreateRsp) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// alipay.merchant.qipan.crowduser.add(人群中追加用户) | |||
// 文档地址:https://opendocs.alipay.com/open/04330914_alipay.merchant.qipan.crowduser.add | |||
func (a *Client) MerchantQipanCrowdUserAdd(ctx context.Context, bm gopay.BodyMap) (aliRsp *MerchantQipanCrowdUserAddRsp, err error) { | |||
err = bm.CheckEmptyError("crowd_code", "user_list") | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "alipay.merchant.qipan.crowduser.add"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(MerchantQipanCrowdUserAddRsp) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// alipay.merchant.qipan.crowduser.delete(人群中删除用户) | |||
// 文档地址:https://opendocs.alipay.com/open/80646633_alipay.merchant.qipan.crowduser.delete | |||
func (a *Client) MerchantQipanCrowdUserDelete(ctx context.Context, bm gopay.BodyMap) (aliRsp *MerchantQipanCrowdUserDeleteRsp, err error) { | |||
err = bm.CheckEmptyError("crowd_code", "user_list") | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "alipay.merchant.qipan.crowduser.delete"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(MerchantQipanCrowdUserDeleteRsp) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// alipay.marketing.qipan.tagbase.batchquery(棋盘人群圈选标签基本信息查询) | |||
// 文档地址:https://opendocs.alipay.com/open/ce6aee00_alipay.marketing.qipan.tagbase.batchquery | |||
func (a *Client) MarketingQipanTagBaseBatchQuery(ctx context.Context) (aliRsp *MarketingQipanTagBaseBatchQueryRsp, err error) { | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, nil, "alipay.marketing.qipan.tagbase.batchquery"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(MarketingQipanTagBaseBatchQueryRsp) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// alipay.marketing.qipan.tag.query(棋盘标签圈选值查询) | |||
// 文档地址:https://opendocs.alipay.com/open/e322cb35_alipay.marketing.qipan.tag.query | |||
func (a *Client) MarketingQipanTagQuery(ctx context.Context, bm gopay.BodyMap) (aliRsp *MarketingQipanTagQueryRsp, err error) { | |||
err = bm.CheckEmptyError("tag_code") | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "alipay.marketing.qipan.tag.query"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(MarketingQipanTagQueryRsp) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// alipay.marketing.qipan.crowdoperation.create(棋盘人群创建) | |||
// 文档地址:https://opendocs.alipay.com/open/09c10677_alipay.marketing.qipan.crowdoperation.create | |||
func (a *Client) MarketingQipanCrowdOperationCreate(ctx context.Context, bm gopay.BodyMap) (aliRsp *MarketingQipanCrowdOperationCreateRsp, err error) { | |||
err = bm.CheckEmptyError("crowd_name", "operation_pool_list") | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "alipay.marketing.qipan.crowdoperation.create"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(MarketingQipanCrowdOperationCreateRsp) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// alipay.marketing.qipan.crowdtag.query(查询圈选标签列表) | |||
// 文档地址:https://opendocs.alipay.com/open/8e411cec_alipay.marketing.qipan.crowdtag.query | |||
func (a *Client) MarketingQipanCrowdTagQuery(ctx context.Context) (aliRsp *MarketingQipanCrowdTagQueryRsp, err error) { | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, nil, "alipay.marketing.qipan.crowdtag.query"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(MarketingQipanCrowdTagQueryRsp) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// alipay.marketing.qipan.crowdwithtag.create(标签圈选创建人群) | |||
// 文档地址:https://opendocs.alipay.com/open/cbf0efa4_alipay.marketing.qipan.crowdwithtag.create | |||
func (a *Client) MarketingQipanCrowdWithTagCreate(ctx context.Context, bm gopay.BodyMap) (aliRsp *MarketingQipanCrowdWithTagCreateRsp, err error) { | |||
err = bm.CheckEmptyError("crowd_name", "apply_channel_list", "select_tag_list") | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "alipay.marketing.qipan.crowdwithtag.create"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(MarketingQipanCrowdWithTagCreateRsp) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// alipay.marketing.qipan.crowdwithtag.query(标签圈选预估人群规模) | |||
// 文档地址:https://opendocs.alipay.com/open/adb5dd04_alipay.marketing.qipan.crowdwithtag.query | |||
func (a *Client) MarketingQipanCrowdWithTagQuery(ctx context.Context, bm gopay.BodyMap) (aliRsp *MarketingQipanCrowdWithTagQueryRsp, err error) { | |||
err = bm.CheckEmptyError("crowd_id") | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "alipay.marketing.qipan.crowdwithtag.query"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(MarketingQipanCrowdWithTagQueryRsp) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// alipay.merchant.qipan.crowd.batchquery(查询人群列表) | |||
// 文档地址:https://opendocs.alipay.com/open/b7f3caec_alipay.merchant.qipan.crowd.batchquery | |||
func (a *Client) MarketingQipanCrowdBatchQuery(ctx context.Context, bm gopay.BodyMap) (aliRsp *MarketingQipanCrowdBatchQueryRsp, err error) { | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "alipay.merchant.qipan.crowd.batchquery"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(MarketingQipanCrowdBatchQueryRsp) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// alipay.merchant.qipan.crowd.query(查询人群详情) | |||
// 文档地址:https://opendocs.alipay.com/open/be384367_alipay.merchant.qipan.crowd.query | |||
func (a *Client) MarketingQipanCrowdQuery(ctx context.Context, bm gopay.BodyMap) (aliRsp *MarketingQipanCrowdQueryRsp, err error) { | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "alipay.merchant.qipan.crowd.query"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(MarketingQipanCrowdQueryRsp) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// alipay.merchant.qipan.crowd.modify(修改人群) | |||
// 文档地址:https://opendocs.alipay.com/open/6c8ebb31_alipay.merchant.qipan.crowd.modify | |||
func (a *Client) MarketingQipanCrowdModify(ctx context.Context, bm gopay.BodyMap) (aliRsp *MarketingQipanCrowdModifyRsp, err error) { | |||
err = bm.CheckEmptyError("crowd_code") | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "alipay.merchant.qipan.crowd.modify"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(MarketingQipanCrowdModifyRsp) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// alipay.merchant.qipan.board.query(看板分析) | |||
// 文档地址:https://opendocs.alipay.com/open/aa5066aa_alipay.merchant.qipan.board.query | |||
func (a *Client) MarketingQipanBoardQuery(ctx context.Context, bm gopay.BodyMap) (aliRsp *MarketingQipanBoardQueryRsp, err error) { | |||
err = bm.CheckEmptyError("scene_code") | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "alipay.merchant.qipan.board.query"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(MarketingQipanBoardQueryRsp) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// alipay.merchant.qipan.insight.query(画像分析) | |||
// 文档地址:https://opendocs.alipay.com/open/46a75f4e_alipay.merchant.qipan.insight.query | |||
func (a *Client) MarketingQipanInsightQuery(ctx context.Context, bm gopay.BodyMap) (aliRsp *MarketingQipanInsightQueryRsp, err error) { | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "alipay.merchant.qipan.insight.query"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(MarketingQipanInsightQueryRsp) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// alipay.merchant.qipan.behavior.query(行为分析) | |||
// 文档地址:https://opendocs.alipay.com/open/56735ac5_alipay.merchant.qipan.behavior.query | |||
func (a *Client) MarketingQipanBehaviorQuery(ctx context.Context, bm gopay.BodyMap) (aliRsp *MarketingQipanBehaviorQueryRsp, err error) { | |||
err = bm.CheckEmptyError("scene_code", "request_params") | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "alipay.merchant.qipan.behavior.query"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(MarketingQipanBehaviorQueryRsp) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// alipay.merchant.qipan.trend.query(趋势分析) | |||
// 文档地址:https://opendocs.alipay.com/open/8ee7795a_alipay.merchant.qipan.trend.query | |||
func (a *Client) MarketingQipanTrendQuery(ctx context.Context, bm gopay.BodyMap) (aliRsp *MarketingQipanTrendQueryRsp, err error) { | |||
err = bm.CheckEmptyError("index_key", "request_params") | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "alipay.merchant.qipan.trend.query"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(MarketingQipanTrendQueryRsp) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// alipay.merchant.qipan.insightcity.query(常住省市查询) | |||
// 文档地址:https://opendocs.alipay.com/open/f7d99821_alipay.merchant.qipan.insightcity.query | |||
func (a *Client) MarketingQipanInsightCityQuery(ctx context.Context, bm gopay.BodyMap) (aliRsp *MarketingQipanInsightCityQueryRsp, err error) { | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "alipay.merchant.qipan.insightcity.query"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(MarketingQipanInsightCityQueryRsp) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} |
@@ -1,354 +0,0 @@ | |||
package alipay | |||
type FundTransUniTransferResponse struct { | |||
Response *TransUniTransfer `json:"alipay_fund_trans_uni_transfer_response"` | |||
AlipayCertSn string `json:"alipay_cert_sn,omitempty"` | |||
SignData string `json:"-"` | |||
Sign string `json:"sign"` | |||
} | |||
type FundAccountQueryResponse struct { | |||
Response *FundAccountQuery `json:"alipay_fund_account_query_response"` | |||
AlipayCertSn string `json:"alipay_cert_sn,omitempty"` | |||
SignData string `json:"-"` | |||
Sign string `json:"sign"` | |||
} | |||
type FundTransCommonQueryResponse struct { | |||
Response *FundTransCommonQuery `json:"alipay_fund_trans_common_query_response"` | |||
AlipayCertSn string `json:"alipay_cert_sn,omitempty"` | |||
SignData string `json:"-"` | |||
Sign string `json:"sign"` | |||
} | |||
type FundTransOrderQueryResponse struct { | |||
Response *FundTransOrderQuery `json:"alipay_fund_trans_order_query_response"` | |||
AlipayCertSn string `json:"alipay_cert_sn,omitempty"` | |||
SignData string `json:"-"` | |||
Sign string `json:"sign"` | |||
} | |||
type FundTransRefundResponse struct { | |||
Response *FundTransRefund `json:"alipay_fund_trans_refund_response"` | |||
AlipayCertSn string `json:"alipay_cert_sn,omitempty"` | |||
SignData string `json:"-"` | |||
Sign string `json:"sign"` | |||
} | |||
type FundAuthOrderFreezeResponse struct { | |||
Response *FundAuthOrderFreeze `json:"alipay_fund_auth_order_freeze_response"` | |||
AlipayCertSn string `json:"alipay_cert_sn,omitempty"` | |||
SignData string `json:"-"` | |||
Sign string `json:"sign"` | |||
} | |||
type FundAuthOrderVoucherCreateResponse struct { | |||
Response *FundAuthOrderVoucherCreate `json:"alipay_fund_auth_order_voucher_create_response"` | |||
AlipayCertSn string `json:"alipay_cert_sn,omitempty"` | |||
SignData string `json:"-"` | |||
Sign string `json:"sign"` | |||
} | |||
type FundAuthOrderUnfreezeResponse struct { | |||
Response *FundAuthOrderUnfreeze `json:"alipay_fund_auth_order_unfreeze_response"` | |||
AlipayCertSn string `json:"alipay_cert_sn,omitempty"` | |||
SignData string `json:"-"` | |||
Sign string `json:"sign"` | |||
} | |||
type FundAuthOperationDetailQueryResponse struct { | |||
Response *FundAuthOperationDetailQuery `json:"alipay_fund_auth_operation_detail_query_response"` | |||
AlipayCertSn string `json:"alipay_cert_sn,omitempty"` | |||
SignData string `json:"-"` | |||
Sign string `json:"sign"` | |||
} | |||
type FundAuthOperationCancelResponse struct { | |||
Response *FundAuthOperationCancel `json:"alipay_fund_auth_operation_cancel_response"` | |||
AlipayCertSn string `json:"alipay_cert_sn,omitempty"` | |||
SignData string `json:"-"` | |||
Sign string `json:"sign"` | |||
} | |||
type FundBatchCreateResponse struct { | |||
Response *FundBatchCreate `json:"alipay_fund_batch_create_response"` | |||
AlipayCertSn string `json:"alipay_cert_sn,omitempty"` | |||
SignData string `json:"-"` | |||
Sign string `json:"sign"` | |||
} | |||
type FundBatchCloseResponse struct { | |||
Response *FundBatchClose `json:"alipay_fund_batch_close_response"` | |||
AlipayCertSn string `json:"alipay_cert_sn,omitempty"` | |||
SignData string `json:"-"` | |||
Sign string `json:"sign"` | |||
} | |||
type FundBatchDetailQueryResponse struct { | |||
Response *FundBatchDetailQuery `json:"alipay_fund_batch_detail_query_response"` | |||
AlipayCertSn string `json:"alipay_cert_sn,omitempty"` | |||
SignData string `json:"-"` | |||
Sign string `json:"sign"` | |||
} | |||
type FundTransAppPayResponse struct { | |||
Response *FundTransAppPay `json:"alipay_fund_trans_app_pay_response"` | |||
AlipayCertSn string `json:"alipay_cert_sn,omitempty"` | |||
SignData string `json:"-"` | |||
Sign string `json:"sign"` | |||
} | |||
type FundTransPayeeBindQueryRsp struct { | |||
Response *FundTransPayeeBindQuery `json:"alipay_fund_trans_payee_bind_query_response"` | |||
AlipayCertSn string `json:"alipay_cert_sn,omitempty"` | |||
SignData string `json:"-"` | |||
Sign string `json:"sign"` | |||
} | |||
type FundTransPagePayRsp struct { | |||
Response *FundTransPagePay `json:"alipay_fund_trans_page_pay_response"` | |||
AlipayCertSn string `json:"alipay_cert_sn,omitempty"` | |||
SignData string `json:"-"` | |||
Sign string `json:"sign"` | |||
} | |||
// =========================================================分割========================================================= | |||
type TransUniTransfer struct { | |||
ErrorResponse | |||
OutBizNo string `json:"out_biz_no,omitempty"` | |||
OrderId string `json:"order_id,omitempty"` | |||
PayFundOrderId string `json:"pay_fund_order_id,omitempty"` | |||
Status string `json:"status,omitempty"` | |||
TransDate string `json:"trans_date,omitempty"` | |||
} | |||
type FundAccountQuery struct { | |||
ErrorResponse | |||
AvailableAmount string `json:"available_amount,omitempty"` | |||
FreezeAmount string `json:"freeze_amount,omitempty"` | |||
ExtCardInfo *ExtCardInfo `json:"ext_card_info,omitempty"` | |||
} | |||
type ExtCardInfo struct { | |||
CardNo string `json:"card_no,omitempty"` | |||
BankAccName string `json:"bank_acc_name,omitempty"` | |||
CardBranch string `json:"card_branch,omitempty"` | |||
CardBank string `json:"card_bank,omitempty"` | |||
CardLocation string `json:"card_location,omitempty"` | |||
CardDeposit string `json:"card_deposit,omitempty"` | |||
Status string `json:"status,omitempty"` | |||
} | |||
type FundTransCommonQuery struct { | |||
ErrorResponse | |||
OrderId string `json:"order_id,omitempty"` | |||
OutBizNo string `json:"out_biz_no,omitempty"` | |||
Status string `json:"status,omitempty"` | |||
SettleSerialNo string `json:"settle_serial_no,omitempty"` | |||
PayFundOrderId string `json:"pay_fund_order_id,omitempty"` | |||
TransAmount string `json:"trans_amount,omitempty"` | |||
PayDate string `json:"pay_date,omitempty"` | |||
ArrivalTimeEnd string `json:"arrival_time_end,omitempty"` | |||
OrderFee string `json:"order_fee,omitempty"` | |||
ErrorCode string `json:"error_code,omitempty"` | |||
FailReason string `json:"fail_reason,omitempty"` | |||
SubOrderErrorCode string `json:"sub_order_error_code,omitempty"` | |||
SubOrderFailReason string `json:"sub_order_fail_reason,omitempty"` | |||
SubOrderStatus string `json:"sub_order_status,omitempty"` | |||
} | |||
type FundTransOrderQuery struct { | |||
ErrorResponse | |||
OrderId string `json:"order_id,omitempty"` | |||
Status string `json:"status,omitempty"` | |||
PayDate string `json:"pay_date,omitempty"` | |||
ArrivalTimeEnd string `json:"arrival_time_end,omitempty"` | |||
OrderFee string `json:"order_fee,omitempty"` | |||
FailReason string `json:"fail_reason,omitempty"` | |||
OutBizNo string `json:"out_biz_no,omitempty"` | |||
ErrorCode string `json:"error_code,omitempty"` | |||
} | |||
type FundTransRefund struct { | |||
ErrorResponse | |||
RefundOrderId string `json:"refund_order_id"` | |||
OrderId string `json:"order_id"` | |||
OutRequestNo string `json:"out_request_no"` | |||
Status string `json:"status"` | |||
RefundAmount string `json:"refund_amount"` | |||
RefundDate string `json:"refund_date"` | |||
} | |||
type FundAuthOrderFreeze struct { | |||
ErrorResponse | |||
AuthNo string `json:"auth_no,omitempty"` | |||
OutOrderNo string `json:"out_order_no,omitempty"` | |||
OperationId string `json:"operation_id,omitempty"` | |||
OutRequestNo string `json:"out_request_no,omitempty"` | |||
Amount string `json:"amount,omitempty"` | |||
Status string `json:"status,omitempty"` | |||
PayerUserId string `json:"payer_user_id,omitempty"` | |||
PayerOpenId string `json:"payer_open_id,omitempty"` | |||
PayerLogonId string `json:"payer_logon_id,omitempty"` | |||
GmtTrans string `json:"gmt_trans,omitempty"` | |||
} | |||
type FundAuthOrderVoucherCreate struct { | |||
ErrorResponse | |||
OutOrderNo string `json:"out_order_no,omitempty"` | |||
OutRequestNo string `json:"out_request_no,omitempty"` | |||
CodeType string `json:"code_type,omitempty"` | |||
CodeValue string `json:"code_value,omitempty"` | |||
CodeUrl string `json:"code_url,omitempty"` | |||
} | |||
type FundAuthOrderUnfreeze struct { | |||
ErrorResponse | |||
AuthNo string `json:"auth_no,omitempty"` | |||
OutOrderNo string `json:"out_order_no,omitempty"` | |||
OperationId string `json:"operation_id,omitempty"` | |||
OutRequestNo string `json:"out_request_no,omitempty"` | |||
Amount string `json:"amount,omitempty"` | |||
Status string `json:"status,omitempty"` | |||
GmtTrans string `json:"gmt_trans,omitempty"` | |||
CreditAmount string `json:"credit_amount,omitempty"` | |||
FundAmount string `json:"fund_amount,omitempty"` | |||
} | |||
type FundAuthOperationDetailQuery struct { | |||
ErrorResponse | |||
AuthNo string `json:"auth_no,omitempty"` | |||
OutOrderNo string `json:"out_order_no,omitempty"` | |||
OrderStatus string `json:"order_status,omitempty"` | |||
TotalFreezeAmount string `json:"total_freeze_amount,omitempty"` | |||
RestAmount string `json:"rest_amount,omitempty"` | |||
TotalPayAmount string `json:"total_pay_amount,omitempty"` | |||
OrderTitle string `json:"order_title,omitempty"` | |||
PayerLogonId string `json:"payer_logon_id,omitempty"` | |||
PayerUserId string `json:"payer_user_id,omitempty"` | |||
PayerOpenId string `json:"payer_open_id,omitempty"` | |||
ExtraParam string `json:"extra_param,omitempty"` | |||
OperationId string `json:"operation_id,omitempty"` | |||
OutRequestNo string `json:"out_request_no,omitempty"` | |||
Amount string `json:"amount,omitempty"` | |||
OperationType string `json:"operation_type,omitempty"` | |||
Status string `json:"status,omitempty"` | |||
Remark string `json:"remark,omitempty"` | |||
GmtCreate string `json:"gmt_create,omitempty"` | |||
GmtTrans string `json:"gmt_trans,omitempty"` | |||
PreAuthType string `json:"pre_auth_type,omitempty"` | |||
TransCurrency string `json:"trans_currency,omitempty"` | |||
TotalFreezeCreditAmount string `json:"total_freeze_credit_amount,omitempty"` | |||
TotalFreezeFundAmount string `json:"total_freeze_fund_amount,omitempty"` | |||
TotalPayCreditAmount string `json:"total_pay_credit_amount,omitempty"` | |||
TotalPayFundAmount string `json:"total_pay_fund_amount,omitempty"` | |||
RestCreditAmount string `json:"rest_credit_amount,omitempty"` | |||
RestFundAmount string `json:"rest_fund_amount,omitempty"` | |||
CreditAmount string `json:"credit_amount,omitempty"` | |||
FundAmount string `json:"fund_amount,omitempty"` | |||
} | |||
type FundAuthOperationCancel struct { | |||
ErrorResponse | |||
AuthNo string `json:"auth_no,omitempty"` | |||
OutOrderNo string `json:"out_order_no,omitempty"` | |||
OperationId string `json:"operation_id,omitempty"` | |||
OutRequestNo string `json:"out_request_no,omitempty"` | |||
Action string `json:"action,omitempty"` | |||
} | |||
type FundBatchCreate struct { | |||
ErrorResponse | |||
OutBatchNo string `json:"out_batch_no,omitempty"` | |||
BatchTransId string `json:"batch_trans_id,omitempty"` | |||
Status string `json:"status,omitempty"` | |||
} | |||
type FundBatchClose struct { | |||
ErrorResponse | |||
BatchTransId string `json:"batch_trans_id,omitempty"` | |||
Status string `json:"status,omitempty"` | |||
} | |||
type FundBatchDetailQuery struct { | |||
ErrorResponse | |||
BatchTransId string `json:"batch_trans_id,omitempty"` | |||
BatchNo string `json:"batch_no,omitempty"` | |||
BizCode string `json:"biz_code,omitempty"` | |||
BizScene string `json:"biz_scene,omitempty"` | |||
BatchStatus string `json:"batch_status,omitempty"` | |||
ApprovalStatus string `json:"approval_status,omitempty"` | |||
ErrorCode string `json:"error_code,omitempty"` | |||
FailReason string `json:"fail_reason,omitempty"` | |||
SignPrincipal string `json:"sign_principal,omitempty"` | |||
PaymentAmount string `json:"payment_amount,omitempty"` | |||
PaymentCurrency string `json:"payment_currency,omitempty"` | |||
PageSize int `json:"page_size,omitempty"` | |||
PageNum int `json:"page_num,omitempty"` | |||
ProductCode string `json:"product_code,omitempty"` | |||
TotalPageCount string `json:"total_page_count,omitempty"` | |||
OutBatchNo string `json:"out_batch_no,omitempty"` | |||
GmtFinish string `json:"gmt_finish,omitempty"` | |||
TotalAmount string `json:"total_amount,omitempty"` | |||
GmtPayFinish string `json:"gmt_pay_finish,omitempty"` | |||
PayerId string `json:"payer_id,omitempty"` | |||
SuccessAmount string `json:"success_amount,omitempty"` | |||
FailAmount string `json:"fail_amount,omitempty"` | |||
FailCount string `json:"fail_count,omitempty"` | |||
SuccessCount string `json:"success_count,omitempty"` | |||
TotalItemCount string `json:"total_item_count,omitempty"` | |||
AccDetailList []*struct { | |||
DetailNo string `json:"detail_no,omitempty"` | |||
PaymentAmount string `json:"payment_amount,omitempty"` | |||
PaymentCurrency string `json:"payment_currency,omitempty"` | |||
TransAmount string `json:"trans_amount,omitempty"` | |||
TransCurrency string `json:"trans_currency,omitempty"` | |||
SettlementAmount string `json:"settlement_amount,omitempty"` | |||
SettlementCurrency string `json:"settlement_currency,omitempty"` | |||
PayeeInfo *struct { | |||
PayeeAccount string `json:"payee_account,omitempty"` | |||
PayeeType string `json:"payee_type,omitempty"` | |||
PayeeName string `json:"payee_name,omitempty"` | |||
} `json:"payee_info,omitempty"` | |||
CertInfo *struct { | |||
CertNo string `json:"cert_no,omitempty"` | |||
CertType string `json:"cert_type,omitempty"` | |||
} `json:"cert_info,omitempty"` | |||
Remark string `json:"remark,omitempty"` | |||
Status string `json:"status,omitempty"` | |||
ExchangeRate *struct { | |||
Rate string `json:"rate,omitempty"` | |||
BaseCurrency string `json:"base_currency,omitempty"` | |||
ExchangeCurrency string `json:"exchange_currency,omitempty"` | |||
} `json:"exchange_rate,omitempty"` | |||
NeedRetry string `json:"need_retry,omitempty"` | |||
AlipayOrderNo string `json:"alipay_order_no,omitempty"` | |||
OutBizNo string `json:"out_biz_no,omitempty"` | |||
DetailId string `json:"detail_id,omitempty"` | |||
ErrorCode string `json:"error_code,omitempty"` | |||
ErrorMsg string `json:"error_msg,omitempty"` | |||
GmtCreate string `json:"gmt_create,omitempty"` | |||
GmtFinish string `json:"gmt_finish,omitempty"` | |||
SubStatus string `json:"sub_status,omitempty"` | |||
} `json:"acc_detail_list,omitempty"` | |||
} | |||
type FundTransAppPay struct { | |||
ErrorResponse | |||
OutBizNo string `json:"out_biz_no,omitempty"` | |||
OrderId string `json:"order_id,omitempty"` | |||
Status string `json:"status,omitempty"` | |||
} | |||
type FundTransPayeeBindQuery struct { | |||
ErrorResponse | |||
Bind string `json:"bind"` // 是否绑定收款账号。true:已绑定;false:未绑定 | |||
} | |||
type FundTransPagePay struct { | |||
ErrorResponse | |||
OutBizNo string `json:"out_biz_no"` | |||
OrderID string `json:"order_id,omitempty"` | |||
Status string `json:"status"` | |||
} |
@@ -1,318 +0,0 @@ | |||
package alipay | |||
const ( | |||
// URL | |||
baseUrl = "https://openapi.alipay.com/gateway.do" | |||
//sandboxBaseUrl = "https://openapi.alipaydev.com/gateway.do" | |||
sandboxBaseUrl = "https://openapi-sandbox.dl.alipaydev.com/gateway.do" | |||
baseUrlUtf8 = "https://openapi.alipay.com/gateway.do?charset=utf-8" | |||
//sandboxBaseUrlUtf8 = "https://openapi.alipaydev.com/gateway.do?charset=utf-8" | |||
sandboxBaseUrlUtf8 = "https://openapi-sandbox.dl.alipaydev.com/gateway.do?charset=utf-8" | |||
LocationShanghai = "Asia/Shanghai" | |||
PKCS1 PKCSType = 1 // 非Java | |||
PKCS8 PKCSType = 2 // Java | |||
RSA = "RSA" | |||
RSA2 = "RSA2" | |||
UTF8 = "utf-8" | |||
) | |||
var ( | |||
//不需要处理AppAuthToken的方法 | |||
appAuthTokenInBizContent = map[string]bool{ | |||
"alipay.open.auth.token.app.query": true, | |||
} | |||
) | |||
type PKCSType uint8 | |||
type NotifyRequest struct { | |||
NotifyTime string `json:"notify_time,omitempty"` | |||
NotifyType string `json:"notify_type,omitempty"` | |||
NotifyId string `json:"notify_id,omitempty"` | |||
AppId string `json:"app_id,omitempty"` | |||
Charset string `json:"charset,omitempty"` | |||
Version string `json:"version,omitempty"` | |||
SignType string `json:"sign_type,omitempty"` | |||
Sign string `json:"sign,omitempty"` | |||
AuthAppId string `json:"auth_app_id,omitempty"` | |||
TradeNo string `json:"trade_no,omitempty"` | |||
OutTradeNo string `json:"out_trade_no,omitempty"` | |||
OutBizNo string `json:"out_biz_no,omitempty"` | |||
BuyerId string `json:"buyer_id,omitempty"` | |||
BuyerLogonId string `json:"buyer_logon_id,omitempty"` | |||
SellerId string `json:"seller_id,omitempty"` | |||
SellerEmail string `json:"seller_email,omitempty"` | |||
TradeStatus string `json:"trade_status,omitempty"` | |||
TotalAmount string `json:"total_amount,omitempty"` | |||
ReceiptAmount string `json:"receipt_amount,omitempty"` | |||
InvoiceAmount string `json:"invoice_amount,omitempty"` | |||
BuyerPayAmount string `json:"buyer_pay_amount,omitempty"` | |||
PointAmount string `json:"point_amount,omitempty"` | |||
RefundFee string `json:"refund_fee,omitempty"` | |||
Subject string `json:"subject,omitempty"` | |||
Body string `json:"body,omitempty"` | |||
GmtCreate string `json:"gmt_create,omitempty"` | |||
GmtPayment string `json:"gmt_payment,omitempty"` | |||
GmtRefund string `json:"gmt_refund,omitempty"` | |||
GmtClose string `json:"gmt_close,omitempty"` | |||
FundBillList []*FundBillListInfo `json:"fund_bill_list,omitempty"` | |||
PassbackParams string `json:"passback_params,omitempty"` | |||
VoucherDetailList []*NotifyVoucherDetail `json:"voucher_detail_list,omitempty"` | |||
Method string `json:"method,omitempty"` // 电脑网站支付 支付宝请求 return_url 同步返回参数 | |||
Timestamp string `json:"timestamp,omitempty"` // 电脑网站支付 支付宝请求 return_url 同步返回参数 | |||
} | |||
type FundBillListInfo struct { | |||
Amount string `json:"amount,omitempty"` | |||
FundChannel string `json:"fundChannel,omitempty"` // 异步通知里是 fundChannel | |||
} | |||
type NotifyVoucherDetail struct { | |||
VoucherId string `json:"voucherId,omitempty"` | |||
TemplateId string `json:"template_id,omitempty"` | |||
Name string `json:"name,omitempty"` | |||
Type string `json:"type,omitempty"` | |||
Amount string `json:"amount,omitempty"` | |||
MerchantContribute string `json:"merchantContribute,omitempty"` | |||
OtherContribute string `json:"otherContribute,omitempty"` | |||
OtherContributeDetail []*ContributeDetail `json:"otherContributeDetail,omitempty"` | |||
Memo string `json:"memo,omitempty"` | |||
Id string `json:"id,omitempty"` | |||
PurchaseBuyerContribute string `json:"purchase_buyer_contribute,omitempty"` | |||
PurchaseMerchantContribute string `json:"purchase_merchant_contribute,omitempty"` | |||
PurchaseAntContribute string `json:"purchase_ant_contribute,omitempty"` | |||
} | |||
type ContributeDetail struct { | |||
ContributeType string `json:"contributeType,omitempty"` | |||
ContributeAmount string `json:"contributeAmount,omitempty"` | |||
} | |||
type UserPhone struct { | |||
ErrorResponse | |||
Mobile string `json:"mobile,omitempty"` | |||
} | |||
type ErrorResponse struct { | |||
Code string `json:"code"` | |||
Msg string `json:"msg"` | |||
SubCode string `json:"sub_code,omitempty"` | |||
SubMsg string `json:"sub_msg,omitempty"` | |||
} | |||
// =================================================== | |||
type FundAuthOrderAppFreezeResponse struct { | |||
Response *FundAuthOrderAppFreeze `json:"alipay_fund_auth_order_app_freeze_response"` | |||
AlipayCertSn string `json:"alipay_cert_sn,omitempty"` | |||
SignData string `json:"-"` | |||
Sign string `json:"sign"` | |||
} | |||
type FundAuthOrderAppFreeze struct { | |||
ErrorResponse | |||
AuthNo string `json:"auth_no,omitempty"` | |||
OutOrderNo string `json:"out_order_no,omitempty"` | |||
OperationId string `json:"operation_id,omitempty"` | |||
OutRequestNo string `json:"out_request_no,omitempty"` | |||
Amount string `json:"amount,omitempty"` | |||
Status string `json:"status,omitempty"` | |||
PayerUserId string `json:"payer_user_id,omitempty"` | |||
GmtTrans string `json:"gmt_trans,omitempty"` | |||
PreAuthType string `json:"pre_auth_type,omitempty"` | |||
CreditAmount string `json:"credit_amount,omitempty"` | |||
FundAmount string `json:"fund_amount,omitempty"` | |||
TransCurrency string `json:"trans_currency,omitempty"` | |||
} | |||
// =================================================== | |||
type OpenAuthTokenAppResponse struct { | |||
Response *AuthTokenApp `json:"alipay_open_auth_token_app_response"` | |||
AlipayCertSn string `json:"alipay_cert_sn,omitempty"` | |||
SignData string `json:"-"` | |||
Sign string `json:"sign"` | |||
} | |||
type AuthTokenApp struct { | |||
ErrorResponse | |||
UserId string `json:"user_id,omitempty"` | |||
AuthAppId string `json:"auth_app_id,omitempty"` | |||
AppAuthToken string `json:"app_auth_token,omitempty"` | |||
ExpiresIn int `json:"expires_in,omitempty"` | |||
AppRefreshToken string `json:"app_refresh_token,omitempty"` | |||
ReExpiresIn int `json:"re_expires_in,omitempty"` | |||
Tokens []*Token `json:"tokens,omitempty"` | |||
} | |||
type Token struct { | |||
AuthAppId string `json:"auth_app_id,omitempty"` | |||
AppAuthToken string `json:"app_auth_token,omitempty"` | |||
ExpiresIn int `json:"expires_in,omitempty"` | |||
AppRefreshToken string `json:"app_refresh_token,omitempty"` | |||
ReExpiresIn int `json:"re_expires_in,omitempty"` | |||
UserId string `json:"user_id,omitempty"` | |||
} | |||
// =================================================== | |||
type OpenAuthTokenAppInviteCreateResponse struct { | |||
Response *OpenAuthTokenAppInviteCreate `json:"alipay_open_auth_appauth_invite_create_response"` | |||
AlipayCertSn string `json:"alipay_cert_sn,omitempty"` | |||
SignData string `json:"-"` | |||
Sign string `json:"sign"` | |||
} | |||
type OpenAuthTokenAppInviteCreate struct { | |||
ErrorResponse | |||
TaskPageUrl string `json:"task_page_url,omitempty"` | |||
} | |||
// =================================================== | |||
type OpenAuthTokenAppQueryResponse struct { | |||
Response *AuthTokenAppQuery `json:"alipay_open_auth_token_app_query_response"` | |||
AlipayCertSn string `json:"alipay_cert_sn,omitempty"` | |||
SignData string `json:"-"` | |||
Sign string `json:"sign"` | |||
} | |||
type AuthTokenAppQuery struct { | |||
ErrorResponse | |||
UserId string `json:"user_id"` //授权商户的user_id | |||
AuthAppId string `json:"auth_app_id"` //授权商户的appid | |||
ExpiresIn int `json:"expires_in"` //应用授权令牌失效时间,单位到秒 | |||
AuthMethods []string `json:"auth_methods"` //当前app_auth_token的授权接口列表 | |||
AuthStart string `json:"auth_start"` //授权生效时间 | |||
AuthEnd string `json:"auth_end"` //授权失效时间 | |||
Status string `json:"status"` //valid:有效状态;invalid:无效状态 | |||
} | |||
// =================================================== | |||
type UserInfoAuthResponse struct { | |||
Response *ErrorResponse `json:"alipay_user_info_auth_response"` | |||
AlipayCertSn string `json:"alipay_cert_sn,omitempty"` | |||
SignData string `json:"-"` | |||
Sign string `json:"sign"` | |||
} | |||
// =================================================== | |||
type MonitorHeartbeatSynResponse struct { | |||
Response *MonitorHeartbeatSynRes `json:"monitor_heartbeat_syn_response"` | |||
AlipayCertSn string `json:"alipay_cert_sn,omitempty"` | |||
SignData string `json:"-"` | |||
Sign string `json:"sign"` | |||
} | |||
type MonitorHeartbeatSynRes struct { | |||
ErrorResponse | |||
Pid string `json:"pid"` | |||
} | |||
// =================================================== | |||
type PublicCertDownloadRsp struct { | |||
Response *PublicCertDownload `json:"alipay_open_app_alipaycert_download_response"` | |||
} | |||
type PublicCertDownload struct { | |||
ErrorResponse | |||
AlipayCertContent string `json:"alipay_cert_content"` | |||
} | |||
// =================================================== | |||
type UserAgreementPageSignRsp struct { | |||
Response *UserAgreementPageSign `json:"alipay_user_agreement_page_sign_response"` | |||
AlipayCertSn string `json:"alipay_cert_sn,omitempty"` | |||
SignData string `json:"-"` | |||
Sign string `json:"sign"` | |||
} | |||
type UserAgreementPageSign struct { | |||
ErrorResponse | |||
ExternalAgreementNo string `json:"external_agreement_no,omitempty"` | |||
PersonalProductCode string `json:"personal_product_code"` | |||
ValidTime string `json:"valid_time"` | |||
SignScene string `json:"sign_scene"` | |||
AgreementNo string `json:"agreement_no"` | |||
ZmOpenId string `json:"zm_open_id,omitempty"` | |||
InvalidTime string `json:"invalid_time"` | |||
SignTime string `json:"sign_time"` | |||
AlipayUserId string `json:"alipay_user_id"` | |||
Status string `json:"status"` | |||
ForexEligible string `json:"forex_eligible,omitempty"` | |||
ExternalLogonId string `json:"external_logon_id,omitempty"` | |||
AlipayLogonId string `json:"alipay_logon_id"` | |||
CreditAuthMode string `json:"credit_auth_mode,omitempty"` | |||
} | |||
// =================================================== | |||
type OpenAppQrcodeCreateRsp struct { | |||
Response *OpenAppQrcodeCreate `json:"alipay_open_app_qrcode_create_response"` | |||
AlipayCertSn string `json:"alipay_cert_sn,omitempty"` | |||
SignData string `json:"-"` | |||
Sign string `json:"sign"` | |||
} | |||
type OpenAppQrcodeCreate struct { | |||
ErrorResponse | |||
QrCodeUrl string `json:"qr_code_url"` | |||
} | |||
// =================================================== | |||
type MerchantItemFileUploadRsp struct { | |||
Response *MerchantItemFileUpload `json:"alipay_merchant_item_file_upload_response"` | |||
AlipayCertSn string `json:"alipay_cert_sn,omitempty"` | |||
SignData string `json:"-"` | |||
Sign string `json:"sign"` | |||
} | |||
type MerchantItemFileUpload struct { | |||
ErrorResponse | |||
MaterialId string `json:"material_id"` // 文件在商品中心的素材标识(素材ID长期有效) | |||
MaterialKey string `json:"material_key"` // 文件在商品中心的素材标示,创建/更新商品时使用 | |||
} | |||
// =================================================== | |||
type DataDataserviceAdDataQueryRsp struct { | |||
Response *DataDataserviceAdDataQuery `json:"alipay_data_dataservice_ad_data_query_response"` | |||
AlipayCertSn string `json:"alipay_cert_sn,omitempty"` | |||
SignData string `json:"-"` | |||
Sign string `json:"sign"` | |||
} | |||
type DataDataserviceAdDataQuery struct { | |||
ErrorResponse | |||
DataList []*DataDetail `json:"data_list,omitempty"` | |||
} | |||
type DataDetail struct { | |||
OuterId string `json:"outer_id,omitempty"` | |||
Impression int64 `json:"impression,omitempty"` | |||
Click int64 `json:"click,omitempty"` | |||
Cost int64 `json:"cost,omitempty"` | |||
ConversionDataList []*ConversionDataDetail `json:"conversion_data_list,omitempty"` | |||
BizDate string `json:"biz_date,omitempty"` | |||
} | |||
type ConversionDataDetail struct { | |||
ConversionId string `json:"conversion_id,omitempty"` | |||
ConversionResult string `json:"conversion_result,omitempty"` | |||
} | |||
// =================================================== | |||
type OpenAppApiQueryResponse struct { | |||
Response *OpenAppApiQuery `json:"alipay_open_app_api_query_response"` | |||
AlipayCertSn string `json:"alipay_cert_sn,omitempty"` | |||
SignData string `json:"-"` | |||
Sign string `json:"sign"` | |||
} | |||
type OpenAppApiQuery struct { | |||
ErrorResponse | |||
Apis []*Apis `json:"apis"` | |||
} | |||
type Apis struct { | |||
ApiName string `json:"api_name,omitempty"` | |||
FieldName string `json:"field_name,omitempty"` | |||
PackageCode string `json:"package_code,omitempty"` | |||
} | |||
// =================================================== |
@@ -1,223 +0,0 @@ | |||
package alipay | |||
type AntMerchantShopModifyRsp struct { | |||
Response *AntMerchantShopModify `json:"ant_merchant_expand_shop_modify_response"` | |||
AlipayCertSn string `json:"alipay_cert_sn,omitempty"` | |||
SignData string `json:"-"` | |||
Sign string `json:"sign"` | |||
} | |||
type AntMerchantShopCreateRsp struct { | |||
Response *AntMerchantShopCreate `json:"ant_merchant_expand_shop_create_response"` | |||
AlipayCertSn string `json:"alipay_cert_sn,omitempty"` | |||
SignData string `json:"-"` | |||
Sign string `json:"sign"` | |||
} | |||
type AntMerchantShopConsultRsp struct { | |||
Response *AntMerchantShopConsult `json:"ant_merchant_expand_shop_consult_response"` | |||
AlipayCertSn string `json:"alipay_cert_sn,omitempty"` | |||
SignData string `json:"-"` | |||
Sign string `json:"sign"` | |||
} | |||
type AntMerchantOrderQueryRsp struct { | |||
Response *AntMerchantOrderQuery `json:"ant_merchant_expand_order_query_response"` | |||
AlipayCertSn string `json:"alipay_cert_sn,omitempty"` | |||
SignData string `json:"-"` | |||
Sign string `json:"sign"` | |||
} | |||
type AntMerchantShopQueryRsp struct { | |||
Response *AntMerchantShopQuery `json:"ant_merchant_expand_shop_query_response"` | |||
AlipayCertSn string `json:"alipay_cert_sn,omitempty"` | |||
SignData string `json:"-"` | |||
Sign string `json:"sign"` | |||
} | |||
type AntMerchantShopPageQueryRsp struct { | |||
Response *AntMerchantShopPageQuery `json:"ant_merchant_expand_shop_page_query_response"` | |||
AlipayCertSn string `json:"alipay_cert_sn,omitempty"` | |||
SignData string `json:"-"` | |||
Sign string `json:"sign"` | |||
} | |||
type AntMerchantShopCloseRsp struct { | |||
Response *AntMerchantShopClose `json:"ant_merchant_expand_shop_close_response"` | |||
AlipayCertSn string `json:"alipay_cert_sn,omitempty"` | |||
SignData string `json:"-"` | |||
Sign string `json:"sign"` | |||
} | |||
type AntMerchantExpandIndirectImageUploadRsp struct { | |||
Response *AntMerchantExpandIndirectImageUpload `json:"ant_merchant_expand_indirect_image_upload_response"` | |||
AlipayCertSn string `json:"alipay_cert_sn,omitempty"` | |||
SignData string `json:"-"` | |||
Sign string `json:"sign"` | |||
} | |||
type AntMerchantExpandMccQueryRsp struct { | |||
Response *AntMerchantExpandMccQuery `json:"ant_merchant_expand_mcc_query_response"` | |||
AlipayCertSn string `json:"alipay_cert_sn,omitempty"` | |||
SignData string `json:"-"` | |||
Sign string `json:"sign"` | |||
} | |||
type AntMerchantExpandShopReceiptAccountSaveRsp struct { | |||
Response *AntMerchantExpandShopReceiptAccountSave `json:"ant_merchant_expand_shop_receiptaccount_save_response"` | |||
AlipayCertSn string `json:"alipay_cert_sn,omitempty"` | |||
SignData string `json:"-"` | |||
Sign string `json:"sign"` | |||
} | |||
// =========================================================分割========================================================= | |||
type AntMerchantShopModify struct { | |||
ErrorResponse | |||
OrderId string `json:"order_id"` | |||
} | |||
type AntMerchantShopCreate struct { | |||
ErrorResponse | |||
OrderId string `json:"order_id"` | |||
} | |||
type AntMerchantShopConsult struct { | |||
ErrorResponse | |||
AccountAudit bool `json:"account_audit"` | |||
RiskAudit bool `json:"risk_audit"` | |||
OrderId string `json:"order_id"` | |||
} | |||
type AntMerchantOrderQuery struct { | |||
ErrorResponse | |||
IPRoleID []string `json:"ip_role_id,omitempty"` | |||
MerchantName string `json:"merchant_name"` | |||
Status string `json:"status"` | |||
ApplyTime string `json:"apply_time"` | |||
ExtInfo string `json:"ext_info"` | |||
} | |||
type AntMerchantShopQuery struct { | |||
ErrorResponse | |||
ShopID string `json:"shop_id"` | |||
BusinessAddress struct { | |||
CityCode string `json:"city_code"` | |||
DistrictCode string `json:"district_code"` | |||
Address string `json:"address"` | |||
ProvinceCode string `json:"province_code"` | |||
Poiid string `json:"poiid,omitempty"` | |||
Longitude string `json:"longitude,omitempty"` | |||
Latitude string `json:"latitude,omitempty"` | |||
Type string `json:"type,omitempty"` | |||
} `json:"business_address"` | |||
ShopCategory string `json:"shop_category"` | |||
StoreID string `json:"store_id"` | |||
ShopType string `json:"shop_type"` | |||
IPRoleID string `json:"ip_role_id"` | |||
ShopName string `json:"shop_name"` | |||
ContactPhone string `json:"contact_phone"` | |||
ContactMobile string `json:"contact_mobile"` | |||
CertNo string `json:"cert_no"` | |||
OutDoorImages []string `json:"out_door_images,omitempty"` | |||
Qualifications []struct { | |||
IndustryQualificationType string `json:"industry_qualification_type,omitempty"` | |||
IndustryQualificationImage string `json:"industry_qualification_image,omitempty"` | |||
} `json:"qualifications,omitempty"` | |||
CertType string `json:"cert_type,omitempty"` | |||
CertName string `json:"cert_name,omitempty"` | |||
CertImage string `json:"cert_image,omitempty"` | |||
LegalName string `json:"legal_name,omitempty"` | |||
LegalCertNo string `json:"legal_cert_no,omitempty"` | |||
LicenseAuthLetterImage string `json:"license_auth_letter_image,omitempty"` | |||
SettleAlipayLogonID string `json:"settle_alipay_logon_id,omitempty"` | |||
ExtInfos []struct { | |||
KeyName string `json:"key_name"` | |||
Value string `json:"value"` | |||
} `json:"ext_infos,omitempty"` | |||
BusinessTime []struct { | |||
WeekDay int `json:"week_day"` | |||
OpenTime string `json:"open_time"` | |||
CloseTime string `json:"close_time"` | |||
} `json:"business_time,omitempty"` | |||
ContactInfos []struct { | |||
Name string `json:"name"` | |||
Phone string `json:"phone,omitempty"` | |||
Mobile string `json:"mobile,omitempty"` | |||
Email string `json:"email,omitempty"` | |||
Tag []string `json:"tag"` | |||
Type string `json:"type"` | |||
IDCardNo string `json:"id_card_no,omitempty"` | |||
} `json:"contact_infos,omitempty"` | |||
Memo string `json:"memo,omitempty"` | |||
BrandID string `json:"brand_id,omitempty"` | |||
Scene string `json:"scene,omitempty"` | |||
NewShopCategory string `json:"new_shop_category"` | |||
} | |||
type AntMerchantShopClose struct { | |||
ErrorResponse | |||
} | |||
type AntMerchantExpandIndirectImageUpload struct { | |||
ErrorResponse | |||
ImageId string `json:"image_id"` | |||
} | |||
type AntMerchantShopPageQuery struct { | |||
ErrorResponse | |||
ShopInfos []*AntShopInfo `json:"shop_infos"` | |||
TotalPages int `json:"total_pages"` | |||
AlipayPoiid string `json:"alipay_poiid"` | |||
} | |||
type AntShopInfo struct { | |||
ShopId string `json:"shop_id"` | |||
BusinessAddress *BusinessAddress `json:"business_address"` | |||
ShopCategory string `json:"shop_category"` | |||
NewShopCategory string `json:"new_shop_category"` | |||
StoreId string `json:"store_id"` | |||
ShopType string `json:"shop_type"` | |||
ShopName string `json:"shop_name"` | |||
ContactPhone string `json:"contact_phone"` | |||
ContactMobile string `json:"contact_mobile"` | |||
BusinessTime []*BusinessTime `json:"business_time"` | |||
ShopStatus string `json:"shop_status"` | |||
ShopInfoStatus string `json:"shop_info_status"` | |||
} | |||
type BusinessAddress struct { | |||
CityCode string `json:"city_code"` | |||
DistrictCode string `json:"district_code"` | |||
Address string `json:"address"` | |||
ProvinceCode string `json:"province_code"` | |||
Poiid string `json:"poiid"` | |||
Longitude string `json:"longitude"` | |||
Latitude string `json:"latitude"` | |||
Type string `json:"type"` | |||
} | |||
type BusinessTime struct { | |||
WeekDay int `json:"week_day"` | |||
OpenTime string `json:"open_time"` | |||
CloseTime string `json:"close_time"` | |||
} | |||
type AntMerchantExpandMccQuery struct { | |||
ErrorResponse | |||
MccInfoList []*MccInfo `json:"mcc_info_list"` | |||
} | |||
type MccInfo struct { | |||
MccLevel1 string `json:"mcc_level_1"` | |||
MccLevel1Name string `json:"mcc_level_1_name"` | |||
MccLevel2 string `json:"mcc_level_2"` | |||
MccLevel2Name string `json:"mcc_level_2_name"` | |||
IsSpecial bool `json:"is_special"` | |||
SpecialQualRequired bool `json:"special_qual_required"` | |||
MccRequirements string `json:"mcc_requirements"` | |||
} | |||
type AntMerchantExpandShopReceiptAccountSave struct { | |||
ErrorResponse | |||
} |
@@ -1,49 +0,0 @@ | |||
package alipay | |||
type CommerceTransportNfccardSendRsp struct { | |||
Response *CommerceTransportNfccardSend `json:"alipay_commerce_transport_nfccard_send_response"` | |||
AlipayCertSn string `json:"alipay_cert_sn,omitempty"` | |||
SignData string `json:"-"` | |||
Sign string `json:"sign"` | |||
} | |||
type CommerceAirCallcenterTradeApplyRsp struct { | |||
Response *CommerceAirCallcenterTradeApply `json:"alipay_commerce_air_callcenter_trade_apply_response"` | |||
AlipayCertSn string `json:"alipay_cert_sn,omitempty"` | |||
SignData string `json:"-"` | |||
Sign string `json:"sign"` | |||
} | |||
type CommerceBenefitApplyRsp struct { | |||
Response *CommerceBenefitApply `json:"alipay_commerce_operation_gamemarketing_benefit_apply_response"` | |||
AlipayCertSn string `json:"alipay_cert_sn,omitempty"` | |||
SignData string `json:"-"` | |||
Sign string `json:"sign"` | |||
} | |||
type CommerceBenefitVerifyRsp struct { | |||
Response *CommerceBenefitVerify `json:"alipay_commerce_operation_gamemarketing_benefit_verify_response"` | |||
AlipayCertSn string `json:"alipay_cert_sn,omitempty"` | |||
SignData string `json:"-"` | |||
Sign string `json:"sign"` | |||
} | |||
// =========================================================分割========================================================= | |||
type CommerceTransportNfccardSend struct { | |||
ErrorResponse | |||
} | |||
type CommerceAirCallcenterTradeApply struct { | |||
ErrorResponse | |||
} | |||
type CommerceBenefitApply struct { | |||
ErrorResponse | |||
ApplyVoucherCodeList string `json:"apply_voucher_code_list,omitempty"` | |||
} | |||
type CommerceBenefitVerify struct { | |||
ErrorResponse | |||
VoucherVerifyStatus bool `json:"voucher_verify_status,omitempty"` | |||
} |
@@ -1,22 +0,0 @@ | |||
package alipay | |||
type TradeCustomsDeclareRsp struct { | |||
Response *TradeCustomsDeclare `json:"alipay_trade_customs_declare_response"` | |||
AlipayCertSn string `json:"alipay_cert_sn,omitempty"` | |||
SignData string `json:"-"` | |||
Sign string `json:"sign"` | |||
} | |||
// =========================================================分割========================================================= | |||
type TradeCustomsDeclare struct { | |||
ErrorResponse | |||
TradeNo string `json:"trade_no,omitempty"` | |||
AlipayDeclareNo string `json:"alipay_declare_no"` | |||
PayCode string `json:"pay_code,omitempty"` | |||
PayTransactionId string `json:"pay_transaction_id,omitempty"` | |||
TotalAmount string `json:"total_amount,omitempty"` | |||
Currency string `json:"currency,omitempty"` | |||
VerDept string `json:"ver_dept,omitempty"` | |||
IdentityCheck string `json:"identity_check,omitempty"` | |||
} |
@@ -1,91 +0,0 @@ | |||
package alipay | |||
type DataBillBalanceQueryResponse struct { | |||
Response *DataBillBalanceQuery `json:"alipay_data_bill_balance_query_response"` | |||
AlipayCertSn string `json:"alipay_cert_sn,omitempty"` | |||
SignData string `json:"-"` | |||
Sign string `json:"sign"` | |||
} | |||
type DataBillAccountLogQueryResponse struct { | |||
Response *DataBillAccountLogQuery `json:"alipay_data_bill_accountlog_query_response"` | |||
AlipayCertSn string `json:"alipay_cert_sn,omitempty"` | |||
SignData string `json:"-"` | |||
Sign string `json:"sign"` | |||
} | |||
type DataBillEreceiptApplyRsp struct { | |||
Response *DataBillEreceiptApply `json:"alipay_data_bill_ereceipt_apply_response"` | |||
AlipayCertSn string `json:"alipay_cert_sn,omitempty"` | |||
SignData string `json:"-"` | |||
Sign string `json:"sign"` | |||
} | |||
type DataBillEreceiptQueryRsp struct { | |||
Response *DataBillEreceiptQuery `json:"alipay_data_bill_ereceipt_query_response"` | |||
AlipayCertSn string `json:"alipay_cert_sn,omitempty"` | |||
SignData string `json:"-"` | |||
Sign string `json:"sign"` | |||
} | |||
type DataBillDownloadUrlQueryResponse struct { | |||
Response *DataBillDownloadUrlQuery `json:"alipay_data_dataservice_bill_downloadurl_query_response"` | |||
AlipayCertSn string `json:"alipay_cert_sn,omitempty"` | |||
SignData string `json:"-"` | |||
Sign string `json:"sign"` | |||
} | |||
// =========================================================分割========================================================= | |||
type DataBillBalanceQuery struct { | |||
ErrorResponse | |||
TotalAmount string `json:"total_amount,omitempty"` | |||
AvailableAmount string `json:"available_amount,omitempty"` | |||
FreezeAmount string `json:"freeze_amount,omitempty"` | |||
SettleAmount string `json:"settle_amount,omitempty"` | |||
} | |||
type DataBillAccountLogQuery struct { | |||
ErrorResponse | |||
PageNo string `json:"page_no,omitempty"` | |||
PageSize string `json:"page_size,omitempty"` | |||
TotalSize string `json:"total_size,omitempty"` | |||
DetailList []*AccountLogItemResult `json:"detail_list,omitempty"` | |||
} | |||
type AccountLogItemResult struct { | |||
TransDt string `json:"trans_dt,omitempty"` | |||
AccountLogId string `json:"account_log_id,omitempty"` | |||
AlipayOrderNo string `json:"alipay_order_no,omitempty"` | |||
MerchantOrderNo string `json:"merchant_order_no,omitempty"` | |||
TransAmount string `json:"trans_amount,omitempty"` | |||
Balance string `json:"balance,omitempty"` | |||
Type string `json:"type,omitempty"` | |||
OtherAccount string `json:"other_account,omitempty"` | |||
TransMemo string `json:"trans_memo,omitempty"` | |||
Direction string `json:"direction,omitempty"` | |||
BillSource string `json:"bill_source,omitempty"` | |||
BizNos string `json:"biz_nos,omitempty"` | |||
BizOrigNo string `json:"biz_orig_no,omitempty"` | |||
BizDesc string `json:"biz_desc,omitempty"` | |||
MerchantOutRefundNo string `json:"merchant_out_refund_no,omitempty"` | |||
ComplementInfo string `json:"complement_info,omitempty"` | |||
StoreName string `json:"store_name,omitempty"` | |||
} | |||
type DataBillDownloadUrlQuery struct { | |||
ErrorResponse | |||
BillDownloadUrl string `json:"bill_download_url,omitempty"` | |||
} | |||
type DataBillEreceiptApply struct { | |||
ErrorResponse | |||
FileId string `json:"file_id"` | |||
} | |||
type DataBillEreceiptQuery struct { | |||
ErrorResponse | |||
Status string `json:"status"` | |||
DownloadUrl string `json:"download_url"` | |||
ErrorMessage string `json:"error_message"` | |||
} |
@@ -1,111 +0,0 @@ | |||
package alipay | |||
type FaceVerificationInitializeRsp struct { | |||
Response *FaceVerificationInitialize `json:"datadigital_fincloud_generalsaas_face_verification_initialize_response"` | |||
AlipayCertSn string `json:"alipay_cert_sn,omitempty"` | |||
SignData string `json:"-"` | |||
Sign string `json:"sign"` | |||
} | |||
type FaceVerificationQueryRsp struct { | |||
Response *FaceVerificationQuery `json:"datadigital_fincloud_generalsaas_face_verification_query_response"` | |||
AlipayCertSn string `json:"alipay_cert_sn,omitempty"` | |||
SignData string `json:"-"` | |||
Sign string `json:"sign"` | |||
} | |||
type FaceCertifyInitializeRsp struct { | |||
Response *FaceCertifyInitialize `json:"datadigital_fincloud_generalsaas_face_certify_initialize_response"` | |||
AlipayCertSn string `json:"alipay_cert_sn,omitempty"` | |||
SignData string `json:"-"` | |||
Sign string `json:"sign"` | |||
} | |||
type FaceCertifyVerifyRsp struct { | |||
Response *FaceCertifyVerify `json:"datadigital_fincloud_generalsaas_face_certify_verify_response"` | |||
AlipayCertSn string `json:"alipay_cert_sn,omitempty"` | |||
SignData string `json:"-"` | |||
Sign string `json:"sign"` | |||
} | |||
type FaceCertifyQueryRsp struct { | |||
Response *FaceCertifyQuery `json:"datadigital_fincloud_generalsaas_face_certify_query_response"` | |||
AlipayCertSn string `json:"alipay_cert_sn,omitempty"` | |||
SignData string `json:"-"` | |||
Sign string `json:"sign"` | |||
} | |||
type FaceSourceCertifyRsp struct { | |||
Response *FaceSourceCertify `json:"datadigital_fincloud_generalsaas_face_source_certify_response"` | |||
AlipayCertSn string `json:"alipay_cert_sn,omitempty"` | |||
SignData string `json:"-"` | |||
Sign string `json:"sign"` | |||
} | |||
type FaceCheckInitializeRsp struct { | |||
Response *FaceCheckInitialize `json:"datadigital_fincloud_generalsaas_face_check_initialize_response"` | |||
AlipayCertSn string `json:"alipay_cert_sn,omitempty"` | |||
SignData string `json:"-"` | |||
Sign string `json:"sign"` | |||
} | |||
type FaceCheckQueryRsp struct { | |||
Response *FaceCheckQuery `json:"datadigital_fincloud_generalsaas_face_check_query_response"` | |||
AlipayCertSn string `json:"alipay_cert_sn,omitempty"` | |||
SignData string `json:"-"` | |||
Sign string `json:"sign"` | |||
} | |||
// =========================================================分割========================================================= | |||
type FaceVerificationInitialize struct { | |||
ErrorResponse | |||
CertifyId string `json:"certify_id"` | |||
WebUrl string `json:"web_url"` | |||
} | |||
type FaceVerificationQuery struct { | |||
ErrorResponse | |||
CertifyState string `json:"certify_state"` | |||
Score string `json:"score"` | |||
Quality string `json:"quality"` | |||
AlivePhoto string `json:"alive_photo"` | |||
AttackFlag string `json:"attack_flag"` | |||
} | |||
type FaceCertifyInitialize struct { | |||
ErrorResponse | |||
CertifyId string `json:"certify_id"` | |||
} | |||
type FaceCertifyVerify struct { | |||
ErrorResponse | |||
CertifyUrl string `json:"certify_url"` | |||
} | |||
type FaceCertifyQuery struct { | |||
ErrorResponse | |||
Passed string `json:"passed"` | |||
} | |||
type FaceSourceCertify struct { | |||
ErrorResponse | |||
CertifyNo string `json:"certify_no"` | |||
Passed string `json:"passed"` | |||
Score string `json:"score"` | |||
Quality string `json:"quality"` | |||
MismatchReason string `json:"mismatch_reason"` | |||
} | |||
type FaceCheckInitialize struct { | |||
ErrorResponse | |||
CertifyId string `json:"certify_id"` | |||
WebUrl string `json:"web_url"` | |||
} | |||
type FaceCheckQuery struct { | |||
ErrorResponse | |||
CertifyState string `json:"certify_state"` | |||
Quality string `json:"quality"` | |||
AlivePhoto string `json:"alive_photo"` | |||
} |
@@ -1,214 +0,0 @@ | |||
package alipay | |||
type KoubeiTradeOrderAggregateConsultRsp struct { | |||
Response *KoubeiTradeOrderAggregateConsult `json:"koubei_trade_order_aggregate_consult_response"` | |||
AlipayCertSn string `json:"alipay_cert_sn,omitempty"` | |||
SignData string `json:"-"` | |||
Sign string `json:"sign"` | |||
} | |||
type KoubeiTradeOrderPrecreateRsp struct { | |||
Response *KoubeiTradeOrderPrecreate `json:"koubei_trade_order_precreate_response"` | |||
AlipayCertSn string `json:"alipay_cert_sn,omitempty"` | |||
SignData string `json:"-"` | |||
Sign string `json:"sign"` | |||
} | |||
type KoubeiTradeItemorderBuyRsp struct { | |||
Response *TradeItemorderBuy `json:"koubei_trade_itemorder_buy_response"` | |||
AlipayCertSn string `json:"alipay_cert_sn,omitempty"` | |||
SignData string `json:"-"` | |||
Sign string `json:"sign"` | |||
} | |||
type KoubeiTradeOrderConsultRsp struct { | |||
Response *KoubeiTradeOrderConsult `json:"koubei_trade_order_consult_response"` | |||
AlipayCertSn string `json:"alipay_cert_sn,omitempty"` | |||
SignData string `json:"-"` | |||
Sign string `json:"sign"` | |||
} | |||
type KoubeiTradeItemorderRefundRsp struct { | |||
Response *KoubeiTradeItemorderRefund `json:"koubei_trade_itemorder_refund_response"` | |||
AlipayCertSn string `json:"alipay_cert_sn,omitempty"` | |||
SignData string `json:"-"` | |||
Sign string `json:"sign"` | |||
} | |||
type KoubeiTradeItemorderQueryRsp struct { | |||
Response *KoubeiTradeItemorderQuery `json:"koubei_trade_itemorder_query_response"` | |||
AlipayCertSn string `json:"alipay_cert_sn,omitempty"` | |||
SignData string `json:"-"` | |||
Sign string `json:"sign"` | |||
} | |||
type KoubeiTradeTicketTicketcodeSendRsp struct { | |||
Response *KoubeiTradeTicketTicketcodeSend `json:"koubei_trade_ticket_ticketcode_send_response"` | |||
AlipayCertSn string `json:"alipay_cert_sn,omitempty"` | |||
SignData string `json:"-"` | |||
Sign string `json:"sign"` | |||
} | |||
type KoubeiTradeTicketTicketcodeDelayRsp struct { | |||
Response *KoubeiTradeTicketTicketcodeDelay `json:"koubei_trade_ticket_ticketcode_delay_response"` | |||
AlipayCertSn string `json:"alipay_cert_sn,omitempty"` | |||
SignData string `json:"-"` | |||
Sign string `json:"sign"` | |||
} | |||
type KoubeiTradeTicketTicketcodeQueryRsp struct { | |||
Response *KoubeiTradeTicketTicketcodeQuery `json:"koubei_trade_ticket_ticketcode_query_response"` | |||
AlipayCertSn string `json:"alipay_cert_sn,omitempty"` | |||
SignData string `json:"-"` | |||
Sign string `json:"sign"` | |||
} | |||
type KoubeiTradeTicketTicketcodeCancelRsp struct { | |||
Response *KoubeiTradeTicketTicketcodeCancel `json:"koubei_trade_ticket_ticketcode_cancel_response"` | |||
AlipayCertSn string `json:"alipay_cert_sn,omitempty"` | |||
SignData string `json:"-"` | |||
Sign string `json:"sign"` | |||
} | |||
// =========================================================分割========================================================= | |||
type KoubeiTradeOrderAggregateConsult struct { | |||
ErrorResponse | |||
OutOrderNo string `json:"out_order_no,omitempty"` | |||
OrderNo string `json:"order_no,omitempty"` | |||
TradeNo string `json:"trade_no,omitempty"` | |||
BuyerId string `json:"buyer_id,omitempty"` | |||
BuyerIdType string `json:"buyer_id_type,omitempty"` | |||
TotalAmount string `json:"total_amount,omitempty"` | |||
ReceiptAmount string `json:"receipt_amount,omitempty"` | |||
BuyerPayAmount string `json:"buyer_pay_amount,omitempty"` | |||
MerchantDiscountAmount string `json:"merchant_discount_amount,omitempty"` | |||
PlatformDiscountAmount string `json:"platform_discount_amount,omitempty"` | |||
DiscountDetailList []*DiscountDetailInfo `json:"discount_detail_list,omitempty"` | |||
OrderStatus string `json:"order_status,omitempty"` | |||
PayChannel string `json:"pay_channel,omitempty"` | |||
CreateTime string `json:"create_time"` | |||
GmtPaymentTime string `json:"gmt_payment_time,omitempty"` | |||
} | |||
type DiscountDetailInfo struct { | |||
Id string `json:"id,omitempty"` | |||
Name string `json:"name,omitempty"` | |||
Type string `json:"type,omitempty"` | |||
Amount string `json:"amount,omitempty"` | |||
} | |||
type KoubeiTradeOrderPrecreate struct { | |||
ErrorResponse | |||
OrderNo string `json:"order_no"` | |||
QrCode string `json:"qr_code,omitempty"` | |||
} | |||
type TradeItemorderBuy struct { | |||
ErrorResponse | |||
OrderNo string `json:"order_no"` | |||
TradeNo string `json:"trade_no"` | |||
CashierOrderId string `json:"cashier_order_id,omitempty"` | |||
} | |||
type KoubeiTradeOrderConsult struct { | |||
ErrorResponse | |||
BuyerPayAmount string `json:"buyer_pay_amount"` | |||
RequestId string `json:"request_id,omitempty"` | |||
MCardDetail *struct { | |||
Name string `json:"name"` | |||
AvailableAmount string `json:"available_amount"` | |||
PayAmount string `json:"pay_amount"` | |||
} `json:"m_card_detail,omitempty"` | |||
DiscountDetail *struct { | |||
Id string `json:"id"` | |||
DiscountDesc []string `json:"discount_desc,omitempty"` | |||
DiscountType string `json:"discount_type"` | |||
IsHit string `json:"is_hit"` | |||
IsPurchased string `json:"is_purchased"` | |||
Name string `json:"name"` | |||
DiscountAmount string `json:"discount_amount,omitempty"` | |||
} `json:"discount_detail,omitempty"` | |||
} | |||
type KoubeiTradeItemorderRefund struct { | |||
ErrorResponse | |||
OrderNo string `json:"order_no"` | |||
OutRequestNo string `json:"out_request_no"` | |||
RealRefundAmount string `json:"real_refund_amount"` | |||
} | |||
type KoubeiTradeItemorderQuery struct { | |||
ErrorResponse | |||
OrderNo string `json:"order_no"` | |||
OutOrderNo string `json:"out_order_no"` | |||
PartnerID string `json:"partner_id"` | |||
TradeNo string `json:"trade_no"` | |||
Status string `json:"status"` | |||
BuyerID string `json:"buyer_id"` | |||
BizProduct string `json:"biz_product"` | |||
GmtCreate string `json:"gmt_create"` | |||
SellerID string `json:"seller_id,omitempty"` | |||
GmtPayment string `json:"gmt_payment,omitempty"` | |||
GmtModified string `json:"gmt_modified"` | |||
TotalAmount string `json:"total_amount"` | |||
RealPayAmount string `json:"real_pay_amount"` | |||
DiscountAmount string `json:"discount_amount,omitempty"` | |||
DeliverSellerRealAmount string `json:"deliver_seller_real_amount"` | |||
ItemOrderVo []*struct { | |||
ItemOrderNo string `json:"item_order_no"` | |||
SkuID string `json:"sku_id"` | |||
Quantity int `json:"quantity"` | |||
Price string `json:"price"` | |||
Status string `json:"status"` | |||
MerchantFund string `json:"merchant_fund,omitempty"` | |||
PlatformFund string `json:"platform_fund,omitempty"` | |||
ExtInfo string `json:"ext_info,omitempty"` | |||
} `json:"item_order_vo"` | |||
} | |||
type KoubeiTradeTicketTicketcodeSend struct { | |||
ErrorResponse | |||
RequestId string `json:"request_id"` | |||
BizCode string `json:"biz_code,omitempty"` | |||
} | |||
type KoubeiTradeTicketTicketcodeDelay struct { | |||
ErrorResponse | |||
RequestId string `json:"request_id"` | |||
BizCode string `json:"biz_code,omitempty"` | |||
} | |||
type KoubeiTradeTicketTicketcodeQuery struct { | |||
ErrorResponse | |||
TicketCode string `json:"ticket_code"` | |||
TicketStatus string `json:"ticket_status"` | |||
TicketStatusDesc string `json:"ticket_status_desc"` | |||
ItemName string `json:"item_name"` | |||
ItemID string `json:"item_id"` | |||
OriginalPrice string `json:"original_price"` | |||
CurrentPrice string `json:"current_price"` | |||
EffectDate string `json:"effect_date"` | |||
ExpireDate string `json:"expire_date"` | |||
VoucherID string `json:"voucher_id"` | |||
OrderNo string `json:"order_no"` | |||
AvailableQuantity string `json:"available_quantity,omitempty"` | |||
TotalQuantity string `json:"total_quantity,omitempty"` | |||
ItemAlias string `json:"item_alias,omitempty"` | |||
TimeCards string `json:"time_cards"` | |||
TicketTransInfoList []*TicketTransInfo `json:"ticket_trans_info_list,omitempty"` | |||
} | |||
type TicketTransInfo struct { | |||
TicketTransID string `json:"ticket_trans_id"` | |||
TicketTransType string `json:"ticket_trans_type"` | |||
CreateTime string `json:"create_time"` | |||
LastModifyTime string `json:"last_modify_time"` | |||
Quantity string `json:"quantity"` | |||
} | |||
type KoubeiTradeTicketTicketcodeCancel struct { | |||
ErrorResponse | |||
RequestId string `json:"request_id"` | |||
BizCode string `json:"biz_code,omitempty"` | |||
} |
@@ -1,368 +0,0 @@ | |||
package alipay | |||
type SystemOauthTokenResponse struct { | |||
Response *OauthTokenInfo `json:"alipay_system_oauth_token_response"` | |||
ErrorResponse *ErrorResponse `json:"error_response,omitempty"` | |||
AlipayCertSn string `json:"alipay_cert_sn,omitempty"` | |||
SignData string `json:"-"` | |||
Sign string `json:"sign"` | |||
} | |||
type UserInfoShareResponse struct { | |||
Response *UserInfoShare `json:"alipay_user_info_share_response"` | |||
ErrorResponse *ErrorResponse `json:"error_response,omitempty"` | |||
AlipayCertSn string `json:"alipay_cert_sn,omitempty"` | |||
SignData string `json:"-"` | |||
Sign string `json:"sign"` | |||
} | |||
type UserCertifyOpenInitResponse struct { | |||
Response *UserCertifyOpenInit `json:"alipay_user_certify_open_initialize_response"` | |||
AlipayCertSn string `json:"alipay_cert_sn,omitempty"` | |||
SignData string `json:"-"` | |||
Sign string `json:"sign"` | |||
} | |||
type UserCertifyOpenQueryResponse struct { | |||
Response *UserCertifyOpenQuery `json:"alipay_user_certify_open_query_response"` | |||
AlipayCertSn string `json:"alipay_cert_sn,omitempty"` | |||
SignData string `json:"-"` | |||
Sign string `json:"sign"` | |||
} | |||
type UserAgreementPageUnSignRsp struct { | |||
Response *ErrorResponse `json:"alipay_user_agreement_unsign_response"` | |||
AlipayCertSn string `json:"alipay_cert_sn,omitempty"` | |||
SignData string `json:"-"` | |||
Sign string `json:"sign"` | |||
} | |||
type UserAgreementQueryRsp struct { | |||
Response *UserAgreementQuery `json:"alipay_user_agreement_query_response"` | |||
AlipayCertSn string `json:"alipay_cert_sn,omitempty"` | |||
SignData string `json:"-"` | |||
Sign string `json:"sign"` | |||
} | |||
type UserAgreementExecutionplanModifyRsp struct { | |||
Response *UserAgreementExecutionplanModify `json:"alipay_user_agreement_executionplan_modify_response"` | |||
AlipayCertSn string `json:"alipay_cert_sn,omitempty"` | |||
SignData string `json:"-"` | |||
Sign string `json:"sign"` | |||
} | |||
type UserAgreementTransferRsp struct { | |||
Response *UserAgreementTransfer `json:"alipay_user_agreement_transfer_response"` | |||
AlipayCertSn string `json:"alipay_cert_sn,omitempty"` | |||
SignData string `json:"-"` | |||
Sign string `json:"sign"` | |||
} | |||
type UserTwostageCommonUseRsp struct { | |||
Response *UserTwostageCommonUse `json:"alipay_user_twostage_common_use_response"` | |||
AlipayCertSn string `json:"alipay_cert_sn,omitempty"` | |||
SignData string `json:"-"` | |||
Sign string `json:"sign"` | |||
} | |||
type UserAuthZhimaorgIdentityApplyRsp struct { | |||
Response *UserAuthZhimaorgIdentityApply `json:"alipay_user_auth_zhimaorg_identity_apply_response"` | |||
AlipayCertSn string `json:"alipay_cert_sn,omitempty"` | |||
SignData string `json:"-"` | |||
Sign string `json:"sign"` | |||
} | |||
type UserCharityRecordexistQueryRsp struct { | |||
Response *UserCharityRecordexistQuery `json:"alipay_user_charity_recordexist_query_response"` | |||
AlipayCertSn string `json:"alipay_cert_sn,omitempty"` | |||
SignData string `json:"-"` | |||
Sign string `json:"sign"` | |||
} | |||
type UserAlipaypointSendRsp struct { | |||
Response *UserAlipaypointSend `json:"alipay_user_alipaypoint_send_response"` | |||
AlipayCertSn string `json:"alipay_cert_sn,omitempty"` | |||
SignData string `json:"-"` | |||
Sign string `json:"sign"` | |||
} | |||
type MemberDataIsvCreateRsp struct { | |||
Response *MemberDataIsvCreate `json:"koubei_member_data_isv_create_response"` | |||
AlipayCertSn string `json:"alipay_cert_sn,omitempty"` | |||
SignData string `json:"-"` | |||
Sign string `json:"sign"` | |||
} | |||
type UserFamilyArchiveQueryRsp struct { | |||
Response *UserFamilyArchiveQuery `json:"alipay_user_family_archive_query_response"` | |||
AlipayCertSn string `json:"alipay_cert_sn,omitempty"` | |||
SignData string `json:"-"` | |||
Sign string `json:"sign"` | |||
} | |||
type UserFamilyArchiveInitializeRsp struct { | |||
Response *UserFamilyArchiveInitialize `json:"alipay_user_family_archive_initialize_response"` | |||
AlipayCertSn string `json:"alipay_cert_sn,omitempty"` | |||
SignData string `json:"-"` | |||
Sign string `json:"sign"` | |||
} | |||
type UserCertdocCertverifyPreconsultRsp struct { | |||
Response *UserCertdocCertverifyPreconsult `json:"alipay_user_certdoc_certverify_preconsult_response"` | |||
AlipayCertSn string `json:"alipay_cert_sn,omitempty"` | |||
SignData string `json:"-"` | |||
Sign string `json:"sign"` | |||
} | |||
type UserCertdocCertverifyConsultRsp struct { | |||
Response *UserCertdocCertverifyConsult `json:"alipay_user_certdoc_certverify_consult_response"` | |||
AlipayCertSn string `json:"alipay_cert_sn,omitempty"` | |||
SignData string `json:"-"` | |||
Sign string `json:"sign"` | |||
} | |||
type UserFamilyShareZmgoInitializeRsp struct { | |||
Response *UserFamilyShareZmgoInitialize `json:"alipay_user_family_share_zmgo_initialize_response"` | |||
AlipayCertSn string `json:"alipay_cert_sn,omitempty"` | |||
SignData string `json:"-"` | |||
Sign string `json:"sign"` | |||
} | |||
type UserDtbankQrcodedataQueryRsp struct { | |||
Response *UserDtbankQrcodedataQuery `json:"alipay_user_dtbank_qrcodedata_query_response"` | |||
AlipayCertSn string `json:"alipay_cert_sn,omitempty"` | |||
SignData string `json:"-"` | |||
Sign string `json:"sign"` | |||
} | |||
type UserAlipaypointBudgetlibQueryRsp struct { | |||
Response *UserAlipaypointBudgetlibQuery `json:"alipay_user_alipaypoint_budgetlib_query_response"` | |||
AlipayCertSn string `json:"alipay_cert_sn,omitempty"` | |||
SignData string `json:"-"` | |||
Sign string `json:"sign"` | |||
} | |||
type UserAuthRelationshipQueryRsp struct { | |||
Response *UserAuthRelationshipQuery `json:"alipay_open_auth_userauth_relationship_query_response"` | |||
AlipayCertSn string `json:"alipay_cert_sn,omitempty"` | |||
SignData string `json:"-"` | |||
Sign string `json:"sign"` | |||
} | |||
type UserDelOAuthDetailQueryRsp struct { | |||
Response *UserDelOAuthDetailQuery `json:"alipay_user_deloauth_detail_query_response"` | |||
AlipayCertSn string `json:"alipay_cert_sn,omitempty"` | |||
SignData string `json:"-"` | |||
Sign string `json:"sign"` | |||
} | |||
// =========================================================分割========================================================= | |||
type OauthTokenInfo struct { | |||
UserId string `json:"user_id,omitempty"` | |||
OpenId string `json:"open_id,omitempty"` | |||
AlipayUserId string `json:"alipay_user_id,omitempty"` | |||
UnionId string `json:"union_id,omitempty"` | |||
AccessToken string `json:"access_token,omitempty"` | |||
ExpiresIn int `json:"expires_in,omitempty"` | |||
RefreshToken string `json:"refresh_token,omitempty"` | |||
ReExpiresIn int `json:"re_expires_in,omitempty"` | |||
AuthStart string `json:"auth_start,omitempty"` | |||
AuthTokenType string `json:"auth_token_type,omitempty"` | |||
} | |||
type UserInfoShare struct { | |||
UserId string `json:"user_id,omitempty"` | |||
OpenId string `json:"open_id,omitempty"` | |||
Avatar string `json:"avatar,omitempty"` | |||
Province string `json:"province,omitempty"` | |||
City string `json:"city,omitempty"` | |||
NickName string `json:"nick_name,omitempty"` | |||
IsStudentCertified string `json:"is_student_certified,omitempty"` | |||
UserType string `json:"user_type,omitempty"` | |||
UserStatus string `json:"user_status,omitempty"` | |||
IsCertified string `json:"is_certified,omitempty"` | |||
Gender string `json:"gender,omitempty"` | |||
Cert_type string `json:"cert_type,omitempty"` | |||
Cert_no string `json:"cert_no,omitempty"` | |||
Mobile string `json:"mobile,omitempty"` | |||
User_name string `json:"user_name,omitempty"` | |||
} | |||
type UserCertifyOpenInit struct { | |||
ErrorResponse | |||
CertifyId string `json:"certify_id,omitempty"` | |||
} | |||
type UserCertifyOpenQuery struct { | |||
ErrorResponse | |||
Passed string `json:"passed,omitempty"` | |||
IdentityInfo string `json:"identity_info,omitempty"` | |||
MaterialInfo string `json:"material_info,omitempty"` | |||
} | |||
type UserAgreementQuery struct { | |||
ErrorResponse | |||
PrincipalId string `json:"principal_id"` | |||
PrincipalOpenId string `json:"principal_open_id,omitempty"` | |||
ValidTime string `json:"valid_time"` | |||
AlipayLogonId string `json:"alipay_logon_id"` | |||
InvalidTime string `json:"invalid_time"` | |||
PricipalType string `json:"pricipal_type"` | |||
DeviceId string `json:"device_id,omitempty"` | |||
SignScene string `json:"sign_scene"` | |||
AgreementNo string `json:"agreement_no"` | |||
ThirdPartyType string `json:"third_party_type"` | |||
Status string `json:"status"` | |||
SignTime string `json:"sign_time"` | |||
PersonalProductCode string `json:"personal_product_code"` | |||
ExternalAgreementNo string `json:"external_agreement_no,omitempty"` | |||
ZmOpenId string `json:"zm_open_id,omitempty"` | |||
ExternalLogonId string `json:"external_logon_id,omitempty"` | |||
CreditAuthMode string `json:"credit_auth_mode,omitempty"` | |||
SingleQuota string `json:"single_quota,omitempty"` | |||
LastDeductTime string `json:"last_deduct_time,omitempty"` | |||
NextDeductTime string `json:"next_deduct_time,omitempty"` | |||
} | |||
type UserAgreementExecutionplanModify struct { | |||
ErrorResponse | |||
AgreementNo string `json:"agreement_no"` | |||
DeductTime string `json:"deduct_time"` | |||
} | |||
type UserAgreementTransfer struct { | |||
ErrorResponse | |||
ExecuteTime string `json:"execute_time,omitempty"` | |||
PeriodType string `json:"period_type,omitempty"` | |||
Amount string `json:"amount,omitempty"` | |||
TotalAmount string `json:"total_amount,omitempty"` | |||
TotalPayments string `json:"total_payments,omitempty"` | |||
Period string `json:"period,omitempty"` | |||
} | |||
type UserTwostageCommonUse struct { | |||
ErrorResponse | |||
UserId string `json:"user_id,omitempty"` | |||
OpenId string `json:"open_id,omitempty"` | |||
UserIdentityInfo []*UserIdentityInfo `json:"user_identity_info,omitempty"` | |||
} | |||
type UserIdentityInfo struct { | |||
HSchoolInfo []*HSchoolInfo `json:"h_school_info,omitempty"` | |||
} | |||
type HSchoolInfo struct { | |||
SchoolStdCode string `json:"school_std_code"` | |||
CampusNo string `json:"campus_no"` | |||
} | |||
type UserAuthZhimaorgIdentityApply struct { | |||
ErrorResponse | |||
AccessToken string `json:"access_token"` | |||
AuthTokenType string `json:"auth_token_type,omitempty"` | |||
RefreshToken string `json:"refresh_token"` | |||
} | |||
type UserCharityRecordexistQuery struct { | |||
ErrorResponse | |||
DonationTag string `json:"donation_tag"` | |||
} | |||
type UserAlipaypointSend struct { | |||
ErrorResponse | |||
RecordId string `json:"record_id"` | |||
} | |||
type MemberDataIsvCreate struct { | |||
ErrorResponse | |||
} | |||
type UserFamilyArchiveQuery struct { | |||
ErrorResponse | |||
ArchiveList []*FamilyArchiveDetail `json:"archive_list"` | |||
} | |||
type FamilyArchiveDetail struct { | |||
ArchiveId string `json:"archive_id"` | |||
RealName string `json:"real_name,omitempty"` | |||
CertNo string `json:"cert_no,omitempty"` | |||
CertType string `json:"cert_type,omitempty"` | |||
Mobile string `json:"mobile,omitempty"` | |||
Email string `json:"email,omitempty"` | |||
Role string `json:"role,omitempty"` | |||
Province string `json:"province,omitempty"` | |||
City string `json:"city,omitempty"` | |||
DesensitizedLogonId string `json:"desensitized_logon_id,omitempty"` | |||
Area string `json:"area,omitempty"` | |||
DesensitizedRealName string `json:"desensitized_real_name,omitempty"` | |||
Address string `json:"address,omitempty"` | |||
Zip string `json:"zip,omitempty"` | |||
Birthday string `json:"birthday,omitempty"` | |||
Gender string `json:"gender,omitempty"` | |||
Profession string `json:"profession,omitempty"` | |||
} | |||
type UserFamilyArchiveInitialize struct { | |||
ErrorResponse | |||
ArchivePluginUrl string `json:"archive_plugin_url"` | |||
} | |||
type UserCertdocCertverifyPreconsult struct { | |||
ErrorResponse | |||
VerifyId string `json:"verify_id"` | |||
} | |||
type UserCertdocCertverifyConsult struct { | |||
ErrorResponse | |||
Passed string `json:"passed"` | |||
FailReason string `json:"fail_reason,omitempty"` | |||
FailParams string `json:"fail_params,omitempty"` | |||
} | |||
type UserFamilyShareZmgoInitialize struct { | |||
ErrorResponse | |||
Shareable bool `json:"shareable"` | |||
HasSharing bool `json:"has_sharing"` | |||
FamilySharingLink string `json:"family_sharing_link"` | |||
} | |||
type UserDtbankQrcodedataQuery struct { | |||
ErrorResponse | |||
DataDate string `json:"data_date,omitempty"` | |||
QrcodeId string `json:"qrcode_id,omitempty"` | |||
QrcodeOutId string `json:"qrcode_out_id,omitempty"` | |||
BindCard string `json:"bind_card,omitempty"` | |||
SendVoucherCnt string `json:"send_voucher_cnt,omitempty"` | |||
SendVoucherAmt string `json:"send_voucher_amt,omitempty"` | |||
WriteOffVoucherCnt string `json:"write_off_voucher_cnt,omitempty"` | |||
WriteOffVoucherAmt string `json:"write_off_voucher_amt,omitempty"` | |||
LeadToFollow string `json:"lead_to_follow,omitempty"` | |||
} | |||
type UserAlipaypointBudgetlibQuery struct { | |||
ErrorResponse | |||
BudgetCode string `json:"budget_code"` | |||
BudgetDesc string `json:"budget_desc"` | |||
Enabled bool `json:"enabled"` | |||
CumulativeAmount int64 `json:"cumulative_amount"` | |||
RemainAmount int64 `json:"remain_amount"` | |||
StartTime string `json:"start_time"` | |||
EndTime string `json:"end_time"` | |||
} | |||
type UserAuthRelationshipQuery struct { | |||
ErrorResponse | |||
QueryDetail string `json:"query_detail"` | |||
} | |||
type UserDelOAuthDetailQuery struct { | |||
ErrorResponse | |||
Details []*DelOAuthDetail `json:"details"` | |||
} | |||
type DelOAuthDetail struct { | |||
DelAuthTime string `json:"del_auth_time"` | |||
UserId string `json:"user_id"` | |||
OpenId string `json:"open_id"` | |||
} |
@@ -1,511 +0,0 @@ | |||
package alipay | |||
type TradeRelationBindResponse struct { | |||
Response *TradeRelationBind `json:"alipay_trade_royalty_relation_bind_response"` | |||
AlipayCertSn string `json:"alipay_cert_sn,omitempty"` | |||
SignData string `json:"-"` | |||
Sign string `json:"sign"` | |||
} | |||
type TradeRelationUnbindResponse struct { | |||
Response *TradeRelationBind `json:"alipay_trade_royalty_relation_unbind_response"` | |||
AlipayCertSn string `json:"alipay_cert_sn,omitempty"` | |||
SignData string `json:"-"` | |||
Sign string `json:"sign"` | |||
} | |||
type TradeRelationBatchQueryResponse struct { | |||
Response *TradeRelationBatchQuery `json:"alipay_trade_order_settle_response"` | |||
AlipayCertSn string `json:"alipay_cert_sn,omitempty"` | |||
SignData string `json:"-"` | |||
Sign string `json:"sign"` | |||
} | |||
type TradeSettleConfirmResponse struct { | |||
Response *TradeOrderSettle `json:"alipay_trade_settle_confirm_response"` | |||
AlipayCertSn string `json:"alipay_cert_sn,omitempty"` | |||
SignData string `json:"-"` | |||
Sign string `json:"sign"` | |||
} | |||
type TradeOrderSettleResponse struct { | |||
Response *TradeOrderSettle `json:"alipay_trade_order_settle_response"` | |||
AlipayCertSn string `json:"alipay_cert_sn,omitempty"` | |||
SignData string `json:"-"` | |||
Sign string `json:"sign"` | |||
} | |||
type TradeOrderSettleQueryResponse struct { | |||
Response *TradeOrderSettleQuery `json:"alipay_trade_order_settle_response"` | |||
AlipayCertSn string `json:"alipay_cert_sn,omitempty"` | |||
SignData string `json:"-"` | |||
Sign string `json:"sign"` | |||
} | |||
type TradeOrderOnSettleQueryResponse struct { | |||
Response *TradeOrderOnSettleQuery `json:"alipay_trade_order_onsettle_query_response"` | |||
AlipayCertSn string `json:"alipay_cert_sn,omitempty"` | |||
SignData string `json:"-"` | |||
Sign string `json:"sign"` | |||
} | |||
type TradeRoyaltyRateQueryResponse struct { | |||
Response *TradeRoyaltyRateQuery `json:"alipay_trade_royalty_rate_query_response"` | |||
AlipayCertSn string `json:"alipay_cert_sn,omitempty"` | |||
SignData string `json:"-"` | |||
Sign string `json:"sign"` | |||
} | |||
type SecurityCustomerRiskSendRsp struct { | |||
Response *SecurityCustomerRiskSend `json:"alipay_security_risk_customerrisk_send_response"` | |||
AlipayCertSn string `json:"alipay_cert_sn,omitempty"` | |||
SignData string `json:"-"` | |||
Sign string `json:"sign"` | |||
} | |||
type PayAppMarketingConsultRsp struct { | |||
Response *PayAppMarketingConsult `json:"alipay_pay_app_marketing_consult_response"` | |||
AlipayCertSn string `json:"alipay_cert_sn,omitempty"` | |||
SignData string `json:"-"` | |||
Sign string `json:"sign"` | |||
} | |||
type MerchantQipanCrowdCreateRsp struct { | |||
Response *MerchantQipanCrowdCreate `json:"alipay_merchant_qipan_crowd_create_response"` | |||
AlipayCertSn string `json:"alipay_cert_sn,omitempty"` | |||
SignData string `json:"-"` | |||
Sign string `json:"sign"` | |||
} | |||
type MerchantQipanCrowdUserAddRsp struct { | |||
Response *MerchantQipanCrowdUserAdd `json:"alipay_merchant_qipan_crowduser_add_response"` | |||
AlipayCertSn string `json:"alipay_cert_sn,omitempty"` | |||
SignData string `json:"-"` | |||
Sign string `json:"sign"` | |||
} | |||
type MerchantQipanCrowdUserDeleteRsp struct { | |||
Response *MerchantQipanCrowdUserDelete `json:"alipay_merchant_qipan_crowduser_delete_response"` | |||
AlipayCertSn string `json:"alipay_cert_sn,omitempty"` | |||
SignData string `json:"-"` | |||
Sign string `json:"sign"` | |||
} | |||
type MarketingQipanTagBaseBatchQueryRsp struct { | |||
Response *MarketingQipanTagBaseBatchQuery `json:"alipay_marketing_qipan_tagbase_batchquery_response"` | |||
AlipayCertSn string `json:"alipay_cert_sn,omitempty"` | |||
SignData string `json:"-"` | |||
Sign string `json:"sign"` | |||
} | |||
type MarketingQipanTagQueryRsp struct { | |||
Response *MarketingQipanTagQuery `json:"alipay_marketing_qipan_tag_query_response"` | |||
AlipayCertSn string `json:"alipay_cert_sn,omitempty"` | |||
SignData string `json:"-"` | |||
Sign string `json:"sign"` | |||
} | |||
type MarketingQipanCrowdOperationCreateRsp struct { | |||
Response *MarketingQipanCrowdOperationCreate `json:"alipay_marketing_qipan_crowdoperation_create_response"` | |||
AlipayCertSn string `json:"alipay_cert_sn,omitempty"` | |||
SignData string `json:"-"` | |||
Sign string `json:"sign"` | |||
} | |||
type MarketingQipanCrowdTagQueryRsp struct { | |||
Response *MarketingQipanCrowdTagQuery `json:"alipay_marketing_qipan_crowdtag_query_response"` | |||
AlipayCertSn string `json:"alipay_cert_sn,omitempty"` | |||
SignData string `json:"-"` | |||
Sign string `json:"sign"` | |||
} | |||
type MarketingQipanCrowdWithTagCreateRsp struct { | |||
Response *MarketingQipanCrowdWithTagCreate `json:"alipay_marketing_qipan_crowdwithtag_create_response"` | |||
AlipayCertSn string `json:"alipay_cert_sn,omitempty"` | |||
SignData string `json:"-"` | |||
Sign string `json:"sign"` | |||
} | |||
type MarketingQipanCrowdWithTagQueryRsp struct { | |||
Response *MarketingQipanCrowdWithTagQuery `json:"alipay_marketing_qipan_crowdwithtag_query_response"` | |||
AlipayCertSn string `json:"alipay_cert_sn,omitempty"` | |||
SignData string `json:"-"` | |||
Sign string `json:"sign"` | |||
} | |||
type MarketingQipanCrowdBatchQueryRsp struct { | |||
Response *MarketingQipanCrowdBatchQuery `json:"alipay_merchant_qipan_crowd_batchquery_response"` | |||
AlipayCertSn string `json:"alipay_cert_sn,omitempty"` | |||
SignData string `json:"-"` | |||
Sign string `json:"sign"` | |||
} | |||
type MarketingQipanCrowdQueryRsp struct { | |||
Response *MarketingQipanCrowdQuery `json:"alipay_merchant_qipan_crowd_query_response"` | |||
AlipayCertSn string `json:"alipay_cert_sn,omitempty"` | |||
SignData string `json:"-"` | |||
Sign string `json:"sign"` | |||
} | |||
type MarketingQipanCrowdModifyRsp struct { | |||
Response *MarketingQipanCrowdModify `json:"alipay_merchant_qipan_crowd_modify_response"` | |||
AlipayCertSn string `json:"alipay_cert_sn,omitempty"` | |||
SignData string `json:"-"` | |||
Sign string `json:"sign"` | |||
} | |||
type MarketingQipanBoardQueryRsp struct { | |||
Response *MarketingQipanBoardQuery `json:"alipay_merchant_qipan_board_query_response"` | |||
AlipayCertSn string `json:"alipay_cert_sn,omitempty"` | |||
SignData string `json:"-"` | |||
Sign string `json:"sign"` | |||
} | |||
type MarketingQipanInsightQueryRsp struct { | |||
Response *MarketingQipanInsightQuery `json:"alipay_merchant_qipan_insight_query_response"` | |||
AlipayCertSn string `json:"alipay_cert_sn,omitempty"` | |||
SignData string `json:"-"` | |||
Sign string `json:"sign"` | |||
} | |||
type MarketingQipanBehaviorQueryRsp struct { | |||
Response *MarketingQipanBehaviorQuery `json:"alipay_merchant_qipan_behavior_query_response"` | |||
AlipayCertSn string `json:"alipay_cert_sn,omitempty"` | |||
SignData string `json:"-"` | |||
Sign string `json:"sign"` | |||
} | |||
type MarketingQipanTrendQueryRsp struct { | |||
Response *MarketingQipanTrendQuery `json:"alipay_merchant_qipan_trend_query_response"` | |||
AlipayCertSn string `json:"alipay_cert_sn,omitempty"` | |||
SignData string `json:"-"` | |||
Sign string `json:"sign"` | |||
} | |||
type MarketingQipanInsightCityQueryRsp struct { | |||
Response *MarketingQipanInsightCityQuery `json:"alipay_merchant_qipan_insightcity_query_response"` | |||
AlipayCertSn string `json:"alipay_cert_sn,omitempty"` | |||
SignData string `json:"-"` | |||
Sign string `json:"sign"` | |||
} | |||
// =========================================================分割========================================================= | |||
type TradeRelationBind struct { | |||
ErrorResponse | |||
ResultCode string `json:"result_code"` | |||
} | |||
type TradeRelationBatchQuery struct { | |||
ErrorResponse | |||
ResultCode string `json:"result_code"` | |||
ReceiverList []*Receiver `json:"receiver_list"` | |||
TotalPageNum int `json:"total_page_num"` | |||
TotalRecordNum int `json:"total_record_num"` | |||
CurrentPageNum int `json:"current_page_num"` | |||
CurrentPageSize int `json:"current_page_size"` | |||
} | |||
type Receiver struct { | |||
Type string `json:"type,omitempty"` | |||
Account string `json:"account,omitempty"` | |||
AccountOpenId string `json:"account_open_id,omitempty"` | |||
Memo string `json:"memo,omitempty"` | |||
LoginName string `json:"login_name,omitempty"` | |||
BindLoginName string `json:"bind_login_name,omitempty"` | |||
} | |||
type TradeOrderSettle struct { | |||
ErrorResponse | |||
TradeNo string `json:"trade_no,omitempty"` | |||
SettleNo string `json:"settle_no,omitempty"` | |||
} | |||
type TradeOrderSettleQuery struct { | |||
ErrorResponse | |||
OutTradeNo string `json:"out_request_no"` | |||
OperationDt string `json:"operation_dt"` | |||
RoyaltyDetailList []*RoyaltyDetail `json:"royalty_detail_list"` | |||
} | |||
type RoyaltyDetail struct { | |||
OperationType string `json:"operation_type"` | |||
ExecuteDt string `json:"execute_dt"` | |||
TransOut string `json:"trans_out"` | |||
TransOutType string `json:"trans_out_type"` | |||
TransOutOpenId string `json:"trans_out_open_id"` | |||
TransIn string `json:"trans_in"` | |||
TransInType string `json:"trans_in_type"` | |||
TransInOpenId string `json:"trans_in_open_id"` | |||
Amount string `json:"amount"` | |||
State string `json:"state"` | |||
DetailId string `json:"detail_id"` | |||
ErrorCode string `json:"error_code"` | |||
ErrorDesc string `json:"error_desc"` | |||
} | |||
type TradeOrderOnSettleQuery struct { | |||
ErrorResponse | |||
UnsettledAmount string `json:"unsettled_amount,omitempty"` | |||
} | |||
type TradeRoyaltyRateQuery struct { | |||
ErrorResponse | |||
UserId string `json:"user_id,omitempty"` | |||
MaxRatio string `json:"max_ratio,omitempty"` | |||
} | |||
type SecurityCustomerRiskSend struct { | |||
ErrorResponse | |||
} | |||
type PayAppMarketingConsult struct { | |||
ErrorResponse | |||
PreConsultId string `json:"pre_consult_id"` | |||
ChannelInfoList []*ChannelInfo `json:"channel_info_list"` | |||
ConfusedCipherList []string `json:"confused_cipher_list"` | |||
BlindSignature string `json:"blind_signature"` | |||
} | |||
type ChannelInfo struct { | |||
ChannelIndex string `json:"channel_index"` | |||
ChannelName string `json:"channel_name"` | |||
ChannelEnable bool `json:"channel_enable"` | |||
ChannelCode string `json:"channel_code"` | |||
ChannelLogo string `json:"channel_logo"` | |||
ChannelOperationInfo string `json:"channel_operation_info"` | |||
OperationList []*Operation `json:"operation_list"` | |||
} | |||
type Operation struct { | |||
SceneCode string `json:"scene_code"` | |||
ViewData *ViewData `json:"view_data"` | |||
} | |||
type ViewData struct { | |||
OperationTip string `json:"operation_tip"` | |||
OperationDesc string `json:"operation_desc"` | |||
PromoType string `json:"promo_type"` | |||
PromoPrice string `json:"promo_price"` | |||
ThresholdAmount string `json:"threshold_amount"` | |||
PayOperationInfo string `json:"pay_operation_info"` | |||
} | |||
type MerchantQipanCrowdCreate struct { | |||
ErrorResponse | |||
CrowdCode string `json:"crowd_code"` | |||
} | |||
type MerchantQipanCrowdUserAdd struct { | |||
ErrorResponse | |||
} | |||
type MerchantQipanCrowdUserDelete struct { | |||
ErrorResponse | |||
} | |||
type MarketingQipanTagBaseBatchQuery struct { | |||
ErrorResponse | |||
OperationTagList []*OperationTagItem `json:"operation_tag_list"` | |||
} | |||
type OperationTagItem struct { | |||
TagCode string `json:"tag_code"` | |||
TagName string `json:"tag_name"` | |||
TagDesc string `json:"tag_desc"` | |||
} | |||
type MarketingQipanTagQuery struct { | |||
ErrorResponse | |||
OperationTag *OperationTag `json:"operation_tag"` | |||
} | |||
type OperationTag struct { | |||
TagCode string `json:"tag_code"` | |||
TagName string `json:"tag_name"` | |||
TagDesc string `json:"tag_desc"` | |||
OperationOptionList []*OperationOptionItem `json:"operation_option_list"` | |||
} | |||
type OperationOptionItem struct { | |||
OptionCode string `json:"option_code"` | |||
OptionName string `json:"option_name"` | |||
OptionDataType string `json:"option_data_type"` | |||
OptionList []*Option `json:"option_list"` | |||
} | |||
type Option struct { | |||
Id int `json:"id"` | |||
Value string `json:"value"` | |||
Text string `json:"text"` | |||
Desc string `json:"desc"` | |||
ParentId string `json:"parent_id"` | |||
ParentValue string `json:"parent_value"` | |||
} | |||
type MarketingQipanCrowdOperationCreate struct { | |||
ErrorResponse | |||
CrowdCode string `json:"crowd_code"` | |||
} | |||
type MarketingQipanCrowdTagQuery struct { | |||
ErrorResponse | |||
SelectTagList []*SelectTag `json:"select_tag_list"` | |||
} | |||
type SelectTag struct { | |||
TagId int `json:"tag_id"` | |||
TagName string `json:"tag_name"` | |||
CategoryTagOptionList []*CategoryTagOption `json:"category_tag_option_list"` | |||
} | |||
type CategoryTagOption struct { | |||
TagOptionCategoryId int `json:"tag_option_category_id"` | |||
TagOptionCategoryName string `json:"tag_option_category_name"` | |||
TagOptionList []*TagOption `json:"tag_option_list"` | |||
} | |||
type TagOption struct { | |||
Text string `json:"text"` | |||
Value string `json:"value"` | |||
Children []*Children `json:"children"` | |||
} | |||
type Children struct { | |||
Text string `json:"text"` | |||
Value string `json:"value"` | |||
} | |||
type MarketingQipanCrowdWithTagCreate struct { | |||
ErrorResponse | |||
CrowdId string `json:"crowd_id"` | |||
} | |||
type MarketingQipanCrowdWithTagQuery struct { | |||
ErrorResponse | |||
CountRange string `json:"count_range"` | |||
} | |||
type MarketingQipanCrowdBatchQuery struct { | |||
ErrorResponse | |||
TotalNumber string `json:"total_number"` | |||
CrowdList []*Crowd `json:"crowd_list"` | |||
} | |||
type Crowd struct { | |||
CrowdCode string `json:"crowd_code"` | |||
CrowdName string `json:"crowd_name"` | |||
CrowdDesc string `json:"crowd_desc"` | |||
ExternalCrowdCode string `json:"external_crowd_code"` | |||
Status string `json:"status"` | |||
Processable bool `json:"processable"` | |||
ApplyChannelList []string `json:"apply_channel_list"` | |||
CrowdSize string `json:"crowd_size"` | |||
Hidden bool `json:"hidden"` | |||
} | |||
type MarketingQipanCrowdQuery struct { | |||
ErrorResponse | |||
CrowdInfo *CrowdInfo `json:"crowd_info"` | |||
} | |||
type CrowdInfo struct { | |||
CrowdCode string `json:"crowd_code"` | |||
CrowdName string `json:"crowd_name"` | |||
CrowdDesc string `json:"crowd_desc"` | |||
ExternalCrowdCode string `json:"external_crowd_code"` | |||
Status string `json:"status"` | |||
Processable bool `json:"processable"` | |||
ApplyChannelList []string `json:"apply_channel_list"` | |||
CrowdSize string `json:"crowd_size"` | |||
Hidden bool `json:"hidden"` | |||
} | |||
type MarketingQipanCrowdModify struct { | |||
ErrorResponse | |||
} | |||
type MarketingQipanBoardQuery struct { | |||
ErrorResponse | |||
IndexList []*Index `json:"index_list"` | |||
} | |||
type Index struct { | |||
IndexKey string `json:"index_key"` | |||
IndexName string `json:"index_name"` | |||
IndexDesc string `json:"index_desc"` | |||
IndexValue string `json:"index_value"` | |||
ReportDate string `json:"report_date"` | |||
} | |||
type MarketingQipanInsightQuery struct { | |||
ErrorResponse | |||
PortraitDataList []*PortraitData `json:"portrait_data_list"` | |||
} | |||
type PortraitData struct { | |||
PortraitKey string `json:"portrait_key"` | |||
PortraitName string `json:"portrait_name"` | |||
PortraitDesc string `json:"portrait_desc"` | |||
Coverage string `json:"coverage"` | |||
ReportDate string `json:"report_date"` | |||
DataList []*DataItem `json:"data_list"` | |||
} | |||
type DataItem struct { | |||
Value string `json:"value"` | |||
Num string `json:"num"` | |||
} | |||
type MarketingQipanBehaviorQuery struct { | |||
ErrorResponse | |||
MultiDataList []*MultiData `json:"multi_data_list"` | |||
} | |||
type MultiData struct { | |||
ObjectType string `json:"object_type"` | |||
ObjectId string `json:"object_id"` | |||
ObjectName string `json:"object_name"` | |||
FeatureKey string `json:"feature_key"` | |||
UserCnt string `json:"user_cnt"` | |||
UserRatio string `json:"user_ratio"` | |||
AvgNum string `json:"avg_num"` | |||
} | |||
type MarketingQipanTrendQuery struct { | |||
ErrorResponse | |||
IndexTrendResults []*IndexTrendResult `json:"index_trend_results"` | |||
} | |||
type IndexTrendResult struct { | |||
IndexKey string `json:"index_key"` | |||
IndexName string `json:"index_name"` | |||
IndexDesc string `json:"index_desc"` | |||
IndexValue string `json:"index_value"` | |||
ReportDate string `json:"report_date"` | |||
StartDate string `json:"start_date"` | |||
EndDate string `json:"end_date"` | |||
} | |||
type MarketingQipanInsightCityQuery struct { | |||
ErrorResponse | |||
PortraitKey string `json:"portrait_key"` | |||
PortraitName string `json:"portrait_name"` | |||
PortraitDesc string `json:"portrait_desc"` | |||
Coverage string `json:"coverage"` | |||
ReportDate string `json:"report_date"` | |||
DataList []*Data `json:"data_list"` | |||
} | |||
type Data struct { | |||
PortraitValue string `json:"portrait_value"` | |||
Num int `json:"num"` | |||
AreaCode string `json:"area_code"` | |||
CityList []*City `json:"city_list"` | |||
} | |||
type City struct { | |||
PortraitValue string `json:"portrait_value"` | |||
AreaCode string `json:"area_code"` | |||
Num int `json:"num"` | |||
} |
@@ -1,41 +0,0 @@ | |||
package alipay | |||
type OcrServerDetectRsp struct { | |||
Response *OcrServerDetect `json:"datadigital_fincloud_generalsaas_ocr_server_detect_response"` | |||
AlipayCertSn string `json:"alipay_cert_sn,omitempty"` | |||
SignData string `json:"-"` | |||
Sign string `json:"sign"` | |||
} | |||
type OcrMobileInitializeRsp struct { | |||
Response *OcrMobileInitialize `json:"datadigital_fincloud_generalsaas_ocr_mobile_initialize_response"` | |||
AlipayCertSn string `json:"alipay_cert_sn,omitempty"` | |||
SignData string `json:"-"` | |||
Sign string `json:"sign"` | |||
} | |||
type OcrCommonDetectRsp struct { | |||
Response *OcrCommonDetect `json:"datadigital_fincloud_generalsaas_ocr_common_detect_response"` | |||
AlipayCertSn string `json:"alipay_cert_sn,omitempty"` | |||
SignData string `json:"-"` | |||
Sign string `json:"sign"` | |||
} | |||
// =========================================================分割========================================================= | |||
type OcrServerDetect struct { | |||
ErrorResponse | |||
OcrData string `json:"ocr_data"` | |||
CertifyId string `json:"certify_id"` | |||
} | |||
type OcrMobileInitialize struct { | |||
ErrorResponse | |||
CertifyId string `json:"certify_id"` | |||
} | |||
type OcrCommonDetect struct { | |||
ErrorResponse | |||
CertifyId string `json:"certify_id"` | |||
OcrData string `json:"ocr_data"` | |||
} |
@@ -1,410 +0,0 @@ | |||
package alipay | |||
type TradePayResponse struct { | |||
Response *TradePay `json:"alipay_trade_pay_response"` | |||
AlipayCertSn string `json:"alipay_cert_sn,omitempty"` | |||
SignData string `json:"-"` | |||
Sign string `json:"sign"` | |||
} | |||
type TradePrecreateResponse struct { | |||
Response *TradePrecreate `json:"alipay_trade_precreate_response"` | |||
NullResponse *ErrorResponse `json:"null_response,omitempty"` | |||
AlipayCertSn string `json:"alipay_cert_sn,omitempty"` | |||
SignData string `json:"-"` | |||
Sign string `json:"sign"` | |||
} | |||
type TradeCreateResponse struct { | |||
Response *TradeCreate `json:"alipay_trade_create_response"` | |||
AlipayCertSn string `json:"alipay_cert_sn,omitempty"` | |||
SignData string `json:"-"` | |||
Sign string `json:"sign"` | |||
} | |||
type TradeOrderPayResponse struct { | |||
Response *TradeOrderPay `json:"alipay_trade_order_pay_response"` | |||
AlipayCertSn string `json:"alipay_cert_sn,omitempty"` | |||
SignData string `json:"-"` | |||
Sign string `json:"sign"` | |||
} | |||
type TradeQueryResponse struct { | |||
Response *TradeQuery `json:"alipay_trade_query_response"` | |||
AlipayCertSn string `json:"alipay_cert_sn,omitempty"` | |||
SignData string `json:"-"` | |||
Sign string `json:"sign"` | |||
} | |||
type TradeCancelResponse struct { | |||
Response *TradeCancel `json:"alipay_trade_cancel_response"` | |||
AlipayCertSn string `json:"alipay_cert_sn,omitempty"` | |||
SignData string `json:"-"` | |||
Sign string `json:"sign"` | |||
} | |||
type TradeCloseResponse struct { | |||
Response *TradeClose `json:"alipay_trade_close_response"` | |||
AlipayCertSn string `json:"alipay_cert_sn,omitempty"` | |||
SignData string `json:"-"` | |||
Sign string `json:"sign"` | |||
} | |||
type TradeRefundResponse struct { | |||
Response *TradeRefund `json:"alipay_trade_refund_response"` | |||
AlipayCertSn string `json:"alipay_cert_sn,omitempty"` | |||
SignData string `json:"-"` | |||
Sign string `json:"sign"` | |||
} | |||
type TradePageRefundResponse struct { | |||
Response *TradePageRefund `json:"alipay_trade_page_refund_response"` | |||
AlipayCertSn string `json:"alipay_cert_sn,omitempty"` | |||
SignData string `json:"-"` | |||
Sign string `json:"sign"` | |||
} | |||
type TradeFastpayRefundQueryResponse struct { | |||
Response *TradeRefundQuery `json:"alipay_trade_fastpay_refund_query_response"` | |||
AlipayCertSn string `json:"alipay_cert_sn,omitempty"` | |||
SignData string `json:"-"` | |||
Sign string `json:"sign"` | |||
} | |||
type TradeOrderInfoSyncRsp struct { | |||
Response *TradeOrderInfoSync `json:"alipay_trade_orderinfo_sync_response"` | |||
AlipayCertSn string `json:"alipay_cert_sn,omitempty"` | |||
SignData string `json:"-"` | |||
Sign string `json:"sign"` | |||
} | |||
type TradeAdvanceConsultRsp struct { | |||
Response *TradeAdvanceConsult `json:"alipay_trade_advance_consult_response"` | |||
AlipayCertSn string `json:"alipay_cert_sn,omitempty"` | |||
SignData string `json:"-"` | |||
Sign string `json:"sign"` | |||
} | |||
type PcreditHuabeiAuthSettleApplyRsp struct { | |||
Response *PcreditHuabeiAuthSettleApply `json:"alipay_pcredit_huabei_auth_settle_apply_response"` | |||
AlipayCertSn string `json:"alipay_cert_sn,omitempty"` | |||
SignData string `json:"-"` | |||
Sign string `json:"sign"` | |||
} | |||
type PaymentTradeOrderCreateRsp struct { | |||
Response *PaymentTradeOrderCreate `json:"mybank_payment_trade_order_create_response"` | |||
AlipayCertSn string `json:"alipay_cert_sn,omitempty"` | |||
SignData string `json:"-"` | |||
Sign string `json:"sign"` | |||
} | |||
type TradeRepaybillQueryRsp struct { | |||
Response *TradeRepaybillQuery `json:"alipay_trade_repaybill_query_response"` | |||
AlipayCertSn string `json:"alipay_cert_sn,omitempty"` | |||
SignData string `json:"-"` | |||
Sign string `json:"sign"` | |||
} | |||
// =========================================================分割========================================================= | |||
type TradePay struct { | |||
ErrorResponse | |||
TradeNo string `json:"trade_no,omitempty"` | |||
OutTradeNo string `json:"out_trade_no,omitempty"` | |||
BuyerLogonId string `json:"buyer_logon_id,omitempty"` | |||
TotalAmount string `json:"total_amount,omitempty"` | |||
ReceiptAmount string `json:"receipt_amount,omitempty"` | |||
BuyerPayAmount string `json:"buyer_pay_amount,omitempty"` | |||
PointAmount string `json:"point_amount,omitempty"` | |||
InvoiceAmount string `json:"invoice_amount,omitempty"` | |||
FundBillList []*TradeFundBill `json:"fund_bill_list"` | |||
StoreName string `json:"store_name,omitempty"` | |||
BuyerUserId string `json:"buyer_user_id,omitempty"` | |||
BuyerOpenId string `json:"buyer_open_id,omitempty"` | |||
DiscountGoodsDetail string `json:"discount_goods_detail,omitempty"` | |||
AsyncPaymentMode string `json:"async_payment_mode,omitempty"` | |||
VoucherDetailList []*VoucherDetail `json:"voucher_detail_list"` | |||
AdvanceAmount string `json:"advance_amount,omitempty"` | |||
AuthTradePayMode string `json:"auth_trade_pay_mode,omitempty"` | |||
MdiscountAmount string `json:"mdiscount_amount,omitempty"` | |||
DiscountAmount string `json:"discount_amount,omitempty"` | |||
CreditPayMode string `json:"credit_pay_mode"` | |||
CreditBizOrderId string `json:"credit_biz_order_id"` | |||
} | |||
type TradeFundBill struct { | |||
FundChannel string `json:"fund_channel,omitempty"` // 同步通知里是 fund_channel | |||
Amount string `json:"amount,omitempty"` | |||
RealAmount string `json:"real_amount,omitempty"` | |||
FundType string `json:"fund_type,omitempty"` | |||
} | |||
type VoucherDetail struct { | |||
Id string `json:"id,omitempty"` | |||
Name string `json:"name,omitempty"` | |||
Type string `json:"type,omitempty"` | |||
Amount string `json:"amount,omitempty"` | |||
MerchantContribute string `json:"merchant_contribute,omitempty"` | |||
OtherContribute string `json:"other_contribute,omitempty"` | |||
Memo string `json:"memo,omitempty"` | |||
TemplateId string `json:"template_id,omitempty"` | |||
PurchaseBuyerContribute string `json:"purchase_buyer_contribute,omitempty"` | |||
PurchaseMerchantContribute string `json:"purchase_merchant_contribute,omitempty"` | |||
PurchaseAntContribute string `json:"purchase_ant_contribute,omitempty"` | |||
} | |||
type TradePrecreate struct { | |||
ErrorResponse | |||
OutTradeNo string `json:"out_trade_no,omitempty"` | |||
QrCode string `json:"qr_code,omitempty"` | |||
} | |||
type TradeCreate struct { | |||
ErrorResponse | |||
TradeNo string `json:"trade_no"` | |||
OutTradeNo string `json:"out_trade_no"` | |||
} | |||
type TradeOrderPay struct { | |||
ErrorResponse | |||
TradeNo string `json:"trade_no"` | |||
OutTradeNo string `json:"out_trade_no"` | |||
FulfillmentAmount string `json:"fulfillment_amount"` | |||
OutRequestNo string `json:"out_request_no"` | |||
TotalAmount string `json:"total_amount"` | |||
GmtPayment string `json:"gmt_payment"` | |||
AsyncPaymentMode string `json:"async_payment_mode"` | |||
} | |||
type TradeQuery struct { | |||
ErrorResponse | |||
TradeNo string `json:"trade_no,omitempty"` | |||
OutTradeNo string `json:"out_trade_no,omitempty"` | |||
BuyerLogonId string `json:"buyer_logon_id,omitempty"` | |||
TradeStatus string `json:"trade_status,omitempty"` | |||
TotalAmount string `json:"total_amount,omitempty"` | |||
TransCurrency string `json:"trans_currency,omitempty"` | |||
SettleCurrency string `json:"settle_currency,omitempty"` | |||
SettleAmount string `json:"settle_amount,omitempty"` | |||
PayCurrency string `json:"pay_currency,omitempty"` | |||
PayAmount string `json:"pay_amount,omitempty"` | |||
SettleTransRate string `json:"settle_trans_rate,omitempty"` | |||
TransPayRate string `json:"trans_pay_rate,omitempty"` | |||
BuyerPayAmount string `json:"buyer_pay_amount,omitempty"` | |||
PointAmount string `json:"point_amount,omitempty"` | |||
InvoiceAmount string `json:"invoice_amount,omitempty"` | |||
SendPayDate string `json:"send_pay_date,omitempty"` | |||
ReceiptAmount string `json:"receipt_amount,omitempty"` | |||
StoreId string `json:"store_id,omitempty"` | |||
TerminalId string `json:"terminal_id,omitempty"` | |||
FundBillList []*TradeFundBill `json:"fund_bill_list"` | |||
StoreName string `json:"store_name,omitempty"` | |||
BuyerUserId string `json:"buyer_user_id,omitempty"` | |||
BuyerOpenId string `json:"buyer_open_id,omitempty"` | |||
DiscountGoodsDetail string `json:"discount_goods_detail,omitempty"` | |||
IndustrySepcDetail string `json:"industry_sepc_detail,omitempty"` | |||
IndustrySepcDetailGov string `json:"industry_sepc_detail_gov,omitempty"` | |||
IndustrySepcDetailAcc string `json:"industry_sepc_detail_acc,omitempty"` | |||
ChargeAmount string `json:"charge_amount,omitempty"` | |||
ChargeFlags string `json:"charge_flags,omitempty"` | |||
SettlementId string `json:"settlement_id,omitempty"` | |||
TradeSettleInfo *TradeSettleInfo `json:"trade_settle_info,omitempty"` | |||
AuthTradePayMode string `json:"auth_trade_pay_mode,omitempty"` | |||
BuyerUserType string `json:"buyer_user_type,omitempty"` | |||
MdiscountAmount string `json:"mdiscount_amount,omitempty"` | |||
DiscountAmount string `json:"discount_amount,omitempty"` | |||
Subject string `json:"subject,omitempty"` | |||
Body string `json:"body,omitempty"` | |||
AlipaySubMerchantId string `json:"alipay_sub_merchant_id,omitempty"` | |||
ExtInfos string `json:"ext_infos,omitempty"` | |||
PassbackParams string `json:"passback_params,omitempty"` | |||
HbFqPayInfo *HbFqPayInfo `json:"hb_fq_pay_info,omitempty"` | |||
CreditPayMode string `json:"credit_pay_mode,omitempty"` | |||
CreditBizOrderId string `json:"credit_biz_order_id,omitempty"` | |||
HybAmount string `json:"hyb_amount,omitempty"` | |||
BkagentRespInfo *BkAgentRespInfo `json:"bkagent_resp_info,omitempty"` | |||
ChargeInfoList []*ChargeInfo `json:"charge_info_list,omitempty"` | |||
BizSettleMode string `json:"biz_settle_mode,omitempty"` | |||
} | |||
type BkAgentRespInfo struct { | |||
BindtrxId string `json:"bindtrx_id,omitempty"` | |||
BindclrissrId string `json:"bindclrissr_id,omitempty"` | |||
BindpyeracctbkId string `json:"bindpyeracctbk_id,omitempty"` | |||
BkpyeruserCode string `json:"bkpyeruser_code,omitempty"` | |||
EstterLocation string `json:"estter_location,omitempty"` | |||
} | |||
type ChargeInfo struct { | |||
ChargeFee string `json:"charge_fee,omitempty"` | |||
OriginalChargeFee string `json:"original_charge_fee,omitempty"` | |||
SwitchFeeRate string `json:"switch_fee_rate,omitempty"` | |||
IsRatingOnTradeReceiver string `json:"is_rating_on_trade_receiver,omitempty"` | |||
IsRatingOnSwitch string `json:"is_rating_on_switch,omitempty"` | |||
ChargeType string `json:"charge_type,omitempty"` | |||
SubFeeDetailList []*SubFee `json:"sub_fee_detail_list,omitempty"` | |||
} | |||
type SubFee struct { | |||
ChargeFee string `json:"charge_fee,omitempty"` | |||
OriginalChargeFee string `json:"original_charge_fee,omitempty"` | |||
SwitchFeeRate string `json:"switch_fee_rate,omitempty"` | |||
} | |||
type TradeSettleInfo struct { | |||
//trade_unsettled_amount|剩余待结算金额 | |||
TradeUnsettledAmount string `json:"trade_unsettled_amount,omitempty"` | |||
TradeSettleDetailList []*TradeSettleDetail `json:"trade_settle_detail_list,omitempty"` | |||
} | |||
type TradeSettleDetail struct { | |||
OperationType string `json:"operation_type,omitempty"` | |||
OperationSerialNo string `json:"operation_serial_no,omitempty"` | |||
OperationDt string `json:"operation_dt,omitempty"` | |||
TransOut string `json:"trans_out,omitempty"` | |||
TransIn string `json:"trans_in,omitempty"` | |||
Amount string `json:"amount,omitempty"` | |||
OriTransOut string `json:"ori_trans_out,omitempty"` | |||
OriTransIn string `json:"ori_trans_in,omitempty"` | |||
} | |||
type HbFqPayInfo struct { | |||
UserInstallNum string `json:"user_install_num,omitempty"` | |||
} | |||
type TradeCancel struct { | |||
ErrorResponse | |||
TradeNo string `json:"trade_no,omitempty"` | |||
OutTradeNo string `json:"out_trade_no,omitempty"` | |||
RetryFlag string `json:"retry_flag,omitempty"` | |||
Action string `json:"action,omitempty"` | |||
GmtRefundPay string `json:"gmt_refund_pay,omitempty"` | |||
RefundSettlementId string `json:"refund_settlement_id,omitempty"` | |||
} | |||
type TradeClose struct { | |||
ErrorResponse | |||
TradeNo string `json:"trade_no,omitempty"` | |||
OutTradeNo string `json:"out_trade_no,omitempty"` | |||
} | |||
type TradeRefund struct { | |||
ErrorResponse | |||
TradeNo string `json:"trade_no,omitempty"` | |||
OutTradeNo string `json:"out_trade_no,omitempty"` | |||
BuyerLogonId string `json:"buyer_logon_id,omitempty"` | |||
FundChange string `json:"fund_change,omitempty"` | |||
RefundFee string `json:"refund_fee,omitempty"` | |||
RefundDetailItemList []*TradeFundBill `json:"refund_detail_item_list,omitempty"` | |||
StoreName string `json:"store_name,omitempty"` | |||
BuyerUserId string `json:"buyer_user_id,omitempty"` | |||
BuyerOpenId string `json:"buyer_open_id,omitempty"` | |||
SendBackFee string `json:"send_back_fee,omitempty"` | |||
OpenId string `json:"open_id,omitempty"` | |||
RefundCurrency string `json:"refund_currency,omitempty"` | |||
GmtRefundPay string `json:"gmt_refund_pay,omitempty"` | |||
RefundPresetPaytoolList []*RefundPresetPaytool `json:"refund_preset_paytool_list,omitempty"` | |||
RefundChargeAmount string `json:"refund_charge_amount,omitempty"` | |||
RefundSettlementId string `json:"refund_settlement_id,omitempty"` | |||
PresentRefundBuyerAmount string `json:"present_refund_buyer_amount,omitempty"` | |||
PresentRefundDiscountAmount string `json:"present_refund_discount_amount,omitempty"` | |||
PresentRefundMdiscountAmount string `json:"present_refund_mdiscount_amount,omitempty"` | |||
HasDepositBack string `json:"has_deposit_back,omitempty"` | |||
RefundHybAmount string `json:"refund_hyb_amount,omitempty"` | |||
} | |||
type RefundPresetPaytool struct { | |||
Amount []string `json:"amount,omitempty"` | |||
AssertTypeCode string `json:"assert_type_code,omitempty"` | |||
} | |||
type TradePageRefund struct { | |||
ErrorResponse | |||
TradeNo string `json:"trade_no,omitempty"` | |||
OutTradeNo string `json:"out_trade_no,omitempty"` | |||
OutRequestNo string `json:"out_request_no,omitempty"` | |||
RefundAmount string `json:"refund_amount,omitempty"` | |||
} | |||
type TradeRefundQuery struct { | |||
ErrorResponse | |||
TradeNo string `json:"trade_no,omitempty"` | |||
OutTradeNo string `json:"out_trade_no,omitempty"` | |||
OutRequestNo string `json:"out_request_no,omitempty"` | |||
RefundReason string `json:"refund_reason,omitempty"` | |||
TotalAmount string `json:"total_amount,omitempty"` | |||
RefundAmount string `json:"refund_amount,omitempty"` | |||
RefundStatus string `json:"refund_status,omitempty"` | |||
RefundRoyaltys []*RefundRoyalty `json:"refund_royaltys,omitempty"` | |||
GmtRefundPay string `json:"gmt_refund_pay,omitempty"` | |||
RefundDetailItemList []*TradeFundBill `json:"refund_detail_item_list,omitempty"` | |||
SendBackFee string `json:"send_back_fee,omitempty"` | |||
DepositBackInfo *DepositBackInfo `json:"deposit_back_info,omitempty"` | |||
} | |||
type RefundRoyalty struct { | |||
RefundAmount string `json:"refund_amount,omitempty"` | |||
RoyaltyType string `json:"royalty_type,omitempty"` | |||
ResultCode string `json:"result_code,omitempty"` | |||
TransOut string `json:"trans_out,omitempty"` | |||
TransOutEmail string `json:"trans_out_email,omitempty"` | |||
TransIn string `json:"trans_in,omitempty"` | |||
TransInEmail string `json:"trans_in_email,omitempty"` | |||
} | |||
type DepositBackInfo struct { | |||
HasDepositBack string `json:"has_deposit_back,omitempty"` | |||
DbackStatus string `json:"dback_status,omitempty"` | |||
DbackAmount string `json:"dback_amount,omitempty"` | |||
BankAckTime string `json:"bank_ack_time,omitempty"` | |||
EstBankReceiptTime string `json:"est_bank_receipt_time,omitempty"` | |||
} | |||
type TradeOrderInfoSync struct { | |||
ErrorResponse | |||
TradeNo string `json:"trade_no"` | |||
OutTradeNo string `json:"out_trade_no"` | |||
BuyerUserId string `json:"buyer_user_id"` | |||
BuyerOpenId string `json:"buyer_open_id,omitempty"` | |||
} | |||
type TradeAdvanceConsult struct { | |||
ErrorResponse | |||
ReferResult bool `json:"refer_result"` | |||
WaitRepaymentOrderInfos []*WaitRepaymentOrderInfo `json:"wait_repayment_order_infos,omitempty"` | |||
WaitRepaymentAmount string `json:"wait_repayment_amount,omitempty"` | |||
WaitRepaymentOrderCount string `json:"wait_repayment_order_count,omitempty"` | |||
RiskLevel string `json:"risk_level,omitempty"` | |||
ResultMessage string `json:"result_message"` | |||
ResultCode string `json:"result_code"` | |||
} | |||
type WaitRepaymentOrderInfo struct { | |||
AdvanceOrderId string `json:"advance_order_id"` | |||
AlipayUserId string `json:"alipay_user_id"` | |||
OrigBizOrderId string `json:"orig_biz_order_id"` | |||
BizProduct string `json:"biz_product"` | |||
WaitRepaymentAmount string `json:"wait_repayment_amount"` | |||
} | |||
type PcreditHuabeiAuthSettleApply struct { | |||
ErrorResponse | |||
OutRequestNo string `json:"out_request_no"` | |||
FailReason string `json:"fail_reason,omitempty"` | |||
} | |||
type PaymentTradeOrderCreate struct { | |||
ErrorResponse | |||
} | |||
type TradeRepaybillQuery struct { | |||
ErrorResponse | |||
BillNo string `json:"bill_no"` | |||
BillAmount string `json:"bill_amount"` | |||
BillOverdueAmount string `json:"bill_overdue_amount"` | |||
BillPaidAmount string `json:"bill_paid_amount"` | |||
BillPaidRevokedAmount string `json:"bill_paid_revoked_amount"` | |||
BillRevokedAmount string `json:"bill_revoked_amount"` | |||
BillStatus string `json:"bill_status"` | |||
} |
@@ -1,41 +0,0 @@ | |||
package alipay | |||
type ZolozAuthenticationSmilepayInitializeRsp struct { | |||
Response *ZolozAuthenticationSmilepayInitialize `json:"zoloz_authentication_smilepay_initialize_response"` | |||
AlipayCertSn string `json:"alipay_cert_sn,omitempty"` | |||
SignData string `json:"-"` | |||
Sign string `json:"sign"` | |||
} | |||
type ZolozAuthenticationCustomerFtokenQueryRsp struct { | |||
Response *ZolozAuthenticationCustomerFtokenQuery `json:"zoloz_authentication_customer_ftoken_query_response"` | |||
AlipayCertSn string `json:"alipay_cert_sn,omitempty"` | |||
SignData string `json:"-"` | |||
Sign string `json:"sign"` | |||
} | |||
// =========================================================分割========================================================= | |||
type ZolozAuthenticationSmilepayInitialize struct { | |||
ErrorResponse | |||
RetCodeSub string `json:"ret_code_sub"` | |||
RetMessageSub string `json:"ret_message_sub"` | |||
ZimId string `json:"zim_id"` | |||
ZimInitClientData string `json:"zim_init_client_data"` | |||
} | |||
type ZolozAuthenticationCustomerFtokenQuery struct { | |||
ErrorResponse | |||
Uid string `json:"uid"` | |||
OpenId string `json:"open_id"` | |||
UidTelPairList []*UidTelPair `json:"uid_tel_pair_list"` | |||
AgeCheckResult string `json:"age_check_result"` | |||
CertNo string `json:"cert_no"` | |||
CertName string `json:"cert_name"` | |||
FaceId string `json:"face_id"` | |||
} | |||
type UidTelPair struct { | |||
UserId string `json:"user_id"` | |||
OpenId string `json:"open_id"` | |||
} |
@@ -1,504 +0,0 @@ | |||
package alipay | |||
type ZhimaCreditScoreGetResponse struct { | |||
Response *ScoreGet `json:"zhima_credit_score_get_response"` | |||
AlipayCertSn string `json:"alipay_cert_sn,omitempty"` | |||
SignData string `json:"-"` | |||
Sign string `json:"sign"` | |||
} | |||
type ZhimaCreditEpSceneRatingInitializeRsp struct { | |||
Response *ZhimaCreditEpSceneRatingInitialize `json:"zhima_credit_ep_scene_rating_initialize_response"` | |||
AlipayCertSn string `json:"alipay_cert_sn,omitempty"` | |||
SignData string `json:"-"` | |||
Sign string `json:"sign"` | |||
} | |||
type ZhimaCreditEpSceneFulfillmentSyncRsp struct { | |||
Response *ZhimaCreditEpSceneFulfillmentSync `json:"zhima_credit_ep_scene_fulfillment_sync_response"` | |||
AlipayCertSn string `json:"alipay_cert_sn,omitempty"` | |||
SignData string `json:"-"` | |||
Sign string `json:"sign"` | |||
} | |||
type ZhimaCreditEpSceneAgreementUseRsp struct { | |||
Response *ZhimaCreditEpSceneAgreementUse `json:"zhima_credit_ep_scene_agreement_use_response"` | |||
AlipayCertSn string `json:"alipay_cert_sn,omitempty"` | |||
SignData string `json:"-"` | |||
Sign string `json:"sign"` | |||
} | |||
type ZhimaCreditEpSceneAgreementCancelRsp struct { | |||
Response *ZhimaCreditEpSceneAgreementCancel `json:"zhima_credit_ep_scene_agreement_cancel_response"` | |||
AlipayCertSn string `json:"alipay_cert_sn,omitempty"` | |||
SignData string `json:"-"` | |||
Sign string `json:"sign"` | |||
} | |||
type ZhimaCreditEpSceneFulfillmentlistSyncRsp struct { | |||
Response *ZhimaCreditEpSceneFulfillmentlistSync `json:"zhima_credit_ep_scene_fulfillmentlist_sync_response"` | |||
AlipayCertSn string `json:"alipay_cert_sn,omitempty"` | |||
SignData string `json:"-"` | |||
Sign string `json:"sign"` | |||
} | |||
type ZhimaCreditPeZmgoCumulationSyncRsp struct { | |||
Response *ZhimaCreditPeZmgoCumulationSync `json:"zhima_credit_pe_zmgo_cumulation_sync_response"` | |||
AlipayCertSn string `json:"alipay_cert_sn,omitempty"` | |||
SignData string `json:"-"` | |||
Sign string `json:"sign"` | |||
} | |||
type ZhimaMerchantZmgoCumulateSyncRsp struct { | |||
Response *ZhimaMerchantZmgoCumulateSync `json:"zhima_merchant_zmgo_cumulate_sync_response"` | |||
AlipayCertSn string `json:"alipay_cert_sn,omitempty"` | |||
SignData string `json:"-"` | |||
Sign string `json:"sign"` | |||
} | |||
type ZhimaMerchantZmgoCumulateQueryRsp struct { | |||
Response *ZhimaMerchantZmgoCumulateQuery `json:"zhima_merchant_zmgo_cumulate_query_response"` | |||
AlipayCertSn string `json:"alipay_cert_sn,omitempty"` | |||
SignData string `json:"-"` | |||
Sign string `json:"sign"` | |||
} | |||
type ZhimaMerchantZmgoTemplateCreateRsp struct { | |||
Response *ZhimaMerchantZmgoTemplateCreate `json:"zhima_merchant_zmgo_template_create_response"` | |||
AlipayCertSn string `json:"alipay_cert_sn,omitempty"` | |||
SignData string `json:"-"` | |||
Sign string `json:"sign"` | |||
} | |||
type ZhimaMerchantZmgoTemplateQueryRsp struct { | |||
Response *ZhimaMerchantZmgoTemplateQuery `json:"zhima_merchant_zmgo_template_query_response"` | |||
AlipayCertSn string `json:"alipay_cert_sn,omitempty"` | |||
SignData string `json:"-"` | |||
Sign string `json:"sign"` | |||
} | |||
type ZhimaCreditPeZmgoBizoptCloseRsp struct { | |||
Response *ZhimaCreditPeZmgoBizoptClose `json:"zhima_credit_pe_zmgo_bizopt_close_response"` | |||
AlipayCertSn string `json:"alipay_cert_sn,omitempty"` | |||
SignData string `json:"-"` | |||
Sign string `json:"sign"` | |||
} | |||
type ZhimaCreditPeZmgoSettleRefundRsp struct { | |||
Response *ZhimaCreditPeZmgoSettleRefund `json:"zhima_credit_pe_zmgo_settle_refund_response"` | |||
AlipayCertSn string `json:"alipay_cert_sn,omitempty"` | |||
SignData string `json:"-"` | |||
Sign string `json:"sign"` | |||
} | |||
type ZhimaCreditPeZmgoPreorderCreateRsp struct { | |||
Response *ZhimaCreditPeZmgoPreorderCreate `json:"zhima_credit_pe_zmgo_preorder_create_response"` | |||
AlipayCertSn string `json:"alipay_cert_sn,omitempty"` | |||
SignData string `json:"-"` | |||
Sign string `json:"sign"` | |||
} | |||
type ZhimaCreditPeZmgoAgreementUnsignRsp struct { | |||
Response *ZhimaCreditPeZmgoAgreementUnsign `json:"zhima_credit_pe_zmgo_agreement_unsign_response"` | |||
AlipayCertSn string `json:"alipay_cert_sn,omitempty"` | |||
SignData string `json:"-"` | |||
Sign string `json:"sign"` | |||
} | |||
type ZhimaCreditPeZmgoAgreementQueryRsp struct { | |||
Response *ZhimaCreditPeZmgoAgreementQuery `json:"zhima_credit_pe_zmgo_agreement_query_response"` | |||
AlipayCertSn string `json:"alipay_cert_sn,omitempty"` | |||
SignData string `json:"-"` | |||
Sign string `json:"sign"` | |||
} | |||
type ZhimaCreditPeZmgoSettleUnfreezeRsp struct { | |||
Response *ZhimaCreditPeZmgoSettleUnfreeze `json:"zhima_credit_pe_zmgo_settle_unfreeze_response"` | |||
AlipayCertSn string `json:"alipay_cert_sn,omitempty"` | |||
SignData string `json:"-"` | |||
Sign string `json:"sign"` | |||
} | |||
type ZhimaCreditPeZmgoPaysignApplyRsp struct { | |||
Response *ZhimaCreditPeZmgoPaysignApply `json:"zhima_credit_pe_zmgo_paysign_apply_response"` | |||
AlipayCertSn string `json:"alipay_cert_sn,omitempty"` | |||
SignData string `json:"-"` | |||
Sign string `json:"sign"` | |||
} | |||
type ZhimaCreditPeZmgoPaysignConfirmRsp struct { | |||
Response *ZhimaCreditPeZmgoPaysignConfirm `json:"zhima_credit_pe_zmgo_paysign_confirm_response"` | |||
AlipayCertSn string `json:"alipay_cert_sn,omitempty"` | |||
SignData string `json:"-"` | |||
Sign string `json:"sign"` | |||
} | |||
type ZhimaCustomerJobworthAdapterQueryRsp struct { | |||
Response *ZhimaCustomerJobworthAdapterQuery `json:"zhima_customer_jobworth_adapter_query_response"` | |||
AlipayCertSn string `json:"alipay_cert_sn,omitempty"` | |||
SignData string `json:"-"` | |||
Sign string `json:"sign"` | |||
} | |||
type ZhimaCustomerJobworthSceneUseRsp struct { | |||
Response *ZhimaCustomerJobworthSceneUse `json:"zhima_customer_jobworth_scene_use_response"` | |||
AlipayCertSn string `json:"alipay_cert_sn,omitempty"` | |||
SignData string `json:"-"` | |||
Sign string `json:"sign"` | |||
} | |||
type ZhimaCustomerJobworthAuthQueryRsp struct { | |||
Response *ZhimaCustomerJobworthAuthQuery `json:"zhima_customer_jobworth_authentication_query_response"` | |||
AlipayCertSn string `json:"alipay_cert_sn,omitempty"` | |||
SignData string `json:"-"` | |||
Sign string `json:"sign"` | |||
} | |||
type ZhimaCustomerJobworthAuthPreConsultRsp struct { | |||
Response *ZhimaCustomerJobworthAuthPreConsult `json:"zhima_customer_jobworth_authentication_preconsult_response"` | |||
AlipayCertSn string `json:"alipay_cert_sn,omitempty"` | |||
SignData string `json:"-"` | |||
Sign string `json:"sign"` | |||
} | |||
type ZhimaCreditPeZmgoSettleApplyRsp struct { | |||
Response *ZhimaCreditPeZmgoSettleApply `json:"zhima_credit_pe_zmgo_settle_apply_response"` | |||
AlipayCertSn string `json:"alipay_cert_sn,omitempty"` | |||
SignData string `json:"-"` | |||
Sign string `json:"sign"` | |||
} | |||
type ZhimaCreditPayAfterUseAgreementQueryRsp struct { | |||
Response *ZhimaCreditPayAfterUseAgreementQuery `json:"zhima_credit_payafteruse_creditagreement_query_response"` | |||
AlipayCertSn string `json:"alipay_cert_sn,omitempty"` | |||
SignData string `json:"-"` | |||
Sign string `json:"sign"` | |||
} | |||
type ZhimaCreditPayAfterUseCreditBizOrderRsp struct { | |||
Response *ZhimaCreditPayAfterUseCreditBizOrder `json:"zhima_credit_payafteruse_creditbizorder_order_response"` | |||
AlipayCertSn string `json:"alipay_cert_sn,omitempty"` | |||
SignData string `json:"-"` | |||
Sign string `json:"sign"` | |||
} | |||
type ZhimaCreditPayAfterUseCreditBizOrderQueryRsp struct { | |||
Response *ZhimaCreditPayAfterUseCreditBizOrderQuery `json:"zhima_credit_payafteruse_creditbizorder_query_response"` | |||
AlipayCertSn string `json:"alipay_cert_sn,omitempty"` | |||
SignData string `json:"-"` | |||
Sign string `json:"sign"` | |||
} | |||
type ZhimaCreditPayAfterUseCreditBizOrderFinishRsp struct { | |||
Response *ZhimaCreditPayAfterUseCreditBizOrderFinish `json:"zhima_credit_payafteruse_creditbizorder_finish_response"` | |||
AlipayCertSn string `json:"alipay_cert_sn,omitempty"` | |||
SignData string `json:"-"` | |||
Sign string `json:"sign"` | |||
} | |||
// =========================================================分割========================================================= | |||
type ScoreGet struct { | |||
ErrorResponse | |||
BizNo string `json:"biz_no,omitempty"` | |||
ZmScore string `json:"zm_score,omitempty"` | |||
} | |||
type ZhimaCreditEpSceneRatingInitialize struct { | |||
ErrorResponse | |||
OrderNo string `json:"order_no"` | |||
} | |||
type ZhimaCreditEpSceneFulfillmentSync struct { | |||
ErrorResponse | |||
FulfillmentOrderNo string `json:"fulfillment_order_no"` | |||
} | |||
type ZhimaCreditEpSceneAgreementUse struct { | |||
ErrorResponse | |||
CreditOrderNo string `json:"credit_order_no"` | |||
} | |||
type ZhimaCreditEpSceneAgreementCancel struct { | |||
ErrorResponse | |||
CreditOrderNo string `json:"credit_order_no"` | |||
} | |||
type ZhimaCreditEpSceneFulfillmentlistSync struct { | |||
ErrorResponse | |||
FulfillmentResultList []*FulfillmentResult `json:"fulfillment_result_list"` | |||
} | |||
type FulfillmentResult struct { | |||
FulfillmentOrderNo string `json:"fulfillment_order_no"` | |||
OutOrderNo string `json:"out_order_no"` | |||
} | |||
type ZhimaCreditPeZmgoCumulationSync struct { | |||
ErrorResponse | |||
OutBizNo string `json:"out_biz_no,omitempty"` | |||
AagreementNo string `json:"aagreement_no,omitempty"` | |||
UserId string `json:"user_id,omitempty"` | |||
OpenId string `json:"open_id,omitempty"` | |||
FailReason string `json:"fail_reason,omitempty"` | |||
} | |||
type ZhimaMerchantZmgoCumulateSync struct { | |||
ErrorResponse | |||
AgreementId string `json:"agreement_id"` | |||
OutBizNo string `json:"out_biz_no"` | |||
FailReason string `json:"fail_reason,omitempty"` | |||
} | |||
type ZhimaMerchantZmgoCumulateQuery struct { | |||
ErrorResponse | |||
AgreementId string `json:"agreement_id"` | |||
AggrAmount string `json:"aggr_amount"` | |||
AggrTimes int64 `json:"aggr_times"` | |||
AggrDiscountAmount string `json:"aggr_discount_amount"` | |||
PageNo int64 `json:"page_no"` | |||
PageSize int64 `json:"page_size"` | |||
DetailList []*CumulateDataDetail `json:"detail_list,omitempty"` | |||
FailReason string `json:"fail_reason,omitempty"` | |||
} | |||
type CumulateDataDetail struct { | |||
OutBizNo string `json:"out_biz_no,omitempty"` | |||
ReferOutBizNo string `json:"refer_out_biz_no,omitempty"` | |||
BizTime string `json:"biz_time,omitempty"` | |||
ActionType string `json:"action_type,omitempty"` | |||
DataType string `json:"data_type,omitempty"` | |||
SubDataType string `json:"sub_data_type,omitempty"` | |||
TaskDesc string `json:"task_desc,omitempty"` | |||
TaskAmount string `json:"task_amount,omitempty"` | |||
TaskTimes int64 `json:"task_times,omitempty"` | |||
DiscountDesc string `json:"discount_desc,omitempty"` | |||
DiscountAmount string `json:"discount_amount,omitempty"` | |||
} | |||
type ZhimaMerchantZmgoTemplateCreate struct { | |||
ErrorResponse | |||
TemplateNo string `json:"template_no"` | |||
} | |||
type ZhimaMerchantZmgoTemplateQuery struct { | |||
ErrorResponse | |||
BasicConfig *BasicConfig `json:"basic_config"` | |||
ObligationConfig *ObligationConfig `json:"obligation_config"` | |||
RightConfig *RightConfig `json:"right_config"` | |||
OpenConfig *OpenConfig `json:"open_config"` | |||
SettlementConfig *SettlementConfig `json:"settlement_config"` | |||
QuitConfig *QuitConfig `json:"quit_config"` | |||
ExtConfig *ExtConfig `json:"ext_config"` | |||
} | |||
type BasicConfig struct { | |||
TemplateName string `json:"template_name"` | |||
PartnerId string `json:"partner_id"` | |||
IsvPid string `json:"isv_pid"` | |||
BizType string `json:"biz_type"` | |||
OutBizNo string `json:"out_biz_no"` | |||
MerchantCustomLogo string `json:"merchant_custom_logo"` | |||
Contact string `json:"contact"` | |||
TemplateNo string `json:"template_no"` | |||
} | |||
type ObligationConfig struct { | |||
ObligationTemplate string `json:"obligation_template"` | |||
ObligationTimes string `json:"obligation_times"` | |||
ObligationAmount int `json:"obligation_amount"` | |||
PromiseTypeDesc string `json:"promise_type_desc"` | |||
BenefitUrl string `json:"benefit_url"` | |||
TaskProgressRedirectSchema string `json:"task_progress_redirect_schema"` | |||
} | |||
type RightConfig struct { | |||
CustomBenefitDesc string `json:"custom_benefit_desc"` | |||
CustomSubBenefitDesc string `json:"custom_sub_benefit_desc"` | |||
CumulativePreferentialRedirectSchema string `json:"cumulative_preferential_redirect_schema"` | |||
} | |||
type OpenConfig struct { | |||
FreezeAmount string `json:"freeze_amount"` | |||
PeriodMode string `json:"period_mode"` | |||
PeriodTime string `json:"period_time"` | |||
AppointDate string `json:"appoint_date"` | |||
MinSignInterval string `json:"min_sign_interval"` | |||
SupportExpireDeferral bool `json:"support_expire_deferral"` | |||
CustomOpenTipList string `json:"custom_open_tip_list"` | |||
CardColorScheme string `json:"card_color_scheme"` | |||
CustomOpenTips string `json:"custom_open_tips"` | |||
ShowSignSuccessPage bool `json:"show_sign_success_page"` | |||
SignSuccessTaskButtonDesc string `json:"sign_success_task_button_desc"` | |||
SignAgainSchema string `json:"sign_again_schema"` | |||
ApplyButtonDesc string `json:"apply_button_desc"` | |||
} | |||
type SettlementConfig struct { | |||
SettlementType string `json:"settlement_type"` | |||
CustomFeeName string `json:"custom_fee_name"` | |||
CycleFlexWithholdConfig *CycleFlexWithholdConfig `json:"cycle_flex_withhold_config"` | |||
FulfilltimesCustomSettlementPlan string `json:"fulfilltimes_custom_settlement_plan"` | |||
ExpStopTimeMode string `json:"exp_stop_time_mode"` | |||
ExpStopTime string `json:"exp_stop_time"` | |||
ExpStopDelayDays int `json:"exp_stop_delay_days"` | |||
CycleWithholdConfig *CycleWithholdConfig `json:"cycle_withhold_config"` | |||
} | |||
type CycleFlexWithholdConfig struct { | |||
CycleFlexWithholdTotalPeriodCount int `json:"cycle_flex_withhold_total_period_count"` | |||
CycleFlexWithholdMaxPrice int `json:"cycle_flex_withhold_max_price"` | |||
CycleFlexWithholdFeeName string `json:"cycle_flex_withhold_fee_name"` | |||
} | |||
type CycleWithholdConfig struct { | |||
WithholdMode string `json:"withhold_mode"` | |||
PeriodType string `json:"period_type"` | |||
Period string `json:"period"` | |||
SupportCycleWithholdHighMode bool `json:"support_cycle_withhold_high_mode"` | |||
DeductPlan []string `json:"deduct_plan"` | |||
SupportExemptionPeriod bool `json:"support_exemption_period"` | |||
ExemptionPeriod string `json:"exemption_period"` | |||
} | |||
type QuitConfig struct { | |||
QuitType string `json:"quit_type"` | |||
QuitJumpUrl string `json:"quit_jump_url"` | |||
QuitDesc string `json:"quit_desc"` | |||
} | |||
type ExtConfig struct { | |||
TextContentFillRuleId string `json:"text_content_fill_rule_id"` | |||
TextContentFillVariable string `json:"text_content_fill_variable"` | |||
} | |||
type ZhimaCreditPeZmgoBizoptClose struct { | |||
ErrorResponse | |||
UserId string `json:"user_id"` | |||
OpenId string `json:"open_id,omitempty"` | |||
BizOptNo string `json:"biz_opt_no,omitempty"` | |||
PartnerId string `json:"partner_id"` | |||
OutRequestNo string `json:"out_request_no"` | |||
} | |||
type ZhimaCreditPeZmgoSettleRefund struct { | |||
ErrorResponse | |||
OutRequestNo string `json:"out_request_no"` | |||
WithholdPlanNo string `json:"withhold_plan_no"` | |||
RefundAmount string `json:"refund_amount"` | |||
FailReason string `json:"fail_reason,omitempty"` | |||
Retry bool `json:"retry,omitempty"` | |||
} | |||
type ZhimaCreditPeZmgoPreorderCreate struct { | |||
ErrorResponse | |||
PreorderNo string `json:"preorder_no"` | |||
PartnerId string `json:"partner_id"` | |||
BizType string `json:"biz_type"` | |||
} | |||
type ZhimaCreditPeZmgoAgreementUnsign struct { | |||
ErrorResponse | |||
AgreementId string `json:"agreement_id"` | |||
WithholdPlanNo string `json:"withhold_plan_no"` | |||
} | |||
type ZhimaCreditPeZmgoAgreementQuery struct { | |||
ErrorResponse | |||
AgreementId string `json:"agreement_id"` | |||
AgreementName string `json:"agreement_name"` | |||
AlipayUserId string `json:"alipay_user_id"` | |||
OpenId string `json:"open_id,omitempty"` | |||
AgreementStatus string `json:"agreement_status"` | |||
} | |||
type ZhimaCreditPeZmgoSettleUnfreeze struct { | |||
ErrorResponse | |||
UnfreezeStatus string `json:"unfreeze_status"` | |||
FailReaseon string `json:"fail_reaseon,omitempty"` | |||
Retry string `json:"retry,omitempty"` | |||
UnfreezeAmount string `json:"unfreeze_amount,omitempty"` | |||
} | |||
type ZhimaCreditPeZmgoPaysignApply struct { | |||
ErrorResponse | |||
BizType string `json:"biz_type"` | |||
ZmgoOptNo string `json:"zmgo_opt_no,omitempty"` | |||
Idempotent bool `json:"idempotent,omitempty"` | |||
AgreementId string `json:"agreement_id,omitempty"` | |||
} | |||
type ZhimaCreditPeZmgoPaysignConfirm struct { | |||
ErrorResponse | |||
AgreementId string `json:"agreement_id,omitempty"` | |||
} | |||
type ZhimaCustomerJobworthAdapterQuery struct { | |||
ErrorResponse | |||
AdapterScore string `json:"adapter_score,omitempty"` | |||
Url string `json:"url,omitempty"` | |||
} | |||
type ZhimaCustomerJobworthSceneUse struct { | |||
ErrorResponse | |||
} | |||
type ZhimaCustomerJobworthAuthQuery struct { | |||
ErrorResponse | |||
IdentityResult string `json:"identity_result"` | |||
IdentityResultSkipUrl string `json:"identity_result_skip_url"` | |||
TokenStatus string `json:"token_status"` | |||
UserId string `json:"user_id"` | |||
OpenId string `json:"open_id"` | |||
} | |||
type ZhimaCustomerJobworthAuthPreConsult struct { | |||
ErrorResponse | |||
PreCheckSuccess bool `json:"pre_check_success"` | |||
Reason string `json:"reason"` | |||
} | |||
type ZhimaCreditPeZmgoSettleApply struct { | |||
ErrorResponse | |||
OutRequestNo string `json:"out_request_no"` | |||
AgreementId string `json:"agreement_id"` | |||
WithholdPlanNo string `json:"withhold_plan_no"` | |||
SettleStatus string `json:"settle_status"` | |||
FailReason string `json:"fail_reason"` | |||
} | |||
type ZhimaCreditPayAfterUseAgreementQuery struct { | |||
ErrorResponse | |||
OutAgreementNo string `json:"out_agreement_no"` | |||
AgreementStatus string `json:"agreement_status"` | |||
CreditAgreementId string `json:"credit_agreement_id"` | |||
BizTime string `json:"biz_time"` | |||
ExtInfo string `json:"ext_info"` | |||
AlipayUserId string `json:"alipay_user_id"` | |||
OpenId string `json:"open_id"` | |||
} | |||
type ZhimaCreditPayAfterUseCreditBizOrder struct { | |||
ErrorResponse | |||
OutOrderNo string `json:"out_order_no"` | |||
CreditBizOrderId string `json:"credit_biz_order_id"` | |||
} | |||
type ZhimaCreditPayAfterUseCreditBizOrderQuery struct { | |||
ErrorResponse | |||
CreditBizOrderId string `json:"credit_biz_order_id"` | |||
CreditAgreementId string `json:"credit_agreement_id"` | |||
TotalAmount string `json:"total_amount"` | |||
CreateTime string `json:"create_time"` | |||
ZmServiceId string `json:"zm_service_id"` | |||
ProductCode string `json:"product_code"` | |||
OrderStatus string `json:"order_status"` | |||
TradeNo string `json:"trade_no"` | |||
} | |||
type ZhimaCreditPayAfterUseCreditBizOrderFinish struct { | |||
ErrorResponse | |||
OutRequestNo string `json:"out_request_no"` | |||
CreditBizOrderId string `json:"credit_biz_order_id"` | |||
OrderStatus string `json:"order_status"` | |||
} |
@@ -1,111 +0,0 @@ | |||
package alipay | |||
import ( | |||
"encoding/json" | |||
"fmt" | |||
"net/http" | |||
"net/url" | |||
"github.com/go-pay/gopay" | |||
) | |||
// 解析支付宝支付异步通知的参数到BodyMap | |||
// req:*http.Request | |||
// 返回参数bm:Notify请求的参数 | |||
// 返回参数err:错误信息 | |||
// 文档:https://opendocs.alipay.com/open/203/105286 | |||
func ParseNotifyToBodyMap(req *http.Request) (bm gopay.BodyMap, err error) { | |||
if err = req.ParseForm(); err != nil { | |||
return nil, err | |||
} | |||
var form map[string][]string = req.Form | |||
bm = make(gopay.BodyMap, len(form)+1) | |||
for k, v := range form { | |||
if len(v) == 1 { | |||
bm.Set(k, v[0]) | |||
} | |||
} | |||
return | |||
} | |||
// 通过 url.Values 解析支付宝支付异步通知的参数到BodyMap | |||
// value:url.Values | |||
// 返回参数notifyReq:Notify请求的参数 | |||
// 返回参数err:错误信息 | |||
// 文档:https://opendocs.alipay.com/open/203/105286 | |||
func ParseNotifyByURLValues(value url.Values) (bm gopay.BodyMap, err error) { | |||
bm = make(gopay.BodyMap, len(value)+1) | |||
for k, v := range value { | |||
if len(v) == 1 { | |||
bm.Set(k, v[0]) | |||
} | |||
} | |||
return | |||
} | |||
// Deprecated | |||
// 推荐使用 ParseNotifyToBodyMap(),以防阿里云通知参数变动,NotifyRequest 无法解析。 | |||
// 解析支付宝支付异步通知的参数到Struct | |||
// req:*http.Request | |||
// 返回参数notifyReq:Notify请求的参数 | |||
// 返回参数err:错误信息 | |||
// 文档:https://opendocs.alipay.com/open/203/105286 | |||
func ParseNotifyResult(req *http.Request) (notifyReq *NotifyRequest, err error) { | |||
notifyReq = new(NotifyRequest) | |||
if err = req.ParseForm(); err != nil { | |||
return | |||
} | |||
notifyReq.NotifyTime = req.Form.Get("notify_time") | |||
notifyReq.NotifyType = req.Form.Get("notify_type") | |||
notifyReq.NotifyId = req.Form.Get("notify_id") | |||
notifyReq.AppId = req.Form.Get("app_id") | |||
notifyReq.Charset = req.Form.Get("charset") | |||
notifyReq.Version = req.Form.Get("version") | |||
notifyReq.SignType = req.Form.Get("sign_type") | |||
notifyReq.Sign = req.Form.Get("sign") | |||
notifyReq.AuthAppId = req.Form.Get("auth_app_id") | |||
notifyReq.TradeNo = req.Form.Get("trade_no") | |||
notifyReq.OutTradeNo = req.Form.Get("out_trade_no") | |||
notifyReq.OutBizNo = req.Form.Get("out_biz_no") | |||
notifyReq.BuyerId = req.Form.Get("buyer_id") | |||
notifyReq.BuyerLogonId = req.Form.Get("buyer_logon_id") | |||
notifyReq.SellerId = req.Form.Get("seller_id") | |||
notifyReq.SellerEmail = req.Form.Get("seller_email") | |||
notifyReq.TradeStatus = req.Form.Get("trade_status") | |||
notifyReq.TotalAmount = req.Form.Get("total_amount") | |||
notifyReq.ReceiptAmount = req.Form.Get("receipt_amount") | |||
notifyReq.InvoiceAmount = req.Form.Get("invoice_amount") | |||
notifyReq.BuyerPayAmount = req.Form.Get("buyer_pay_amount") | |||
notifyReq.PointAmount = req.Form.Get("point_amount") | |||
notifyReq.RefundFee = req.Form.Get("refund_fee") | |||
notifyReq.Subject = req.Form.Get("subject") | |||
notifyReq.Body = req.Form.Get("body") | |||
notifyReq.GmtCreate = req.Form.Get("gmt_create") | |||
notifyReq.GmtPayment = req.Form.Get("gmt_payment") | |||
notifyReq.GmtRefund = req.Form.Get("gmt_refund") | |||
notifyReq.GmtClose = req.Form.Get("gmt_close") | |||
notifyReq.PassbackParams = req.Form.Get("passback_params") | |||
billList := req.Form.Get("fund_bill_list") | |||
if billList != gopay.NULL { | |||
bills := make([]*FundBillListInfo, 0) | |||
if err = json.Unmarshal([]byte(billList), &bills); err != nil { | |||
return nil, fmt.Errorf(`"fund_bill_list" json.Unmarshal(%s):%w`, billList, err) | |||
} | |||
notifyReq.FundBillList = bills | |||
} else { | |||
notifyReq.FundBillList = nil | |||
} | |||
detailList := req.Form.Get("voucher_detail_list") | |||
if detailList != gopay.NULL { | |||
details := make([]*NotifyVoucherDetail, 0) | |||
if err = json.Unmarshal([]byte(detailList), &details); err != nil { | |||
return nil, fmt.Errorf(`"voucher_detail_list" json.Unmarshal(%s):%w`, detailList, err) | |||
} | |||
notifyReq.VoucherDetailList = details | |||
} else { | |||
notifyReq.VoucherDetailList = nil | |||
} | |||
return | |||
} |
@@ -1,78 +0,0 @@ | |||
package alipay | |||
import ( | |||
"context" | |||
"encoding/json" | |||
"fmt" | |||
"github.com/go-pay/gopay" | |||
) | |||
// datadigital.fincloud.generalsaas.ocr.server.detect(服务端OCR) | |||
// 文档地址:https://opendocs.alipay.com/open/05ut8h | |||
func (a *Client) OcrServerDetect(ctx context.Context, bm gopay.BodyMap) (aliRsp *OcrServerDetectRsp, err error) { | |||
err = bm.CheckEmptyError("ocr_type", "outer_order_no") | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "datadigital.fincloud.generalsaas.ocr.server.detect"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(OcrServerDetectRsp) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// datadigital.fincloud.generalsaas.ocr.mobile.initialize(App端OCR初始化) | |||
// 文档地址:https://opendocs.alipay.com/open/043ksf | |||
func (a *Client) OcrMobileInitialize(ctx context.Context, bm gopay.BodyMap) (aliRsp *OcrMobileInitializeRsp, err error) { | |||
err = bm.CheckEmptyError("outer_order_no", "biz_code") | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "datadigital.fincloud.generalsaas.ocr.mobile.initialize"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(OcrMobileInitializeRsp) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// datadigital.fincloud.generalsaas.ocr.common.detect(文字识别OCR) | |||
// 文档地址:https://opendocs.alipay.com/open/0776c2cb_datadigital.fincloud.generalsaas.ocr.common.detect | |||
func (a *Client) OcrCommonDetect(ctx context.Context, bm gopay.BodyMap) (aliRsp *OcrCommonDetectRsp, err error) { | |||
err = bm.CheckEmptyError("ocr_type", "outer_order_no", "file_content") | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "datadigital.fincloud.generalsaas.ocr.common.detect"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(OcrCommonDetectRsp) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} |
@@ -1,154 +0,0 @@ | |||
package alipay | |||
import ( | |||
"fmt" | |||
"log" | |||
"time" | |||
"github.com/go-pay/gopay" | |||
) | |||
// AppId string `json:"app_id"` //支付宝分配给开发者的应用ID | |||
// Method string `json:"method"` //接口名称 | |||
// Format string `json:"format"` //仅支持 JSON | |||
// ReturnUrl string `json:"return_url"` //HTTP/HTTPS开头字符串 | |||
// Charset string `json:"charset"` //请求使用的编码格式,如utf-8,gbk,gb2312等,推荐使用 utf-8 | |||
// SignType string `json:"sign_type"` //商户生成签名字符串所使用的签名算法类型,目前支持RSA2和RSA,推荐使用 RSA2 | |||
// Sign string `json:"sign"` //商户请求参数的签名串 | |||
// Timestamp string `json:"timestamp"` //发送请求的时间,格式"yyyy-MM-dd HH:mm:ss" | |||
// Version string `json:"version"` //调用的接口版本,固定为:1.0 | |||
// NotifyUrl string `json:"notify_url"` //支付宝服务器主动通知商户服务器里指定的页面http/https路径。 | |||
// BizContent string `json:"biz_content"` //业务请求参数的集合,最大长度不限,除公共参数外所有请求参数都必须放在这个参数中传递,具体参照各产品快速接入文档 | |||
type RoyaltyDetailInfoPojo struct { | |||
RoyaltyType string `json:"royalty_type,omitempty"` | |||
TransOut string `json:"trans_out,omitempty"` | |||
TransOutType string `json:"trans_out_type,omitempty"` | |||
TransInType string `json:"trans_in_type,omitempty"` | |||
TransIn string `json:"trans_in"` | |||
Amount string `json:"amount,omitempty"` | |||
Desc string `json:"desc,omitempty"` | |||
} | |||
// Deprecated | |||
func (a *Client) SetPrivateKeyType(t PKCSType) (client *Client) { | |||
return a | |||
} | |||
// 设置 时区,不设置或出错均为默认服务器时间 | |||
func (a *Client) SetLocation(name string) (client *Client) { | |||
location, err := time.LoadLocation(name) | |||
if err != nil { | |||
log.Println("set Location err") | |||
return a | |||
} | |||
a.location = location | |||
return a | |||
} | |||
// Deprecated | |||
// 推荐使用 client.SetCertSnByContent() 或 client.SetCertSnByPath() | |||
// 设置 应用公钥证书SN | |||
// appCertSN:应用公钥证书SN,通过 alipay.GetCertSN() 获取 | |||
func (a *Client) SetAppCertSN(appCertSN string) (client *Client) { | |||
a.AppCertSN = appCertSN | |||
return a | |||
} | |||
// Deprecated | |||
// 推荐使用 client.SetCertSnByContent() 或 client.SetCertSnByPath() | |||
// 设置 支付宝公钥证书SN | |||
// aliPayPublicCertSN:支付宝公钥证书SN,通过 alipay.GetCertSN() 获取 | |||
func (a *Client) SetAliPayPublicCertSN(aliPayPublicCertSN string) (client *Client) { | |||
a.AliPayPublicCertSN = aliPayPublicCertSN | |||
return a | |||
} | |||
// Deprecated | |||
// 推荐使用 client.SetCertSnByContent() 或 client.SetCertSnByPath() | |||
// 设置 支付宝CA根证书SN | |||
// aliPayRootCertSN:支付宝CA根证书SN,通过 alipay.GetRootCertSN() 获取 | |||
func (a *Client) SetAliPayRootCertSN(aliPayRootCertSN string) (client *Client) { | |||
a.AliPayRootCertSN = aliPayRootCertSN | |||
return a | |||
} | |||
// 通过应用公钥证书路径设置 app_cert_sn、alipay_root_cert_sn、alipay_cert_sn | |||
// appCertPath:应用公钥证书路径 | |||
// aliPayRootCertPath:支付宝根证书文件路径 | |||
// aliPayPublicCertPath:支付宝公钥证书文件路径 | |||
func (a *Client) SetCertSnByPath(appCertPath, aliPayRootCertPath, aliPayPublicCertPath string) (err error) { | |||
appCertSn, err := GetCertSN(appCertPath) | |||
if err != nil { | |||
return fmt.Errorf("get app_cert_sn return err, but alse return alipay client. err: %w", err) | |||
} | |||
rootCertSn, err := GetRootCertSN(aliPayRootCertPath) | |||
if err != nil { | |||
return fmt.Errorf("get alipay_root_cert_sn return err, but alse return alipay client. err: %w", err) | |||
} | |||
publicCertSn, err := GetCertSN(aliPayPublicCertPath) | |||
if err != nil { | |||
return fmt.Errorf("get alipay_cert_sn return err, but alse return alipay client. err: %w", err) | |||
} | |||
a.AppCertSN = appCertSn | |||
a.AliPayRootCertSN = rootCertSn | |||
a.AliPayPublicCertSN = publicCertSn | |||
return nil | |||
} | |||
// 通过应用公钥证书内容设置 app_cert_sn、alipay_root_cert_sn、alipay_cert_sn | |||
// appCertContent:应用公钥证书文件内容 | |||
// aliPayRootCertContent:支付宝根证书文件内容 | |||
// aliPayPublicCertContent:支付宝公钥证书文件内容 | |||
func (a *Client) SetCertSnByContent(appCertContent, aliPayRootCertContent, aliPayPublicCertContent []byte) (err error) { | |||
appCertSn, err := GetCertSN(appCertContent) | |||
if err != nil { | |||
return fmt.Errorf("get app_cert_sn return err, but alse return alipay client. err: %w", err) | |||
} | |||
rootCertSn, err := GetRootCertSN(aliPayRootCertContent) | |||
if err != nil { | |||
return fmt.Errorf("get alipay_root_cert_sn return err, but alse return alipay client. err: %w", err) | |||
} | |||
publicCertSn, err := GetCertSN(aliPayPublicCertContent) | |||
if err != nil { | |||
return fmt.Errorf("get alipay_cert_sn return err, but alse return alipay client. err: %w", err) | |||
} | |||
a.AppCertSN = appCertSn | |||
a.AliPayRootCertSN = rootCertSn | |||
a.AliPayPublicCertSN = publicCertSn | |||
return nil | |||
} | |||
// 设置支付后的ReturnUrl | |||
func (a *Client) SetReturnUrl(url string) (client *Client) { | |||
a.ReturnUrl = url | |||
return a | |||
} | |||
// 设置支付宝服务器主动通知商户服务器里指定的页面http/https路径。 | |||
func (a *Client) SetNotifyUrl(url string) (client *Client) { | |||
a.NotifyUrl = url | |||
return a | |||
} | |||
// 设置编码格式,如utf-8,gbk,gb2312等,默认推荐使用 utf-8 | |||
func (a *Client) SetCharset(charset string) (client *Client) { | |||
if charset != gopay.NULL { | |||
a.Charset = charset | |||
} | |||
return a | |||
} | |||
// 设置签名算法类型,目前支持RSA2和RSA,默认推荐使用 RSA2 | |||
func (a *Client) SetSignType(signType string) (client *Client) { | |||
if signType != gopay.NULL { | |||
a.SignType = signType | |||
} | |||
return a | |||
} | |||
// 设置应用授权 | |||
func (a *Client) SetAppAuthToken(appAuthToken string) (client *Client) { | |||
a.AppAuthToken = appAuthToken | |||
return a | |||
} |
@@ -1,427 +0,0 @@ | |||
package alipay | |||
import ( | |||
"context" | |||
"encoding/json" | |||
"errors" | |||
"fmt" | |||
"github.com/go-pay/gopay" | |||
) | |||
// alipay.trade.pay(统一收单交易支付接口) | |||
// 文档地址:https://opendocs.alipay.com/open/02cdx8 | |||
func (a *Client) TradePay(ctx context.Context, bm gopay.BodyMap) (aliRsp *TradePayResponse, err error) { | |||
err = bm.CheckEmptyError("out_trade_no", "subject") | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "alipay.trade.pay"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(TradePayResponse) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheckTradePay(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// alipay.trade.precreate(统一收单线下交易预创建) | |||
// 文档地址:https://opendocs.alipay.com/open/02ekfg | |||
func (a *Client) TradePrecreate(ctx context.Context, bm gopay.BodyMap) (aliRsp *TradePrecreateResponse, err error) { | |||
err = bm.CheckEmptyError("out_trade_no", "total_amount", "subject") | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "alipay.trade.precreate"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(TradePrecreateResponse) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
if aliRsp.NullResponse != nil { | |||
info := aliRsp.NullResponse | |||
return aliRsp, fmt.Errorf(`{"code":"%s","msg":"%s","sub_code":"%s","sub_msg":"%s"}`, info.Code, info.Msg, info.SubCode, info.SubMsg) | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// alipay.trade.app.pay(app支付接口2.0) | |||
// 文档地址:https://opendocs.alipay.com/open/02e7gq | |||
func (a *Client) TradeAppPay(ctx context.Context, bm gopay.BodyMap) (payParam string, err error) { | |||
err = bm.CheckEmptyError("out_trade_no", "total_amount", "subject") | |||
if err != nil { | |||
return gopay.NULL, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "alipay.trade.app.pay"); err != nil { | |||
return gopay.NULL, err | |||
} | |||
payParam = string(bs) | |||
return payParam, nil | |||
} | |||
// alipay.trade.wap.pay(手机网站支付接口2.0) | |||
// 文档地址:https://opendocs.alipay.com/open/02ivbs | |||
func (a *Client) TradeWapPay(ctx context.Context, bm gopay.BodyMap) (payUrl string, err error) { | |||
bm.Set("product_code", "QUICK_WAP_WAY") | |||
err = bm.CheckEmptyError("out_trade_no", "total_amount", "subject") | |||
if err != nil { | |||
return gopay.NULL, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "alipay.trade.wap.pay"); err != nil { | |||
return gopay.NULL, err | |||
} | |||
payUrl = string(bs) | |||
return payUrl, nil | |||
} | |||
// alipay.trade.page.pay(统一收单下单并支付页面接口) | |||
// 文档地址:https://opendocs.alipay.com/open/028r8t | |||
func (a *Client) TradePagePay(ctx context.Context, bm gopay.BodyMap) (payUrl string, err error) { | |||
bm.Set("product_code", "FAST_INSTANT_TRADE_PAY") | |||
err = bm.CheckEmptyError("out_trade_no", "total_amount", "subject") | |||
if err != nil { | |||
return gopay.NULL, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "alipay.trade.page.pay"); err != nil { | |||
return gopay.NULL, err | |||
} | |||
payUrl = string(bs) | |||
return payUrl, nil | |||
} | |||
// alipay.trade.create(统一收单交易创建接口) | |||
// 文档地址:https://opendocs.alipay.com/open/02ekfj | |||
func (a *Client) TradeCreate(ctx context.Context, bm gopay.BodyMap) (aliRsp *TradeCreateResponse, err error) { | |||
err = bm.CheckEmptyError("out_trade_no", "total_amount", "subject") | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "alipay.trade.create"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(TradeCreateResponse) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// alipay.trade.order.pay(统一收单交易订单支付接口) | |||
// 文档地址:https://opendocs.alipay.com/open/03vtew | |||
func (a *Client) TradeOrderPay(ctx context.Context, bm gopay.BodyMap) (aliRsp *TradeOrderPayResponse, err error) { | |||
err = bm.CheckEmptyError("trade_no") | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "alipay.trade.order.pay"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(TradeOrderPayResponse) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// alipay.trade.query(统一收单线下交易查询) | |||
// 文档地址:https://opendocs.alipay.com/open/02e7gm | |||
func (a *Client) TradeQuery(ctx context.Context, bm gopay.BodyMap) (aliRsp *TradeQueryResponse, err error) { | |||
if bm.GetString("out_trade_no") == gopay.NULL && bm.GetString("trade_no") == gopay.NULL { | |||
return nil, errors.New("out_trade_no and trade_no are not allowed to be null at the same time") | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "alipay.trade.query"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(TradeQueryResponse) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// alipay.trade.cancel(统一收单交易撤销接口) | |||
// 文档地址:https://opendocs.alipay.com/open/02ekfi | |||
func (a *Client) TradeCancel(ctx context.Context, bm gopay.BodyMap) (aliRsp *TradeCancelResponse, err error) { | |||
if bm.GetString("out_trade_no") == gopay.NULL && bm.GetString("trade_no") == gopay.NULL { | |||
return nil, errors.New("out_trade_no and trade_no are not allowed to be null at the same time") | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "alipay.trade.cancel"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(TradeCancelResponse) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// alipay.trade.close(统一收单交易关闭接口) | |||
// 文档地址:https://opendocs.alipay.com/open/02e7gn | |||
func (a *Client) TradeClose(ctx context.Context, bm gopay.BodyMap) (aliRsp *TradeCloseResponse, err error) { | |||
if bm.GetString("out_trade_no") == gopay.NULL && bm.GetString("trade_no") == gopay.NULL { | |||
return nil, errors.New("out_trade_no and trade_no are not allowed to be null at the same time") | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "alipay.trade.close"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(TradeCloseResponse) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// alipay.trade.refund(统一收单交易退款接口) | |||
// 文档地址:https://opendocs.alipay.com/open/02e7go | |||
func (a *Client) TradeRefund(ctx context.Context, bm gopay.BodyMap) (aliRsp *TradeRefundResponse, err error) { | |||
if bm.GetString("out_trade_no") == gopay.NULL && bm.GetString("trade_no") == gopay.NULL { | |||
return nil, errors.New("out_trade_no and trade_no are not allowed to be null at the same time") | |||
} | |||
err = bm.CheckEmptyError("refund_amount") | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "alipay.trade.refund"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(TradeRefundResponse) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// alipay.trade.page.refund(统一收单退款页面接口) | |||
// 文档地址:https://opendocs.alipay.com/apis/api_1/alipay.trade.page.refund | |||
func (a *Client) TradePageRefund(ctx context.Context, bm gopay.BodyMap) (aliRsp *TradePageRefundResponse, err error) { | |||
if bm.GetString("out_trade_no") == gopay.NULL && bm.GetString("trade_no") == gopay.NULL { | |||
return nil, errors.New("out_trade_no and trade_no are not allowed to be null at the same time") | |||
} | |||
err = bm.CheckEmptyError("out_request_no", "refund_amount") | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "alipay.trade.page.refund"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(TradePageRefundResponse) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// alipay.trade.fastpay.refund.query(统一收单交易退款查询) | |||
// 文档地址:https://opendocs.alipay.com/open/02e7gp | |||
func (a *Client) TradeFastPayRefundQuery(ctx context.Context, bm gopay.BodyMap) (aliRsp *TradeFastpayRefundQueryResponse, err error) { | |||
if bm.GetString("out_trade_no") == gopay.NULL && bm.GetString("trade_no") == gopay.NULL { | |||
return nil, errors.New("out_trade_no and trade_no are not allowed to be null at the same time") | |||
} | |||
err = bm.CheckEmptyError("out_request_no") | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "alipay.trade.fastpay.refund.query"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(TradeFastpayRefundQueryResponse) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// alipay.trade.orderinfo.sync(支付宝订单信息同步接口) | |||
// 文档地址:https://opendocs.alipay.com/open/02cnou | |||
func (a *Client) TradeOrderInfoSync(ctx context.Context, bm gopay.BodyMap) (aliRsp *TradeOrderInfoSyncRsp, err error) { | |||
err = bm.CheckEmptyError("out_request_no", "trade_no", "biz_type") | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "alipay.trade.orderinfo.sync"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(TradeOrderInfoSyncRsp) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// alipay.trade.advance.consult(订单咨询服务) | |||
// 文档地址:https://opendocs.alipay.com/apis/api_1/alipay.trade.advance.consult | |||
func (a *Client) TradeAdvanceConsult(ctx context.Context, bm gopay.BodyMap) (aliRsp *TradeAdvanceConsultRsp, err error) { | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "alipay.trade.advance.consult"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(TradeAdvanceConsultRsp) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// alipay.pcredit.huabei.auth.settle.apply(花芝轻会员结算申请) | |||
// 文档地址:https://opendocs.alipay.com/apis/api_1/alipay.pcredit.huabei.auth.settle.apply | |||
func (a *Client) PcreditHuabeiAuthSettleApply(ctx context.Context, bm gopay.BodyMap) (aliRsp *PcreditHuabeiAuthSettleApplyRsp, err error) { | |||
err = bm.CheckEmptyError("agreement_no", "pay_amount", "out_request_no", "alipay_user_id") | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "alipay.pcredit.huabei.auth.settle.apply"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(PcreditHuabeiAuthSettleApplyRsp) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// alipay.data.dataservice.ad.data.query(广告投放数据查询) | |||
// 文档地址:https://opendocs.alipay.com/apis/api_1/alipay.data.dataservice.ad.data.query | |||
func (a *Client) DataDataserviceAdDataQuery(ctx context.Context, bm gopay.BodyMap) (aliRsp *DataDataserviceAdDataQueryRsp, err error) { | |||
err = bm.CheckEmptyError("query_type", "biz_token", "ad_level", "start_date", "end_date", "outer_id_list") | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "alipay.data.dataservice.ad.data.query"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(DataDataserviceAdDataQueryRsp) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// mybank.payment.trade.order.create(网商银行全渠道收单业务订单创建) | |||
// 文档地址:https://opendocs.alipay.com/apis/api_1/mybank.payment.trade.order.create | |||
func (a *Client) PaymentTradeOrderCreate(ctx context.Context, bm gopay.BodyMap) (aliRsp *PaymentTradeOrderCreateRsp, err error) { | |||
err = bm.CheckEmptyError("partner_id", "out_trade_no", "recon_related_no", "pd_code", "ev_code", "total_amount", "currency_code", "goods_info", "seller_id", "pay_type", "pay_date") | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "mybank.payment.trade.order.create"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(PaymentTradeOrderCreateRsp) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// alipay.trade.repaybill.query(还款账单查询) | |||
// 文档地址:https://opendocs.alipay.com/apis/api_1/alipay.trade.repaybill.query | |||
func (a *Client) TradeRepaybillQuery(ctx context.Context, bm gopay.BodyMap) (aliRsp *TradeRepaybillQueryRsp, err error) { | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "alipay.trade.repaybill.query"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(TradeRepaybillQueryRsp) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} |
@@ -1,491 +0,0 @@ | |||
package alipay | |||
import ( | |||
"testing" | |||
"github.com/go-pay/gopay" | |||
"github.com/go-pay/gopay/alipay/cert" | |||
"github.com/go-pay/util" | |||
"github.com/go-pay/xlog" | |||
) | |||
func TestClient_TradePrecreate(t *testing.T) { | |||
// 请求参数 | |||
bm := make(gopay.BodyMap) | |||
bm.Set("subject", "预创建创建订单"). | |||
Set("out_trade_no", util.RandomString(32)). | |||
Set("total_amount", "0.01") | |||
// 创建订单 | |||
aliRsp, err := client.TradePrecreate(ctx, bm) | |||
if err != nil { | |||
if bizErr, ok := IsBizError(err); ok { | |||
xlog.Errorf("%+v", bizErr) | |||
// do something | |||
return | |||
} | |||
return | |||
} | |||
xlog.Debugf("aliRsp:%+v", aliRsp.Response) | |||
xlog.Debug("aliRsp.QrCode:", aliRsp.Response.QrCode) | |||
xlog.Debug("aliRsp.OutTradeNo:", aliRsp.Response.OutTradeNo) | |||
// 同步返回验签 | |||
ok, err := VerifySyncSignWithCert(cert.AlipayPublicContentRSA2, aliRsp.SignData, aliRsp.Sign) | |||
if err != nil { | |||
xlog.Error(err) | |||
} | |||
xlog.Debug("同步返回验签:", ok) | |||
} | |||
func TestClient_TradeCreate(t *testing.T) { | |||
// 请求参数 | |||
bm := make(gopay.BodyMap) | |||
bm.Set("subject", "创建订单"). | |||
Set("buyer_id", "2088722003236450"). | |||
Set("out_trade_no", util.RandomString(32)). | |||
Set("total_amount", "100.10") | |||
// 创建订单 | |||
aliRsp, err := client.TradeCreate(ctx, bm) | |||
if err != nil { | |||
if bizErr, ok := IsBizError(err); ok { | |||
xlog.Errorf("%s, %s", bizErr.Code, bizErr.Msg) | |||
// do something | |||
return | |||
} | |||
xlog.Errorf("%s", err) | |||
return | |||
} | |||
xlog.Debug("aliRsp:", *aliRsp) | |||
xlog.Debug("aliRsp.TradeNo:", aliRsp.Response.TradeNo) | |||
} | |||
func TestClient_TradeAppPay(t *testing.T) { | |||
// 请求参数 | |||
bm := make(gopay.BodyMap) | |||
bm.Set("subject", "测试APP支付"). | |||
Set("out_trade_no", "GZ201901301040355706100469"). | |||
Set("total_amount", "1.00") | |||
// 手机APP支付参数请求 | |||
payParam, err := client.TradeAppPay(ctx, bm) | |||
if err != nil { | |||
if bizErr, ok := IsBizError(err); ok { | |||
xlog.Errorf("%+v", bizErr) | |||
// do something | |||
return | |||
} | |||
return | |||
} | |||
xlog.Debug("payParam:", payParam) | |||
} | |||
func TestClient_TradeCancel(t *testing.T) { | |||
// 请求参数 | |||
bm := make(gopay.BodyMap) | |||
bm.Set("out_trade_no", "GZ201909081743431443") | |||
// 撤销支付订单 | |||
aliRsp, err := client.TradeCancel(ctx, bm) | |||
if err != nil { | |||
if bizErr, ok := IsBizError(err); ok { | |||
xlog.Errorf("%+v", bizErr) | |||
// do something | |||
return | |||
} | |||
return | |||
} | |||
xlog.Debug("aliRsp:", *aliRsp) | |||
} | |||
func TestClient_TradeClose(t *testing.T) { | |||
// 请求参数 | |||
bm := make(gopay.BodyMap) | |||
bm.Set("out_trade_no", "GZ201909081743431443") | |||
// 条码支付 | |||
aliRsp, err := client.TradeClose(ctx, bm) | |||
if err != nil { | |||
if bizErr, ok := IsBizError(err); ok { | |||
xlog.Errorf("%+v", bizErr) | |||
// do something | |||
return | |||
} | |||
return | |||
} | |||
xlog.Debug("aliRsp:", *aliRsp) | |||
} | |||
func TestClient_TradePay(t *testing.T) { | |||
// 请求参数 | |||
bm := make(gopay.BodyMap) | |||
bm.Set("subject", "条码支付"). | |||
Set("scene", "bar_code"). | |||
Set("auth_code", "286248566432274952"). | |||
Set("out_trade_no", "GZ201909081743431443"). | |||
Set("total_amount", "0.01"). | |||
Set("timeout_express", "2m") | |||
// 条码支付 | |||
aliRsp, err := client.TradePay(ctx, bm) | |||
if err != nil { | |||
if bizErr, ok := IsBizError(err); ok { | |||
xlog.Errorf("%+v", bizErr) | |||
// do something | |||
return | |||
} | |||
return | |||
} | |||
xlog.Debug("aliRsp:", *aliRsp) | |||
// 同步返回验签 | |||
ok, err := VerifySyncSignWithCert(cert.AlipayPublicContentRSA2, aliRsp.SignData, aliRsp.Sign) | |||
if err != nil { | |||
xlog.Error(err) | |||
} | |||
xlog.Debug("同步返回验签:", ok) | |||
} | |||
func TestClient_TradeQuery(t *testing.T) { | |||
const outTradeNo = "GZ201909081743431443" | |||
// 请求参数 | |||
bm := make(gopay.BodyMap) | |||
bm.Set("out_trade_no", outTradeNo) | |||
// 查询订单 | |||
aliRsp, err := client.TradeQuery(ctx, bm) | |||
if err != nil { | |||
if bizErr, ok := IsBizError(err); ok { | |||
xlog.Errorf("%+v", bizErr) | |||
// do something | |||
return | |||
} | |||
return | |||
} | |||
xlog.Debugf("aliRsp:%+v", aliRsp.Response) | |||
// 同步返回验签 | |||
ok, err := VerifySyncSignWithCert(cert.AlipayPublicContentRSA2, aliRsp.SignData, aliRsp.Sign) | |||
if err != nil { | |||
xlog.Error(err) | |||
} | |||
xlog.Debug("同步返回验签:", ok) | |||
} | |||
func TestClient_TradeWapPay(t *testing.T) { | |||
// 请求参数 | |||
bm := make(gopay.BodyMap) | |||
bm.Set("subject", "手机网站测试支付"). | |||
Set("out_trade_no", "GZ201909081743431443"). | |||
Set("quit_url", "https://www.fmm.ink"). | |||
Set("total_amount", "100.00"). | |||
Set("product_code", "QUICK_WAP_WAY") | |||
// 手机网站支付请求 | |||
payUrl, err := client.TradeWapPay(ctx, bm) | |||
if err != nil { | |||
xlog.Errorf("client.TradeWapPay(%+v),error:%+v", bm, err) | |||
return | |||
} | |||
xlog.Debug("payUrl:", payUrl) | |||
} | |||
func TestClient_TradePagePay(t *testing.T) { | |||
// 请求参数 | |||
bm := make(gopay.BodyMap) | |||
bm.Set("subject", "网站测试支付"). | |||
Set("out_trade_no", "GZ201909081743431443"). | |||
Set("total_amount", "88.88"). | |||
Set("product_code", "FAST_INSTANT_TRADE_PAY") | |||
// 电脑网站支付请求 | |||
payUrl, err := client.TradePagePay(ctx, bm) | |||
if err != nil { | |||
xlog.Errorf("client.TradePagePay(%+v),error:%+v", bm, err) | |||
return | |||
} | |||
xlog.Debug("payUrl:", payUrl) | |||
} | |||
func TestClient_TradeRefund(t *testing.T) { | |||
// 请求参数 | |||
bm := make(gopay.BodyMap) | |||
bm.Set("out_trade_no", "GZ201909081743431443"). | |||
Set("refund_amount", "5"). | |||
Set("refund_reason", "测试退款") | |||
// 发起退款请求 | |||
aliRsp, err := client.TradeRefund(ctx, bm) | |||
if err != nil { | |||
if bizErr, ok := IsBizError(err); ok { | |||
xlog.Errorf("%+v", bizErr) | |||
// do something | |||
return | |||
} | |||
return | |||
} | |||
xlog.Debug("aliRsp:", *aliRsp) | |||
} | |||
func TestClient_TradePageRefund(t *testing.T) { | |||
// 请求参数 | |||
bm := make(gopay.BodyMap) | |||
bm.Set("out_trade_no", "GZ201909081743431443"). | |||
Set("refund_amount", "5"). | |||
Set("out_request_no", util.RandomString(32)) | |||
// 发起退款请求 | |||
aliRsp, err := client.TradePageRefund(ctx, bm) | |||
if err != nil { | |||
if bizErr, ok := IsBizError(err); ok { | |||
xlog.Errorf("%+v", bizErr) | |||
// do something | |||
return | |||
} | |||
return | |||
} | |||
xlog.Debug("aliRsp:", *aliRsp) | |||
} | |||
func TestClient_TradeFastPayRefundQuery(t *testing.T) { | |||
// 请求参数 | |||
bm := make(gopay.BodyMap) | |||
bm.Set("out_trade_no", "GZ201909081743431443"). | |||
Set("out_request_no", "GZ201909081743431443") | |||
// 发起退款查询请求 | |||
aliRsp, err := client.TradeFastPayRefundQuery(ctx, bm) | |||
if err != nil { | |||
if bizErr, ok := IsBizError(err); ok { | |||
xlog.Errorf("%+v", bizErr) | |||
// do something | |||
return | |||
} | |||
return | |||
} | |||
xlog.Debug("aliRsp:", *aliRsp) | |||
} | |||
func TestClient_TradeOrderSettle(t *testing.T) { | |||
// 请求参数 | |||
bm := make(gopay.BodyMap) | |||
bm.Set("out_request_no", "201907301518083384"). | |||
Set("trade_no", "2019072522001484690549776067") | |||
var listParams []RoyaltyDetailInfoPojo | |||
listParams = append(listParams, RoyaltyDetailInfoPojo{"transfer", "2088802095984694", "userId", "userId", "2088102363632794", "0.01", "分账给2088102363632794"}) | |||
bm.Set("royalty_parameters", listParams) | |||
// xlog.Debug("listParams:", bm.GetString("royalty_parameters")) | |||
// 发起交易结算接口 | |||
aliRsp, err := client.TradeOrderSettle(ctx, bm) | |||
if err != nil { | |||
if bizErr, ok := IsBizError(err); ok { | |||
xlog.Errorf("%+v", bizErr) | |||
// do something | |||
return | |||
} | |||
return | |||
} | |||
xlog.Debug("aliRsp:", *aliRsp) | |||
} | |||
// 订单咨询服务测试 | |||
func TestClient_TradeAdvanceConsult(t *testing.T) { | |||
// 请求参数 | |||
bm := make(gopay.BodyMap) | |||
bm.Set("alipay_user_id", "2088302483540171"). | |||
Set("consult_scene", "ORDER_RISK_EVALUATION") | |||
aliRsp, err := client.TradeAdvanceConsult(ctx, bm) | |||
if err != nil { | |||
if bizErr, ok := IsBizError(err); ok { | |||
xlog.Errorf("%+v", bizErr) | |||
// do something | |||
return | |||
} | |||
return | |||
} | |||
xlog.Debug("aliRsp:", *aliRsp) | |||
} | |||
func TestClient_PcreditHuabeiAuthSettleApply(t *testing.T) { | |||
// 请求参数 | |||
bm := make(gopay.BodyMap) | |||
bm.Set("agreement_no", "20170502000610755993") | |||
bm.Set("pay_amount", "3.00") | |||
bm.Set("out_request_no", "8077735255938032") | |||
bm.Set("alipay_user_id", "2088101117955611") | |||
aliRsp, err := client.PcreditHuabeiAuthSettleApply(ctx, bm) | |||
if err != nil { | |||
if bizErr, ok := IsBizError(err); ok { | |||
xlog.Errorf("%+v", bizErr) | |||
// do something | |||
return | |||
} | |||
return | |||
} | |||
xlog.Debug("aliRsp:", *aliRsp) | |||
} | |||
func TestClient_CommerceTransportNfccardSend(t *testing.T) { | |||
// 请求参数 | |||
bm := make(gopay.BodyMap) | |||
bm.Set("issue_org_no", "12345678") | |||
bm.Set("card_no", "12345678") | |||
bm.Set("card_status", "CANCEL") | |||
aliRsp, err := client.CommerceTransportNfccardSend(ctx, bm) | |||
if err != nil { | |||
if bizErr, ok := IsBizError(err); ok { | |||
xlog.Errorf("%+v", bizErr) | |||
// do something | |||
return | |||
} | |||
return | |||
} | |||
xlog.Debug("aliRsp:", *aliRsp) | |||
} | |||
func TestClient_DataDataserviceAdDataQuery(t *testing.T) { | |||
// 请求参数 | |||
bm := make(gopay.BodyMap) | |||
bm.Set("query_type", "ALL_SUM") | |||
bm.Set("biz_token", "e09d869511189c24ce13fe3294f2bd6e") | |||
bm.Set("ad_level", "CREATIVE") | |||
bm.Set("start_date", "20180820") | |||
bm.Set("end_date", "20180820") | |||
bm.Set("outer_id_list", "10760000471-2") | |||
aliRsp, err := client.DataDataserviceAdDataQuery(ctx, bm) | |||
if err != nil { | |||
if bizErr, ok := IsBizError(err); ok { | |||
xlog.Errorf("%+v", bizErr) | |||
// do something | |||
return | |||
} | |||
return | |||
} | |||
xlog.Debug("aliRsp:", *aliRsp) | |||
} | |||
func TestClient_CommerceAirCallcenterTradeApply(t *testing.T) { | |||
// 请求参数 | |||
bm := make(gopay.BodyMap) | |||
bm.Set("scene_code", "flight_ticket_order") | |||
bm.Set("op_code", "order_acquire_proxy") | |||
bm.Set("channel", "hangsiair") | |||
bm.Set("target_id", "2088102122001010") | |||
bm.Set("target_id_type", "ALIPAY_USER_ID") | |||
bm.SetBodyMap("trade_apply_params", func(bm gopay.BodyMap) { | |||
bm.Set("buyer_name", "张三") | |||
bm.Set("subject", "北京---上海 单程") | |||
bm.Set("expire_time", "2017-03-30 18:30:00") | |||
bm.Set("out_trade_no", "2387238273827387") | |||
bm.Set("total_amount", "1000.00") | |||
bm.Set("currency", "CNY") | |||
}) | |||
aliRsp, err := client.CommerceAirCallcenterTradeApply(ctx, bm) | |||
if err != nil { | |||
if bizErr, ok := IsBizError(err); ok { | |||
xlog.Errorf("%+v", bizErr) | |||
// do something | |||
return | |||
} | |||
return | |||
} | |||
xlog.Debug("aliRsp:", *aliRsp) | |||
} | |||
func TestClient_PaymentTradeOrderCreate(t *testing.T) { | |||
// 请求参数 | |||
bm := make(gopay.BodyMap) | |||
bm.Set("partner_id", "202210000000000001278") | |||
bm.Set("out_trade_no", "20150320010101001") | |||
bm.Set("recon_related_no", "20150320010101001") | |||
bm.Set("pd_code", "01050200000000000009") | |||
bm.Set("ev_code", "12050001") | |||
bm.Set("total_amount", "10000") | |||
bm.Set("currency_code", "156") | |||
bm.Set("seller_id", "2088102146225135") | |||
bm.Set("pay_type", "pay") | |||
bm.Set("pay_date", "2014-07-24 03:07:50") | |||
bm.SetBodyMap("goods_info", func(bm gopay.BodyMap) { | |||
bm.Set("goods_name", "ipad") | |||
bm.Set("goods_price", "2000.00") | |||
}) | |||
aliRsp, err := client.PaymentTradeOrderCreate(ctx, bm) | |||
if err != nil { | |||
if bizErr, ok := IsBizError(err); ok { | |||
xlog.Errorf("%+v", bizErr) | |||
// do something | |||
return | |||
} | |||
xlog.Errorf("client.PaymentTradeOrderCreate(%+v),error:%+v", bm, err) | |||
return | |||
} | |||
xlog.Debug("aliRsp:", *aliRsp) | |||
} | |||
func TestClient_CommerceBenefitApply(t *testing.T) { | |||
// 请求参数 | |||
bm := make(gopay.BodyMap) | |||
bm.Set("activity_code", "alipay_game_marketing") | |||
bm.Set("trade_no", "2020081210122512120003") | |||
bm.Set("user_account", "342812199010013210") | |||
bm.Set("platform", "ios") | |||
aliRsp, err := client.CommerceBenefitApply(ctx, bm) | |||
if err != nil { | |||
if bizErr, ok := IsBizError(err); ok { | |||
xlog.Errorf("%+v", bizErr) | |||
// do something | |||
return | |||
} | |||
xlog.Errorf("client.CommerceBenefitApply(%+v),error:%+v", bm, err) | |||
return | |||
} | |||
xlog.Debug("aliRsp:", *aliRsp) | |||
} | |||
func TestClient_CommerceBenefitVerify(t *testing.T) { | |||
// 请求参数 | |||
bm := make(gopay.BodyMap) | |||
bm.Set("activity_code", "alipay_1212_marketing") | |||
bm.Set("voucher_code", "JHK51ITYK") | |||
bm.Set("user_account", "342812199010013210") | |||
bm.Set("trade_no", "2020081210122512120003") | |||
aliRsp, err := client.CommerceBenefitVerify(ctx, bm) | |||
if err != nil { | |||
if bizErr, ok := IsBizError(err); ok { | |||
xlog.Errorf("%+v", bizErr) | |||
// do something | |||
return | |||
} | |||
xlog.Errorf("client.CommerceBenefitVerify(%+v),error:%+v", bm, err) | |||
return | |||
} | |||
xlog.Debug("aliRsp:", *aliRsp) | |||
} | |||
func TestClient_TradeRepaybillQuery(t *testing.T) { | |||
// 请求参数 | |||
bm := make(gopay.BodyMap) | |||
aliRsp, err := client.TradeRepaybillQuery(ctx, bm) | |||
if err != nil { | |||
if bizErr, ok := IsBizError(err); ok { | |||
xlog.Errorf("%+v", bizErr) | |||
// do something | |||
return | |||
} | |||
return | |||
} | |||
xlog.Debug("aliRsp:", *aliRsp) | |||
} |
@@ -1,464 +0,0 @@ | |||
package alipay | |||
import ( | |||
"crypto" | |||
"crypto/md5" | |||
"crypto/rand" | |||
"crypto/rsa" | |||
"crypto/sha1" | |||
"crypto/sha256" | |||
"crypto/x509" | |||
"encoding/base64" | |||
"encoding/hex" | |||
"encoding/json" | |||
"encoding/pem" | |||
"errors" | |||
"fmt" | |||
"hash" | |||
"os" | |||
"reflect" | |||
"strings" | |||
"github.com/go-pay/crypto/xpem" | |||
"github.com/go-pay/crypto/xrsa" | |||
"github.com/go-pay/gopay" | |||
) | |||
// 允许进行 sn 提取的证书签名算法 | |||
var allowSignatureAlgorithm = map[string]bool{ | |||
"MD2-RSA": true, | |||
"MD5-RSA": true, | |||
"SHA1-RSA": true, | |||
"SHA256-RSA": true, | |||
"SHA384-RSA": true, | |||
"SHA512-RSA": true, | |||
"SHA256-RSAPSS": true, | |||
"SHA384-RSAPSS": true, | |||
"SHA512-RSAPSS": true, | |||
} | |||
/* | |||
Q:使用公钥证书签名方式下,为什么开放平台网关的响应报文需要携带支付宝公钥证书SN(alipay_cert_sn)? | |||
** | |||
A:开发者上传自己的应用公钥证书后,开放平台会为开发者应用自动签发支付宝公钥证书供开发者下载,用来对开放平台网关响应报文做验签。 | |||
但是支付宝公钥证书可能因证书到期或者变更CA签发机构等原因,可能会重新签发证书。在重新签发前,开放平台会在门户上提前提醒开发者支付宝应用公钥证书变更时间。 | |||
但为避免开发者因未能及时感知支付宝公钥证书变更而导致验签失败,开放平台提供了一种支付宝公钥证书无感知升级机制,具体流程如下: | |||
1)开放平台网关在响应报文中会多返回支付宝公钥证书SN | |||
2)开放平台网关提供根据SN下载对应支付宝公钥证书的API接口 | |||
3)开发者在验签过程中,先比较本地使用的支付宝公钥证书SN与开放平台网关响应中SN是否一致。若不一致,可调用支付宝公钥证书下载接口下载对应SN的支付宝公钥证书。 | |||
4)对下载的支付宝公钥证书执行证书链校验,若校验通过,则用该证书验签。 | |||
基于该机制可实现支付宝公钥证书变更时开发者无感知,当前开放平台提供的SDK已基于该机制实现对应功能。若开发者未通过SDK接入,须自行实现该功能。 | |||
*/ | |||
// GetCertSN 获取证书序列号SN | |||
// certPathOrData x509证书文件路径(appPublicCert.crt、alipayPublicCert.crt) 或证书 buffer | |||
// 返回 sn:证书序列号(app_cert_sn、alipay_cert_sn) | |||
// 返回 err:error 信息 | |||
func GetCertSN(certPathOrData any) (sn string, err error) { | |||
var certData []byte | |||
switch pathOrData := certPathOrData.(type) { | |||
case string: | |||
certData, err = os.ReadFile(pathOrData) | |||
if err != nil { | |||
return gopay.NULL, err | |||
} | |||
case []byte: | |||
certData = pathOrData | |||
default: | |||
return gopay.NULL, errors.New("certPathOrData 证书类型断言错误") | |||
} | |||
if block, _ := pem.Decode(certData); block != nil { | |||
cert, err := x509.ParseCertificate(block.Bytes) | |||
if err != nil { | |||
return gopay.NULL, err | |||
} | |||
name := cert.Issuer.String() | |||
serialNumber := cert.SerialNumber.String() | |||
h := md5.New() | |||
h.Write([]byte(name)) | |||
h.Write([]byte(serialNumber)) | |||
sn = hex.EncodeToString(h.Sum(nil)) | |||
} | |||
if sn == gopay.NULL { | |||
return gopay.NULL, errors.New("failed to get sn,please check your cert") | |||
} | |||
return sn, nil | |||
} | |||
// GetRootCertSN 获取root证书序列号SN | |||
// rootCertPathOrData x509证书文件路径(alipayRootCert.crt) 或文件 buffer | |||
// 返回 sn:证书序列号(alipay_root_cert_sn) | |||
// 返回 err:error 信息 | |||
func GetRootCertSN(rootCertPathOrData any) (sn string, err error) { | |||
var ( | |||
certData []byte | |||
certEnd = `-----END CERTIFICATE-----` | |||
) | |||
switch pathOrData := rootCertPathOrData.(type) { | |||
case string: | |||
certData, err = os.ReadFile(pathOrData) | |||
if err != nil { | |||
return gopay.NULL, err | |||
} | |||
case []byte: | |||
certData = pathOrData | |||
default: | |||
return gopay.NULL, errors.New("rootCertPathOrData 断言异常") | |||
} | |||
pems := strings.Split(string(certData), certEnd) | |||
for _, c := range pems { | |||
if block, _ := pem.Decode([]byte(c + certEnd)); block != nil { | |||
cert, err := x509.ParseCertificate(block.Bytes) | |||
if err != nil { | |||
continue | |||
} | |||
if !allowSignatureAlgorithm[cert.SignatureAlgorithm.String()] { | |||
continue | |||
} | |||
name := cert.Issuer.String() | |||
serialNumber := cert.SerialNumber.String() | |||
h := md5.New() | |||
h.Write([]byte(name)) | |||
h.Write([]byte(serialNumber)) | |||
if sn == gopay.NULL { | |||
sn += hex.EncodeToString(h.Sum(nil)) | |||
} else { | |||
sn += "_" + hex.EncodeToString(h.Sum(nil)) | |||
} | |||
} | |||
} | |||
if sn == gopay.NULL { | |||
return gopay.NULL, errors.New("failed to get sn,please check your cert") | |||
} | |||
return sn, nil | |||
} | |||
// 获取支付宝参数签名 | |||
// bm:签名参数 | |||
// signType:签名类型,alipay.RSA 或 alipay.RSA2 | |||
// privateKey:应用私钥,支持PKCS1和PKCS8 | |||
func GetRsaSign(bm gopay.BodyMap, signType string, privateKey *rsa.PrivateKey) (sign string, err error) { | |||
var ( | |||
h hash.Hash | |||
hashs crypto.Hash | |||
encryptedBytes []byte | |||
) | |||
switch signType { | |||
case RSA: | |||
h = sha1.New() | |||
hashs = crypto.SHA1 | |||
case RSA2: | |||
h = sha256.New() | |||
hashs = crypto.SHA256 | |||
default: | |||
h = sha256.New() | |||
hashs = crypto.SHA256 | |||
} | |||
signParams := bm.EncodeAliPaySignParams() | |||
if _, err = h.Write([]byte(signParams)); err != nil { | |||
return | |||
} | |||
if encryptedBytes, err = rsa.SignPKCS1v15(rand.Reader, privateKey, hashs, h.Sum(nil)); err != nil { | |||
return gopay.NULL, fmt.Errorf("[%w]: %+v", gopay.SignatureErr, err) | |||
} | |||
sign = base64.StdEncoding.EncodeToString(encryptedBytes) | |||
return | |||
} | |||
func (a *Client) getRsaSign(bm gopay.BodyMap, signType string) (sign string, err error) { | |||
var ( | |||
h hash.Hash | |||
hashs crypto.Hash | |||
encryptedBytes []byte | |||
) | |||
switch signType { | |||
case RSA: | |||
h = sha1.New() | |||
hashs = crypto.SHA1 | |||
case RSA2: | |||
h = sha256.New() | |||
hashs = crypto.SHA256 | |||
default: | |||
h = sha256.New() | |||
hashs = crypto.SHA256 | |||
} | |||
signParams := bm.EncodeAliPaySignParams() | |||
if a.DebugSwitch == gopay.DebugOn { | |||
a.logger.Debugf("Alipay_Request_SignStr: %s", signParams) | |||
} | |||
if _, err = h.Write([]byte(signParams)); err != nil { | |||
return | |||
} | |||
if encryptedBytes, err = rsa.SignPKCS1v15(rand.Reader, a.privateKey, hashs, h.Sum(nil)); err != nil { | |||
return gopay.NULL, fmt.Errorf("[%w]: %+v", gopay.SignatureErr, err) | |||
} | |||
sign = base64.StdEncoding.EncodeToString(encryptedBytes) | |||
return | |||
} | |||
// =============================== 获取SignData =============================== | |||
// 需注意的是,公钥签名模式和公钥证书签名模式的不同之处 | |||
// 验签文档:https://opendocs.alipay.com/open/200/106120 | |||
func (a *Client) getSignData(bs []byte, alipayCertSN string) (signData string, err error) { | |||
var ( | |||
str = string(bs) | |||
indexStart = strings.Index(str, `_response":`) | |||
indexEnd int | |||
) | |||
indexStart = indexStart + 11 | |||
bsLen := len(str) | |||
if alipayCertSN != "" { | |||
// 公钥证书模式 | |||
if alipayCertSN != a.AliPayPublicCertSN { | |||
return gopay.NULL, fmt.Errorf("[%w], 当前使用的支付宝公钥证书SN[%s]与网关响应报文中的SN[%s]不匹配", gopay.CertNotMatchErr, a.AliPayPublicCertSN, alipayCertSN) | |||
} | |||
indexEnd = strings.Index(str, `,"alipay_cert_sn":`) | |||
if indexEnd > indexStart && bsLen > indexStart { | |||
signData = str[indexStart:indexEnd] | |||
return | |||
} | |||
return gopay.NULL, fmt.Errorf("[%w], value: %s", gopay.GetSignDataErr, str) | |||
} | |||
// 普通公钥模式 | |||
indexEnd = strings.Index(str, `,"sign":`) | |||
if indexEnd > indexStart && bsLen > indexStart { | |||
signData = str[indexStart:indexEnd] | |||
return | |||
} | |||
return gopay.NULL, fmt.Errorf("[%w], value: %s", gopay.GetSignDataErr, str) | |||
} | |||
// =============================== 同步验签 =============================== | |||
// VerifySyncSign 支付宝同步返回验签(公钥模式) | |||
// 注意:APP支付,手机网站支付,电脑网站支付,身份认证开始认证 不支持同步返回验签 | |||
// aliPayPublicKey:支付宝平台获取的支付宝公钥 | |||
// signData:待验签参数,aliRsp.SignData | |||
// sign:待验签sign,aliRsp.Sign | |||
// 返回参数ok:是否验签通过 | |||
// 返回参数err:错误信息 | |||
// 验签文档:https://opendocs.alipay.com/open/200/106120 | |||
func VerifySyncSign(aliPayPublicKey, signData, sign string) (ok bool, err error) { | |||
// 支付宝公钥验签 | |||
pKey := xrsa.FormatAlipayPublicKey(aliPayPublicKey) | |||
if err = verifySign(signData, sign, RSA2, pKey); err != nil { | |||
return false, err | |||
} | |||
return true, nil | |||
} | |||
// VerifySyncSignWithCert 支付宝同步返回验签(公钥证书模式) | |||
// 注意:APP支付,手机网站支付,电脑网站支付,身份认证开始认证 不支持同步返回验签 | |||
// aliPayPublicKeyCert:支付宝公钥证书存放路径 alipayPublicCert.crt 或文件内容[]byte | |||
// signData:待验签参数,aliRsp.SignData | |||
// sign:待验签sign,aliRsp.Sign | |||
// 返回参数ok:是否验签通过 | |||
// 返回参数err:错误信息 | |||
// 验签文档:https://opendocs.alipay.com/open/200/106120 | |||
func VerifySyncSignWithCert(alipayPublicKeyCert any, signData, sign string) (ok bool, err error) { | |||
switch alipayPublicKeyCert.(type) { | |||
case string: | |||
if alipayPublicKeyCert == gopay.NULL { | |||
return false, errors.New("aliPayPublicKeyPath is null") | |||
} | |||
case []byte: | |||
default: | |||
return false, errors.New("alipayPublicKeyCert type assert error") | |||
} | |||
if err = verifySignCert(signData, sign, RSA2, alipayPublicKeyCert); err != nil { | |||
return false, err | |||
} | |||
return true, nil | |||
} | |||
func (a *Client) autoVerifySignByCert(sign, signData string, signDataErr error) (err error) { | |||
if a.autoSign && a.aliPayPublicKey != nil { | |||
if a.DebugSwitch == gopay.DebugOn { | |||
a.logger.Debugf("Alipay_SyncSignData: %s, Sign=[%s]", signData, sign) | |||
} | |||
// 只有证书验签时,才可能出现此error | |||
if signDataErr != nil { | |||
return signDataErr | |||
} | |||
signBytes, _ := base64.StdEncoding.DecodeString(sign) | |||
sum256 := sha256.Sum256([]byte(signData)) | |||
if err = rsa.VerifyPKCS1v15(a.aliPayPublicKey, crypto.SHA256, sum256[:], signBytes); err != nil { | |||
return fmt.Errorf("[%w]: %v", gopay.VerifySignatureErr, err) | |||
} | |||
} | |||
return nil | |||
} | |||
// =============================== 异步验签 =============================== | |||
// VerifySign 支付宝异步通知验签(公钥模式) | |||
// 注意:APP支付,手机网站支付,电脑网站支付 暂不支持同步返回验签 | |||
// alipayPublicKey:支付宝平台获取的支付宝公钥 | |||
// notifyBean:此参数为异步通知解析的结构体或BodyMap:notifyReq 或 bm,推荐通 BodyMap 验签 | |||
// 返回参数ok:是否验签通过 | |||
// 返回参数err:错误信息 | |||
// 验签文档:https://opendocs.alipay.com/common/02mse7 | |||
func VerifySign(alipayPublicKey string, notifyBean any) (ok bool, err error) { | |||
if alipayPublicKey == gopay.NULL || notifyBean == nil { | |||
return false, errors.New("alipayPublicKey or notifyBean is nil") | |||
} | |||
var ( | |||
bodySign string | |||
bodySignType string | |||
signData string | |||
bm = make(gopay.BodyMap) | |||
) | |||
if reflect.ValueOf(notifyBean).Kind() == reflect.Map { | |||
if bm, ok = notifyBean.(gopay.BodyMap); ok { | |||
bodySign = bm.GetString("sign") | |||
bodySignType = bm.GetString("sign_type") | |||
bm.Remove("sign") | |||
bm.Remove("sign_type") | |||
signData = bm.EncodeAliPaySignParams() | |||
} | |||
} else { | |||
bs, err := json.Marshal(notifyBean) | |||
if err != nil { | |||
return false, fmt.Errorf("json.Marshal:%w", err) | |||
} | |||
if err = json.Unmarshal(bs, &bm); err != nil { | |||
return false, fmt.Errorf("json.Unmarshal(%s):%w", string(bs), err) | |||
} | |||
bodySign = bm.GetString("sign") | |||
bodySignType = bm.GetString("sign_type") | |||
bm.Remove("sign") | |||
bm.Remove("sign_type") | |||
signData = bm.EncodeAliPaySignParams() | |||
} | |||
pKey := xrsa.FormatAlipayPublicKey(alipayPublicKey) | |||
if err = verifySign(signData, bodySign, bodySignType, pKey); err != nil { | |||
return false, err | |||
} | |||
return true, nil | |||
} | |||
// 支付宝异步通知验签(公钥证书模式) | |||
// 注意:APP支付,手机网站支付,电脑网站支付 暂不支持同步返回验签 | |||
// aliPayPublicKeyCert:支付宝公钥证书存放路径 alipayPublicCert.crt 或文件内容[]byte | |||
// notifyBean:此参数为异步通知解析的结构体或BodyMap:notifyReq 或 bm,推荐通 BodyMap 验签 | |||
// 返回参数ok:是否验签通过 | |||
// 返回参数err:错误信息 | |||
// 验签文档:https://opendocs.alipay.com/common/02mse7 | |||
func VerifySignWithCert(aliPayPublicKeyCert, notifyBean any) (ok bool, err error) { | |||
if notifyBean == nil || aliPayPublicKeyCert == nil { | |||
return false, errors.New("aliPayPublicKeyCert or notifyBean is nil") | |||
} | |||
switch aliPayPublicKeyCert.(type) { | |||
case string: | |||
if aliPayPublicKeyCert == gopay.NULL { | |||
return false, errors.New("aliPayPublicKeyPath is null") | |||
} | |||
case []byte: | |||
default: | |||
return false, errors.New("aliPayPublicKeyCert type assert error") | |||
} | |||
var bm gopay.BodyMap | |||
switch nb := notifyBean.(type) { | |||
case map[string]any: | |||
bm = make(gopay.BodyMap, len(nb)) | |||
for key, val := range nb { | |||
bm[key] = val | |||
} | |||
case gopay.BodyMap: | |||
bm = nb | |||
default: | |||
bs, err := json.Marshal(notifyBean) | |||
if err != nil { | |||
return false, fmt.Errorf("json.Marshal:%w", err) | |||
} | |||
if err = json.Unmarshal(bs, &bm); err != nil { | |||
return false, fmt.Errorf("json.Unmarshal(%s):%w", string(bs), err) | |||
} | |||
} | |||
bodySign := bm.GetString("sign") | |||
bodySignType := bm.GetString("sign_type") | |||
bm.Remove("sign") | |||
bm.Remove("sign_type") | |||
signData := bm.EncodeAliPaySignParams() | |||
if err = verifySignCert(signData, bodySign, bodySignType, aliPayPublicKeyCert); err != nil { | |||
return false, err | |||
} | |||
return true, nil | |||
} | |||
// =============================== 通用底层验签方法 =============================== | |||
func verifySign(signData, sign, signType, alipayPublicKey string) (err error) { | |||
var ( | |||
h hash.Hash | |||
hashs crypto.Hash | |||
) | |||
publicKey, err := xpem.DecodePublicKey([]byte(alipayPublicKey)) | |||
if err != nil { | |||
return err | |||
} | |||
signBytes, _ := base64.StdEncoding.DecodeString(sign) | |||
switch signType { | |||
case RSA: | |||
hashs = crypto.SHA1 | |||
case RSA2: | |||
hashs = crypto.SHA256 | |||
default: | |||
hashs = crypto.SHA256 | |||
} | |||
h = hashs.New() | |||
h.Write([]byte(signData)) | |||
if err = rsa.VerifyPKCS1v15(publicKey, hashs, h.Sum(nil), signBytes); err != nil { | |||
return fmt.Errorf("[%w]: %v", gopay.VerifySignatureErr, err) | |||
} | |||
return nil | |||
} | |||
func verifySignCert(signData, sign, signType string, alipayPublicKeyCert any) (err error) { | |||
var ( | |||
h hash.Hash | |||
hashs crypto.Hash | |||
bytes []byte | |||
) | |||
if v, ok := alipayPublicKeyCert.(string); ok { | |||
if bytes, err = os.ReadFile(v); err != nil { | |||
return fmt.Errorf("支付宝公钥文件读取失败: %w", err) | |||
} | |||
} else { | |||
bytes, ok = alipayPublicKeyCert.([]byte) | |||
if !ok { | |||
return fmt.Errorf("支付宝公钥读取失败: %w", err) | |||
} | |||
} | |||
publicKey, err := xpem.DecodePublicKey(bytes) | |||
if err != nil { | |||
return err | |||
} | |||
signBytes, _ := base64.StdEncoding.DecodeString(sign) | |||
switch signType { | |||
case RSA: | |||
hashs = crypto.SHA1 | |||
case RSA2: | |||
hashs = crypto.SHA256 | |||
default: | |||
hashs = crypto.SHA256 | |||
} | |||
h = hashs.New() | |||
h.Write([]byte(signData)) | |||
if err = rsa.VerifyPKCS1v15(publicKey, hashs, h.Sum(nil), signBytes); err != nil { | |||
return fmt.Errorf("[%w]: %v", gopay.VerifySignatureErr, err) | |||
} | |||
return nil | |||
} |
@@ -1,148 +0,0 @@ | |||
package alipay | |||
import ( | |||
"os" | |||
"testing" | |||
"github.com/go-pay/crypto/xrsa" | |||
"github.com/go-pay/gopay" | |||
"github.com/go-pay/xlog" | |||
) | |||
func TestSyncVerifySign(t *testing.T) { | |||
signData := `{"code":"10000","msg":"Success","buyer_logon_id":"854***@qq.com","buyer_pay_amount":"0.01","buyer_user_id":"2088102363632794","fund_bill_list":[{"amount":"0.01","fund_channel":"PCREDIT"}],"gmt_payment":"2019-08-29 20:14:05","invoice_amount":"0.01","out_trade_no":"GZ201901301040361012","point_amount":"0.00","receipt_amount":"0.01","total_amount":"0.01","trade_no":"2019082922001432790585537960"}` | |||
sign := "bk3SzX0CZRI811IJioS2XKQHcgMixUT8mYyGQj+vcOAQas7GIYi6LpykqqSc3m7+yvqoG0TdX/c2JjYnpw/J53JxtC2IC4vsLuIPIgghVo5qafsfSxEJ22w20RZDatI2dYqFVcj8Jp+4aesQ8zMMNw7cX9NLyk7kw3DecYeyQp+zrZMueZPqLh88Z+54G+e6QuSU++0ouqQVd4PkpPqy6YI+8MdMUX4Ve0jOQxMmYH8BC6n5ZsTH/uEaLEtzYVZdSw/xdSQ7K1SH73aEH8XbRYx6rL7RkKksrdvhezX+ThDjQ+fTWjvNFrGcg3fmqXRy2elvoalu+BQmqlkWWjEJYA==" | |||
alipayPublicKey := "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAp8gueNlkbiDidz6FBQEBpqoRgH8h7JtsPtYW0nzAqy1MME4mFnDSMfSKlreUomS3a55gmBopL1eF4/Km/dEnaL5tCY9+24SKn1D4iyls+lvz/ZjvUjVwxoUYBh8kkcxMZSDeDz8//o+9qZTrICVP2a4sBB8T0XmU4gxfw8FsmtoomBH1nLk3AO7wgRN2a3+SRSAmxrhIGDmF1lljSlhY32eJpJ2TZQKaWNW+7yDBU/0Wt3kQVY84vr14yYagnSCiIfqyVFqePayRtmVJDr5qvSXr51tdqs2zKZCu+26X7JAF4BSsaq4gmY5DmDTm4TohCnBduI1+bPGD+igVmtl05wIDAQAB" | |||
pKey := xrsa.FormatAlipayPublicKey(alipayPublicKey) | |||
err := verifySign(signData, sign, RSA2, pKey) | |||
if err != nil { | |||
xlog.Errorf("verifySign(),error:%+v", err) | |||
} | |||
} | |||
func TestVerifySign(t *testing.T) { | |||
// 测试,假数据,无法验签通过 | |||
publicKey := "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAp8gueNlkbiDidz6FBQEBpqoRgH8h7JtsPtYW0nzAqy1MME4mFnDSMfSKlreUomS3a55gmBopL1eF4/Km/dEnaL5tCY9+24SKn1D4iyls+lvz/ZjvUjVwxoUYBh8kkcxMZSDeDz8//o+9qZTrICVP2a4sBB8T0XmU4gxfw8FsmtoomBH1nLk3AO7wgRN2a3+SRSAmxrhIGDmF1lljSlhY32eJpJ2TZQKaWNW+7yDBU/0Wt3kQVY84vr14yYagnSCiIfqyVFqePayRtmVJDr5qvSXr51tdqs2zKZCu+26X7JAF4BSsaq4gmY5DmDTm4TohCnBduI1+bPGD+igVmtl05wIDAQAB" | |||
bm := make(gopay.BodyMap) | |||
bm.Set("sign", "f19WZ3rko3cVpSG3uEEJF0eb4DuZVLt4/GXnNw9qg8iHUsJLkav0V91R5SSTDhW5lgkn3Xhq7TkFRJiDXdVXMu3XUlsONArp3Iu4tXagYJWt9jbcnc2/l29VYDXPLNcs7BXEWFEaCZLutQY2U82AumEwSc1XBKtsLC4mVX3M3f/ExFQHWklJEBHArYBGe4535uFRlsT2fk6WVuX8CuYZatCrVF1o02xMS5aD29eICPkmin/h87OcTbE1syktyCU1WVgcypagUdGGPTF0SVDFf7FRov7+w7fiCGGGL10tNlK/MLzcewtN2dyGF6RLUX3m+HQ7sNEk2wylRXLNUFig==") | |||
bm.Set("seller_email", "imonkey@100tal.com") | |||
bm.Set("sign_type", RSA2) | |||
bm.Set("total_amount", "0.02") | |||
bm.Set("buyer_id", "2088812847201551") | |||
bm.Set("invoice_amount", "0.02") | |||
bm.Set("fund_bill_list", `[{"amount":"0.02","fundChannel":"PCREDIT"}]`) | |||
bm.Set("trade_no", "2020010222001401551430614892") | |||
bm.Set("receipt_amount", "0.02") | |||
bm.Set("buyer_pay_amount", "0.02") | |||
bm.Set("notify_time", "2020-01-02 16:18:21") | |||
bm.Set("subject", "商品") | |||
bm.Set("auth_app_id", "2015102700040153") | |||
bm.Set("charset", "utf-8") | |||
bm.Set("point_amount", "0.00") | |||
bm.Set("notify_type", "trade_status_sync") | |||
bm.Set("out_trade_no", "1086209247658383466") | |||
bm.Set("gmt_payment", "2020-01-02 16:18:21") | |||
bm.Set("trade_status", "TRADE_SUCCESS") | |||
bm.Set("version", "1.0") | |||
bm.Set("buyer_logon_id", "185****2920") | |||
bm.Set("gmt_create", "2020-01-02 16:18:21") | |||
bm.Set("app_id", "2015102700040153") | |||
bm.Set("seller_id", "2088631240818980") | |||
bm.Set("notify_id", "2020010200222161821001551453140885") | |||
ok, err := VerifySign(publicKey, bm) | |||
if err != nil { | |||
xlog.Errorf("VerifySign(%+v),error:%+v", bm, err) | |||
return | |||
} | |||
xlog.Debug("OK:", ok) | |||
} | |||
func TestVerifySignWithCert(t *testing.T) { | |||
// 测试,假数据,无法验签通过 | |||
bm := make(gopay.BodyMap) | |||
bm.Set("sign", "kPbQIjX+xQc8F0/A6/AocELIjhhZnGbcBN6G4MM/HmfWL4ZiHM6fWl5NQhzXJusaklZ1LFuMo+lHQUELAYeugH8LYFvxnNajOvZhuxNFbN2LhF0l/KL8ANtj8oyPM4NN7Qft2kWJTDJUpQOzCzNnV9hDxh5AaT9FPqRS6ZKxnzM=") | |||
bm.Set("sign_type", RSA2) | |||
bm.Set("total_amount", "2.00") | |||
bm.Set("buyer_id", "2088102116773037") | |||
bm.Set("body", "大乐透2.1") | |||
bm.Set("trade_no", "2016071921001003030200089909") | |||
bm.Set("refund_fee", "0.00") | |||
bm.Set("notify_time", "2016-07-19 14:10:49") | |||
bm.Set("subject", "大乐透2.1") | |||
bm.Set("charset", "utf-8") | |||
bm.Set("notify_type", "trade_status_sync") | |||
bm.Set("out_trade_no", "0719141034-6418") | |||
bm.Set("gmt_close", "2016-07-19 14:10:46") | |||
bm.Set("gmt_payment", "2016-07-19 14:10:47") | |||
bm.Set("trade_status", "TRADE_SUCCESS") | |||
bm.Set("version", "1.0") | |||
bm.Set("gmt_create", "2016-07-19 14:10:44") | |||
bm.Set("app_id", "2015102700040153") | |||
bm.Set("seller_id", "2088102119685838") | |||
bm.Set("notify_id", "4a91b7a78a503640467525113fb7d8bg8e") | |||
// filePath | |||
filepath := "/cert/alipayPublicCert.crt" | |||
ok, err := VerifySignWithCert(filepath, bm) | |||
if err != nil { | |||
xlog.Errorf("VerifySignWithCert(%+v),error:%+v", bm, err) | |||
return | |||
} | |||
xlog.Debug("VerifySignWithCert", "OK:", ok) | |||
// fileByte | |||
bts, err := os.ReadFile(filepath) | |||
if err != nil { | |||
xlog.Errorf("VerifySignWithCert(%+v),error:%+v", bm, err) | |||
return | |||
} | |||
ok, err = VerifySignWithCert(bts, bm) | |||
if err != nil { | |||
xlog.Errorf("VerifySignWithCert(%+v),error:%+v", bm, err) | |||
return | |||
} | |||
xlog.Debug("VerifySignWithCert", "OK:", ok) | |||
} | |||
func TestGetCertSN(t *testing.T) { | |||
sn, err := GetCertSN("cert/alipayPublicCert.crt") | |||
if err != nil { | |||
xlog.Errorf("GetCertSN(),error:%+v", err) | |||
return | |||
} | |||
xlog.Debug(sn) | |||
pubKeyPath := "cert/appPublicCert.crt" | |||
sn, err = GetCertSN(pubKeyPath) | |||
if err != nil { | |||
xlog.Errorf("GetCertSN(),error:%+v", err) | |||
return | |||
} | |||
xlog.Debug(sn) | |||
bts, _ := os.ReadFile(pubKeyPath) | |||
sn, err = GetCertSN(bts) | |||
if err != nil { | |||
xlog.Errorf("GetCertSN(),error:%+v", err) | |||
return | |||
} | |||
xlog.Debug(sn) | |||
rootCrtPath := "cert/alipayRootCert.crt" | |||
sn, err = GetRootCertSN(rootCrtPath) | |||
if err != nil { | |||
xlog.Errorf("GetCertSN(),error:%+v", err) | |||
return | |||
} | |||
xlog.Debug(sn) | |||
bts, _ = os.ReadFile(rootCrtPath) | |||
sn, err = GetRootCertSN(bts) | |||
if err != nil { | |||
xlog.Errorf("GetCertSN(),error:%+v", err) | |||
return | |||
} | |||
xlog.Debug(sn) | |||
// Output: | |||
// 04afd423ea5bd6f5c5482854ed73278c | |||
// 4498aaa8ab0c8986c15c41b36186db7d | |||
// 4498aaa8ab0c8986c15c41b36186db7d | |||
// 687b59193f3f462dd5336e5abf83c5d8_02941eef3187dddf3d3b83462e1dfcf6 | |||
// 687b59193f3f462dd5336e5abf83c5d8_02941eef3187dddf3d3b83462e1dfcf6 | |||
} |
@@ -1,51 +0,0 @@ | |||
package alipay | |||
import ( | |||
"context" | |||
"encoding/json" | |||
"fmt" | |||
"github.com/go-pay/gopay" | |||
) | |||
// zoloz.authentication.smilepay.initialize(刷脸支付初始化) | |||
// 文档地址:https://opendocs.alipay.com/open/2f7c1d5f_zoloz.authentication.smilepay.initialize | |||
func (a *Client) ZolozAuthenticationSmilepayInitialize(ctx context.Context, bm gopay.BodyMap) (aliRsp *ZolozAuthenticationSmilepayInitializeRsp, err error) { | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "zoloz.authentication.smilepay.initialize"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(ZolozAuthenticationSmilepayInitializeRsp) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// zoloz.authentication.customer.ftoken.query(查询刷脸结果信息接口) | |||
// 文档地址:https://opendocs.alipay.com/open/c8e4d285_zoloz.authentication.customer.ftoken.query | |||
func (a *Client) ZolozAuthenticationCustomerFtokenQuery(ctx context.Context, bm gopay.BodyMap) (aliRsp *ZolozAuthenticationCustomerFtokenQueryRsp, err error) { | |||
err = bm.CheckEmptyError("ftoken", "biz_type") | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "zoloz.authentication.customer.ftoken.query"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(ZolozAuthenticationCustomerFtokenQueryRsp) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} |
@@ -1,81 +0,0 @@ | |||
package alipay | |||
import ( | |||
"context" | |||
"encoding/json" | |||
"errors" | |||
"fmt" | |||
"github.com/go-pay/gopay" | |||
) | |||
// alipay.open.auth.token.app(换取应用授权令牌) | |||
// 文档地址:https://opendocs.alipay.com/isv/04h3uf | |||
func (a *Client) OpenAuthTokenApp(ctx context.Context, bm gopay.BodyMap) (aliRsp *OpenAuthTokenAppResponse, err error) { | |||
if bm.GetString("code") == gopay.NULL && bm.GetString("refresh_token") == gopay.NULL { | |||
return nil, errors.New("code and refresh_token are not allowed to be null at the same time") | |||
} | |||
err = bm.CheckEmptyError("grant_type") | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "alipay.open.auth.token.app"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(OpenAuthTokenAppResponse) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// alipay.open.auth.token.app.query(查询某个应用授权AppAuthToken的授权信息) | |||
// 文档地址:https://opendocs.alipay.com/isv/04hgcp | |||
func (a *Client) OpenAuthTokenAppQuery(ctx context.Context, bm gopay.BodyMap) (aliRsp *OpenAuthTokenAppQueryResponse, err error) { | |||
err = bm.CheckEmptyError("app_auth_token") | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "alipay.open.auth.token.app.query"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(OpenAuthTokenAppQueryResponse) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// alipay.open.auth.appauth.invite.create(ISV向商户发起应用授权邀约) | |||
// 文档地址:https://opendocs.alipay.com/isv/06evao | |||
func (a *Client) OpenAuthTokenAppInviteCreate(ctx context.Context, bm gopay.BodyMap) (aliRsp *OpenAuthTokenAppInviteCreateResponse, err error) { | |||
if err = bm.CheckEmptyError("auth_app_id"); err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "alipay.open.auth.appauth.invite.create"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(OpenAuthTokenAppInviteCreateResponse) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} |
@@ -1,32 +0,0 @@ | |||
package alipay | |||
import ( | |||
"context" | |||
"encoding/json" | |||
"fmt" | |||
"github.com/go-pay/gopay" | |||
) | |||
// alipay.open.app.api.query(查询应用可申请的接口出参敏感字段列表) | |||
// 文档地址:https://opendocs.alipay.com/isv/04f74n | |||
func (a *Client) OpenAppApiQuery(ctx context.Context, bm gopay.BodyMap) (aliRsp *OpenAppApiQueryResponse, err error) { | |||
err = bm.CheckEmptyError("app_auth_token") | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "alipay.open.app.api.query"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(OpenAppApiQueryResponse) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} |
@@ -1,36 +0,0 @@ | |||
package alipay | |||
import ( | |||
"context" | |||
"encoding/base64" | |||
"encoding/json" | |||
"fmt" | |||
"github.com/go-pay/gopay" | |||
) | |||
// alipay.open.app.alipaycert.download(应用支付宝公钥证书下载) | |||
// 文档地址:https://opendocs.alipay.com/apis/api_9/alipay.open.app.alipaycert.download | |||
func (a *Client) PublicCertDownload(ctx context.Context, bm gopay.BodyMap) (aliRsp *PublicCertDownloadRsp, err error) { | |||
err = bm.CheckEmptyError("alipay_cert_sn") | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "alipay.open.app.alipaycert.download"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(PublicCertDownloadRsp) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
certBs, err := base64.StdEncoding.DecodeString(aliRsp.Response.AlipayCertContent) | |||
if err != nil { | |||
return nil, fmt.Errorf("AlipayCertContent(%s)_DecodeErr:%+v", aliRsp.Response.AlipayCertContent, err) | |||
} | |||
aliRsp.Response.AlipayCertContent = string(certBs) | |||
return aliRsp, nil | |||
} |
@@ -1,122 +0,0 @@ | |||
package alipay | |||
import ( | |||
"testing" | |||
"github.com/go-pay/gopay" | |||
"github.com/go-pay/gopay/alipay/cert" | |||
"github.com/go-pay/xlog" | |||
) | |||
func TestClient_SystemOauthToken(t *testing.T) { | |||
// 请求参数 | |||
bm := make(gopay.BodyMap) | |||
bm.Set("grant_type", "authorization_code") | |||
bm.Set("code", "3a06216ac8f84b8c93507bb9774bWX11") | |||
// 发起请求 | |||
aliRsp, err := client.SystemOauthToken(ctx, bm) | |||
if err != nil { | |||
if bizErr, ok := IsBizError(err); ok { | |||
xlog.Errorf("%+v", bizErr) | |||
// do something | |||
return | |||
} | |||
return | |||
} | |||
xlog.Debug("aliRsp:", *aliRsp) | |||
xlog.Debug("aliRsp:", aliRsp.Response.AccessToken) | |||
xlog.Debug("aliRsp:", aliRsp.SignData) | |||
} | |||
func TestClient_OpenAuthTokenApp(t *testing.T) { | |||
// 请求参数 | |||
bm := make(gopay.BodyMap) | |||
bm.Set("grant_type", "authorization_code"). | |||
Set("code", "866185490c4e40efa9f71efea6766X02") | |||
// 发起请求 | |||
aliRsp, err := client.OpenAuthTokenApp(ctx, bm) | |||
if err != nil { | |||
if bizErr, ok := IsBizError(err); ok { | |||
xlog.Errorf("%+v", bizErr) | |||
// do something | |||
return | |||
} | |||
return | |||
} | |||
xlog.Debug("aliRsp:", *aliRsp) | |||
} | |||
func TestClient_OpenAuthTokenAppQuery(t *testing.T) { | |||
// 请求参数 | |||
bm := make(gopay.BodyMap) | |||
bm.Set("app_auth_token", "202212BB9e1cd0c2e0ab489393aa2570ec4faX87") | |||
// 发起请求 | |||
aliRsp, err := client.OpenAuthTokenAppQuery(ctx, bm) | |||
if err != nil { | |||
if bizErr, ok := IsBizError(err); ok { | |||
xlog.Errorf("%+v", bizErr) | |||
// do something | |||
return | |||
} | |||
return | |||
} | |||
xlog.Debug("aliRsp:", *aliRsp) | |||
} | |||
func TestClient_UserInfoAuth(t *testing.T) { | |||
// 请求参数 | |||
bm := make(gopay.BodyMap) | |||
// 接口权限值,目前只支持auth_user和auth_base两个值。具体说明看文档介绍 | |||
bm.Set("scopes", []string{"auth_user"}). | |||
Set("state", "init") | |||
// 发起请求 | |||
html, err := client.UserInfoAuth(ctx, bm) | |||
if err != nil { | |||
if bizErr, ok := IsBizError(err); ok { | |||
xlog.Errorf("%+v", bizErr) | |||
// do something | |||
return | |||
} | |||
return | |||
} | |||
xlog.Debugf("html: %s", string(html)) | |||
} | |||
func TestClient_UserInfoShare(t *testing.T) { | |||
// 发起请求 | |||
aliRsp, err := client.UserInfoShare(ctx, "auth_token") | |||
if err != nil { | |||
if bizErr, ok := IsBizError(err); ok { | |||
xlog.Errorf("%+v", bizErr) | |||
// do something | |||
return | |||
} | |||
return | |||
} | |||
xlog.Debug("aliRsp:", *aliRsp) | |||
// 同步返回验签 | |||
ok, err := VerifySyncSignWithCert(cert.AlipayPublicContentRSA2, aliRsp.SignData, aliRsp.Sign) | |||
if err != nil { | |||
xlog.Error(err) | |||
} | |||
xlog.Debug("ok:", ok) | |||
} | |||
func TestClient_PublicCertDownload(t *testing.T) { | |||
// 请求参数 | |||
bm := make(gopay.BodyMap) | |||
bm.Set("alipay_cert_sn", "52c63ed47b57c049b4bc9bea9da02c2a") | |||
// 发起请求 | |||
aliRsp, err := client.PublicCertDownload(ctx, bm) | |||
if err != nil { | |||
//xlog.Errorf("client.UserInfoShare(),error:%+v", err) | |||
return | |||
} | |||
xlog.Debugf("aliRsp.Response.AlipayCertContent:\n %s", aliRsp.Response.AlipayCertContent) | |||
} |
@@ -1,109 +0,0 @@ | |||
package alipay | |||
import ( | |||
"crypto/md5" | |||
"crypto/x509" | |||
"encoding/hex" | |||
"encoding/pem" | |||
"errors" | |||
"os" | |||
"strings" | |||
"github.com/go-pay/gopay" | |||
) | |||
// 允许进行 sn 提取的证书签名算法 | |||
var allowSignatureAlgorithm = map[string]bool{ | |||
"MD2-RSA": true, | |||
"MD5-RSA": true, | |||
"SHA1-RSA": true, | |||
"SHA256-RSA": true, | |||
"SHA384-RSA": true, | |||
"SHA512-RSA": true, | |||
"SHA256-RSAPSS": true, | |||
"SHA384-RSAPSS": true, | |||
"SHA512-RSAPSS": true, | |||
} | |||
// certPathOrData x509证书文件路径(appPublicCert.crt、alipayPublicCert.crt) 或证书 buffer | |||
// 返回 sn:证书序列号(app_cert_sn、alipay_cert_sn) | |||
// 返回 err:error 信息 | |||
func getCertSN(certPathOrData any) (sn string, err error) { | |||
var certData []byte | |||
switch pathOrData := certPathOrData.(type) { | |||
case string: | |||
certData, err = os.ReadFile(pathOrData) | |||
if err != nil { | |||
return gopay.NULL, err | |||
} | |||
case []byte: | |||
certData = pathOrData | |||
default: | |||
return gopay.NULL, errors.New("certPathOrData 证书类型断言错误") | |||
} | |||
if block, _ := pem.Decode(certData); block != nil { | |||
cert, err := x509.ParseCertificate(block.Bytes) | |||
if err != nil { | |||
return gopay.NULL, err | |||
} | |||
name := cert.Issuer.String() | |||
serialNumber := cert.SerialNumber.String() | |||
h := md5.New() | |||
h.Write([]byte(name)) | |||
h.Write([]byte(serialNumber)) | |||
sn = hex.EncodeToString(h.Sum(nil)) | |||
} | |||
if sn == gopay.NULL { | |||
return gopay.NULL, errors.New("failed to get sn,please check your cert") | |||
} | |||
return sn, nil | |||
} | |||
// rootCertPathOrData x509证书文件路径(alipayRootCert.crt) 或文件 buffer | |||
// 返回 sn:证书序列号(alipay_root_cert_sn) | |||
// 返回 err:error 信息 | |||
func getRootCertSN(rootCertPathOrData any) (sn string, err error) { | |||
var ( | |||
certData []byte | |||
certEnd = `-----END CERTIFICATE-----` | |||
) | |||
switch pathOrData := rootCertPathOrData.(type) { | |||
case string: | |||
certData, err = os.ReadFile(pathOrData) | |||
if err != nil { | |||
return gopay.NULL, err | |||
} | |||
case []byte: | |||
certData = pathOrData | |||
default: | |||
return gopay.NULL, errors.New("rootCertPathOrData 断言异常") | |||
} | |||
pems := strings.Split(string(certData), certEnd) | |||
for _, c := range pems { | |||
if block, _ := pem.Decode([]byte(c + certEnd)); block != nil { | |||
cert, err := x509.ParseCertificate(block.Bytes) | |||
if err != nil { | |||
continue | |||
} | |||
if !allowSignatureAlgorithm[cert.SignatureAlgorithm.String()] { | |||
continue | |||
} | |||
name := cert.Issuer.String() | |||
serialNumber := cert.SerialNumber.String() | |||
h := md5.New() | |||
h.Write([]byte(name)) | |||
h.Write([]byte(serialNumber)) | |||
if sn == gopay.NULL { | |||
sn += hex.EncodeToString(h.Sum(nil)) | |||
} else { | |||
sn += "_" + hex.EncodeToString(h.Sum(nil)) | |||
} | |||
} | |||
} | |||
if sn == gopay.NULL { | |||
return gopay.NULL, errors.New("failed to get sn,please check your cert") | |||
} | |||
return sn, nil | |||
} |
@@ -1,125 +0,0 @@ | |||
package alipay | |||
import ( | |||
"crypto/rsa" | |||
"fmt" | |||
"time" | |||
"github.com/go-pay/crypto/xpem" | |||
"github.com/go-pay/crypto/xrsa" | |||
"github.com/go-pay/gopay" | |||
"github.com/go-pay/gopay/pkg/xhttp" | |||
"github.com/go-pay/xlog" | |||
) | |||
// ClientV3 支付宝 V3 | |||
type ClientV3 struct { | |||
AppId string | |||
AppCertSN string | |||
AliPayPublicCertSN string | |||
AliPayRootCertSN string | |||
AppAuthToken string | |||
IsProd bool | |||
aesKey string // biz_content 加密的 AES KEY | |||
ivKey []byte | |||
privateKey *rsa.PrivateKey | |||
aliPayPublicKey *rsa.PublicKey // 支付宝证书公钥内容 alipayPublicCert.crt | |||
DebugSwitch gopay.DebugSwitch | |||
logger xlog.XLogger | |||
requestIdFunc xhttp.RequestIdHandler | |||
location *time.Location | |||
hc *xhttp.Client | |||
} | |||
// NewClientV3 初始化支付宝客户端 V3 | |||
// appid:应用ID | |||
// privateKey:应用私钥,支持PKCS1和PKCS8 | |||
// isProd:是否是正式环境,沙箱环境请选择新版沙箱应用。 | |||
func NewClientV3(appid, privateKey string, isProd bool) (client *ClientV3, err error) { | |||
if appid == gopay.NULL || privateKey == gopay.NULL { | |||
return nil, gopay.MissAlipayInitParamErr | |||
} | |||
key := xrsa.FormatAlipayPrivateKey(privateKey) | |||
priKey, err := xpem.DecodePrivateKey([]byte(key)) | |||
if err != nil { | |||
return nil, err | |||
} | |||
logger := xlog.NewLogger() | |||
logger.SetLevel(xlog.DebugLevel) | |||
client = &ClientV3{ | |||
AppId: appid, | |||
IsProd: isProd, | |||
privateKey: priKey, | |||
DebugSwitch: gopay.DebugOff, | |||
logger: logger, | |||
requestIdFunc: defaultRequestIdFunc, | |||
hc: xhttp.NewClient(), | |||
} | |||
return client, nil | |||
} | |||
// 设置自定义RequestId生成函数 | |||
func (a *ClientV3) SetRequestIdFunc(requestIdFunc xhttp.RequestIdHandler) { | |||
if requestIdFunc != nil { | |||
a.requestIdFunc = requestIdFunc | |||
} | |||
} | |||
// 应用公钥证书内容设置 app_cert_sn、alipay_root_cert_sn、alipay_cert_sn | |||
// appCertContent:应用公钥证书文件内容 | |||
// alipayRootCertContent:支付宝根证书文件内容 | |||
// alipayPublicCertContent:支付宝公钥证书文件内容 | |||
func (a *ClientV3) SetCert(appCertContent, alipayRootCertContent, alipayPublicCertContent []byte) (err error) { | |||
appCertSn, err := getCertSN(appCertContent) | |||
if err != nil { | |||
return fmt.Errorf("get app_cert_sn return err, but alse return alipay client. err: %w", err) | |||
} | |||
rootCertSn, err := getRootCertSN(alipayRootCertContent) | |||
if err != nil { | |||
return fmt.Errorf("get alipay_root_cert_sn return err, but alse return alipay client. err: %w", err) | |||
} | |||
publicCertSn, err := getCertSN(alipayPublicCertContent) | |||
if err != nil { | |||
return fmt.Errorf("get alipay_cert_sn return err, but alse return alipay client. err: %w", err) | |||
} | |||
// alipay public key | |||
pubKey, err := xpem.DecodePublicKey(alipayPublicCertContent) | |||
if err != nil { | |||
return fmt.Errorf("decode alipayPublicCertContent err: %w", err) | |||
} | |||
a.AppCertSN = appCertSn | |||
a.AliPayRootCertSN = rootCertSn | |||
a.AliPayPublicCertSN = publicCertSn | |||
a.aliPayPublicKey = pubKey | |||
return nil | |||
} | |||
// SetBodySize 设置http response body size(MB) | |||
func (a *ClientV3) SetBodySize(sizeMB int) { | |||
if sizeMB > 0 { | |||
a.hc.SetBodySize(sizeMB) | |||
} | |||
} | |||
// SetHttpClient 设置自定义的xhttp.Client | |||
func (a *ClientV3) SetHttpClient(client *xhttp.Client) { | |||
if client != nil { | |||
a.hc = client | |||
} | |||
} | |||
// SetLogger 设置自定义的logger | |||
func (a *ClientV3) SetLogger(logger xlog.XLogger) { | |||
if logger != nil { | |||
a.logger = logger | |||
} | |||
} | |||
// SetAESKey 设置 biz_content 的AES加密key,设置此参数默认开启 biz_content 参数加密 | |||
// 注意:目前不可用,设置后会报错 | |||
func (a *ClientV3) SetAESKey(aesKey string) { | |||
a.aesKey = aesKey | |||
a.ivKey = []byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} | |||
} |
@@ -1,76 +0,0 @@ | |||
package alipay | |||
import ( | |||
"context" | |||
"os" | |||
"testing" | |||
"github.com/go-pay/gopay" | |||
"github.com/go-pay/gopay/alipay/cert" | |||
"github.com/go-pay/gopay/pkg/js" | |||
"github.com/go-pay/util" | |||
"github.com/go-pay/xlog" | |||
) | |||
var ( | |||
ctx = context.Background() | |||
client *ClientV3 | |||
err error | |||
) | |||
func TestMain(m *testing.M) { | |||
xlog.SetLevel(xlog.DebugLevel) | |||
// 初始化支付宝客V3户端 | |||
// appid:应用ID | |||
// privateKey:应用私钥,支持PKCS1和PKCS8 | |||
// isProd:是否是正式环境,沙箱环境请选择新版沙箱应用。 | |||
client, err = NewClientV3(cert.Appid, cert.PrivateKey, false) | |||
if err != nil { | |||
xlog.Error(err) | |||
return | |||
} | |||
// 自定义配置http请求接收返回结果body大小,默认 10MB | |||
//client.SetBodySize() // 没有特殊需求,可忽略此配置 | |||
// Debug开关,输出/关闭日志 | |||
client.DebugSwitch = gopay.DebugOn | |||
// 设置自定义RequestId生成方法 | |||
//client.SetRequestIdFunc() | |||
// 设置biz_content加密KEY,设置此参数默认开启加密(目前不可用) | |||
//client.SetAESKey("KvKUTqSVZX2fUgmxnFyMaQ==") | |||
// 传入证书内容 | |||
err = client.SetCert(cert.AppPublicContent, cert.AlipayRootContent, cert.AlipayPublicContentRSA2) | |||
if err != nil { | |||
xlog.Debug("SetCert:", err) | |||
return | |||
} | |||
os.Exit(m.Run()) | |||
} | |||
func TestDoAliPayAPISelfV3(t *testing.T) { | |||
// 请求参数 | |||
bm := make(gopay.BodyMap) | |||
bm.Set("subject", "预创建创建订单"). | |||
Set("out_trade_no", util.RandomString(32)). | |||
Set("total_amount", "0.01") | |||
rsp := new(struct { | |||
OutTradeNo string `json:"out_trade_no"` | |||
QrCode string `json:"qr_code"` | |||
}) | |||
// 创建订单 | |||
res, err := client.DoAliPayAPISelfV3(ctx, MethodPost, v3TradePrecreate, bm, rsp) | |||
if err != nil { | |||
xlog.Errorf("client.TradePrecreate(), err:%v", err) | |||
return | |||
} | |||
xlog.Debugf("aliRsp:%s", js.Marshal(rsp)) | |||
if res.StatusCode != Success { | |||
xlog.Errorf("aliRsp.StatusCode:%d", res.StatusCode) | |||
return | |||
} | |||
} |
@@ -1,65 +0,0 @@ | |||
package alipay | |||
import "net/http" | |||
const ( | |||
Success = http.StatusOK | |||
MethodGet = "GET" | |||
MethodPost = "POST" | |||
MethodPut = "PUT" | |||
MethodDelete = "DELETE" | |||
MethodPATCH = "PATCH" | |||
HeaderAuthorization = "Authorization" | |||
HeaderRequestID = "alipay-request-id" | |||
HeaderSdkVersion = "alipay-sdk-version" | |||
HeaderAppAuthToken = "alipay-app-auth-token" | |||
HeaderTimestamp = "alipay-timestamp" | |||
HeaderNonce = "alipay-nonce" | |||
HeaderSignature = "alipay-signature" | |||
SignTypeRSA = "ALIPAY-SHA256withRSA" | |||
v3BaseUrlCh = "https://openapi.alipay.com" // 正式环境 | |||
v3SandboxBaseUrl = "https://openapi-sandbox.dl.alipaydev.com" // 沙箱环境 | |||
) | |||
// 支付 | |||
const ( | |||
// 交易 | |||
v3TradePay = "/v3/alipay/trade/pay" // 统一收单交易支付接口 | |||
v3TradeQuery = "/v3/alipay/trade/query" // 统一收单交易查询接口 | |||
v3TradeRefund = "/v3/alipay/trade/refund" // 统一收单交易退款接口 | |||
v3TradeFastPayRefundQuery = "/v3/alipay/trade/fastpay/refund/query" // 统一收单交易退款查询接口 | |||
v3TradeCancel = "/v3/alipay/trade/cancel" // 统一收单交易撤销接口 | |||
v3TradeClose = "/v3/alipay/trade/close" // 统一收单交易关闭接口 | |||
v3DataBillDownloadUrlQuery = "/v3/alipay/data/dataservice/bill/downloadurl/query" // 查询对账单下载地址 | |||
v3TradePrecreate = "/v3/alipay/trade/precreate" // 统一收单线下交易预创建 | |||
v3TradeCreate = "/v3/alipay/trade/create" // 统一收单交易创建接口 | |||
// 商家扣款 | |||
v3UserAgreementQuery = "/v3/alipay/user/agreement/query" // 支付宝个人代扣协议查询接口 | |||
v3UserAgreementPageUnSign = "/v3/alipay/user/agreement/unsign" // 支付宝个人代扣协议解约接口 | |||
// 商家分账 | |||
v3TradeRoyaltyRelationBind = "/v3/alipay/trade/royalty/relation/bind" // 分账关系绑定 | |||
v3TradeRoyaltyRelationUnbind = "/v3/alipay/trade/royalty/relation/unbind" // 分账关系解绑 | |||
v3TradeRoyaltyRelationBatchQuery = "/v3/alipay/trade/royalty/relation/batchquery" // 分账关系查询 | |||
v3TradeRoyaltyRateQuery = "/v3/alipay/trade/royalty/rate/query" // 分账比例查询 | |||
v3TradeOrderSettle = "/v3/alipay/trade/order/settle" // 统一收单交易结算接口 | |||
v3TradeOrderSettleQuery = "/v3/alipay/trade/order/settle/query" // 交易分账查询接口 | |||
v3TradeOrderOnSettleQuery = "/v3/alipay/trade/order/onsettle/query" // 分账剩余金额查询 | |||
v3TradeOrderInfoSync = "/v3/alipay/trade/orderinfo/sync" // 支付宝订单信息同步接口 | |||
// 刷脸付 | |||
v3ZolozAuthenticationSmilepayInitialize = "/v3/zoloz/authentication/smilepay/initialize" // 刷脸支付初始化 | |||
v3ZolozAuthenticationCustomerFtokenQuery = "/v3/zoloz/authentication/customer/ftoken/query" // 查询刷脸结果信息接口 | |||
// 预授权支付 | |||
v3FundAuthOperationDetailQuery = "/v3/alipay/fund/auth/operation/detail/query" // 资金授权操作查询接口 | |||
v3FundAuthOrderFreeze = "/v3/alipay/fund/auth/order/freeze" // 资金授权冻结接口 | |||
v3FundAuthOrderUnfreeze = "/v3/alipay/fund/auth/order/unfreeze" // 资金授权解冻接口 | |||
v3FundAuthOrderVoucherCreate = "/v3/alipay/fund/auth/order/voucher/create" // 资金授权发码接口 | |||
) |
@@ -1,35 +0,0 @@ | |||
package alipay | |||
// HTTP 状态码 | |||
// 常见的 HTTP 状态码见下表。 | |||
// HTTP 状态码 错误类型 一般的解决方案 | |||
// 200 - OK 处理成功 - | |||
// 202 - Accepted 服务器已接受请求,但尚未处理 请使用原参数重复请求一遍。 | |||
// 204 - No Content 处理成功,无返回Body - | |||
// 400 - Bad Request 协议或者参数非法 请检查请求参数是否符合要求。 | |||
// 401 - Unauthorized 调用未授权 请检查签名参数和方法是否都符合签名算法要求。 | |||
// 403 - Forbidden 无权限调用 请检查产品权限开通情况,可联系产品或商务申请。 | |||
// 404 - Not Found 请求的资源不存在 请检查需要查询的 id 或者请求 URL 是否正确。 | |||
// 429 - Too Many Requests 请求超过频率限制 请求未受理,请降低频率后重试。 | |||
// 500 - Server Error 系统错误 按具体接口的错误指引进行重试。 | |||
type ErrResponse struct { | |||
Code string `json:"code"` // 详细错误码,参考接口描述及公共错误码,商家需要对该错误码处理。 | |||
Message string `json:"message"` // 错误描述,具体错误原因的文字描述,开发者可参考该描述判断错误原因。 | |||
Details []*Detail `json:"details,omitempty"` | |||
Links []*Link `json:"links,omitempty"` | |||
} | |||
type Detail struct { | |||
Field string `json:"field"` | |||
Value string `json:"value"` | |||
Location string `json:"location"` | |||
Issue string `json:"issue"` | |||
Description string `json:"description"` | |||
} | |||
type Link struct { | |||
Link string `json:"link"` | |||
Desc string `json:"desc"` | |||
Rel string `json:"rel"` | |||
} |
@@ -1,211 +0,0 @@ | |||
package alipay | |||
type TradePayRsp struct { | |||
StatusCode int `json:"status_code"` | |||
ErrResponse ErrResponse `json:"-"` | |||
TradeNo string `json:"trade_no"` | |||
OutTradeNo string `json:"out_trade_no"` | |||
BuyerLogonId string `json:"buyer_logon_id"` | |||
TotalAmount string `json:"total_amount"` | |||
ReceiptAmount string `json:"receipt_amount"` | |||
BuyerPayAmount string `json:"buyer_pay_amount"` | |||
PointAmount string `json:"point_amount"` | |||
InvoiceAmount string `json:"invoice_amount"` | |||
GmtPayment string `json:"gmt_payment"` | |||
FundBillList []*FundBill `json:"fund_bill_list"` | |||
StoreName string `json:"store_name"` | |||
DiscountGoodsDetail string `json:"discount_goods_detail"` | |||
BuyerUserId string `json:"buyer_user_id"` | |||
BuyerOpenId string `json:"buyer_open_id"` | |||
VoucherDetailList []*VoucherDetail `json:"voucher_detail_list"` | |||
MdiscountAmount string `json:"mdiscount_amount"` | |||
DiscountAmount string `json:"discount_amount"` | |||
} | |||
type FundBill struct { | |||
FundChannel string `json:"fund_channel"` | |||
Amount string `json:"amount"` | |||
RealAmount string `json:"real_amount"` | |||
} | |||
type VoucherDetail struct { | |||
Id string `json:"id"` | |||
Name string `json:"name"` | |||
Type string `json:"type"` | |||
Amount string `json:"amount"` | |||
MerchantContribute string `json:"merchant_contribute"` | |||
OtherContribute string `json:"other_contribute"` | |||
Memo string `json:"memo"` | |||
TemplateId string `json:"template_id"` | |||
PurchaseBuyerContribute string `json:"purchase_buyer_contribute"` | |||
PurchaseMerchantContribute string `json:"purchase_merchant_contribute"` | |||
PurchaseAntContribute string `json:"purchase_ant_contribute"` | |||
} | |||
type TradeQueryRsp struct { | |||
StatusCode int `json:"status_code"` | |||
ErrResponse ErrResponse `json:"-"` | |||
TradeNo string `json:"trade_no"` | |||
OutTradeNo string `json:"out_trade_no"` | |||
BuyerLogonId string `json:"buyer_logon_id"` | |||
TradeStatus string `json:"trade_status"` | |||
TotalAmount string `json:"total_amount"` | |||
BuyerPayAmount string `json:"buyer_pay_amount"` | |||
PointAmount string `json:"point_amount"` | |||
InvoiceAmount string `json:"invoice_amount"` | |||
SendPayDate string `json:"send_pay_date"` | |||
ReceiptAmount string `json:"receipt_amount"` | |||
StoreId string `json:"store_id"` | |||
TerminalId string `json:"terminal_id"` | |||
FundBillList []*FundBill `json:"fund_bill_list"` | |||
StoreName string `json:"store_name"` | |||
BuyerUserId string `json:"buyer_user_id"` | |||
BuyerOpenId string `json:"buyer_open_id"` | |||
BuyerUserType string `json:"buyer_user_type"` | |||
MdiscountAmount string `json:"mdiscount_amount"` | |||
DiscountAmount string `json:"discount_amount"` | |||
ExtInfos string `json:"ext_infos"` | |||
} | |||
type TradeRefundRsp struct { | |||
StatusCode int `json:"status_code"` | |||
ErrResponse ErrResponse `json:"-"` | |||
TradeNo string `json:"trade_no"` | |||
OutTradeNo string `json:"out_trade_no"` | |||
BuyerLogonId string `json:"buyer_logon_id"` | |||
FundChange string `json:"fund_change"` | |||
RefundFee string `json:"refund_fee"` | |||
RefundDetailItemList []*RefundDetailItem `json:"refund_detail_item_list"` | |||
StoreName string `json:"store_name"` | |||
BuyerUserId string `json:"buyer_user_id"` | |||
BuyerOpenId string `json:"buyer_open_id"` | |||
SendBackFee string `json:"send_back_fee"` | |||
RefundHybAmount string `json:"refund_hyb_amount"` | |||
RefundChargeInfoList []*RefundChargeInfo `json:"refund_charge_info_list"` | |||
RefundVoucherDetailList []*RefundVoucherDetail `json:"refund_voucher_detail_list"` | |||
} | |||
type RefundDetailItem struct { | |||
FundChannel string `json:"fund_channel"` | |||
Amount string `json:"amount"` | |||
RealAmount string `json:"real_amount"` | |||
FundType string `json:"fund_type"` | |||
} | |||
type RefundChargeInfo struct { | |||
RefundChargeFee string `json:"refund_charge_fee"` | |||
SwitchFeeRate string `json:"switch_fee_rate"` | |||
ChargeType string `json:"charge_type"` | |||
RefundSubFeeDetailList []*RefundSubFeeDetail `json:"refund_sub_fee_detail_list"` | |||
} | |||
type RefundSubFeeDetail struct { | |||
RefundChargeFee string `json:"refund_charge_fee"` | |||
SwitchFeeRate string `json:"switch_fee_rate"` | |||
} | |||
type RefundVoucherDetail struct { | |||
Id string `json:"id"` | |||
Name string `json:"name"` | |||
Type string `json:"type"` | |||
Amount string `json:"amount"` | |||
MerchantContribute string `json:"merchant_contribute"` | |||
OtherContribute string `json:"other_contribute"` | |||
Memo string `json:"memo"` | |||
TemplateId string `json:"template_id"` | |||
OtherContributeDetail []*OtherContributeDetail `json:"other_contribute_detail"` | |||
PurchaseBuyerContribute string `json:"purchase_buyer_contribute"` | |||
PurchaseMerchantContribute string `json:"purchase_merchant_contribute"` | |||
PurchaseAntContribute string `json:"purchase_ant_contribute"` | |||
} | |||
type OtherContributeDetail struct { | |||
ContributeType string `json:"contribute_type"` | |||
ContributeAmount string `json:"contribute_amount"` | |||
} | |||
type TradeFastPayRefundQueryRsp struct { | |||
StatusCode int `json:"status_code"` | |||
ErrResponse ErrResponse `json:"-"` | |||
TradeNo string `json:"trade_no"` | |||
OutTradeNo string `json:"out_trade_no"` | |||
OutRequestNo string `json:"out_request_no"` | |||
TotalAmount string `json:"total_amount"` | |||
RefundAmount string `json:"refund_amount"` | |||
RefundStatus string `json:"refund_status"` | |||
RefundRoyaltys []*RefundRoyalty `json:"refund_royaltys"` | |||
GmtRefundPay string `json:"gmt_refund_pay"` | |||
RefundDetailItemList []*RefundDetailItem `json:"refund_detail_item_list"` | |||
SendBackFee string `json:"send_back_fee"` | |||
DepositBackInfo *DepositBackInfo `json:"deposit_back_info"` | |||
RefundHybAmount string `json:"refund_hyb_amount"` | |||
RefundChargeInfoList []*RefundChargeInfo `json:"refund_charge_info_list"` | |||
DepositBackInfoList []*DepositBackInfo `json:"deposit_back_info_list"` | |||
RefundVoucherDetailList []*RefundVoucherDetail `json:"refund_voucher_detail_list"` | |||
} | |||
type RefundRoyalty struct { | |||
RefundAmount string `json:"refund_amount"` | |||
RoyaltyType string `json:"royalty_type"` | |||
ResultCode string `json:"result_code"` | |||
TransOut string `json:"trans_out"` | |||
TransOutEmail string `json:"trans_out_email"` | |||
TransIn string `json:"trans_in"` | |||
TransInEmail string `json:"trans_in_email"` | |||
OriTransOut string `json:"ori_trans_out"` | |||
OriTransIn string `json:"ori_trans_in"` | |||
} | |||
type DepositBackInfo struct { | |||
HasDepositBack string `json:"has_deposit_back"` | |||
DbackStatus string `json:"dback_status"` | |||
DbackAmount string `json:"dback_amount"` | |||
BankAckTime string `json:"bank_ack_time"` | |||
EstBankReceiptTime string `json:"est_bank_receipt_time"` | |||
} | |||
type TradeCancelRsp struct { | |||
StatusCode int `json:"status_code"` | |||
ErrResponse ErrResponse `json:"-"` | |||
TradeNo string `json:"trade_no"` | |||
OutTradeNo string `json:"out_trade_no"` | |||
RetryFlag string `json:"retry_flag"` | |||
Action string `json:"action"` | |||
} | |||
type TradeCloseRsp struct { | |||
StatusCode int `json:"status_code"` | |||
ErrResponse ErrResponse `json:"-"` | |||
TradeNo string `json:"trade_no"` | |||
OutTradeNo string `json:"out_trade_no"` | |||
} | |||
type DataBillDownloadUrlQueryRsp struct { | |||
StatusCode int `json:"status_code"` | |||
ErrResponse ErrResponse `json:"-"` | |||
BillDownloadUrl string `json:"bill_download_url"` | |||
BillFileCode string `json:"bill_file_code"` | |||
} | |||
type TradePrecreateRsp struct { | |||
StatusCode int `json:"status_code"` | |||
ErrResponse ErrResponse `json:"-"` | |||
OutTradeNo string `json:"out_trade_no"` | |||
QrCode string `json:"qr_code"` | |||
} | |||
type TradeCreateRsp struct { | |||
StatusCode int `json:"status_code"` | |||
ErrResponse ErrResponse `json:"-"` | |||
TradeNo string `json:"trade_no"` | |||
OutTradeNo string `json:"out_trade_no"` | |||
} |
@@ -1,270 +0,0 @@ | |||
package alipay | |||
import ( | |||
"context" | |||
"encoding/json" | |||
"errors" | |||
"fmt" | |||
"net/http" | |||
"github.com/go-pay/gopay" | |||
) | |||
// 统一收单交易支付接口 | |||
// Code = 200 is success | |||
func (a *ClientV3) TradePay(ctx context.Context, bm gopay.BodyMap) (aliRsp *TradePayRsp, err error) { | |||
err = bm.CheckEmptyError("out_trade_no", "total_amount", "subject", "auth_code", "scene") | |||
if err != nil { | |||
return nil, err | |||
} | |||
authorization, err := a.authorization(MethodPost, v3TradePay, bm) | |||
if err != nil { | |||
return nil, err | |||
} | |||
res, bs, err := a.doPost(ctx, bm, v3TradePay, authorization) | |||
if err != nil { | |||
return nil, err | |||
} | |||
aliRsp = &TradePayRsp{StatusCode: res.StatusCode} | |||
if res.StatusCode != http.StatusOK { | |||
if err = json.Unmarshal(bs, &aliRsp.ErrResponse); err != nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
return aliRsp, nil | |||
} | |||
if err = json.Unmarshal(bs, aliRsp); err != nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
return aliRsp, a.autoVerifySignByCert(res, bs) | |||
} | |||
// 统一收单交易查询 | |||
// Code = 200 is success | |||
func (a *ClientV3) TradeQuery(ctx context.Context, bm gopay.BodyMap) (aliRsp *TradeQueryRsp, err error) { | |||
if bm.GetString("out_trade_no") == gopay.NULL && bm.GetString("trade_no") == gopay.NULL { | |||
return nil, errors.New("out_trade_no and trade_no are not allowed to be null at the same time") | |||
} | |||
authorization, err := a.authorization(MethodPost, v3TradeQuery, bm) | |||
if err != nil { | |||
return nil, err | |||
} | |||
res, bs, err := a.doPost(ctx, bm, v3TradeQuery, authorization) | |||
if err != nil { | |||
return nil, err | |||
} | |||
aliRsp = &TradeQueryRsp{StatusCode: res.StatusCode} | |||
if res.StatusCode != http.StatusOK { | |||
if err = json.Unmarshal(bs, &aliRsp.ErrResponse); err != nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
return aliRsp, nil | |||
} | |||
if err = json.Unmarshal(bs, aliRsp); err != nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
return aliRsp, a.autoVerifySignByCert(res, bs) | |||
} | |||
// 统一收单交易退款接口 | |||
// Code = 200 is success | |||
func (a *ClientV3) TradeRefund(ctx context.Context, bm gopay.BodyMap) (aliRsp *TradeRefundRsp, err error) { | |||
err = bm.CheckEmptyError("refund_amount") | |||
if err != nil { | |||
return nil, err | |||
} | |||
if bm.GetString("out_trade_no") == gopay.NULL && bm.GetString("trade_no") == gopay.NULL { | |||
return nil, errors.New("out_trade_no and trade_no are not allowed to be null at the same time") | |||
} | |||
authorization, err := a.authorization(MethodPost, v3TradeRefund, bm) | |||
if err != nil { | |||
return nil, err | |||
} | |||
res, bs, err := a.doPost(ctx, bm, v3TradeRefund, authorization) | |||
if err != nil { | |||
return nil, err | |||
} | |||
aliRsp = &TradeRefundRsp{StatusCode: res.StatusCode} | |||
if res.StatusCode != http.StatusOK { | |||
if err = json.Unmarshal(bs, &aliRsp.ErrResponse); err != nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
return aliRsp, nil | |||
} | |||
if err = json.Unmarshal(bs, aliRsp); err != nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
return aliRsp, a.autoVerifySignByCert(res, bs) | |||
} | |||
// 统一收单交易退款查询 | |||
// Code = 200 is success | |||
func (a *ClientV3) TradeFastPayRefundQuery(ctx context.Context, bm gopay.BodyMap) (aliRsp *TradeFastPayRefundQueryRsp, err error) { | |||
err = bm.CheckEmptyError("out_request_no") | |||
if err != nil { | |||
return nil, err | |||
} | |||
if bm.GetString("out_trade_no") == gopay.NULL && bm.GetString("trade_no") == gopay.NULL { | |||
return nil, errors.New("out_trade_no and trade_no are not allowed to be null at the same time") | |||
} | |||
authorization, err := a.authorization(MethodPost, v3TradeFastPayRefundQuery, bm) | |||
if err != nil { | |||
return nil, err | |||
} | |||
res, bs, err := a.doPost(ctx, bm, v3TradeFastPayRefundQuery, authorization) | |||
if err != nil { | |||
return nil, err | |||
} | |||
aliRsp = &TradeFastPayRefundQueryRsp{StatusCode: res.StatusCode} | |||
if res.StatusCode != http.StatusOK { | |||
if err = json.Unmarshal(bs, &aliRsp.ErrResponse); err != nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
return aliRsp, nil | |||
} | |||
if err = json.Unmarshal(bs, aliRsp); err != nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
return aliRsp, a.autoVerifySignByCert(res, bs) | |||
} | |||
// 统一收单交易撤销接口 | |||
// Code = 200 is success | |||
func (a *ClientV3) TradeCancel(ctx context.Context, bm gopay.BodyMap) (aliRsp *TradeCancelRsp, err error) { | |||
if bm.GetString("out_trade_no") == gopay.NULL && bm.GetString("trade_no") == gopay.NULL { | |||
return nil, errors.New("out_trade_no and trade_no are not allowed to be null at the same time") | |||
} | |||
authorization, err := a.authorization(MethodPost, v3TradeCancel, bm) | |||
if err != nil { | |||
return nil, err | |||
} | |||
res, bs, err := a.doPost(ctx, bm, v3TradeCancel, authorization) | |||
if err != nil { | |||
return nil, err | |||
} | |||
aliRsp = &TradeCancelRsp{StatusCode: res.StatusCode} | |||
if res.StatusCode != http.StatusOK { | |||
if err = json.Unmarshal(bs, &aliRsp.ErrResponse); err != nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
return aliRsp, nil | |||
} | |||
if err = json.Unmarshal(bs, aliRsp); err != nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
return aliRsp, a.autoVerifySignByCert(res, bs) | |||
} | |||
// 统一收单交易关闭接口 | |||
// Code = 200 is success | |||
func (a *ClientV3) TradeClose(ctx context.Context, bm gopay.BodyMap) (aliRsp *TradeCloseRsp, err error) { | |||
if bm.GetString("out_trade_no") == gopay.NULL && bm.GetString("trade_no") == gopay.NULL { | |||
return nil, errors.New("out_trade_no and trade_no are not allowed to be null at the same time") | |||
} | |||
authorization, err := a.authorization(MethodPost, v3TradeClose, bm) | |||
if err != nil { | |||
return nil, err | |||
} | |||
res, bs, err := a.doPost(ctx, bm, v3TradeClose, authorization) | |||
if err != nil { | |||
return nil, err | |||
} | |||
aliRsp = &TradeCloseRsp{StatusCode: res.StatusCode} | |||
if res.StatusCode != http.StatusOK { | |||
if err = json.Unmarshal(bs, &aliRsp.ErrResponse); err != nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
return aliRsp, nil | |||
} | |||
if err = json.Unmarshal(bs, aliRsp); err != nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
return aliRsp, a.autoVerifySignByCert(res, bs) | |||
} | |||
// 查询对账单下载地址 | |||
// Code = 200 is success | |||
func (a *ClientV3) DataBillDownloadUrlQuery(ctx context.Context, bm gopay.BodyMap) (aliRsp *DataBillDownloadUrlQueryRsp, err error) { | |||
err = bm.CheckEmptyError("bill_type", "bill_date") | |||
if err != nil { | |||
return nil, err | |||
} | |||
uri := v3DataBillDownloadUrlQuery + "?" + bm.EncodeURLParams() | |||
authorization, err := a.authorization(MethodGet, uri, nil) | |||
if err != nil { | |||
return nil, err | |||
} | |||
res, bs, err := a.doGet(ctx, uri, authorization) | |||
if err != nil { | |||
return nil, err | |||
} | |||
aliRsp = &DataBillDownloadUrlQueryRsp{StatusCode: res.StatusCode} | |||
if res.StatusCode != http.StatusOK { | |||
if err = json.Unmarshal(bs, &aliRsp.ErrResponse); err != nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
return aliRsp, nil | |||
} | |||
if err = json.Unmarshal(bs, aliRsp); err != nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
return aliRsp, a.autoVerifySignByCert(res, bs) | |||
} | |||
// 统一收单线下交易预创建 | |||
// Code = 200 is success | |||
func (a *ClientV3) TradePrecreate(ctx context.Context, bm gopay.BodyMap) (aliRsp *TradePrecreateRsp, err error) { | |||
err = bm.CheckEmptyError("out_trade_no", "total_amount", "subject") | |||
if err != nil { | |||
return nil, err | |||
} | |||
authorization, err := a.authorization(MethodPost, v3TradePrecreate, bm) | |||
if err != nil { | |||
return nil, err | |||
} | |||
res, bs, err := a.doPost(ctx, bm, v3TradePrecreate, authorization) | |||
if err != nil { | |||
return nil, err | |||
} | |||
aliRsp = &TradePrecreateRsp{StatusCode: res.StatusCode} | |||
if res.StatusCode != http.StatusOK { | |||
if err = json.Unmarshal(bs, &aliRsp.ErrResponse); err != nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
return aliRsp, nil | |||
} | |||
if err = json.Unmarshal(bs, aliRsp); err != nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
return aliRsp, a.autoVerifySignByCert(res, bs) | |||
} | |||
// 统一收单交易创建接口 | |||
// Code = 200 is success | |||
func (a *ClientV3) TradeCreate(ctx context.Context, bm gopay.BodyMap) (aliRsp *TradeCreateRsp, err error) { | |||
err = bm.CheckEmptyError("out_trade_no", "total_amount", "subject", "product_code", "op_app_id") | |||
if err != nil { | |||
return nil, err | |||
} | |||
if bm.GetString("buyer_id") == gopay.NULL && bm.GetString("buyer_open_id") == gopay.NULL { | |||
return nil, errors.New("buyer_id and buyer_open_id are not allowed to be null at the same time") | |||
} | |||
authorization, err := a.authorization(MethodPost, v3TradeCreate, bm) | |||
if err != nil { | |||
return nil, err | |||
} | |||
res, bs, err := a.doPost(ctx, bm, v3TradeCreate, authorization) | |||
if err != nil { | |||
return nil, err | |||
} | |||
aliRsp = &TradeCreateRsp{StatusCode: res.StatusCode} | |||
if res.StatusCode != http.StatusOK { | |||
if err = json.Unmarshal(bs, &aliRsp.ErrResponse); err != nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
return aliRsp, nil | |||
} | |||
if err = json.Unmarshal(bs, aliRsp); err != nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
return aliRsp, a.autoVerifySignByCert(res, bs) | |||
} |
@@ -1,33 +0,0 @@ | |||
package alipay | |||
import ( | |||
"testing" | |||
"github.com/go-pay/gopay" | |||
"github.com/go-pay/gopay/pkg/js" | |||
"github.com/go-pay/util" | |||
"github.com/go-pay/xlog" | |||
) | |||
func TestTradePrecreate(t *testing.T) { | |||
// 请求参数 | |||
bm := make(gopay.BodyMap) | |||
bm.Set("subject", "预创建创建订单"). | |||
Set("out_trade_no", util.RandomString(32)). | |||
Set("total_amount", "0.01") | |||
// 创建订单 | |||
aliRsp, err := client.TradePrecreate(ctx, bm) | |||
if err != nil { | |||
xlog.Errorf("client.TradePrecreate(), err:%v", err) | |||
return | |||
} | |||
xlog.Debugf("aliRsp:%s", js.Marshal(aliRsp)) | |||
if aliRsp.StatusCode != Success { | |||
xlog.Errorf("aliRsp.StatusCode:%d", aliRsp.StatusCode) | |||
return | |||
} | |||
xlog.Debug("aliRsp.QrCode:", aliRsp.QrCode) | |||
xlog.Debug("aliRsp.OutTradeNo:", aliRsp.OutTradeNo) | |||
} |
@@ -1,136 +0,0 @@ | |||
package alipay | |||
import ( | |||
"context" | |||
"encoding/json" | |||
"fmt" | |||
"net/http" | |||
"time" | |||
"github.com/go-pay/gopay" | |||
"github.com/go-pay/gopay/pkg/xhttp" | |||
"github.com/go-pay/util" | |||
) | |||
var defaultRequestIdFunc = &requestIdFunc{} | |||
type requestIdFunc struct{} | |||
func (d *requestIdFunc) RequestId() string { | |||
return fmt.Sprintf("%s-%d", util.RandomString(21), time.Now().Unix()) | |||
} | |||
// DoAliPayAPISelfV3 支付宝接口自行实现方法 | |||
func (a *ClientV3) DoAliPayAPISelfV3(ctx context.Context, method, path string, bm gopay.BodyMap, aliRsp any) (res *http.Response, err error) { | |||
var ( | |||
bs []byte | |||
authorization string | |||
) | |||
switch method { | |||
case MethodGet: | |||
uri := path + "?" + bm.EncodeURLParams() | |||
authorization, err = a.authorization(MethodGet, uri, nil) | |||
if err != nil { | |||
return nil, err | |||
} | |||
res, bs, err = a.doGet(ctx, uri, authorization) | |||
if err != nil { | |||
return nil, err | |||
} | |||
case MethodPost: | |||
authorization, err = a.authorization(MethodPost, path, bm) | |||
if err != nil { | |||
return nil, err | |||
} | |||
res, bs, err = a.doPost(ctx, bm, path, authorization) | |||
if err != nil { | |||
return nil, err | |||
} | |||
} | |||
if err = json.Unmarshal(bs, aliRsp); err != nil { | |||
return nil, err | |||
} | |||
return res, nil | |||
} | |||
func (a *ClientV3) doPost(ctx context.Context, bm gopay.BodyMap, uri, authorization string) (res *http.Response, bs []byte, err error) { | |||
var url = v3BaseUrlCh + uri | |||
if !a.IsProd { | |||
url = v3SandboxBaseUrl + uri | |||
} | |||
req := a.hc.Req() // default json | |||
req.Header.Add(HeaderAuthorization, authorization) | |||
req.Header.Add(HeaderRequestID, a.requestIdFunc.RequestId()) | |||
req.Header.Add(HeaderSdkVersion, "gopay/"+gopay.Version) | |||
if a.AppAuthToken != "" { | |||
req.Header.Add(HeaderAppAuthToken, a.AppAuthToken) | |||
} | |||
req.Header.Add("Accept", "application/json") | |||
if a.DebugSwitch == gopay.DebugOn { | |||
a.logger.Debugf("Alipay_V3_Url: %s", url) | |||
a.logger.Debugf("Alipay_V3_Req_Body: %s", bm.JsonBody()) | |||
a.logger.Debugf("Alipay_V3_Req_Headers: %#v", req.Header) | |||
} | |||
res, bs, err = req.Post(url).SendBodyMap(bm).EndBytesForAlipayV3(ctx) | |||
if err != nil { | |||
return nil, nil, err | |||
} | |||
if a.DebugSwitch == gopay.DebugOn { | |||
a.logger.Debugf("Alipay_V3_Response: %d > %s", res.StatusCode, string(bs)) | |||
a.logger.Debugf("Alipay_V3_Rsp_Headers: %#v", res.Header) | |||
} | |||
return res, bs, nil | |||
} | |||
func (a *ClientV3) doGet(ctx context.Context, uri, authorization string) (res *http.Response, bs []byte, err error) { | |||
var url = v3BaseUrlCh + uri | |||
if !a.IsProd { | |||
url = v3SandboxBaseUrl + uri | |||
} | |||
req := a.hc.Req() // default json | |||
req.Header.Add(HeaderAuthorization, authorization) | |||
req.Header.Add(HeaderRequestID, a.requestIdFunc.RequestId()) | |||
req.Header.Add(HeaderSdkVersion, "gopay/"+gopay.Version) | |||
if a.AppAuthToken != "" { | |||
req.Header.Add(HeaderAppAuthToken, a.AppAuthToken) | |||
} | |||
req.Header.Add("Accept", "application/json") | |||
if a.DebugSwitch == gopay.DebugOn { | |||
a.logger.Debugf("Alipay_V3_Url: %s", url) | |||
a.logger.Debugf("Alipay_V3_Req_Headers: %#v", req.Header) | |||
} | |||
res, bs, err = req.Get(url).EndBytesForAlipayV3(ctx) | |||
if err != nil { | |||
return nil, nil, err | |||
} | |||
if a.DebugSwitch == gopay.DebugOn { | |||
a.logger.Debugf("Alipay_V3_Response: %d > %s", res.StatusCode, string(bs)) | |||
a.logger.Debugf("Alipay_V3_Rsp_Headers: %#v", res.Header) | |||
} | |||
return res, bs, nil | |||
} | |||
func (a *ClientV3) doProdPostFile(ctx context.Context, bm gopay.BodyMap, uri, authorization string) (res *http.Response, bs []byte, err error) { | |||
var url = v3BaseUrlCh + uri | |||
req := a.hc.Req(xhttp.TypeMultipartFormData) | |||
req.Header.Add(HeaderAuthorization, authorization) | |||
req.Header.Add(HeaderRequestID, a.requestIdFunc.RequestId()) | |||
req.Header.Add(HeaderSdkVersion, "gopay/"+gopay.Version) | |||
req.Header.Add("Accept", "application/json") | |||
if a.DebugSwitch == gopay.DebugOn { | |||
a.logger.Debugf("Alipay_V3_Url: %s", url) | |||
a.logger.Debugf("Alipay_V3_Req_Body: %s", bm.JsonBody()) | |||
a.logger.Debugf("Alipay_V3_Req_Headers: %#v", req.Header) | |||
} | |||
res, bs, err = req.Post(url).SendMultipartBodyMap(bm).EndBytesForAlipayV3(ctx) | |||
if err != nil { | |||
return nil, nil, err | |||
} | |||
if a.DebugSwitch == gopay.DebugOn { | |||
a.logger.Debugf("Alipay_V3_Response: %d > %s", res.StatusCode, string(bs)) | |||
a.logger.Debugf("Alipay_V3_Rsp_Headers: %#v", res.Header) | |||
} | |||
return res, bs, nil | |||
} |
@@ -1,189 +0,0 @@ | |||
package alipay | |||
import ( | |||
"crypto" | |||
"crypto/rand" | |||
"crypto/rsa" | |||
"crypto/sha256" | |||
"encoding/base64" | |||
"errors" | |||
"fmt" | |||
"net/http" | |||
"os" | |||
"strings" | |||
"time" | |||
"github.com/go-pay/crypto/xpem" | |||
"github.com/go-pay/gopay" | |||
"github.com/go-pay/util" | |||
"github.com/go-pay/util/convert" | |||
) | |||
// v3 鉴权请求 Authorization Header | |||
func (a *ClientV3) authorization(method, uri string, bm gopay.BodyMap) (string, error) { | |||
var ( | |||
jb = "" | |||
timestamp = convert.Int64ToString(time.Now().UnixNano() / int64(time.Millisecond)) | |||
nonceStr = util.RandomString(32) | |||
// app_id=2014060600164699,app_cert_sn=xxx,nonce=5f9fba93-bbb2-40f0-b328-04d5ead3e131,timestamp=1667804301218 | |||
authString = "app_id=" + a.AppId + ",app_cert_sn=" + a.AppCertSN + ",nonce=" + nonceStr + ",timestamp=" + timestamp | |||
) | |||
if a.AppCertSN == gopay.NULL { | |||
authString = "app_id=" + a.AppId + ",nonce=" + nonceStr + ",timestamp=" + timestamp | |||
} | |||
if bm != nil { | |||
jb = bm.JsonBody() | |||
} | |||
// ${authString}\n 步骤1中生成的认证串 authString。 | |||
// ${httpMethod}\n 本次请求的 http 方法,例如 GET\POST\PUT 等。 | |||
// ${httpReuqestUrl}\n 本次请求的 uri 信息,包括 queryString,不包括域名,例如 /v3/alipay/marketing/activity/ordervoucher/get?id=123。 | |||
// ${httpRequestBody}\n 本次请求的 body 内容。当使用GET等请求时,body 为空,该值传入空字符串,即""。 | |||
// ${appAuthToken}\n 应用授权令牌,和 header 参数中 alipay-app-auth-token 值保持一致。可选参数,不使用代调用模式时,不需要传入该字段。 | |||
// | |||
// 示例: | |||
// app_id=2014060600164699,timestamp=1655869956477,nonce=eb4ade8f-8cfa-4ebf-a048-7eb52684ab32,expired_seconds=120 | |||
// POST | |||
// /v3/alipay/marketing/activity/ordervoucher/create?auth_token=123 | |||
// {"activity_name": "单品特价满10减1活动","publish_start_time": "2022-02-01 00:00:01"} | |||
// | |||
// body 空示例: | |||
// app_id=2014060600164699,timestamp=1655869956477,nonce=eb4ade8f-8cfa-4ebf-a048-7eb52684ab32,expired_seconds=120 | |||
// GET | |||
// /v3/alipay/marketing/activity/ordervoucher?id=123 | |||
// | |||
// 代调示例: | |||
// app_id=2014060600164699,timestamp=1655869956477,nonce=eb4ade8f-8cfa-4ebf-a048-7eb52684ab32,expired_seconds=120 | |||
// GET | |||
// /v3/alipay/marketing/activity/ordervoucher?id=123 | |||
// 202212BB_D64b2be8afd4b6c8468cf585bd05E50 | |||
signStr := authString + "\n" + method + "\n" + uri + "\n" + jb + "\n" | |||
if a.AppAuthToken != "" { | |||
signStr += a.AppAuthToken + "\n" | |||
} | |||
if a.DebugSwitch == gopay.DebugOn { | |||
a.logger.Debugf("Alipay_V3_SignString:\n%s", signStr) | |||
} | |||
sign, err := a.rsaSign(signStr) | |||
if err != nil { | |||
return "", err | |||
} | |||
if a.DebugSwitch == gopay.DebugOn { | |||
a.logger.Debugf("Alipay_V3_Sign:\n%s", sign) | |||
} | |||
// authorization: ${签名算法} ${authString},sign=${signature} | |||
authorization := SignTypeRSA + " " + authString + ",sign=" + sign | |||
return authorization, nil | |||
} | |||
func (a *ClientV3) rsaSign(str string) (string, error) { | |||
if a.privateKey == nil { | |||
return "", errors.New("privateKey can't be nil") | |||
} | |||
h := sha256.New() | |||
h.Write([]byte(str)) | |||
result, err := rsa.SignPKCS1v15(rand.Reader, a.privateKey, crypto.SHA256, h.Sum(nil)) | |||
if err != nil { | |||
return gopay.NULL, fmt.Errorf("[%w]: %+v", gopay.SignatureErr, err) | |||
} | |||
return base64.StdEncoding.EncodeToString(result), nil | |||
} | |||
// =============================== 获取SignData =============================== | |||
// 需注意的是,公钥签名模式和公钥证书签名模式的不同之处 | |||
// 验签文档:https://opendocs.alipay.com/open/200/106120 | |||
func (a *ClientV3) getSignData(bs []byte, alipayCertSN string) (signData string, err error) { | |||
var ( | |||
str = string(bs) | |||
indexStart = strings.Index(str, `_response":`) | |||
indexEnd int | |||
) | |||
indexStart = indexStart + 11 | |||
bsLen := len(str) | |||
if alipayCertSN != "" { | |||
// 公钥证书模式 | |||
if alipayCertSN != a.AliPayPublicCertSN { | |||
return gopay.NULL, fmt.Errorf("[%w], 当前使用的支付宝公钥证书SN[%s]与网关响应报文中的SN[%s]不匹配", gopay.CertNotMatchErr, a.AliPayPublicCertSN, alipayCertSN) | |||
} | |||
indexEnd = strings.Index(str, `,"alipay_cert_sn":`) | |||
if indexEnd > indexStart && bsLen > indexStart { | |||
signData = str[indexStart:indexEnd] | |||
return | |||
} | |||
return gopay.NULL, fmt.Errorf("[%w], value: %s", gopay.GetSignDataErr, str) | |||
} | |||
// 普通公钥模式 | |||
indexEnd = strings.Index(str, `,"sign":`) | |||
if indexEnd > indexStart && bsLen > indexStart { | |||
signData = str[indexStart:indexEnd] | |||
return | |||
} | |||
return gopay.NULL, fmt.Errorf("[%w], value: %s", gopay.GetSignDataErr, str) | |||
} | |||
// =============================== 同步验签 =============================== | |||
func (a *ClientV3) autoVerifySignByCert(res *http.Response, body []byte) (err error) { | |||
if a.aliPayPublicKey != nil { | |||
ts := res.Header.Get(HeaderTimestamp) | |||
nonce := res.Header.Get(HeaderNonce) | |||
sign := res.Header.Get(HeaderSignature) | |||
if a.DebugSwitch == gopay.DebugOn { | |||
a.logger.Debugf("Alipay_VerifySignHeader: alipay-timestamp=[%s], alipay-nonce=[%s], alipay-signature=[%s]", ts, nonce, sign) | |||
} | |||
signData := ts + "\n" + nonce + "\n" + string(body) + "\n" | |||
signBytes, _ := base64.StdEncoding.DecodeString(sign) | |||
sum256 := sha256.Sum256([]byte(signData)) | |||
if err = rsa.VerifyPKCS1v15(a.aliPayPublicKey, crypto.SHA256, sum256[:], signBytes); err != nil { | |||
return fmt.Errorf("[%w]: %v", gopay.VerifySignatureErr, err) | |||
} | |||
} | |||
return nil | |||
} | |||
// =============================== 通用底层验签方法 =============================== | |||
func verifySign(signData, sign, alipayPublicKey string) (err error) { | |||
publicKey, err := xpem.DecodePublicKey([]byte(alipayPublicKey)) | |||
if err != nil { | |||
return err | |||
} | |||
signBytes, _ := base64.StdEncoding.DecodeString(sign) | |||
h := sha256.New() | |||
h.Write([]byte(signData)) | |||
if err = rsa.VerifyPKCS1v15(publicKey, crypto.SHA256, h.Sum(nil), signBytes); err != nil { | |||
return fmt.Errorf("[%w]: %v", gopay.VerifySignatureErr, err) | |||
} | |||
return nil | |||
} | |||
func verifySignCert(signData, sign string, alipayPublicKeyCert any) (err error) { | |||
var ( | |||
bytes []byte | |||
) | |||
if v, ok := alipayPublicKeyCert.(string); ok { | |||
if bytes, err = os.ReadFile(v); err != nil { | |||
return fmt.Errorf("支付宝公钥文件读取失败: %w", err) | |||
} | |||
} else { | |||
bytes, ok = alipayPublicKeyCert.([]byte) | |||
if !ok { | |||
return fmt.Errorf("支付宝公钥读取失败: %w", err) | |||
} | |||
} | |||
publicKey, err := xpem.DecodePublicKey(bytes) | |||
if err != nil { | |||
return err | |||
} | |||
signBytes, _ := base64.StdEncoding.DecodeString(sign) | |||
h := sha256.New() | |||
h.Write([]byte(signData)) | |||
if err = rsa.VerifyPKCS1v15(publicKey, crypto.SHA256, h.Sum(nil), signBytes); err != nil { | |||
return fmt.Errorf("[%w]: %v", gopay.VerifySignatureErr, err) | |||
} | |||
return nil | |||
} |
@@ -1,674 +0,0 @@ | |||
package alipay | |||
import ( | |||
"context" | |||
"encoding/json" | |||
"fmt" | |||
"github.com/go-pay/gopay" | |||
) | |||
// Deprecated | |||
// zhima.credit.score.get(查询芝麻用户的芝麻分) | |||
// 文档地址:https://opendocs.alipay.com/apis/api_8/zhima.credit.score.get | |||
func (a *Client) ZhimaCreditScoreGet(ctx context.Context, bm gopay.BodyMap) (aliRsp *ZhimaCreditScoreGetResponse, err error) { | |||
if bm.GetString("product_code") == gopay.NULL { | |||
bm.Set("product_code", "w1010100100000000001") | |||
} | |||
err = bm.CheckEmptyError("transaction_id") | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "zhima.credit.score.get"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(ZhimaCreditScoreGetResponse) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// zhima.credit.ep.scene.rating.initialize(芝麻企业信用信用评估初始化) | |||
// 文档地址:https://opendocs.alipay.com/apis/api_8/zhima.credit.ep.scene.rating.initialize | |||
func (a *Client) ZhimaCreditEpSceneRatingInitialize(ctx context.Context, bm gopay.BodyMap) (aliRsp *ZhimaCreditEpSceneRatingInitializeRsp, err error) { | |||
if bm.GetString("product_code") == gopay.NULL { | |||
bm.Set("product_code", "w1010100100000000001") | |||
} | |||
err = bm.CheckEmptyError("credit_category", "out_order_no", "user_id") | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "zhima.credit.ep.scene.rating.initialize"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(ZhimaCreditEpSceneRatingInitializeRsp) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// zhima.credit.ep.scene.fulfillment.sync(信用服务履约同步) | |||
// 文档地址:https://opendocs.alipay.com/apis/api_8/zhima.credit.ep.scene.fulfillment.sync | |||
func (a *Client) ZhimaCreditEpSceneFulfillmentSync(ctx context.Context, bm gopay.BodyMap) (aliRsp *ZhimaCreditEpSceneFulfillmentSyncRsp, err error) { | |||
err = bm.CheckEmptyError("credit_order_no", "out_order_no", "biz_time", "biz_ext_param") | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "zhima.credit.ep.scene.fulfillment.sync"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(ZhimaCreditEpSceneFulfillmentSyncRsp) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// zhima.credit.ep.scene.agreement.use(加入信用服务) | |||
// 文档地址:https://opendocs.alipay.com/apis/api_8/zhima.credit.ep.scene.agreement.use | |||
func (a *Client) ZhimaCreditEpSceneAgreementUse(ctx context.Context, bm gopay.BodyMap) (aliRsp *ZhimaCreditEpSceneAgreementUseRsp, err error) { | |||
err = bm.CheckEmptyError("rating_order_no", "out_order_no", "biz_time", "provision_code") | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "zhima.credit.ep.scene.agreement.use"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(ZhimaCreditEpSceneAgreementUseRsp) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// zhima.credit.ep.scene.agreement.cancel(取消信用服务) | |||
// 文档地址:https://opendocs.alipay.com/apis/api_8/zhima.credit.ep.scene.agreement.cancel | |||
func (a *Client) ZhimaCreditEpSceneAgreementCancel(ctx context.Context, bm gopay.BodyMap) (aliRsp *ZhimaCreditEpSceneAgreementCancelRsp, err error) { | |||
err = bm.CheckEmptyError("credit_order_no", "out_order_no", "biz_time") | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "zhima.credit.ep.scene.agreement.cancel"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(ZhimaCreditEpSceneAgreementCancelRsp) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// zhima.credit.ep.scene.fulfillmentlist.sync(信用服务履约同步(批量)) | |||
// 文档地址:https://opendocs.alipay.com/apis/api_8/zhima.credit.ep.scene.fulfillmentlist.sync | |||
func (a *Client) ZhimaCreditEpSceneFulfillmentlistSync(ctx context.Context, bm gopay.BodyMap) (aliRsp *ZhimaCreditEpSceneFulfillmentlistSyncRsp, err error) { | |||
err = bm.CheckEmptyError("credit_order_no", "fulfillment_info_list") | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "zhima.credit.ep.scene.fulfillmentlist.sync"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(ZhimaCreditEpSceneFulfillmentlistSyncRsp) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// zhima.credit.pe.zmgo.cumulation.sync(芝麻go用户数据回传) | |||
// 文档地址:https://opendocs.alipay.com/apis/api_8/zhima.credit.pe.zmgo.cumulation.sync | |||
func (a *Client) ZhimaCreditPeZmgoCumulationSync(ctx context.Context, bm gopay.BodyMap) (aliRsp *ZhimaCreditPeZmgoCumulationSyncRsp, err error) { | |||
err = bm.CheckEmptyError("agreement_no", "user_id", "partner_id", "out_biz_no", "biz_time", "request_from", "biz_action", "cumulate_data_type") | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "zhima.credit.pe.zmgo.cumulation.sync"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(ZhimaCreditPeZmgoCumulationSyncRsp) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// zhima.merchant.zmgo.cumulate.sync(商家芝麻GO累计数据回传接口) | |||
// 文档地址:https://opendocs.alipay.com/apis/01ol9h | |||
func (a *Client) ZhimaMerchantZmgoCumulateSync(ctx context.Context, bm gopay.BodyMap) (aliRsp *ZhimaMerchantZmgoCumulateSyncRsp, err error) { | |||
err = bm.CheckEmptyError("agreement_id", "user_id", "provider_pid", "out_biz_no", "biz_time", "biz_action", "sub_biz_action", "data_type") | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "zhima.merchant.zmgo.cumulate.sync"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(ZhimaMerchantZmgoCumulateSyncRsp) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// zhima.merchant.zmgo.cumulate.query(商家芝麻GO累计数据查询接口) | |||
// 文档地址:https://opendocs.alipay.com/open/03ui2q | |||
func (a *Client) ZhimaMerchantZmgoCumulateQuery(ctx context.Context, bm gopay.BodyMap) (aliRsp *ZhimaMerchantZmgoCumulateQueryRsp, err error) { | |||
err = bm.CheckEmptyError("agreement_id", "user_id", "provider_pid") | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "zhima.merchant.zmgo.cumulate.query"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(ZhimaMerchantZmgoCumulateQueryRsp) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// zhima.merchant.zmgo.template.create(商户创建芝麻GO模板接口) | |||
// 文档地址:https://opendocs.alipay.com/open/03uq08 | |||
func (a *Client) ZhimaMerchantZmgoTemplateCreate(ctx context.Context, bm gopay.BodyMap) (aliRsp *ZhimaMerchantZmgoTemplateCreateRsp, err error) { | |||
err = bm.CheckEmptyError("basic_config", "right_config", "open_config", "settlement_config") | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "zhima.merchant.zmgo.template.create"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(ZhimaMerchantZmgoTemplateCreateRsp) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// zhima.merchant.zmgo.template.query(芝麻GO模板查询) | |||
// 文档地址:https://opendocs.alipay.com/open/04m8ci | |||
func (a *Client) ZhimaMerchantZmgoTemplateQuery(ctx context.Context, bm gopay.BodyMap) (aliRsp *ZhimaMerchantZmgoTemplateQueryRsp, err error) { | |||
err = bm.CheckEmptyError("template_no", "partner_id") | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "zhima.merchant.zmgo.template.query"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(ZhimaMerchantZmgoTemplateQueryRsp) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// zhima.credit.pe.zmgo.settle.apply(芝麻GO结算申请) | |||
// 文档地址:https://opendocs.alipay.com/open/03usxk | |||
func (a *Client) ZhimaCreditPeZmgoSettleApply(ctx context.Context, bm gopay.BodyMap) (aliRsp *ZhimaCreditPeZmgoSettleApplyRsp, err error) { | |||
err = bm.CheckEmptyError("agreement_id", "partner_id", "out_request_no", "withhold_plan_no", "pay_amount") | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "zhima.credit.pe.zmgo.settle.apply"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(ZhimaCreditPeZmgoSettleApplyRsp) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// zhima.credit.pe.zmgo.bizopt.close(芝麻GO签约关单) | |||
// 文档地址:https://opendocs.alipay.com/apis/01qii3 | |||
func (a *Client) ZhimaCreditPeZmgoBizoptClose(ctx context.Context, bm gopay.BodyMap) (aliRsp *ZhimaCreditPeZmgoBizoptCloseRsp, err error) { | |||
err = bm.CheckEmptyError("alipay_user_id", "partner_id", "out_request_no", "template_id") | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "zhima.credit.pe.zmgo.bizopt.close"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(ZhimaCreditPeZmgoBizoptCloseRsp) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// zhima.credit.pe.zmgo.settle.refund(芝麻GO结算退款接口) | |||
// 文档地址:https://opendocs.alipay.com/open/03ub1e | |||
func (a *Client) ZhimaCreditPeZmgoSettleRefund(ctx context.Context, bm gopay.BodyMap) (aliRsp *ZhimaCreditPeZmgoSettleRefundRsp, err error) { | |||
err = bm.CheckEmptyError("agreement_id", "partner_id", "alipay_user_id", "refund_amount", "out_request_no") | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "zhima.credit.pe.zmgo.settle.refund"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(ZhimaCreditPeZmgoSettleRefundRsp) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// zhima.credit.pe.zmgo.preorder.create(芝麻GO签约预创单) | |||
// 文档地址:https://opendocs.alipay.com/open/03ujao | |||
func (a *Client) ZhimaCreditPeZmgoPreorderCreate(ctx context.Context, bm gopay.BodyMap) (aliRsp *ZhimaCreditPeZmgoPreorderCreateRsp, err error) { | |||
err = bm.CheckEmptyError("partner_id", "template_id", "out_request_no", "biz_time") | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "zhima.credit.pe.zmgo.preorder.create"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(ZhimaCreditPeZmgoPreorderCreateRsp) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// zhima.credit.pe.zmgo.sign.apply(芝麻GO页面签约接口) | |||
// 文档地址:https://opendocs.alipay.com/open/03u934 | |||
func (a *Client) ZhimaCreditPeZmgoSignApply(ctx context.Context, bm gopay.BodyMap) (orderStr string, err error) { | |||
err = bm.CheckEmptyError("partner_id", "template_id", "out_request_no") | |||
if err != nil { | |||
return gopay.NULL, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "zhima.credit.pe.zmgo.sign.apply"); err != nil { | |||
return gopay.NULL, err | |||
} | |||
orderStr = string(bs) | |||
return orderStr, nil | |||
} | |||
// zhima.credit.pe.zmgo.agreement.unsign(芝麻GO协议解约) | |||
// 文档地址:https://opendocs.alipay.com/open/03ub1g | |||
func (a *Client) ZhimaCreditPeZmgoAgreementUnsign(ctx context.Context, bm gopay.BodyMap) (aliRsp *ZhimaCreditPeZmgoAgreementUnsignRsp, err error) { | |||
err = bm.CheckEmptyError("partner_id", "agreement_id") | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "zhima.credit.pe.zmgo.agreement.unsign"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(ZhimaCreditPeZmgoAgreementUnsignRsp) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// zhima.credit.pe.zmgo.agreement.query(芝麻Go协议查询接口) | |||
// 文档地址:https://opendocs.alipay.com/open/03utv3 | |||
func (a *Client) ZhimaCreditPeZmgoAgreementQuery(ctx context.Context, bm gopay.BodyMap) (aliRsp *ZhimaCreditPeZmgoAgreementQueryRsp, err error) { | |||
err = bm.CheckEmptyError("agreement_id", "alipay_user_id") | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "zhima.credit.pe.zmgo.agreement.query"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(ZhimaCreditPeZmgoAgreementQueryRsp) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// zhima.credit.pe.zmgo.settle.unfreeze(芝麻Go解冻接口) | |||
// 文档地址:https://opendocs.alipay.com/apis/01vx41 | |||
func (a *Client) ZhimaCreditPeZmgoSettleUnfreeze(ctx context.Context, bm gopay.BodyMap) (aliRsp *ZhimaCreditPeZmgoSettleUnfreezeRsp, err error) { | |||
err = bm.CheckEmptyError("agreement_id", "out_request_no", "unfreeze_amount", "biz_time", "alipay_user_id") | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "zhima.credit.pe.zmgo.settle.unfreeze"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(ZhimaCreditPeZmgoSettleUnfreezeRsp) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// zhima.credit.pe.zmgo.paysign.apply(芝麻GO支付下单链路签约申请) | |||
// 文档地址:https://opendocs.alipay.com/apis/01xdtu | |||
func (a *Client) ZhimaCreditPeZmgoPaysignApply(ctx context.Context, bm gopay.BodyMap) (aliRsp *ZhimaCreditPeZmgoPaysignApplyRsp, err error) { | |||
err = bm.CheckEmptyError("alipay_user_id", "partner_id", "template_id", "merchant_app_id", "out_request_no", "biz_time", "timeout_express") | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "zhima.credit.pe.zmgo.paysign.apply"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(ZhimaCreditPeZmgoPaysignApplyRsp) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// zhima.credit.pe.zmgo.paysign.confirm(芝麻GO支付下单链路签约确认) | |||
// 文档地址:https://opendocs.alipay.com/apis/01xcif | |||
func (a *Client) ZhimaCreditPeZmgoPaysignConfirm(ctx context.Context, bm gopay.BodyMap) (aliRsp *ZhimaCreditPeZmgoPaysignConfirmRsp, err error) { | |||
err = bm.CheckEmptyError("alipay_user_id", "partner_id", "merchant_app_id", "zmgo_opt_no", "biz_type") | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "zhima.credit.pe.zmgo.paysign.confirm"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(ZhimaCreditPeZmgoPaysignConfirmRsp) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// zhima.credit.payafteruse.creditagreement.sign(信用服务开通/授权) | |||
// 文档地址:https://opendocs.alipay.com/open/03uloz | |||
func (a *Client) ZhimaCreditPayAfterUseAgreementSign(ctx context.Context, bm gopay.BodyMap) (orderStr string, err error) { | |||
err = bm.CheckEmptyError("out_agreement_no", "zm_service_id") | |||
if err != nil { | |||
return gopay.NULL, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "zhima.credit.payafteruse.creditagreement.sign"); err != nil { | |||
return gopay.NULL, err | |||
} | |||
orderStr = string(bs) | |||
return orderStr, nil | |||
} | |||
// zhima.credit.payafteruse.creditagreement.query(查询服务开通/授权信息) | |||
// 文档地址:https://opendocs.alipay.com/open/03ulp0 | |||
func (a *Client) ZhimaCreditPayAfterUseAgreementQuery(ctx context.Context, bm gopay.BodyMap) (aliRsp *ZhimaCreditPayAfterUseAgreementQueryRsp, err error) { | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "zhima.credit.payafteruse.creditagreement.query"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(ZhimaCreditPayAfterUseAgreementQueryRsp) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// zhima.credit.payafteruse.creditbizorder.order(芝麻信用服务下单(免用户确认场景)) | |||
// 文档地址:https://opendocs.alipay.com/open/03ulpo | |||
func (a *Client) ZhimaCreditPayAfterUseCreditBizOrder(ctx context.Context, bm gopay.BodyMap) (aliRsp *ZhimaCreditPayAfterUseCreditBizOrderRsp, err error) { | |||
err = bm.CheckEmptyError("out_order_no", "credit_agreement_id", "subject") | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "zhima.credit.payafteruse.creditbizorder.order"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(ZhimaCreditPayAfterUseCreditBizOrderRsp) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// zhima.credit.payafteruse.creditbizorder.query(信用服务订单查询) | |||
// 文档地址:https://opendocs.alipay.com/open/03vtet | |||
func (a *Client) ZhimaCreditPayAfterUseCreditBizOrderQuery(ctx context.Context, bm gopay.BodyMap) (aliRsp *ZhimaCreditPayAfterUseCreditBizOrderQueryRsp, err error) { | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "zhima.credit.payafteruse.creditbizorder.query"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(ZhimaCreditPayAfterUseCreditBizOrderQueryRsp) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// zhima.credit.payafteruse.creditbizorder.finish(结束信用服务订单) | |||
// 文档地址:https://opendocs.alipay.com/open/03vteu | |||
func (a *Client) ZhimaCreditPayAfterUseCreditBizOrderFinish(ctx context.Context, bm gopay.BodyMap) (aliRsp *ZhimaCreditPayAfterUseCreditBizOrderFinishRsp, err error) { | |||
err = bm.CheckEmptyError("out_request_no", "credit_biz_order_id") | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "zhima.credit.payafteruse.creditbizorder.finish"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(ZhimaCreditPayAfterUseCreditBizOrderFinishRsp) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// zhima.customer.jobworth.adapter.query(职得工作证信息匹配度查询) | |||
// 文档地址:https://opendocs.alipay.com/apis/022mvz | |||
func (a *Client) ZhimaCustomerJobworthAdapterQuery(ctx context.Context, bm gopay.BodyMap) (aliRsp *ZhimaCustomerJobworthAdapterQueryRsp, err error) { | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "zhima.customer.jobworth.adapter.query"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(ZhimaCustomerJobworthAdapterQueryRsp) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// zhima.customer.jobworth.scene.use(职得工作证外部渠道应用数据回流) | |||
// 文档地址:https://opendocs.alipay.com/apis/022waz | |||
func (a *Client) ZhimaCustomerJobworthSceneUse(ctx context.Context, bm gopay.BodyMap) (aliRsp *ZhimaCustomerJobworthSceneUseRsp, err error) { | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "zhima.customer.jobworth.scene.use"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(ZhimaCustomerJobworthSceneUseRsp) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// zhima.customer.jobworth.authentication.query(职得身份认证查询接口) | |||
// 文档地址:https://opendocs.alipay.com/open/351177b5_zhima.customer.jobworth.authentication.query | |||
func (a *Client) ZhimaCustomerJobworthAuthQuery(ctx context.Context, bm gopay.BodyMap) (aliRsp *ZhimaCustomerJobworthAuthQueryRsp, err error) { | |||
err = bm.CheckEmptyError("conn_key", "once_token", "query_type", "identity_type", "service_id") | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "zhima.customer.jobworth.authentication.query"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(ZhimaCustomerJobworthAuthQueryRsp) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} | |||
// zhima.customer.jobworth.authentication.preconsult(身份验真预咨询服务) | |||
// 文档地址:https://opendocs.alipay.com/open/16f72e43_zhima.customer.jobworth.authentication.preconsult | |||
func (a *Client) ZhimaCustomerJobworthAuthPreConsult(ctx context.Context, bm gopay.BodyMap) (aliRsp *ZhimaCustomerJobworthAuthPreConsultRsp, err error) { | |||
err = bm.CheckEmptyError("out_agreement_no", "once_token", "identity_type", "query_type", "zm_service_id") | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = a.doAliPay(ctx, bm, "zhima.customer.jobworth.authentication.preconsult"); err != nil { | |||
return nil, err | |||
} | |||
aliRsp = new(ZhimaCustomerJobworthAuthPreConsultRsp) | |||
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { | |||
return aliRsp, err | |||
} | |||
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) | |||
aliRsp.SignData = signData | |||
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) | |||
} |
@@ -1,439 +0,0 @@ | |||
package alipay | |||
import ( | |||
"errors" | |||
"testing" | |||
"github.com/go-pay/gopay" | |||
"github.com/go-pay/util" | |||
"github.com/go-pay/xlog" | |||
) | |||
// 芝麻企业信用信用评估初始化测试 | |||
func TestZhimaCreditEpSceneRatingInitialize(t *testing.T) { | |||
// 请求参数 | |||
bm := make(gopay.BodyMap) | |||
bm.Set("credit_category", "ZMSCCO_5_1_1") | |||
bm.Set("product_code", "w1010100100000000001") | |||
bm.Set("out_order_no", "201805301527674106562F0000954216") | |||
bm.Set("user_id", "2088302248028263") | |||
aliRsp, err := client.ZhimaCreditEpSceneRatingInitialize(ctx, bm) | |||
if err != nil { | |||
//xlog.Errorf("client.ZhimaCreditEpSceneRatingInitialize(%+v),error:%+v", bm, err) | |||
return | |||
} | |||
xlog.Debug("aliRsp:", *aliRsp) | |||
} | |||
// 信用服务履约同步测试 | |||
func TestZhimaCreditEpSceneFulfillmentSync(t *testing.T) { | |||
// 请求参数 | |||
bm := make(gopay.BodyMap) | |||
bm.Set("credit_order_no", "zme20181106154144733795615964647") | |||
bm.Set("out_order_no", "trade201805301527674106562F0000954217") | |||
bm.Set("biz_time", "2018-12-06 18:53:59") | |||
bm.Set("biz_ext_param", "{\"total_amount\":\"32890\"}") | |||
aliRsp, err := client.ZhimaCreditEpSceneFulfillmentSync(ctx, bm) | |||
if err != nil { | |||
//xlog.Errorf("client.ZhimaCreditEpSceneFulfillmentSync(%+v),error:%+v", bm, err) | |||
return | |||
} | |||
xlog.Debug("aliRsp:", *aliRsp) | |||
} | |||
// 加入信用服务测试 | |||
func TestZhimaCreditEpSceneAgreementUse(t *testing.T) { | |||
// 请求参数 | |||
bm := make(gopay.BodyMap) | |||
bm.Set("rating_order_no", "zme20181106154144730565715957902") | |||
bm.Set("out_order_no", "test201805301527674106562F0000954216") | |||
bm.Set("biz_time", "2018-12-06 18:53:59") | |||
bm.Set("provision_code", "P$ZMSCCO_5_1_1$00001") | |||
bm.Set("biz_ext_param", "{\"total_amount\":\"32890\"}") | |||
aliRsp, err := client.ZhimaCreditEpSceneAgreementUse(ctx, bm) | |||
if err != nil { | |||
//xlog.Errorf("client.ZhimaCreditEpSceneAgreementUse(%+v),error:%+v", bm, err) | |||
return | |||
} | |||
xlog.Debug("aliRsp:", *aliRsp) | |||
} | |||
// 取消信用服务测试 | |||
func TestZhimaCreditEpSceneAgreementCancel(t *testing.T) { | |||
// 请求参数 | |||
bm := make(gopay.BodyMap) | |||
bm.Set("credit_order_no", "zme20181106154144733795615964647") | |||
bm.Set("out_order_no", util.RandomString(64)) | |||
bm.Set("biz_time", "2018-12-06 18:53:59") | |||
aliRsp, err := client.ZhimaCreditEpSceneAgreementCancel(ctx, bm) | |||
if err != nil { | |||
//xlog.Errorf("client.ZhimaCreditEpSceneAgreementCancel(%+v),error:%+v", bm, err) | |||
return | |||
} | |||
xlog.Debug("aliRsp:", *aliRsp) | |||
} | |||
// 信用服务履约同步(批量)测试 | |||
func TestZhimaCreditEpSceneFulfillmentlistSync(t *testing.T) { | |||
// 请求参数 | |||
bm := make(gopay.BodyMap) | |||
bm.Set("credit_order_no", "zme20181106154144733795615964647") | |||
bm.SetBodyMap("fulfillment_info_list", func(bm gopay.BodyMap) { | |||
bm.Set("out_order_no", "trade201805301527674106562F0000954217") | |||
bm.Set("biz_time", "2018-12-06 18:53:59") | |||
bm.Set("biz_ext_param", "{\"total_amount\":\"32890\"}") | |||
}) | |||
aliRsp, err := client.ZhimaCreditEpSceneFulfillmentlistSync(ctx, bm) | |||
if err != nil { | |||
//xlog.Errorf("client.ZhimaCreditEpSceneFulfillmentlistSync(%+v),error:%+v", bm, err) | |||
return | |||
} | |||
xlog.Debug("aliRsp:", *aliRsp) | |||
} | |||
// 芝麻go用户数据回传测试 | |||
func TestZhimaCreditPeZmgoCumulationSync(t *testing.T) { | |||
// 请求参数 | |||
bm := make(gopay.BodyMap) | |||
bm.Set("agreement_no", "20195108518085620000") | |||
bm.Set("user_id", "2088602002015001") | |||
bm.Set("partner_id", "2088621805983504") | |||
bm.Set("out_biz_no", "2020081211223006150094012926289") | |||
bm.Set("biz_time", "2019-03-08 19:51:35") | |||
bm.Set("request_from", "ExternalMerchantSource") | |||
bm.Set("biz_action", "ORDER_PAID") | |||
// 可选 | |||
bm.Set("cumulate_data_type", "AMOUNT") | |||
bm.Set("pay_out_biz_no", "2020081211223006150094012926289") | |||
bm.Set("has_alipay_trade", "false") | |||
bm.Set("ext_info", "{\"number\":\"20200303938282939\"}") | |||
bm.SetBodyMap("task_type_data", func(bm gopay.BodyMap) { | |||
bm.Set("name", "滴滴打车任务001") | |||
}) | |||
bm.SetBodyMap("amount_type_data", func(bm gopay.BodyMap) { | |||
bm.Set("name", "优惠累计名称001") | |||
bm.SetBodyMap("trade_info", func(bm gopay.BodyMap) { | |||
bm.Set("trade_no", "2020081722001435461000061785") | |||
bm.Set("amount", "3.57") | |||
}) | |||
bm.SetBodyMap("out_discount_infos", func(bm gopay.BodyMap) { | |||
bm.Set("discount_name", "滴滴打车优惠001") | |||
bm.Set("discount_type", "exclusiveBenefit") | |||
bm.Set("discount_amount", "8.75") | |||
}) | |||
}) | |||
aliRsp, err := client.ZhimaCreditPeZmgoCumulationSync(ctx, bm) | |||
if err != nil { | |||
//xlog.Errorf("client.ZhimaCreditPeZmgoCumulationSync(%+v),error:%+v", bm, err) | |||
return | |||
} | |||
xlog.Debug("aliRsp:", *aliRsp) | |||
} | |||
// 商家芝麻GO累计数据回传接口测试 | |||
func TestZhimaMerchantZmgoCumulateSync(t *testing.T) { | |||
// 请求参数 | |||
bm := make(gopay.BodyMap) | |||
bm.Set("agreement_id", "20195108518085620000") | |||
bm.Set("user_id", "2088602002015001") | |||
bm.Set("provider_pid", "2088621805983504") | |||
bm.Set("out_biz_no", "2020081211223006150094012926289") | |||
bm.Set("biz_time", "2019-03-08 19:51:35") | |||
bm.Set("biz_action", "POSITIVE") | |||
bm.Set("sub_biz_action", "ADD") | |||
bm.Set("data_type", "TASK") | |||
// 可选 | |||
bm.Set("refer_out_biz_no", "2020081211223006150094012926289") | |||
bm.SetBodyMap("amount_type_sync_data", func(bm gopay.BodyMap) { | |||
bm.Set("task_desc", "完成一次任务001") | |||
bm.Set("task_amount", "3.57") | |||
bm.Set("trade_no", "2020081722001435461000061785") | |||
bm.Set("has_alipay_trade", "false") | |||
bm.Set("discount_desc", "消费满减优惠001") | |||
bm.Set("discount_amount", "8.75") | |||
}) | |||
bm.SetBodyMap("times_type_sync_data", func(bm gopay.BodyMap) { | |||
bm.Set("task_desc", "完成一次任务001") | |||
bm.Set("task_times", "1") | |||
bm.Set("task_amount", "3.57") | |||
bm.Set("discount_desc", "消费满减优惠001") | |||
bm.Set("discount_amount", "8.75") | |||
}) | |||
bm.SetBodyMap("discount_type_sync_data", func(bm gopay.BodyMap) { | |||
bm.Set("discount_desc", "消费满减优惠001") | |||
bm.Set("discount_amount", "8.75") | |||
}) | |||
aliRsp, err := client.ZhimaMerchantZmgoCumulateSync(ctx, bm) | |||
if err != nil { | |||
//xlog.Errorf("client.ZhimaMerchantZmgoCumulateSync(%+v),error:%+v", bm, err) | |||
return | |||
} | |||
xlog.Debug("aliRsp:", *aliRsp) | |||
} | |||
// 商家芝麻GO累计数据查询接口测试 | |||
func TestZhimaMerchantZmgoCumulateQuery(t *testing.T) { | |||
// 请求参数 | |||
bm := make(gopay.BodyMap) | |||
bm.Set("agreement_id", "20195108518085620000") | |||
bm.Set("user_id", "2088602002015001") | |||
bm.Set("provider_pid", "2088621805983504") | |||
// 可选 | |||
bm.Set("need_detail", "false") | |||
bm.Set("page_no", "1") | |||
bm.Set("page_size", "20") | |||
aliRsp, err := client.ZhimaMerchantZmgoCumulateQuery(ctx, bm) | |||
if err != nil { | |||
//xlog.Errorf("client.ZhimaMerchantZmgoCumulateQuery(%+v),error:%+v", bm, err) | |||
return | |||
} | |||
xlog.Debug("aliRsp:", *aliRsp) | |||
} | |||
// 芝麻GO签约关单测试 | |||
func TestZhimaCreditPeZmgoBizoptClose(t *testing.T) { | |||
// 请求参数 | |||
bm := make(gopay.BodyMap) | |||
bm.Set("alipay_user_id", "2088302841345600") | |||
bm.Set("partner_id", "2088302424614288") | |||
bm.Set("out_request_no", "99202005050100930053707258") | |||
bm.Set("template_id", "2021012300020903090008858258") | |||
aliRsp, err := client.ZhimaCreditPeZmgoBizoptClose(ctx, bm) | |||
if err != nil { | |||
//xlog.Errorf("client.ZhimaCreditPeZmgoBizoptClose(%+v),error:%+v", bm, err) | |||
return | |||
} | |||
xlog.Debug("aliRsp:", *aliRsp) | |||
} | |||
// 芝麻GO结算退款接口测试 | |||
func TestZhimaCreditPeZmgoSettleRefund(t *testing.T) { | |||
// 请求参数 | |||
bm := make(gopay.BodyMap) | |||
bm.Set("agreement_id", "ZMGO_AGR2021010510020604080000006001") | |||
bm.Set("partner_id", "2088302424614288") | |||
bm.Set("alipay_user_id", "2088302841345600") | |||
bm.Set("refund_amount", "3.00") | |||
bm.Set("out_request_no", "99202005050100930053707258") | |||
// 可选 | |||
bm.Set("memo", "退款") | |||
bm.Set("withhold_plan_no", "ZMGO_WHD2021010510020603410000006001") | |||
bm.Set("refund_type", "MEMBER_FEE_REFUND") | |||
aliRsp, err := client.ZhimaCreditPeZmgoSettleRefund(ctx, bm) | |||
if err != nil { | |||
//xlog.Errorf("client.ZhimaCreditPeZmgoSettleRefund(%+v),error:%+v", bm, err) | |||
return | |||
} | |||
xlog.Debug("aliRsp:", *aliRsp) | |||
} | |||
// 芝麻GO签约预创单测试 | |||
func TestZhimaCreditPeZmgoPreorderCreate(t *testing.T) { | |||
// 请求参数 | |||
bm := make(gopay.BodyMap) | |||
bm.Set("partner_id", "2088437463829741") | |||
bm.Set("template_id", "2020122200020903760008552025") | |||
bm.Set("out_request_no", "ORDER_12345678") | |||
bm.Set("biz_time", "2016-07-06 00:00:02") | |||
// 可选 | |||
bm.Set("freeze_amount", "1.00") | |||
bm.Set("timeout_express", "15m") | |||
bm.Set("alipay_user_id", "2088759402857364") | |||
bm.Set("partner_user_identifier", "user102934889234") | |||
bm.Set("isv_pid", "2088374762857463") | |||
bm.Set("sign_aisle_data", "业务方签约标识") | |||
bm.Set("expire_aisle_data", "业务方签约标识") | |||
bm.Set("pay_aisle_data", "业务方签约标识") | |||
bm.SetBodyMap("ext_template_conf", func(bm gopay.BodyMap) { | |||
bm.Set("xxhm_info_id", "687542") | |||
bm.Set("buyer_id", "11212321121") | |||
}) | |||
aliRsp, err := client.ZhimaCreditPeZmgoPreorderCreate(ctx, bm) | |||
if err != nil { | |||
//xlog.Errorf("client.ZhimaCreditPeZmgoPreorderCreate(%+v),error:%+v", bm, err) | |||
return | |||
} | |||
xlog.Debug("aliRsp:", *aliRsp) | |||
} | |||
// 芝麻GO协议解约测试 | |||
func TestZhimaCreditPeZmgoAgreementUnsign(t *testing.T) { | |||
// 请求参数 | |||
bm := make(gopay.BodyMap) | |||
bm.Set("agreement_id", "ZMGO_AGR2020122710020604120000000001") | |||
bm.Set("partner_id", "2088302424614288") | |||
// 可选 | |||
bm.Set("alipay_user_id", "2088302841345600") | |||
bm.Set("quit_type", "SETTLE_APPLY_QUIT") | |||
aliRsp, err := client.ZhimaCreditPeZmgoAgreementUnsign(ctx, bm) | |||
if err != nil { | |||
//xlog.Errorf("client.ZhimaCreditPeZmgoAgreementUnsign(%+v),error:%+v", bm, err) | |||
return | |||
} | |||
xlog.Debug("aliRsp:", *aliRsp) | |||
} | |||
// 芝麻Go协议查询接口测试 | |||
func TestZhimaCreditPeZmgoAgreementQuery(t *testing.T) { | |||
// 请求参数 | |||
bm := make(gopay.BodyMap) | |||
bm.Set("agreement_id", "20185513447859192007") | |||
bm.Set("alipay_user_id", "2088101117955611") | |||
aliRsp, err := client.ZhimaCreditPeZmgoAgreementQuery(ctx, bm) | |||
if err != nil { | |||
//xlog.Errorf("client.ZhimaCreditPeZmgoAgreementQuery(%+v),error:%+v", bm, err) | |||
return | |||
} | |||
xlog.Debug("aliRsp:", *aliRsp) | |||
} | |||
// 芝麻Go解冻接口测试 | |||
func TestZhimaCreditPeZmgoSettleUnfreeze(t *testing.T) { | |||
// 请求参数 | |||
bm := make(gopay.BodyMap) | |||
bm.Set("agreement_id", "20185513447859192007") | |||
bm.Set("out_request_no", "8077735255938032") | |||
bm.Set("unfreeze_amount", "3.00") | |||
bm.Set("biz_time", "2014-09-15 11:23:04") | |||
bm.Set("alipay_user_id", "2088101117955611") | |||
// 可选 | |||
bm.Set("partner_id", "2088411663864410") | |||
bm.Set("order_title", "2088411663864410") | |||
bm.SetBodyMap("unfreeze_extend_params", func(bm gopay.BodyMap) { | |||
bm.Set("total_real_pay_amount", "3.00") | |||
bm.Set("total_discount_amount", "3.00") | |||
bm.Set("total_task_count", "0") | |||
bm.Set("quit_type", "SETTLE_APPLY_QUIT") | |||
}) | |||
aliRsp, err := client.ZhimaCreditPeZmgoSettleUnfreeze(ctx, bm) | |||
if err != nil { | |||
//xlog.Errorf("client.ZhimaCreditPeZmgoSettleUnfreeze(%+v),error:%+v", bm, err) | |||
return | |||
} | |||
xlog.Debug("aliRsp:", *aliRsp) | |||
} | |||
// 芝麻GO支付下单链路签约申请测试 | |||
func TestZhimaCreditPeZmgoPaysignApply(t *testing.T) { | |||
// 请求参数 | |||
bm := make(gopay.BodyMap) | |||
bm.Set("alipay_user_id", "2088302841345600") | |||
bm.Set("partner_id", "2088302424614288") | |||
bm.Set("template_id", "2021012300020903090008858258") | |||
bm.Set("merchant_app_id", "2021001118641054") | |||
bm.Set("out_request_no", "99202005050100930053707258") | |||
bm.Set("biz_time", "2016-07-06 00:00:02") | |||
bm.Set("timeout_express", "1m") | |||
// 可选 | |||
aliRsp, err := client.ZhimaCreditPeZmgoPaysignApply(ctx, bm) | |||
if err != nil { | |||
//xlog.Errorf("client.ZhimaCreditPeZmgoPaysignApply(%+v),error:%+v", bm, err) | |||
return | |||
} | |||
xlog.Debug("aliRsp:", *aliRsp) | |||
} | |||
// 芝麻GO支付下单链路签约确认测试 | |||
func TestZhimaCreditPeZmgoPaysignConfirm(t *testing.T) { | |||
// 请求参数 | |||
bm := make(gopay.BodyMap) | |||
bm.Set("alipay_user_id", "20195108518085620000") | |||
bm.Set("partner_id", "2088302424614288") | |||
bm.Set("merchant_app_id", "2021001118641054") | |||
bm.Set("zmgo_opt_no", "ZMGO_OPT2021040110020607570001198871") | |||
bm.Set("biz_type", "hongbaoqiandao") | |||
// 可选 | |||
aliRsp, err := client.ZhimaCreditPeZmgoPaysignConfirm(ctx, bm) | |||
if err != nil { | |||
//xlog.Errorf("client.ZhimaCreditPeZmgoPaysignConfirm(%+v),error:%+v", bm, err) | |||
return | |||
} | |||
xlog.Debug("aliRsp:", *aliRsp) | |||
} | |||
// 职得工作证信息匹配度查询测试 | |||
func TestZhimaCustomerJobworthAdapterQuery(t *testing.T) { | |||
// 请求参数 | |||
bm := make(gopay.BodyMap) | |||
// 可选 | |||
bm.Set("user_id", "2088302887413828") | |||
bm.Set("cert_no", "01011219900101XXXX") | |||
bm.Set("user_name", "张三") | |||
bm.Set("cert_type", "1") | |||
bm.Set("job_name", "java开发") | |||
bm.SetBodyMap("adapter", func(bm gopay.BodyMap) { | |||
bm.Set("edu_level", "BACHELOR") | |||
bm.Set("skill_certificate", "电工证") | |||
bm.Set("age", "18.35") | |||
bm.Set("gender", "男") | |||
bm.Set("city", "330100") | |||
bm.Set("recommend", "5") | |||
}) | |||
aliRsp, err := client.ZhimaCustomerJobworthAdapterQuery(ctx, bm) | |||
if err != nil { | |||
//xlog.Errorf("client.ZhimaCustomerJobworthAdapterQuery(%+v),error:%+v", bm, err) | |||
return | |||
} | |||
xlog.Debug("aliRsp:", *aliRsp) | |||
} | |||
// 职得工作证外部渠道应用数据回流测试 | |||
func TestZhimaCustomerJobworthSceneUse(t *testing.T) { | |||
// 请求参数 | |||
bm := make(gopay.BodyMap) | |||
// 可选 | |||
bm.Set("scene_type", "zhima_job_ext_exposure_info") | |||
bm.SetBodyMap("extra_info", func(bm gopay.BodyMap) { | |||
bm.Set("user_id", "2088302887413828") | |||
bm.Set("cert_no", "01011219900101XXXX") | |||
bm.Set("user_name", "张三") | |||
bm.Set("job_name", "java开发") | |||
bm.Set("job_id", "123456") | |||
bm.Set("scene_time", "1624278367975") | |||
bm.Set("job_category_id", "project") | |||
bm.Set("company_name", "58") | |||
bm.Set("company_id", "123456789") | |||
bm.Set("job_category", "技术") | |||
bm.Set("employer_visit", "true") | |||
bm.Set("self_visit", "true") | |||
}) | |||
aliRsp, err := client.ZhimaCustomerJobworthSceneUse(ctx, bm) | |||
if err != nil { | |||
if errors.Is(err, gopay.UnmarshalErr) { | |||
//xlog.Errorf("%v", err) | |||
return | |||
} | |||
xlog.Errorf("client.ZhimaCustomerJobworthSceneUse(%+v),error:%+v", bm, err) | |||
return | |||
} | |||
xlog.Debug("aliRsp:", *aliRsp) | |||
} |
@@ -1,16 +0,0 @@ | |||
package allinpay | |||
const ( | |||
// 统一支付接口 | |||
payPath = "/unitorder/pay" | |||
// 统一扫码接口 | |||
scanQrPath = "/unitorder/scanqrpay" | |||
// 交易查询接口 | |||
queryPath = "/tranx/query" | |||
// 交易退款接口 | |||
refundPath = "/tranx/refund" | |||
// 交易取消接口 | |||
cancelPath = "/tranx/cancel" | |||
// 订单关闭 | |||
closePath = "/unitorder/close" | |||
) |
@@ -1,8 +0,0 @@ | |||
package cert | |||
const ( | |||
CusId = "990361082416001" | |||
AppId = "00012395" | |||
PrivateKey = "MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQCW/IG0a0swTXKqT6h9rEDh7i2LS1+92Ab/e4ZbNT+zWKzYPkbJ96EphN49ik7gMK1BOaMS9C+AgGvEDgizGxTR+RoRsbbeTqBMdVm2rDUK4tnlVHoWEa5eDOLomzb4EJs03OJ91qcgJk9neCTEkntXWcBKNNXEvlCFXAPEfsaccEXmi2ouYyaqT5cYBihULYB7DTTPXsOg09A/KjICSJIBGTFRjjpfwgXisjBaNjOWYAlXHF3UVisMlZueKVWnO1USdWK24gQEis1HSf0mj61rAVQMt5/dkMYbxVQlQvKlJFMXt/koKzo1GoanMfyFSg0iyI6zcBWynhmBIASwwkdzAgMBAAECggEAO/vYOcnQhsGWFvRrr3XiFwAtZuQMhtsOuKwl7hFjG8jUblqbe/ydseV/93n9qRKdmkagM1UAlDAw4CRlL2bIaDzrLvFoAbzB8W5DtI+IySjjwTjFAgSHPgUnlpqnhXjveFpyvuSq49pkfGpeTRwW1VaqTrDb5nxnd/vc4VEubZKO6D1wgUpyczNiqvjfEecX0gwLHtwUI6jqMYcq0bRCJ5aXqXZHBqIDZ+2j9wpBx0CvdNdRULYAwO824xLxmCu3cIAUBntTsZ6MlBjIfYHdXJY3jOwK2AR+RPJ3NDPotgwf9JkxcAGRqC47GEn1Wjz1iDglhLnasPHYeOXczLsAfQKBgQDJYL4CIXPNfAbCdJKGb0H2kKrkG4Jt2PnYKySFLKzY9HvKnco9h+6t6lxvtTlWZtb8gLwiDsqaP4X24W6pVwedkSSK8JPbjaepDA7gzqCGRE7IVJLMU6PO8j0DNXGT5z9whNQJXWv6qIlC3AeWBHNov0b2BK7RXWr54YP5tpoChwKBgQC/8K54scZYV/XlYmaFQnzv9ZCUaLrPyvpDzXi0jxmIuYs2uslWKnsXzgGZNcbaDdIRa0T4xNHCVkbb3AW2QfEqXA+TUjse877znScTkfdVsW0dADHEm5YN9Ec1sxPQI4IUaWqC//59AjewfDJS6lEcerGvIZLPVG6y1L7E0AcStQKBgQDIrWSMQQPiyO7/hyWhXGvypxX1fUiL6QaJmeyp3exdw709G+M3UCfVHlCBbao25QLm2+8fTXgvIJCChwI9NKI9Li+pWbcuuspSltaYxrCHPLj5v/YOMmdySkns0axehLreiS+4KWX6g0tN2nCg2cycnMi9T8tajmqVm1tmVMbDLwKBgFC6/ddcBq3vyUhC3BYewgf3xGj3p+NwX1UXXjarnbTJPcm2RKrOUVnQ1xFG8i2S9JFJCgiMWCGiQkmFQI3JLJOBhzeStbUuFlnG9sGfemV7rAYvp78nJbUW0sC+Yo3/8V1+fUM+Qx73SM8dXdlMHvOYk5WyzFoSDEGBg/+p89+lAoGBAMhuMLE0K1mDxF4fp9Bpxvu2xhJuFYfBQNizUQE4nPvjG7czFv7UZXhO9ml6OOf9483YBHi9O3uhMTjiiqnFVcJrjiy3bhsdamm9FnO7GMgoZ7QOlq8LNikVRuPj+udSwrF3ICVAMMKq8bAxzZTGQoAH2He3S5K4dY+kGbsTsQxt" | |||
PublicKey = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCm9OV6zH5DYH/ZnAVYHscEELdCNfNTHGuBv1nYYEY9FrOzE0/4kLl9f7Y9dkWHlc2ocDwbrFSm0Vqz0q2rJPxXUYBCQl5yW3jzuKSXif7q1yOwkFVtJXvuhf5WRy+1X5FOFoMvS7538No0RpnLzmNi3ktmiqmhpcY/1pmt20FHQQIDAQAB" | |||
) |
@@ -1,143 +0,0 @@ | |||
package allinpay | |||
import ( | |||
"context" | |||
"crypto" | |||
"crypto/rand" | |||
"crypto/rsa" | |||
"crypto/sha1" | |||
"encoding/base64" | |||
"errors" | |||
"fmt" | |||
"hash" | |||
"sync" | |||
"github.com/go-pay/crypto/xpem" | |||
"github.com/go-pay/crypto/xrsa" | |||
"github.com/go-pay/gopay" | |||
"github.com/go-pay/gopay/pkg/xhttp" | |||
"github.com/go-pay/util" | |||
) | |||
type Client struct { | |||
orgId string // 集团/代理编号 可为空 | |||
CusId string // 实际交易商户号 | |||
AppId string // 平台分配的APPID | |||
SignType string // 签名类型 | |||
isProd bool // 是否正式环境 | |||
privateKey *rsa.PrivateKey // 商户的RSA私钥 | |||
publicKey *rsa.PublicKey // 通联的公钥 | |||
hc *xhttp.Client | |||
mu sync.Mutex | |||
sha1Hash hash.Hash | |||
} | |||
// NewClient 初始化通联客户端 | |||
// cusId:实际交易商户号 | |||
// appid:平台分配的APPID | |||
// privateKey:商户的RSA私钥 | |||
// publicKey:通联的公钥 | |||
// isProd:是否是正式环境 | |||
func NewClient(cusId, appId, privateKey, publicKey string, isProd bool) (*Client, error) { | |||
prk, err := xpem.DecodePrivateKey([]byte(xrsa.FormatAlipayPrivateKey(privateKey))) | |||
if err != nil { | |||
return nil, err | |||
} | |||
puk, err := xpem.DecodePublicKey([]byte(xrsa.FormatAlipayPublicKey(publicKey))) | |||
if err != nil { | |||
return nil, err | |||
} | |||
return &Client{ | |||
CusId: cusId, | |||
AppId: appId, | |||
SignType: RSA, | |||
isProd: isProd, | |||
privateKey: prk, | |||
publicKey: puk, | |||
hc: xhttp.NewClient(), | |||
sha1Hash: sha1.New(), | |||
}, nil | |||
} | |||
// SetOrgId 集团/代理商商户号(因orgid非必填)因此单开方法 | |||
func (c *Client) SetOrgId(id string) *Client { | |||
c.orgId = id | |||
return c | |||
} | |||
// getRsaSign 获取签名字符串 | |||
func (c *Client) getRsaSign(bm gopay.BodyMap, signType string, privateKey *rsa.PrivateKey) (sign string, err error) { | |||
var ( | |||
hashs crypto.Hash | |||
encryptedBytes []byte | |||
) | |||
switch signType { | |||
case RSA: | |||
hashs = crypto.SHA1 | |||
case SM2: | |||
return "", errors.New("暂不支持SM2加密") | |||
default: | |||
hashs = crypto.SHA1 | |||
} | |||
signParams := bm.EncodeAliPaySignParams() | |||
c.mu.Lock() | |||
defer func() { | |||
c.sha1Hash.Reset() | |||
c.mu.Unlock() | |||
}() | |||
c.sha1Hash.Write([]byte(signParams)) | |||
if encryptedBytes, err = rsa.SignPKCS1v15(rand.Reader, privateKey, hashs, c.sha1Hash.Sum(nil)); err != nil { | |||
return gopay.NULL, fmt.Errorf("[%w]: %+v", gopay.SignatureErr, err) | |||
} | |||
sign = base64.StdEncoding.EncodeToString(encryptedBytes) | |||
return | |||
} | |||
// pubParamsHandle 公共参数处理 | |||
func (c *Client) pubParamsHandle(bm gopay.BodyMap) (param string, err error) { | |||
bm.Set("cusid", c.CusId). | |||
Set("appid", c.AppId). | |||
Set("signtype", c.SignType) | |||
//集团/代理商商户号 | |||
if c.orgId != gopay.NULL { | |||
bm.Set("orgid", c.orgId) | |||
} | |||
// version | |||
if version := bm.GetString("version"); version == gopay.NULL { | |||
bm.Set("version", "11") | |||
} | |||
bm.Set("randomstr", util.RandomString(20)) | |||
sign, err := c.getRsaSign(bm, bm.GetString("signtype"), c.privateKey) | |||
if err != nil { | |||
return "", fmt.Errorf("GetRsaSign Error: %w", err) | |||
} | |||
bm.Set("sign", sign) | |||
param = bm.EncodeURLParams() | |||
return | |||
} | |||
// doPost 发起请求 | |||
func (c *Client) doPost(ctx context.Context, path string, bm gopay.BodyMap) (bs []byte, err error) { | |||
param, err := c.pubParamsHandle(bm) | |||
if err != nil { | |||
return nil, err | |||
} | |||
url := baseUrl | |||
if !c.isProd { | |||
url = sandboxBaseUrl | |||
} | |||
res, bs, err := c.hc.Req(xhttp.TypeFormData).Post(url + path).SendString(param).EndBytes(ctx) | |||
if err != nil { | |||
return nil, err | |||
} | |||
if res.StatusCode != 200 { | |||
return nil, fmt.Errorf("HTTP Request Error, StatusCode = %d", res.StatusCode) | |||
} | |||
return bs, nil | |||
} | |||
// SetHttpClient 设置自定义的xhttp.Client | |||
func (c *Client) SetHttpClient(client *xhttp.Client) { | |||
c.hc = client | |||
} |
@@ -1,32 +0,0 @@ | |||
package allinpay | |||
import ( | |||
"context" | |||
"os" | |||
"testing" | |||
"github.com/go-pay/gopay/allinpay/cert" | |||
"github.com/go-pay/xlog" | |||
) | |||
var ( | |||
ctx = context.Background() | |||
client *Client | |||
err error | |||
) | |||
func TestMain(m *testing.M) { | |||
// 初始化通联客户端 | |||
// cusId: 实际交易商户号 | |||
// appid:平台分配的APPID | |||
// privateKey:商户的RSA私钥 | |||
// publicKey:通联的公钥 | |||
// isProd:是否是正式环境 | |||
client, err = NewClient(cert.CusId, cert.AppId, cert.PrivateKey, cert.PublicKey, true) | |||
if err != nil { | |||
xlog.Error(err) | |||
return | |||
} | |||
os.Exit(m.Run()) | |||
} |
@@ -1,26 +0,0 @@ | |||
package allinpay | |||
import ( | |||
"fmt" | |||
) | |||
// BizErr 用于判断通联的业务逻辑是否有错误 | |||
type BizErr struct { | |||
Code string `json:"code"` | |||
Msg string `json:"msg"` | |||
} | |||
// bizErrCheck 检查返回码是否为SUCCESS 否则返回一个BizErr | |||
func bizErrCheck(resp RspBase) error { | |||
if resp.RetCode != "SUCCESS" { | |||
return &BizErr{ | |||
Code: resp.RetCode, | |||
Msg: resp.RetMsg, | |||
} | |||
} | |||
return nil | |||
} | |||
func (e *BizErr) Error() string { | |||
return fmt.Sprintf(`{"code":"%s","msg":"%s"}`, e.Code, e.Msg) | |||
} |
@@ -1,100 +0,0 @@ | |||
package allinpay | |||
const ( | |||
// URL | |||
baseUrl = "https://vsp.allinpay.com/apiweb" | |||
sandboxBaseUrl = "https://syb-test.allinpay.com/apiweb" | |||
RSA = "RSA" | |||
SM2 = "SM2" | |||
// OrderTypeReqSN 商家自由订单号 | |||
OrderTypeReqSN = "reqsn" | |||
// OrderTypeTrxId 通联生产支付号 | |||
OrderTypeTrxId = "trxid" | |||
// PayTypeWXScan 微信扫码支付 | |||
PayTypeWXScan = "W01" | |||
// PayTypeWXJS 微信JS支付 | |||
PayTypeWXJS = "W02" | |||
// PayTypeWXMini 微信小程序支付 | |||
PayTypeWXMini = "W03" | |||
// PayTypeAliScan 支付宝扫码支付 | |||
PayTypeAliScan = "A01" | |||
// PayTypeAliJS 支付宝JS支付 | |||
PayTypeAliJS = "A02" | |||
// PayTypeAliApp 支付宝APP支付 | |||
PayTypeAliApp = "A03" | |||
// PayTypeQQScan 手机QQ扫码支付 | |||
PayTypeQQScan = "Q01" | |||
// PayTypeQQJS 手机QQ JS支付 | |||
PayTypeQQJS = "Q02" | |||
// PayTypeUniPay 银联扫码支付(CSB) | |||
PayTypeUniPay = "U01" | |||
// PayTypeUniJS 银联JS支付 | |||
PayTypeUniJS = "U02" | |||
// PayTypeNumH5 数字货币H5 | |||
PayTypeNumH5 = "S01" | |||
) | |||
type RspBase struct { | |||
RetCode string `json:"retcode"` | |||
RetMsg string `json:"retmsg"` | |||
Sign string `json:"sign"` | |||
Cusid string `json:"cusid"` | |||
Appid string `json:"appid"` | |||
} | |||
// PayRsp 通用支付响应 | |||
type PayRsp struct { | |||
RspBase | |||
Trxid string `json:"trxid"` | |||
ChnlTrxId string `json:"chnltrxid"` | |||
Reqsn string `json:"reqsn"` | |||
RandomStr string `json:"randomstr"` | |||
TrxStatus string `json:"trxstatus"` | |||
FinTime string `json:"fintime"` | |||
ErrMsg string `json:"errmsg"` | |||
PayInfo string `json:"payinfo"` | |||
} | |||
// ScanPayRsp 扫码支付、订单查询响应 | |||
type ScanPayRsp struct { | |||
RspBase | |||
Trxid string `json:"trxid"` | |||
ChnlTrxId string `json:"chnltrxid"` | |||
Reqsn string `json:"reqsn"` | |||
TrxStatus string `json:"trxstatus"` | |||
Acct string `json:"acct"` | |||
TrxCode string `json:"trxcode"` | |||
FinTime string `json:"fintime"` | |||
ErrMsg string `json:"errmsg"` | |||
RandomStr string `json:"randomstr"` | |||
InitAmt string `json:"initamt"` | |||
TrxAmt string `json:"trxamt"` | |||
Fee string `json:"fee"` | |||
Cmid string `json:"cmid"` | |||
Chnlid string `json:"chnlid"` | |||
ChnlData string `json:"chnldata"` | |||
AcctType string `json:"accttype"` | |||
} | |||
// RefundRsp 退款响应 | |||
type RefundRsp struct { | |||
RspBase | |||
Trxid string `json:"trxid"` | |||
Reqsn string `json:"reqsn"` | |||
TrxStatus string `json:"trxstatus"` | |||
FinTime string `json:"fintime"` | |||
ErrMsg string `json:"errmsg"` | |||
Fee string `json:"fee"` | |||
TrxCode string `json:"trxCode"` | |||
RandomStr string `json:"randomstr"` | |||
ChnlTrxId string `json:"chnltrxid"` | |||
} | |||
// CloseRsp 关闭响应 | |||
type CloseRsp struct { | |||
RspBase | |||
TrxStatus string `json:"trxstatus"` | |||
} |
@@ -1,141 +0,0 @@ | |||
package allinpay | |||
import ( | |||
"context" | |||
"encoding/json" | |||
"fmt" | |||
"github.com/go-pay/gopay" | |||
) | |||
// Pay 统一支付接口 https://aipboss.allinpay.com/know/devhelp/main.php?pid=15#mid=88 | |||
func (c *Client) Pay(ctx context.Context, bm gopay.BodyMap) (rsp *PayRsp, err error) { | |||
err = bm.CheckEmptyError("reqsn", "paytype") | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = c.doPost(ctx, payPath, bm); err != nil { | |||
return nil, err | |||
} | |||
rsp = new(PayRsp) | |||
if err = json.Unmarshal(bs, rsp); err != nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err := bizErrCheck(rsp.RspBase); err != nil { | |||
return nil, err | |||
} | |||
rsp = new(PayRsp) | |||
if err = json.Unmarshal(bs, rsp); err != nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
return rsp, c.verifySign(bs) | |||
} | |||
// ScanPay 统一扫码接口 https://aipboss.allinpay.com/know/devhelp/main.php?pid=15#mid=89 | |||
func (c *Client) ScanPay(ctx context.Context, bm gopay.BodyMap) (rsp *ScanPayRsp, err error) { | |||
err = bm.CheckEmptyError("reqsn", "authcode", "terminfo") | |||
if err != nil { | |||
return nil, err | |||
} | |||
var bs []byte | |||
if bs, err = c.doPost(ctx, scanQrPath, bm); err != nil { | |||
return nil, err | |||
} | |||
rsp = new(ScanPayRsp) | |||
if err = json.Unmarshal(bs, rsp); err != nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err := bizErrCheck(rsp.RspBase); err != nil { | |||
return nil, err | |||
} | |||
return rsp, c.verifySign(bs) | |||
} | |||
// Query 统一查询接口 https://aipboss.allinpay.com/know/devhelp/main.php?pid=15#mid=836 | |||
func (c *Client) Query(ctx context.Context, orderType string, no string) (rsp *ScanPayRsp, err error) { | |||
bm := gopay.BodyMap{} | |||
switch orderType { | |||
case OrderTypeReqSN: | |||
bm.Set("reqsn", no) | |||
case OrderTypeTrxId: | |||
bm.Set("trxid", no) | |||
} | |||
var bs []byte | |||
if bs, err = c.doPost(ctx, queryPath, bm); err != nil { | |||
return nil, err | |||
} | |||
rsp = new(ScanPayRsp) | |||
if err = json.Unmarshal(bs, rsp); err != nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err := bizErrCheck(rsp.RspBase); err != nil { | |||
return nil, err | |||
} | |||
return rsp, nil | |||
} | |||
// Refund 统一退款接口 https://aipboss.allinpay.com/know/devhelp/main.php?pid=15#mid=838 | |||
func (c *Client) Refund(ctx context.Context, bm gopay.BodyMap) (rsp *RefundRsp, err error) { | |||
err = bm.CheckEmptyError("reqsn", "trxamt") | |||
if err != nil { | |||
return nil, err | |||
} | |||
if bm.GetString("oldreqsn") == gopay.NULL && bm.GetString("oldtrxid") == gopay.NULL { | |||
return nil, fmt.Errorf("[%w], %v", gopay.MissParamErr, "oldreqsn和oldtrxid必填其一") | |||
} | |||
var bs []byte | |||
if bs, err = c.doPost(ctx, refundPath, bm); err != nil { | |||
return nil, err | |||
} | |||
rsp = new(RefundRsp) | |||
if err = json.Unmarshal(bs, rsp); err != nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err := bizErrCheck(rsp.RspBase); err != nil { | |||
return nil, err | |||
} | |||
return rsp, nil | |||
} | |||
// Cancel 统一撤销接口 https://aipboss.allinpay.com/know/devhelp/main.php?pid=15#mid=837 | |||
func (c *Client) Cancel(ctx context.Context, bm gopay.BodyMap) (rsp *RefundRsp, err error) { | |||
err = bm.CheckEmptyError("reqsn", "trxamt") | |||
if err != nil { | |||
return nil, err | |||
} | |||
if bm.GetString("oldreqsn") == gopay.NULL && bm.GetString("oldtrxid") == gopay.NULL { | |||
return nil, fmt.Errorf("[%w], %v", gopay.MissParamErr, "oldreqsn和oldtrxid必填其一") | |||
} | |||
var bs []byte | |||
if bs, err = c.doPost(ctx, cancelPath, bm); err != nil { | |||
return nil, err | |||
} | |||
rsp = new(RefundRsp) | |||
if err = json.Unmarshal(bs, rsp); err != nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err := bizErrCheck(rsp.RspBase); err != nil { | |||
return nil, err | |||
} | |||
return rsp, nil | |||
} | |||
// Close 订单关闭 https://aipboss.allinpay.com/know/devhelp/main.php?pid=15#mid=424 | |||
func (c *Client) Close(ctx context.Context, bm gopay.BodyMap) (rsp *CloseRsp, err error) { | |||
if bm.GetString("oldreqsn") == gopay.NULL && bm.GetString("oldtrxid") == gopay.NULL { | |||
return nil, fmt.Errorf("[%w], %v", gopay.MissParamErr, "oldreqsn和oldtrxid必填其一") | |||
} | |||
var bs []byte | |||
if bs, err = c.doPost(ctx, closePath, bm); err != nil { | |||
return nil, err | |||
} | |||
rsp = new(CloseRsp) | |||
if err = json.Unmarshal(bs, rsp); err != nil { | |||
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) | |||
} | |||
if err := bizErrCheck(rsp.RspBase); err != nil { | |||
return nil, err | |||
} | |||
return rsp, nil | |||
} |
@@ -1,86 +0,0 @@ | |||
package allinpay | |||
import ( | |||
"testing" | |||
"github.com/go-pay/gopay" | |||
"github.com/go-pay/xlog" | |||
) | |||
func TestClient_ScanPay(t *testing.T) { | |||
// 扫码支付 | |||
// 请求参数 | |||
bm := make(gopay.BodyMap) | |||
bm.Set("trxamt", "1"). | |||
Set("reqsn", "larry01"). | |||
Set("body", "支付测试"). | |||
SetBodyMap("terminfo", func(b gopay.BodyMap) { | |||
b.Set("devicetype", "10"). | |||
Set("termno", "00000001") | |||
}). | |||
Set("authcode", "131104796948096102") | |||
// 创建订单 | |||
resp, err := client.ScanPay(ctx, bm) | |||
xlog.Debugf("allRsp:%+v", resp) | |||
if err != nil { | |||
xlog.Errorf("%+v", err) | |||
return | |||
} | |||
} | |||
func TestClient_Query(t *testing.T) { | |||
// 查询订单 | |||
resp, err := client.Query(ctx, OrderTypeReqSN, "larry01") | |||
xlog.Debugf("aliRsp:%+v", resp) | |||
if err != nil { | |||
xlog.Errorf("%+v", err) | |||
return | |||
} | |||
} | |||
func TestClient_Refund(t *testing.T) { | |||
// 请求参数 | |||
bm := make(gopay.BodyMap) | |||
bm.Set("trxamt", "1"). | |||
Set("reqsn", "relarry01"). | |||
Set("remark", "支付测试退款"). | |||
Set("oldreqsn", "larry01") | |||
// 退款 | |||
resp, err := client.Refund(ctx, bm) | |||
xlog.Debugf("allRsp:%+v", resp) | |||
if err != nil { | |||
xlog.Errorf("%+v", err) | |||
return | |||
} | |||
} | |||
func TestClient_Cancel(t *testing.T) { | |||
// 订单退款 | |||
bm := make(gopay.BodyMap) | |||
bm.Set("trxamt", "1"). | |||
Set("reqsn", "cclarry01"). | |||
Set("remark", "支付测试取消"). | |||
Set("oldreqsn", "larry01") | |||
// 取消订单 | |||
resp, err := client.Cancel(ctx, bm) | |||
xlog.Debugf("allRsp:%+v", resp) | |||
if err != nil { | |||
xlog.Errorf("%+v", err) | |||
return | |||
} | |||
} | |||
func TestClient_Close(t *testing.T) { | |||
// 订单关闭 | |||
bm := make(gopay.BodyMap) | |||
bm.Set("oldreqsn", "larry01") | |||
// 创建订单 | |||
resp, err := client.Close(ctx, bm) | |||
xlog.Debugf("allRsp:%+v", resp) | |||
if err != nil { | |||
xlog.Errorf("%+v", err) | |||
return | |||
} | |||
} |
@@ -1,34 +0,0 @@ | |||
package allinpay | |||
import ( | |||
"crypto" | |||
"crypto/rsa" | |||
"encoding/base64" | |||
"encoding/json" | |||
"fmt" | |||
"github.com/go-pay/gopay" | |||
) | |||
// verifySign 验证响应签名 | |||
func (c *Client) verifySign(bs []byte) (err error) { | |||
bm := gopay.BodyMap{} | |||
if err = json.Unmarshal(bs, &bm); err != nil { | |||
return err | |||
} | |||
sign := bm.Get("sign") | |||
bm.Remove("sign") | |||
signData := bm.EncodeAliPaySignParams() | |||
signBytes, _ := base64.StdEncoding.DecodeString(sign) | |||
hashs := crypto.SHA1 | |||
c.mu.Lock() | |||
defer func() { | |||
c.sha1Hash.Reset() | |||
c.mu.Unlock() | |||
}() | |||
c.sha1Hash.Write([]byte(signData)) | |||
if err = rsa.VerifyPKCS1v15(c.publicKey, hashs, c.sha1Hash.Sum(nil), signBytes); err != nil { | |||
return fmt.Errorf("[%w]: %v", gopay.VerifySignatureErr, err) | |||
} | |||
return nil | |||
} |
@@ -1,30 +0,0 @@ | |||
package apple | |||
import ( | |||
"crypto/ecdsa" | |||
"crypto/x509" | |||
"encoding/pem" | |||
"errors" | |||
) | |||
// ParseECPrivateKeyFromPEM parses a PEM encoded Elliptic Curve Private Key Structure | |||
func ParseECPrivateKeyFromPEM(key []byte) (*ecdsa.PrivateKey, error) { | |||
var err error | |||
// Parse PEM block | |||
var block *pem.Block | |||
if block, _ = pem.Decode(key); block == nil { | |||
return nil, errors.New("decode private key error") | |||
} | |||
// Parse the key | |||
var parsedKey any | |||
if parsedKey, err = x509.ParseECPrivateKey(block.Bytes); err != nil { | |||
if parsedKey, err = x509.ParsePKCS8PrivateKey(block.Bytes); err != nil { | |||
return nil, err | |||
} | |||
} | |||
pkey, ok := parsedKey.(*ecdsa.PrivateKey) | |||
if !ok { | |||
return nil, errors.New("private key must be ECP private key") | |||
} | |||
return pkey, nil | |||
} |
@@ -1,103 +0,0 @@ | |||
package apple | |||
import ( | |||
"context" | |||
"crypto/ecdsa" | |||
"net/http" | |||
"github.com/go-pay/gopay" | |||
"github.com/go-pay/gopay/pkg/xhttp" | |||
) | |||
// Client AppleClient | |||
type Client struct { | |||
iss string // Your issuer ID from the Keys page in App Store Connect (Ex: "57246542-96fe-1a63-e053-0824d011072a") | |||
bid string // Your app’s bundle ID (Ex: “com.example.testbundleid2021”) | |||
kid string // Your private key ID from App Store Connect (Ex: 2X9R4HXF34) | |||
isProd bool // 是否是正式环境 | |||
privateKey *ecdsa.PrivateKey | |||
hc *xhttp.Client | |||
} | |||
// NewClient 初始化Apple客户端 | |||
// iss:issuer ID | |||
// bid:bundle ID | |||
// kid:private key ID | |||
// privateKey:私钥文件读取后的字符串内容 | |||
// isProd:是否是正式环境 | |||
func NewClient(iss, bid, kid, privateKey string, isProd bool) (client *Client, err error) { | |||
if iss == gopay.NULL || bid == gopay.NULL || kid == gopay.NULL || privateKey == gopay.NULL { | |||
return nil, gopay.MissAppleInitParamErr | |||
} | |||
ecPrivateKey, err := ParseECPrivateKeyFromPEM([]byte(privateKey)) | |||
if err != nil { | |||
return nil, err | |||
} | |||
//ecPrivateKey, err := ecdsa.GenerateKey(elliptic.P256(), rand.Reader) | |||
//if err != nil { | |||
// panic(err) | |||
//} | |||
client = &Client{ | |||
iss: iss, | |||
bid: bid, | |||
kid: kid, | |||
privateKey: ecPrivateKey, | |||
isProd: isProd, | |||
hc: xhttp.NewClient(), | |||
} | |||
return client, nil | |||
} | |||
func (c *Client) doRequestGet(ctx context.Context, path string) (res *http.Response, bs []byte, err error) { | |||
uri := hostUrl + path | |||
if !c.isProd { | |||
uri = sandBoxHostUrl + path | |||
} | |||
token, err := c.generatingToken() | |||
if err != nil { | |||
return nil, nil, err | |||
} | |||
req := c.hc.Req() | |||
req.Header.Set("Authorization", "Bearer "+token) | |||
res, bs, err = req.Get(uri).EndBytes(ctx) | |||
if err != nil { | |||
return nil, nil, err | |||
} | |||
return res, bs, nil | |||
} | |||
func (c *Client) doRequestPost(ctx context.Context, path string, bm gopay.BodyMap) (res *http.Response, bs []byte, err error) { | |||
uri := hostUrl + path | |||
if !c.isProd { | |||
uri = sandBoxHostUrl + path | |||
} | |||
token, err := c.generatingToken() | |||
if err != nil { | |||
return nil, nil, err | |||
} | |||
req := c.hc.Req() | |||
req.Header.Set("Authorization", "Bearer "+token) | |||
res, bs, err = req.Post(uri).SendBodyMap(bm).EndBytes(ctx) | |||
if err != nil { | |||
return nil, nil, err | |||
} | |||
return res, bs, nil | |||
} | |||
func (c *Client) doRequestPut(ctx context.Context, path string, bm gopay.BodyMap) (res *http.Response, bs []byte, err error) { | |||
uri := hostUrl + path | |||
if !c.isProd { | |||
uri = sandBoxHostUrl + path | |||
} | |||
token, err := c.generatingToken() | |||
if err != nil { | |||
return nil, nil, err | |||
} | |||
req := c.hc.Req() | |||
req.Header.Set("Authorization", "Bearer "+token) | |||
res, bs, err = req.Put(uri).SendBodyMap(bm).EndBytes(ctx) | |||
if err != nil { | |||
return nil, nil, err | |||
} | |||
return res, bs, nil | |||
} |
@@ -1,36 +0,0 @@ | |||
package apple | |||
import ( | |||
"context" | |||
"os" | |||
"testing" | |||
"github.com/go-pay/xlog" | |||
) | |||
var ( | |||
ctx = context.Background() | |||
client *Client | |||
err error | |||
iss = "57246542-96fe-1a63-e053-0824d011072a" | |||
bid = "com.example.testbundleid2021" | |||
kid = "2X9R4HXF34" | |||
) | |||
func TestMain(m *testing.M) { | |||
xlog.SetLevel(xlog.DebugLevel) | |||
// 初始化客户端 | |||
// iss:issuer ID | |||
// bid:bundle ID | |||
// kid:private key ID | |||
// privateKey:私钥文件读取后的字符串内容 | |||
// isProd:是否是正式环境 | |||
client, err = NewClient(iss, bid, kid, "privateKey", false) | |||
if err != nil { | |||
xlog.Error(err) | |||
return | |||
} | |||
os.Exit(m.Run()) | |||
} |
@@ -1,27 +0,0 @@ | |||
package apple | |||
const ( | |||
hostUrl = "https://api.storekit.itunes.apple.com" | |||
sandBoxHostUrl = "https://api.storekit-sandbox.itunes.apple.com" | |||
// Get Transaction History | |||
getTransactionHistory = "/inApps/v1/history/%s" // transactionId | |||
// Get Transaction Info | |||
getTransactionInfo = "/inApps/v1/transactions/%s" // transactionId | |||
// Get All Subscription Statuses | |||
getAllSubscriptionStatuses = "/inApps/v1/subscriptions/%s" // transactionId | |||
// Send Consumption Information | |||
sendConsumptionInformation = "/inApps/v1/transactions/consumption/%s" // transactionId | |||
// Look Up Order ID | |||
lookUpOrderID = "/inApps/v1/lookup/%s" // orderId | |||
// Get Subscription Status | |||
getRefundHistory = "/inApps/v2/refund/lookup/%s" // transactionId | |||
// Get Notification History | |||
getNotificationHistory = "/inApps/v1/notifications/history" | |||
) |
@@ -1,23 +0,0 @@ | |||
package apple | |||
import ( | |||
"context" | |||
"fmt" | |||
"net/http" | |||
"github.com/go-pay/gopay" | |||
) | |||
// SendConsumptionInformation Send Consumption Information | |||
// Doc: https://developer.apple.com/documentation/appstoreserverapi/send_consumption_information | |||
func (c *Client) SendConsumptionInformation(ctx context.Context, transactionId string, bm gopay.BodyMap) (err error) { | |||
path := fmt.Sprintf(sendConsumptionInformation, transactionId) | |||
res, _, err := c.doRequestPut(ctx, path, bm) | |||
if err != nil { | |||
return err | |||
} | |||
if res.StatusCode != http.StatusAccepted { | |||
return fmt.Errorf("http.stauts_code = %d", res.StatusCode) | |||
} | |||
return nil | |||
} |