蛋蛋星球-制度模式
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

179 lignes
5.3 KiB

  1. package alipay
  2. import (
  3. "testing"
  4. "github.com/go-pay/gopay"
  5. "github.com/go-pay/xlog"
  6. )
  7. func TestKoubeiTradeOrderPrecreate(t *testing.T) {
  8. // 请求参数
  9. bm := make(gopay.BodyMap)
  10. bm.Set("request_id", "20181120111040030100030100002400")
  11. bm.Set("biz_type", "POST_ORDER_PAY")
  12. aliRsp, err := client.KoubeiTradeOrderPrecreate(ctx, bm)
  13. if err != nil {
  14. xlog.Errorf("client.KoubeiTradeOrderPrecreate(%+v),error:%+v", bm, err)
  15. return
  16. }
  17. xlog.Debug("aliRsp:", *aliRsp)
  18. }
  19. func TestKoubeiTradeItemorderBuy(t *testing.T) {
  20. // 请求参数
  21. bm := make(gopay.BodyMap)
  22. bm.Set("out_order_no", "A2018011200000001")
  23. bm.Set("subject", "星巴克礼品卡")
  24. bm.Set("biz_product", "ONLINE_PURCHASE")
  25. bm.Set("biz_scene", "giftCard")
  26. bm.Set("shop_id", "2015051100077000000000000300")
  27. bm.Set("buyer_id", "2088102015433735")
  28. bm.Set("total_amount", "100.00")
  29. bm.SetBodyMap("item_order_details", func(bm gopay.BodyMap) {
  30. bm.Set("sku_id", "2015060400076000000000012100")
  31. bm.Set("original_price", "50.00")
  32. bm.Set("price", "10.00")
  33. bm.Set("quantity", "10")
  34. })
  35. aliRsp, err := client.KoubeiTradeItemorderBuy(ctx, bm)
  36. if err != nil {
  37. xlog.Errorf("client.KoubeiTradeItemorderBuy(%+v),error:%+v", bm, err)
  38. return
  39. }
  40. xlog.Debug("aliRsp:", *aliRsp)
  41. }
  42. func TestKoubeiTradeOrderConsult(t *testing.T) {
  43. // 请求参数
  44. bm := make(gopay.BodyMap)
  45. bm.Set("request_id", "0ad1e47b1500473065347103327127")
  46. bm.Set("user_id", "2088212151390950")
  47. bm.Set("total_amount", "88.88")
  48. bm.Set("shop_id", "2015051100077000000000000300")
  49. aliRsp, err := client.KoubeiTradeOrderConsult(ctx, bm)
  50. if err != nil {
  51. xlog.Errorf("client.KoubeiTradeOrderConsult(%+v),error:%+v", bm, err)
  52. return
  53. }
  54. xlog.Debug("aliRsp:", *aliRsp)
  55. }
  56. func TestKoubeiTradeItemorderRefund(t *testing.T) {
  57. // 请求参数
  58. bm := make(gopay.BodyMap)
  59. bm.Set("order_no", "20171114111040030100030100002400")
  60. bm.Set("out_request_no", "B201701180000002")
  61. bm.Set("total_amount", "88.88")
  62. bm.SetBodyMap("refund_infos", func(bm gopay.BodyMap) {
  63. bm.Set("item_order_no", "201701220000008000000001")
  64. bm.Set("amount", "10.00")
  65. })
  66. aliRsp, err := client.KoubeiTradeItemorderRefund(ctx, bm)
  67. if err != nil {
  68. xlog.Errorf("client.KoubeiTradeItemorderRefund(%+v),error:%+v", bm, err)
  69. return
  70. }
  71. xlog.Debug("aliRsp:", *aliRsp)
  72. }
  73. func TestKoubeiTradeItemorderQuery(t *testing.T) {
  74. // 请求参数
  75. bm := make(gopay.BodyMap)
  76. bm.Set("order_no", "20160831001040010900010000000001")
  77. bm.Set("out_request_no", "20160831001040010900010000000001")
  78. bm.Set("partner_id", "20180000000001")
  79. bm.Set("status", "CLOSE")
  80. bm.Set("buyer_id", "2088102164040745")
  81. bm.Set("biz_product", "ONLINE_TRADE_PAY")
  82. bm.Set("gmt_create", "2016-09-29 00:00:00")
  83. bm.Set("gmt_modified", "2016-09-29 00:00:00")
  84. bm.Set("total_amount", "25.00")
  85. bm.Set("real_pay_amount", "20.00")
  86. bm.Set("deliver_seller_real_amount", "5.00")
  87. bm.SetBodyMap("item_order_vo", func(bm gopay.BodyMap) {
  88. bm.Set("item_order_no", "2015060400076000000000000000")
  89. bm.Set("sku_id", "2015060400076000000000012100")
  90. bm.Set("quantity", "2")
  91. bm.Set("price", "10.00")
  92. bm.Set("status", "SUCCESS")
  93. })
  94. aliRsp, err := client.KoubeiTradeItemorderQuery(ctx, bm)
  95. if err != nil {
  96. xlog.Errorf("client.KoubeiTradeItemorderQuery(%+v),error:%+v", bm, err)
  97. return
  98. }
  99. xlog.Debug("aliRsp:", *aliRsp)
  100. }
  101. func TestKoubeiTradeTicketTicketcodeSend(t *testing.T) {
  102. // 请求参数
  103. bm := make(gopay.BodyMap)
  104. bm.Set("request_id", "20161029032144700000000001467823")
  105. bm.Set("send_order_no", "20170428001640010400000000006800")
  106. bm.Set("send_token", "eed3206686d349d2a22c3d9ada35c0f8")
  107. bm.Set("order_no", "20180404111040030100130500594477")
  108. bm.SetBodyMap("isv_ma_list", func(bm gopay.BodyMap) {
  109. bm.Set("code", "GAL358309629")
  110. bm.Set("num", "2")
  111. })
  112. aliRsp, err := client.KoubeiTradeTicketTicketcodeSend(ctx, bm)
  113. if err != nil {
  114. xlog.Errorf("client.KoubeiTradeTicketTicketcodeSend(%+v),error:%+v", bm, err)
  115. return
  116. }
  117. xlog.Debug("aliRsp:", *aliRsp)
  118. }
  119. func TestKoubeiTradeTicketTicketcodeDelay(t *testing.T) {
  120. // 请求参数
  121. bm := make(gopay.BodyMap)
  122. bm.Set("request_id", "20161029032144700000000001467823")
  123. bm.Set("end_date", "2017-09-09 12:12:12")
  124. bm.Set("ticket_code", "358309629059")
  125. bm.Set("code_type", "INTERNAL_CODE")
  126. bm.Set("order_no", "20180404111040030100130500594477")
  127. aliRsp, err := client.KoubeiTradeTicketTicketcodeDelay(ctx, bm)
  128. if err != nil {
  129. xlog.Errorf("client.KoubeiTradeTicketTicketcodeDelay(%+v),error:%+v", bm, err)
  130. return
  131. }
  132. xlog.Debug("aliRsp:", *aliRsp)
  133. }
  134. func TestKoubeiTradeTicketTicketcodeQuery(t *testing.T) {
  135. // 请求参数
  136. bm := make(gopay.BodyMap)
  137. bm.Set("ticket_code", "016569843362")
  138. bm.Set("shop_id", "2017071200077000000039734370")
  139. aliRsp, err := client.KoubeiTradeTicketTicketcodeQuery(ctx, bm)
  140. if err != nil {
  141. xlog.Errorf("client.KoubeiTradeTicketTicketcodeQuery(%+v),error:%+v", bm, err)
  142. return
  143. }
  144. xlog.Debug("aliRsp:", *aliRsp)
  145. }
  146. func TestKoubeiTradeTicketTicketcodeCancel(t *testing.T) {
  147. // 请求参数
  148. bm := make(gopay.BodyMap)
  149. bm.Set("request_id", "2016102903214476899999999")
  150. bm.Set("request_biz_no", "2016102903214476899999999")
  151. bm.Set("ticket_code", "016569843362")
  152. aliRsp, err := client.KoubeiTradeTicketTicketcodeCancel(ctx, bm)
  153. if err != nil {
  154. xlog.Errorf("client.KoubeiTradeTicketTicketcodeCancel(%+v),error:%+v", bm, err)
  155. return
  156. }
  157. xlog.Debug("aliRsp:", *aliRsp)
  158. }