AdapayServiceTest.java 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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/order/1");
  38. paymentParams.put("description", "orderId=1");
  39. Map<String, Object> expend = new HashMap<>();
  40. expend.put("open_id", "oWJG55wLnwdVzXoKka1-DzQKOd_Y");
  41. paymentParams.put("expend", expend);
  42. Map<String, Object> payment = Payment.create(paymentParams);
  43. System.out.println("payment result=" + JSON.toJSONString(payment, SerializerFeature.PrettyFormat));
  44. }
  45. @Test
  46. public void createMember() throws BaseAdaPayException {
  47. adapayService.createMember(99999999999999L, "15077886171", "熊竹", "321002199408304614");
  48. }
  49. @Test
  50. public void createSettleAccount() throws BaseAdaPayException {
  51. adapayService.createSettleAccount("99999999999999", "熊竹", "321002199408304614",
  52. "15077886171", "6222024301070380163");
  53. }
  54. @Test
  55. public void delSettleAccount() throws BaseAdaPayException {
  56. adapayService.delSettleAccount("99999999999999", "0288070028826880");
  57. }
  58. @Test
  59. public void queryBalance() throws BaseAdaPayException {
  60. adapayService.queryBalance("1110", "0288514678171392");
  61. }
  62. }