2023-04-27 09:53:25 +08:00
|
|
|
package com.jsowell.adapay.service;
|
|
|
|
|
|
2023-05-10 08:19:44 +08:00
|
|
|
import com.alibaba.fastjson2.JSON;
|
2023-04-27 09:53:25 +08:00
|
|
|
import com.google.common.collect.Maps;
|
|
|
|
|
import com.huifu.adapay.core.exception.BaseAdaPayException;
|
|
|
|
|
import com.huifu.adapay.model.Payment;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
|
|
@Service
|
|
|
|
|
public class AdapayService {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 创建交易对象
|
2023-05-10 08:19:44 +08:00
|
|
|
* createTransactionObject
|
2023-04-27 09:53:25 +08:00
|
|
|
*/
|
2023-05-10 08:19:44 +08:00
|
|
|
public void createTransactionObject() {
|
2023-04-27 09:53:25 +08:00
|
|
|
// 请求参数
|
|
|
|
|
Map<String, Object> paymentParams = Maps.newHashMap();
|
2023-05-10 08:19:44 +08:00
|
|
|
paymentParams.put("app_id", "app_d0c80cb1-ffc8-48cb-a030-fe9bec823aaa");
|
|
|
|
|
paymentParams.put("order_no", "2023050911410199622174123");
|
|
|
|
|
paymentParams.put("pay_channel", "wx_lite");
|
|
|
|
|
paymentParams.put("pay_amt", "0.01");
|
|
|
|
|
paymentParams.put("currency", "cny");
|
|
|
|
|
paymentParams.put("goods_title", "测试商品");
|
|
|
|
|
paymentParams.put("goods_desc", "用于支付流程测试的商品");
|
2023-04-27 09:53:25 +08:00
|
|
|
// paymentParams.put("div_members", [{"amount":"0.05", "fee_flag":"Y", "member_id":"member_id_test"}]);
|
|
|
|
|
// 调用创建方法,获取 Payment对象_
|
|
|
|
|
try {
|
|
|
|
|
Map<String, Object> response = Payment.create(paymentParams);
|
2023-05-10 08:19:44 +08:00
|
|
|
System.out.println("response:" + JSON.toJSONString(response));
|
2023-04-27 09:53:25 +08:00
|
|
|
} catch (BaseAdaPayException e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|