pay.go 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. package pay
  2. import (
  3. "github.com/yaotian/gowechat/mch/base"
  4. "github.com/yaotian/gowechat/server/context"
  5. )
  6. //Pay pay
  7. type Pay struct {
  8. base.MchBase
  9. }
  10. //NewPay 实例化
  11. func NewPay(context *context.Context) *Pay {
  12. pay := new(Pay)
  13. pay.Context = context
  14. return pay
  15. }
  16. // UnifiedOrder 统一下单.
  17. func (c *Pay) UnifiedOrder(req map[string]string) (resp map[string]string, err error) {
  18. return c.PostXML("https://api.mch.weixin.qq.com/pay/unifiedorder", req, false)
  19. }
  20. // 查询订单.
  21. func (c *Pay) OrderQuery(req map[string]string) (resp map[string]string, err error) {
  22. return c.PostXML("https://api.mch.weixin.qq.com/pay/orderquery", req, false)
  23. }
  24. // 关闭订单.
  25. func (c *Pay) CloseOrder(req map[string]string) (resp map[string]string, err error) {
  26. return c.PostXML("https://api.mch.weixin.qq.com/pay/closeorder", req, false)
  27. }
  28. // 申请退款.
  29. // NOTE: 请求需要双向证书.
  30. func (c *Pay) Refund(req map[string]string) (resp map[string]string, err error) {
  31. return c.PostXML("https://api.mch.weixin.qq.com/secapi/pay/refund", req, true)
  32. }
  33. // 查询退款.
  34. func (c *Pay) RefundQuery(req map[string]string) (resp map[string]string, err error) {
  35. return c.PostXML("https://api.mch.weixin.qq.com/pay/refundquery", req, false)
  36. }