AdapayServiceTest.java 3.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. package com.izouma.nineth.service;
  2. import com.alibaba.fastjson.JSON;
  3. import com.alibaba.fastjson.serializer.SerializerFeature;
  4. import com.huifu.adapay.core.exception.BaseAdaPayException;
  5. import com.huifu.adapay.model.AdapayCommon;
  6. import com.huifu.adapay.model.Payment;
  7. import com.izouma.nineth.ApplicationTests;
  8. import com.izouma.nineth.config.GeneralProperties;
  9. import org.junit.Test;
  10. import org.springframework.beans.factory.annotation.Autowired;
  11. import java.math.BigDecimal;
  12. import java.util.ArrayList;
  13. import java.util.HashMap;
  14. import java.util.List;
  15. import java.util.Map;
  16. public class AdapayServiceTest extends ApplicationTests {
  17. @Autowired
  18. private AdapayService adapayService;
  19. @Autowired
  20. private GeneralProperties generalProperties;
  21. @Test
  22. public void testPay() throws BaseAdaPayException {
  23. Map<String, Object> paymentParams = new HashMap<String, Object>(10);
  24. List<Map<String, Object>> divMembers = new ArrayList<>();
  25. divMembers.add(new HashMap<>() {{
  26. put("member_id", "0");
  27. put("amount", BigDecimal.valueOf(0.05));
  28. put("fee_flag", "Y");
  29. }});
  30. divMembers.add(new HashMap<>() {{
  31. put("member_id", "1110");
  32. put("amount", BigDecimal.valueOf(0.05));
  33. }});
  34. paymentParams.put("app_id", "app_f8760acc-f4d8-46f6-8f70-d80e36517075");
  35. paymentParams.put("order_no", "jsdk_payment" + System.currentTimeMillis());
  36. paymentParams.put("pay_channel", "wx_pub");
  37. paymentParams.put("pay_amt", "0.10");
  38. paymentParams.put("goods_title", "your goods title");
  39. paymentParams.put("goods_desc", "your goods desc");
  40. paymentParams.put("notify_url", "http://9th.frp.izouma.com/notify/adapay/order/1");
  41. paymentParams.put("description", "orderId=1");
  42. Map<String, Object> expend = new HashMap<>();
  43. expend.put("open_id", "oWJG55wLnwdVzXoKka1-DzQKOd_Y");
  44. paymentParams.put("expend", expend);
  45. Map<String, Object> payment = Payment.create(paymentParams);
  46. System.out.println("payment result=" + JSON.toJSONString(payment, SerializerFeature.PrettyFormat));
  47. }
  48. @Test
  49. public void testWxPay() throws BaseAdaPayException {
  50. Map<String, Object> params = new HashMap<String, Object>();
  51. params.put("order_no", "host_wx_lite_params_sdk_" + System.currentTimeMillis());
  52. params.put("adapay_func_code", "wxpay.createOrder");
  53. params.put("pay_amt", "0.02");
  54. params.put("app_id", "app_f8760acc-f4d8-46f6-8f70-d80e36517075");
  55. params.put("currency", "cny");
  56. params.put("goods_title", "Your goods_title");
  57. params.put("goods_desc", "Your goods_desc");
  58. params.put("description", "payment Discription");
  59. params.put("callback_url", generalProperties.getHost() + "/9th/orders");
  60. Map<String, Object> response = AdapayCommon.requestAdapayUits(params);
  61. System.out.println("payment result=" + JSON.toJSONString(response, SerializerFeature.PrettyFormat));
  62. }
  63. @Test
  64. public void createMember() throws BaseAdaPayException {
  65. adapayService.createMember(99999999999999L, "15077886171", "熊竹", "321002199408304614");
  66. }
  67. @Test
  68. public void createSettleAccount() throws BaseAdaPayException {
  69. adapayService.createSettleAccount("99999999999999", "熊竹", "321002199408304614",
  70. "15077886171", "6222024301070380163");
  71. }
  72. @Test
  73. public void delSettleAccount() throws BaseAdaPayException {
  74. adapayService.delSettleAccount("1110", "0288514678171392");
  75. }
  76. @Test
  77. public void queryBalance() throws BaseAdaPayException {
  78. adapayService.queryBalance("1110", "0288514678171392");
  79. }
  80. }