AdapayServiceTest.java 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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.Payment;
  6. import com.izouma.nineth.ApplicationTests;
  7. import org.junit.Test;
  8. import org.springframework.beans.factory.annotation.Autowired;
  9. import java.math.BigDecimal;
  10. import java.util.ArrayList;
  11. import java.util.HashMap;
  12. import java.util.List;
  13. import java.util.Map;
  14. public class AdapayServiceTest extends ApplicationTests {
  15. @Autowired
  16. private AdapayService adapayService;
  17. @Test
  18. public void testPay() throws BaseAdaPayException {
  19. Map<String, Object> paymentParams = new HashMap<String, Object>(10);
  20. List<Map<String, Object>> divMembers = new ArrayList<>();
  21. divMembers.add(new HashMap<>() {{
  22. put("member_id", "0");
  23. put("amount", BigDecimal.valueOf(0.05));
  24. put("fee_flag", "Y");
  25. }});
  26. divMembers.add(new HashMap<>() {{
  27. put("member_id", "1110");
  28. put("amount", BigDecimal.valueOf(0.05));
  29. }});
  30. paymentParams.put("app_id", "app_f8760acc-f4d8-46f6-8f70-d80e36517075");
  31. paymentParams.put("order_no", "jsdk_payment" + System.currentTimeMillis());
  32. paymentParams.put("pay_channel", "wx_pub");
  33. paymentParams.put("pay_amt", "0.10");
  34. paymentParams.put("goods_title", "your goods title");
  35. paymentParams.put("goods_desc", "your goods desc");
  36. paymentParams.put("div_members", JSON.toJSONString(divMembers));
  37. paymentParams.put("notify_url", "http://9th.frp.izouma.com/notify/adapay");
  38. Map<String, Object> expend = new HashMap<>();
  39. expend.put("open_id", "oWJG55wLnwdVzXoKka1-DzQKOd_Y");
  40. paymentParams.put("expend", expend);
  41. Map<String, Object> payment = Payment.create(paymentParams);
  42. System.out.println("payment result=" + JSON.toJSONString(payment, SerializerFeature.PrettyFormat));
  43. }
  44. @Test
  45. public void createMember() throws BaseAdaPayException {
  46. adapayService.createMember(99999999999999L, "15077886171", "熊竹", "321002199408304614");
  47. }
  48. @Test
  49. public void createSettleAccount() throws BaseAdaPayException {
  50. adapayService.createSettleAccount("99999999999999", "熊竹", "321002199408304614",
  51. "15077886171", "6222024301070380163");
  52. }
  53. @Test
  54. public void delSettleAccount() throws BaseAdaPayException {
  55. adapayService.delSettleAccount("99999999999999", "0288070028826880");
  56. }
  57. @Test
  58. public void queryBalance() throws BaseAdaPayException {
  59. adapayService.queryBalance("1110", "0288514678171392");
  60. }
  61. }