蛋蛋星球-制度模式
Não pode escolher mais do que 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

102 linhas
4.1 KiB

  1. package alipay
  2. import (
  3. "context"
  4. "encoding/json"
  5. "fmt"
  6. "github.com/go-pay/gopay"
  7. )
  8. // alipay.commerce.transport.nfccard.send(NFC用户卡信息同步)
  9. // 文档地址:https://opendocs.alipay.com/apis/api_1/alipay.commerce.transport.nfccard.send
  10. func (a *Client) CommerceTransportNfccardSend(ctx context.Context, bm gopay.BodyMap) (aliRsp *CommerceTransportNfccardSendRsp, err error) {
  11. err = bm.CheckEmptyError("issue_org_no", "card_no", "card_status")
  12. if err != nil {
  13. return nil, err
  14. }
  15. var bs []byte
  16. if bs, err = a.doAliPay(ctx, bm, "alipay.commerce.transport.nfccard.send"); err != nil {
  17. return nil, err
  18. }
  19. aliRsp = new(CommerceTransportNfccardSendRsp)
  20. if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil {
  21. return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs))
  22. }
  23. if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil {
  24. return aliRsp, err
  25. }
  26. signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn)
  27. aliRsp.SignData = signData
  28. return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr)
  29. }
  30. // alipay.commerce.air.callcenter.trade.apply(航司电话订票待申请接口)
  31. // 文档地址:https://opendocs.alipay.com/apis/api_1/alipay.commerce.air.callcenter.trade.apply
  32. func (a *Client) CommerceAirCallcenterTradeApply(ctx context.Context, bm gopay.BodyMap) (aliRsp *CommerceAirCallcenterTradeApplyRsp, err error) {
  33. err = bm.CheckEmptyError("scene_code", "op_code", "channel", "target_id", "target_id_type", "trade_apply_params")
  34. if err != nil {
  35. return nil, err
  36. }
  37. var bs []byte
  38. if bs, err = a.doAliPay(ctx, bm, "alipay.commerce.air.callcenter.trade.apply"); err != nil {
  39. return nil, err
  40. }
  41. aliRsp = new(CommerceAirCallcenterTradeApplyRsp)
  42. if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil {
  43. return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs))
  44. }
  45. if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil {
  46. return aliRsp, err
  47. }
  48. signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn)
  49. aliRsp.SignData = signData
  50. return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr)
  51. }
  52. // alipay.commerce.operation.gamemarketing.benefit.apply(申请权益发放)
  53. // 文档地址:https://opendocs.alipay.com/apis/api_1/alipay.commerce.operation.gamemarketing.benefit.apply
  54. func (a *Client) CommerceBenefitApply(ctx context.Context, bm gopay.BodyMap) (aliRsp *CommerceBenefitApplyRsp, err error) {
  55. err = bm.CheckEmptyError("activity_code", "trade_no", "user_account", "platform")
  56. if err != nil {
  57. return nil, err
  58. }
  59. var bs []byte
  60. if bs, err = a.doAliPay(ctx, bm, "alipay.commerce.operation.gamemarketing.benefit.apply"); err != nil {
  61. return nil, err
  62. }
  63. aliRsp = new(CommerceBenefitApplyRsp)
  64. if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil {
  65. return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs))
  66. }
  67. if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil {
  68. return aliRsp, err
  69. }
  70. signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn)
  71. aliRsp.SignData = signData
  72. return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr)
  73. }
  74. // alipay.commerce.operation.gamemarketing.benefit.verify(权益核销)
  75. // 文档地址:https://opendocs.alipay.com/apis/api_1/alipay.commerce.operation.gamemarketing.benefit.verify
  76. func (a *Client) CommerceBenefitVerify(ctx context.Context, bm gopay.BodyMap) (aliRsp *CommerceBenefitVerifyRsp, err error) {
  77. err = bm.CheckEmptyError("activity_code", "voucher_code", "user_account", "trade_no")
  78. if err != nil {
  79. return nil, err
  80. }
  81. var bs []byte
  82. if bs, err = a.doAliPay(ctx, bm, "alipay.commerce.operation.gamemarketing.benefit.verify"); err != nil {
  83. return nil, err
  84. }
  85. aliRsp = new(CommerceBenefitVerifyRsp)
  86. if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil {
  87. return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs))
  88. }
  89. if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil {
  90. return aliRsp, err
  91. }
  92. signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn)
  93. aliRsp.SignData = signData
  94. return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr)
  95. }