settings.go 797 B

123456789101112131415161718192021222324252627282930
  1. // Copyright 2021 Tencent Inc. All rights reserved.
  2. package core
  3. import (
  4. "fmt"
  5. "net/http"
  6. "git.nanodreamtech.com/sg/wechatpay-go/core/auth"
  7. "git.nanodreamtech.com/sg/wechatpay-go/core/cipher"
  8. )
  9. // DialSettings 微信支付 API v3 Go SDK core.Client 需要的配置信息
  10. type DialSettings struct {
  11. HTTPClient *http.Client // 自定义所使用的 HTTPClient 实例
  12. Signer auth.Signer // 签名器
  13. Validator auth.Validator // 应答包签名校验器
  14. Cipher cipher.Cipher // 敏感字段加解密套件
  15. }
  16. // Validate 校验请求配置是否有效
  17. func (ds *DialSettings) Validate() error {
  18. if ds.Validator == nil {
  19. return fmt.Errorf("validator is required for Client")
  20. }
  21. if ds.Signer == nil {
  22. return fmt.Errorf("signer is required for Client")
  23. }
  24. return nil
  25. }