微信接口的RPC包
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

63 lines
1.4 KiB

  1. package weixinrpc
  2. import (
  3. "encoding/json"
  4. )
  5. /**
  6. * 订单号,子单号,总金额,退款金额,微信商户id,微信商户平台API私钥,平台证书,商户平台证书序列号,商品名,退款原因商品id,回调地址
  7. */
  8. func PayRefund(order_sn, sn, total, refund, wx_mp_mch_id, wx_mch_apiclient_key,
  9. wx_pay_cert, mch_serial_no, title, uuid, reason, notify_url string,
  10. url ...string) (map[string]string, error) {
  11. conn, err := rpc_server_conn(url...)
  12. if err != nil {
  13. return nil, err
  14. }
  15. defer conn.Close()
  16. data := map[string]string{
  17. "order_sn": order_sn,
  18. "sn": sn,
  19. "total": total,
  20. "refund": refund,
  21. "wx_mp_mch_id": wx_mp_mch_id,
  22. "wx_mch_apiclient_key": wx_mch_apiclient_key,
  23. "wx_pay_cert": wx_pay_cert,
  24. "mch_serial_no": mch_serial_no,
  25. "reason": reason,
  26. "uuid": uuid,
  27. "title": title,
  28. "notify_url": notify_url,
  29. }
  30. req, err := SetReqData(data)
  31. if err != nil {
  32. return nil, err
  33. }
  34. res := &Response{}
  35. err = conn.PayRefund(req, res)
  36. if err != nil {
  37. return nil, err
  38. }
  39. res_data_de, err := GetResData(res)
  40. if err != nil {
  41. return nil, err
  42. }
  43. if res_data_de == "" {
  44. return nil, nil
  45. }
  46. var res_arr map[string]string
  47. err = json.Unmarshal([]byte(res_data_de), &res_arr)
  48. if err != nil {
  49. return nil, err
  50. }
  51. return res_arr, nil
  52. }