蛋蛋星球-制度模式
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

194 行
7.6 KiB

  1. package alipay
  2. import (
  3. "context"
  4. "encoding/json"
  5. "fmt"
  6. "github.com/go-pay/gopay"
  7. )
  8. // datadigital.fincloud.generalsaas.face.verification.initialize(人脸核身初始化)
  9. // 文档地址:https://opendocs.alipay.com/open/04jg6r
  10. func (a *Client) FaceVerificationInitialize(ctx context.Context, bm gopay.BodyMap) (aliRsp *FaceVerificationInitializeRsp, err error) {
  11. err = bm.CheckEmptyError("outer_order_no", "biz_code", "identity_type", "cert_type", "cert_name", "cert_no")
  12. if err != nil {
  13. return nil, err
  14. }
  15. var bs []byte
  16. if bs, err = a.doAliPay(ctx, bm, "datadigital.fincloud.generalsaas.face.verification.initialize"); err != nil {
  17. return nil, err
  18. }
  19. aliRsp = new(FaceVerificationInitializeRsp)
  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. // datadigital.fincloud.generalsaas.face.verification.query(人脸核身结果查询)
  31. // 文档地址:https://opendocs.alipay.com/open/04jg6s
  32. func (a *Client) FaceVerificationQuery(ctx context.Context, bm gopay.BodyMap) (aliRsp *FaceVerificationQueryRsp, err error) {
  33. err = bm.CheckEmptyError("certify_id")
  34. if err != nil {
  35. return nil, err
  36. }
  37. var bs []byte
  38. if bs, err = a.doAliPay(ctx, bm, "datadigital.fincloud.generalsaas.face.verification.query"); err != nil {
  39. return nil, err
  40. }
  41. aliRsp = new(FaceVerificationQueryRsp)
  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. // datadigital.fincloud.generalsaas.face.certify.initialize(H5人脸核身初始化)
  53. // 文档地址:https://opendocs.alipay.com/open/02zloa
  54. func (a *Client) FaceCertifyInitialize(ctx context.Context, bm gopay.BodyMap) (aliRsp *FaceCertifyInitializeRsp, err error) {
  55. err = bm.CheckEmptyError("outer_order_no", "biz_code", "identity_param", "merchant_config")
  56. if err != nil {
  57. return nil, err
  58. }
  59. var bs []byte
  60. if bs, err = a.doAliPay(ctx, bm, "datadigital.fincloud.generalsaas.face.certify.initialize"); err != nil {
  61. return nil, err
  62. }
  63. aliRsp = new(FaceCertifyInitializeRsp)
  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. // datadigital.fincloud.generalsaas.face.certify.verify(H5人脸核身开始认证)
  75. // 文档地址:https://opendocs.alipay.com/open/02zlob
  76. func (a *Client) FaceCertifyVerify(ctx context.Context, bm gopay.BodyMap) (aliRsp *FaceCertifyVerifyRsp, err error) {
  77. err = bm.CheckEmptyError("certify_id")
  78. if err != nil {
  79. return nil, err
  80. }
  81. var bs []byte
  82. if bs, err = a.doAliPay(ctx, bm, "datadigital.fincloud.generalsaas.face.certify.verify"); err != nil {
  83. return nil, err
  84. }
  85. aliRsp = new(FaceCertifyVerifyRsp)
  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. }
  96. // datadigital.fincloud.generalsaas.face.certify.query(H5人脸核身查询记录)
  97. // 文档地址:https://opendocs.alipay.com/open/02zloc
  98. func (a *Client) FaceCertifyQuery(ctx context.Context, bm gopay.BodyMap) (aliRsp *FaceCertifyQueryRsp, err error) {
  99. err = bm.CheckEmptyError("certify_id")
  100. if err != nil {
  101. return nil, err
  102. }
  103. var bs []byte
  104. if bs, err = a.doAliPay(ctx, bm, "datadigital.fincloud.generalsaas.face.certify.query"); err != nil {
  105. return nil, err
  106. }
  107. aliRsp = new(FaceCertifyQueryRsp)
  108. if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil {
  109. return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs))
  110. }
  111. if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil {
  112. return aliRsp, err
  113. }
  114. signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn)
  115. aliRsp.SignData = signData
  116. return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr)
  117. }
  118. // datadigital.fincloud.generalsaas.face.source.certify(纯服务端人脸核身)
  119. // 文档地址:https://opendocs.alipay.com/open/04pxq6
  120. func (a *Client) FaceSourceCertify(ctx context.Context, bm gopay.BodyMap) (aliRsp *FaceSourceCertifyRsp, err error) {
  121. err = bm.CheckEmptyError("outer_biz_no", "cert_type", "cert_no", "cert_name")
  122. if err != nil {
  123. return nil, err
  124. }
  125. var bs []byte
  126. if bs, err = a.doAliPay(ctx, bm, "datadigital.fincloud.generalsaas.face.source.certify"); err != nil {
  127. return nil, err
  128. }
  129. aliRsp = new(FaceSourceCertifyRsp)
  130. if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil {
  131. return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs))
  132. }
  133. if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil {
  134. return aliRsp, err
  135. }
  136. signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn)
  137. aliRsp.SignData = signData
  138. return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr)
  139. }
  140. // datadigital.fincloud.generalsaas.face.check.initialize(活体检测初始化)
  141. // 文档地址:https://opendocs.alipay.com/open/03nisu
  142. func (a *Client) FaceCheckInitialize(ctx context.Context, bm gopay.BodyMap) (aliRsp *FaceCheckInitializeRsp, err error) {
  143. err = bm.CheckEmptyError("outer_order_no", "biz_code")
  144. if err != nil {
  145. return nil, err
  146. }
  147. var bs []byte
  148. if bs, err = a.doAliPay(ctx, bm, "datadigital.fincloud.generalsaas.face.check.initialize"); err != nil {
  149. return nil, err
  150. }
  151. aliRsp = new(FaceCheckInitializeRsp)
  152. if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil {
  153. return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs))
  154. }
  155. if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil {
  156. return aliRsp, err
  157. }
  158. signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn)
  159. aliRsp.SignData = signData
  160. return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr)
  161. }
  162. // datadigital.fincloud.generalsaas.face.check.query(活体检测结果查询)
  163. // 文档地址:https://opendocs.alipay.com/open/03nisv
  164. func (a *Client) FaceCheckQuery(ctx context.Context, bm gopay.BodyMap) (aliRsp *FaceCheckQueryRsp, err error) {
  165. err = bm.CheckEmptyError("certify_id")
  166. if err != nil {
  167. return nil, err
  168. }
  169. var bs []byte
  170. if bs, err = a.doAliPay(ctx, bm, "datadigital.fincloud.generalsaas.face.check.query"); err != nil {
  171. return nil, err
  172. }
  173. aliRsp = new(FaceCheckQueryRsp)
  174. if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil {
  175. return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs))
  176. }
  177. if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil {
  178. return aliRsp, err
  179. }
  180. signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn)
  181. aliRsp.SignData = signData
  182. return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr)
  183. }