|
@@ -9,75 +9,6 @@ import com.huifu.adapay.core.exception.BaseAdaPayException;
|
|
|
import org.springframework.util.DigestUtils;
|
|
|
|
|
|
public class Payment extends ConfigInit {
|
|
|
-
|
|
|
-
|
|
|
- /**
|
|
|
- * 运行支付类接口
|
|
|
- *
|
|
|
- * @return paymentId
|
|
|
- * @throws Exception 异常
|
|
|
- */
|
|
|
- public static String executePaymentTest(String merchantKey) throws Exception {
|
|
|
- //支付接口
|
|
|
- Map<String, Object> paymentParams = new HashMap<>(10);
|
|
|
- paymentParams.put("order_no", "jsdk_payment_" + System.currentTimeMillis());
|
|
|
- paymentParams.put("pay_channel", "alipay_wap");
|
|
|
- paymentParams.put("pay_amt", "0.01");
|
|
|
-
|
|
|
- paymentParams.put("goods_title", "your goods title");
|
|
|
- paymentParams.put("goods_desc", "your goods desc");
|
|
|
- paymentParams.put("notify_url", "https://wxwechat.utools.club/studentOrder/adaNotify");
|
|
|
-
|
|
|
-
|
|
|
- paymentParams.put("div_members", "");
|
|
|
-
|
|
|
- Map<String, Object> deviceInfo = new HashMap<>(2);
|
|
|
-
|
|
|
- deviceInfo.put("device_ip", "127.0.0.1");
|
|
|
- deviceInfo.put("device_mac", "交易设备 MAC");
|
|
|
- deviceInfo.put("device_type", "1");
|
|
|
- deviceInfo.put("device_imei", "交易设备 IMEI");
|
|
|
- deviceInfo.put("device_imsi", "交易设备 IMSI");
|
|
|
- deviceInfo.put("device_iccId", "ICCID");
|
|
|
- deviceInfo.put("device_wifi_mac", "WIFIMAC");
|
|
|
-
|
|
|
- paymentParams.put("device_info", deviceInfo);
|
|
|
-
|
|
|
-// Map<String, Object> goodsDetail = new HashMap<>();
|
|
|
-//
|
|
|
-// goodsDetail.put("goods_id", "gooods_id_100002");
|
|
|
-// goodsDetail.put("goods_name", "商品名称");
|
|
|
-// goodsDetail.put("quantity", "1");
|
|
|
-// goodsDetail.put("price", "100");
|
|
|
-// goodsDetail.put("goods_category", "商品类目");
|
|
|
-// goodsDetail.put("goods_body", "商品描述信息");
|
|
|
-// goodsDetail.put("show_url", "商品的展示地址");
|
|
|
-//
|
|
|
-// Map<String, Object> promotionDetail = new HashMap<>();
|
|
|
-//
|
|
|
-// promotionDetail.put("cost_price", "100");
|
|
|
-// promotionDetail.put("receipt_id", "商家小票 id");
|
|
|
-// promotionDetail.put("goods_detail", goodsDetail);
|
|
|
-
|
|
|
- Map<String, Object> expendParams = new HashMap<>(2);
|
|
|
- String openId = "";//微信授权获取
|
|
|
- expendParams.put("open_id", openId);
|
|
|
- expendParams.put("is_raw", "1");
|
|
|
- expendParams.put("callback_url", "绝对路径");
|
|
|
- expendParams.put("limit_pay", "1");
|
|
|
-
|
|
|
- // expendParams.put("promotion_detail", promotionDetail);
|
|
|
- paymentParams.put("expend", expendParams);
|
|
|
- Map<String, Object> payment = executePayment(paymentParams);
|
|
|
- System.out.println("钱包支付地址:" + payment.get("pay_url"));
|
|
|
- //支付查询接口
|
|
|
- // queryPayment((String) payment.get("id"));
|
|
|
- // //关单接口
|
|
|
- // closePayment((String) payment.get("id"));
|
|
|
-
|
|
|
- return (String) payment.get("id");
|
|
|
- }
|
|
|
-
|
|
|
/**
|
|
|
* 执行一个支付交易
|
|
|
*
|
|
@@ -89,18 +20,12 @@ public class Payment extends ConfigInit {
|
|
|
|
|
|
//调用sdk方法,创建支付,得到支付对象
|
|
|
Map<String, Object> payment = new HashMap<>();
|
|
|
- try {
|
|
|
- payment = com.huifu.adapay.model.Payment.create(paymentParams);
|
|
|
- } catch (BaseAdaPayException e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
+ payment = com.huifu.adapay.model.Payment.create(paymentParams);
|
|
|
|
|
|
- String error_code = (String) payment.get("error_code");
|
|
|
- if (null != error_code) {
|
|
|
- System.out.println("创建支付返回参数:" + JSON.toJSONString(payment));
|
|
|
-
|
|
|
- String error_msg = (String) payment.get("error_msg");
|
|
|
- System.out.println("error_code:" + error_code + "............." + error_msg);
|
|
|
+ String errorCode = (String) payment.get("error_code");
|
|
|
+ if (null != errorCode) {
|
|
|
+ String errorMsg = (String) payment.get("error_msg");
|
|
|
+ throw new BaseAdaPayException(errorMsg);
|
|
|
}
|
|
|
|
|
|
return payment;
|
|
@@ -174,6 +99,23 @@ public class Payment extends ConfigInit {
|
|
|
}
|
|
|
|
|
|
|
|
|
+ public static Map<String, Object> queryList(Integer pageIndex, Long createdGte, Long createdLte) throws Exception {
|
|
|
+ Map<java.lang.String, java.lang.Object> paymentParams = new HashMap<>();
|
|
|
+ paymentParams.put("app_id", ConfigInit.appId);
|
|
|
+ paymentParams.put("page_index", pageIndex);
|
|
|
+ paymentParams.put("page_size", "20");
|
|
|
+ paymentParams.put("created_gte", createdGte);
|
|
|
+ paymentParams.put("created_lte", createdLte);
|
|
|
+ Map<String, Object> payment = com.huifu.adapay.model.Payment.queryList(paymentParams);
|
|
|
+ String error_code = (String) payment.get("error_code");
|
|
|
+ if (null != error_code) {
|
|
|
+ String errorMsg = (String) payment.get("error_msg");
|
|
|
+ throw new BaseAdaPayException(errorMsg);
|
|
|
+ }
|
|
|
+ return payment;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
public static Map<String, Object> getPayMap(BigDecimal amount, String orderNo, String notifyUrl, String returnUrl, String orderSubject, String orderBody, String sellerNo, List<Map<String, Object>> tempRoutingList) throws Exception {
|
|
|
Map<String, Object> paymentParams = new LinkedHashMap<>();
|
|
|
paymentParams.put("appId", appId);
|