api_transfer_detail_example_test.go 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. // Copyright 2021 Tencent Inc. All rights reserved.
  2. //
  3. // 服务商批量转账API
  4. //
  5. // No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
  6. //
  7. // API version: 0.0.2
  8. // Code generated by WechatPay APIv3 Generator based on [OpenAPI Generator](https://openapi-generator.tech); DO NOT EDIT.
  9. package partnertransferbatch_test
  10. import (
  11. "context"
  12. "log"
  13. "git.nanodreamtech.com/sg/wechatpay-go/core"
  14. "git.nanodreamtech.com/sg/wechatpay-go/core/option"
  15. "git.nanodreamtech.com/sg/wechatpay-go/services/partnertransferbatch"
  16. "git.nanodreamtech.com/sg/wechatpay-go/utils"
  17. )
  18. func ExampleTransferDetailApiService_GetTransferDetailByNo() {
  19. var (
  20. mchID string = "190000****" // 商户号
  21. mchCertificateSerialNumber string = "3775************************************" // 商户证书序列号
  22. mchAPIv3Key string = "2ab9****************************" // 商户APIv3密钥
  23. )
  24. // 使用 utils 提供的函数从本地文件中加载商户私钥,商户私钥会用来生成请求的签名
  25. mchPrivateKey, err := utils.LoadPrivateKeyWithPath("/path/to/merchant/apiclient_key.pem")
  26. if err != nil {
  27. log.Print("load merchant private key error")
  28. }
  29. ctx := context.Background()
  30. // 使用商户私钥等初始化 client,并使它具有自动定时获取微信支付平台证书的能力
  31. opts := []core.ClientOption{
  32. option.WithWechatPayAutoAuthCipher(mchID, mchCertificateSerialNumber, mchPrivateKey, mchAPIv3Key),
  33. }
  34. client, err := core.NewClient(ctx, opts...)
  35. if err != nil {
  36. log.Printf("new wechat pay client err:%s", err)
  37. }
  38. svc := partnertransferbatch.TransferDetailApiService{Client: client}
  39. resp, result, err := svc.GetTransferDetailByNo(ctx,
  40. partnertransferbatch.GetTransferDetailByNoRequest{
  41. BatchId: core.String("1030000071100999991182020050700019480001"),
  42. DetailId: core.String("1040000071100999991182020050700019500100"),
  43. },
  44. )
  45. if err != nil {
  46. // 处理错误
  47. log.Printf("call GetTransferDetailByNo err:%s", err)
  48. } else {
  49. // 处理返回结果
  50. log.Printf("status=%d resp=%s", result.Response.StatusCode, resp)
  51. }
  52. }
  53. func ExampleTransferDetailApiService_GetTransferDetailByOutNo() {
  54. var (
  55. mchID string = "190000****" // 商户号
  56. mchCertificateSerialNumber string = "3775************************************" // 商户证书序列号
  57. mchAPIv3Key string = "2ab9****************************" // 商户APIv3密钥
  58. )
  59. // 使用 utils 提供的函数从本地文件中加载商户私钥,商户私钥会用来生成请求的签名
  60. mchPrivateKey, err := utils.LoadPrivateKeyWithPath("/path/to/merchant/apiclient_key.pem")
  61. if err != nil {
  62. log.Print("load merchant private key error")
  63. }
  64. ctx := context.Background()
  65. // 使用商户私钥等初始化 client,并使它具有自动定时获取微信支付平台证书的能力
  66. opts := []core.ClientOption{
  67. option.WithWechatPayAutoAuthCipher(mchID, mchCertificateSerialNumber, mchPrivateKey, mchAPIv3Key),
  68. }
  69. client, err := core.NewClient(ctx, opts...)
  70. if err != nil {
  71. log.Printf("new wechat pay client err:%s", err)
  72. }
  73. svc := partnertransferbatch.TransferDetailApiService{Client: client}
  74. resp, result, err := svc.GetTransferDetailByOutNo(ctx,
  75. partnertransferbatch.GetTransferDetailByOutNoRequest{
  76. OutBatchNo: core.String("plfk2020042013"),
  77. OutDetailNo: core.String("x23zy545Bd5436"),
  78. },
  79. )
  80. if err != nil {
  81. // 处理错误
  82. log.Printf("call GetTransferDetailByOutNo err:%s", err)
  83. } else {
  84. // 处理返回结果
  85. log.Printf("status=%d resp=%s", result.Response.StatusCode, resp)
  86. }
  87. }