蛋蛋星球-制度模式
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

37 rindas
1.1 KiB

  1. package alipay
  2. import (
  3. "context"
  4. "encoding/base64"
  5. "encoding/json"
  6. "fmt"
  7. "github.com/go-pay/gopay"
  8. )
  9. // alipay.open.app.alipaycert.download(应用支付宝公钥证书下载)
  10. // 文档地址:https://opendocs.alipay.com/apis/api_9/alipay.open.app.alipaycert.download
  11. func (a *Client) PublicCertDownload(ctx context.Context, bm gopay.BodyMap) (aliRsp *PublicCertDownloadRsp, err error) {
  12. err = bm.CheckEmptyError("alipay_cert_sn")
  13. if err != nil {
  14. return nil, err
  15. }
  16. var bs []byte
  17. if bs, err = a.doAliPay(ctx, bm, "alipay.open.app.alipaycert.download"); err != nil {
  18. return nil, err
  19. }
  20. aliRsp = new(PublicCertDownloadRsp)
  21. if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil {
  22. return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs))
  23. }
  24. if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil {
  25. return aliRsp, err
  26. }
  27. certBs, err := base64.StdEncoding.DecodeString(aliRsp.Response.AlipayCertContent)
  28. if err != nil {
  29. return nil, fmt.Errorf("AlipayCertContent(%s)_DecodeErr:%+v", aliRsp.Response.AlipayCertContent, err)
  30. }
  31. aliRsp.Response.AlipayCertContent = string(certBs)
  32. return aliRsp, nil
  33. }