request_response.go 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. package wx
  2. import "encoding/xml"
  3. /*type UnionPayRequest struct {
  4. AppId string `xml:"appid"` //公众账号ID(是)
  5. MchId string `xml:"mch_id"` //商户号(是)
  6. DeviceInfo string `xml:"device_info"` //设备号
  7. NonceStr string `xml:"nonce_str"` //随机字符串(是)
  8. Sign string `xml:"sign"` //签名(是)
  9. Body string `xml:"body"` //商品描述(是)
  10. Detail string `xml:"detail"` //商品详情
  11. Attach string `xml:"attach"` //附加数据
  12. OutTradeNo string `xml:"out_trade_no"` //商户订单号(是)
  13. FeeType string `xml:"fee_type"` //货币类型
  14. TotalFee int `xml:"total_fee"` //总金额(是)
  15. SpbillCreateIp string `xml:"spbill_create_ip"` //终端IP(是)
  16. TimeStart string `xml:"time_start"` //交易起始时间
  17. TimeExpire string `xml:"time_expire"` //交易结束时间
  18. GoodsTag string `xml:"goods_tag"` //商品标记
  19. NotifyUrl string `xml:"notify_url"` //通知地址(是)
  20. TradeType string `xml:"trade_type"` //交易类型(是)
  21. ProductId string `xml:"product_id"` //商品ID
  22. LimitPay string `xml:"limit_pay"` //指定支付方式
  23. OpenId string `xml:"openid"` //用户标识
  24. }*/
  25. type UnionPayRequest map[string]string
  26. func (s UnionPayRequest) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
  27. tokens := []xml.Token{start}
  28. for key, value := range s {
  29. t := xml.StartElement{Name: xml.Name{"", key}}
  30. tokens = append(tokens, t, xml.CharData(value), xml.EndElement{t.Name})
  31. }
  32. tokens = append(tokens, xml.EndElement{start.Name})
  33. for _, t := range tokens {
  34. err := e.EncodeToken(t)
  35. if err != nil {
  36. return err
  37. }
  38. }
  39. // flush to ensure tokens are
  40. // written
  41. err := e.Flush()
  42. if err != nil {
  43. return err
  44. }
  45. return nil
  46. }
  47. type UnionPayResponse struct {
  48. ReturnCode string `xml:"return_code"`
  49. ReturnMsg string `xml:"return_msg"`
  50. AppId string `xml:"appid"`
  51. MchId string `xml:"mch_id"`
  52. DeviceInfo string `xml:"device_info"` //设备号
  53. NonceStr string `xml:"nonce_str"`
  54. Sign string `xml:"sign"`
  55. ResultCode string `xml:"result_code"` //业务结果
  56. ErrCode string `xml:"err_code"`
  57. ErrCodeDes string `xml:"err_code_des"`
  58. TradeType string `xml:"trade_type"`
  59. PrepayId string `xml:"prepay_id"`
  60. CodeUrl string `xml:"code_url"`
  61. MWebUrl string `xml:"mweb_url"` //h5支付中间回调页
  62. }
  63. type UnionPayResult struct {
  64. ReturnCode string `xml:"return_code"`
  65. ReturnMsg string `xml:"return_msg"`
  66. AppId string `xml:"appid"`
  67. MchId string `xml:"mch_id"`
  68. DeviceInfo string `xml:"device_info"` //设备号
  69. NonceStr string `xml:"nonce_str"`
  70. Sign string `xml:"sign"`
  71. ResultCode string `xml:"result_code"` //业务结果
  72. ErrCode string `xml:"err_code"`
  73. ErrCodeDes string `xml:"err_code_des"`
  74. OpenId string `xml:"openid"`
  75. IsSubscribe string `xml:"is_subscribe"`
  76. TradeType string `xml:"trade_type"`
  77. BankType string `xml:"bank_type"`
  78. TotalFee int `xml:"total_fee"`
  79. FeeType string `xml:"fee_type"`
  80. CashFee int `xml:"cash_fee"`
  81. CashFeeType string `xml:"cash_fee_type"`
  82. CouponFee int `xml:"coupon_fee"`
  83. CouponCount int `xml:"coupon_count"`
  84. CouponFee0 int `xml:"coupon_fee_0"`
  85. CouponId0 string `xml:"coupon_id_0"`
  86. TransactionId string `xml:"transaction_id"`
  87. OutTradeNo string `xml:"out_trade_no"`
  88. Attach string `xml:"attach"`
  89. TimeEnd string `xml:"time_end"`
  90. TradeState string `xml:"trade_state"`
  91. }
  92. //type UnionPayResult map[string]string
  93. /*type OrderQueryResult struct {
  94. ReturnCode string `xml:"return_code"`
  95. ReturnMsg string `xml:"return_msg"`
  96. AppId string `xml:"appid"`
  97. MchId string `xml:"mch_id"`
  98. DeviceInfo string `xml:"device_info"` //设备号
  99. NonceStr string `xml:"nonce_str"`
  100. Sign string `xml:"sign"`
  101. ResultCode string `xml:"result_code"` //业务结果
  102. ErrCode string `xml:"err_code"`
  103. ErrCodeDes string `xml:"err_code_des"`
  104. OpenId string `xml:"openid"`
  105. IsSubscribe string `xml:"is_subscribe"`
  106. TradeType string `xml:"trade_type"`
  107. BankType string `xml:"bank_type"`
  108. TotalFee int `xml:"total_fee"`
  109. FeeType string `xml:"fee_type"`
  110. CashFee int `xml:"cash_fee"`
  111. CashFeeType string `xml:"cash_fee_type"`
  112. CouponFee int `xml:"coupon_fee"`
  113. CouponCount int `xml:"coupon_count"`
  114. TransactionId string `xml:"transaction_id"`
  115. OutTradeNo string `xml:"out_trade_no"`
  116. Attach string `xml:"attach"`
  117. TimeEnd string `xml:"time_end"`
  118. }*/