|
@@ -8,6 +8,7 @@ import com.fdkankan.pay.entity.Order;
|
|
import com.fdkankan.pay.entity.PaypalConfig;
|
|
import com.fdkankan.pay.entity.PaypalConfig;
|
|
import com.fdkankan.pay.exception.BusinessException;
|
|
import com.fdkankan.pay.exception.BusinessException;
|
|
import com.fdkankan.pay.response.OpenPayResponse;
|
|
import com.fdkankan.pay.response.OpenPayResponse;
|
|
|
|
+import com.fdkankan.pay.service.IAutopayOrderService;
|
|
import com.fdkankan.pay.service.IOrderService;
|
|
import com.fdkankan.pay.service.IOrderService;
|
|
import com.fdkankan.pay.service.IPaypalConfigService;
|
|
import com.fdkankan.pay.service.IPaypalConfigService;
|
|
import com.fdkankan.pay.util.CacheUtil;
|
|
import com.fdkankan.pay.util.CacheUtil;
|
|
@@ -17,6 +18,7 @@ import com.fdkankan.pay.util.paypal.restApi.vo.Product;
|
|
import com.fdkankan.pay.util.paypal.restApi.vo.plan.PlanVo;
|
|
import com.fdkankan.pay.util.paypal.restApi.vo.plan.PlanVo;
|
|
import com.fdkankan.pay.util.paypal.restApi.vo.subscription.ApplicationContext;
|
|
import com.fdkankan.pay.util.paypal.restApi.vo.subscription.ApplicationContext;
|
|
import com.fdkankan.pay.util.paypal.restApi.vo.subscription.PaymentMethod;
|
|
import com.fdkankan.pay.util.paypal.restApi.vo.subscription.PaymentMethod;
|
|
|
|
+import com.fdkankan.pay.util.paypal.restApi.vo.subscription.SubscriptionVo;
|
|
import com.paypal.api.payments.*;
|
|
import com.paypal.api.payments.*;
|
|
import com.paypal.base.codec.binary.Base64;
|
|
import com.paypal.base.codec.binary.Base64;
|
|
import com.paypal.base.rest.APIContext;
|
|
import com.paypal.base.rest.APIContext;
|
|
@@ -425,6 +427,8 @@ public class PaypalService {
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
RestApiPaypalService restApiPaypalService;
|
|
RestApiPaypalService restApiPaypalService;
|
|
|
|
+ @Autowired
|
|
|
|
+ IAutopayOrderService autopayOrderService;
|
|
|
|
|
|
public Object autoPay(Order order, PaypalConfig paypalConfig) {
|
|
public Object autoPay(Order order, PaypalConfig paypalConfig) {
|
|
|
|
|
|
@@ -444,11 +448,13 @@ public class PaypalService {
|
|
String planId = restApiPaypalService.createPlan(paypalConfig, plan);
|
|
String planId = restApiPaypalService.createPlan(paypalConfig, plan);
|
|
log.info("创建订阅计划:"+planId);
|
|
log.info("创建订阅计划:"+planId);
|
|
|
|
|
|
- String subscription = restApiPaypalService.createSubscription(paypalConfig, planId);
|
|
|
|
|
|
+ SubscriptionVo subscription = restApiPaypalService.createSubscription(paypalConfig, planId);
|
|
log.info("创建订阅支付链接:"+subscription);
|
|
log.info("创建订阅支付链接:"+subscription);
|
|
|
|
+ autopayOrderService.saveAutoOrder(order.getOrderSn(),productId,planId,subscription.getSubscriptionId());
|
|
|
|
+
|
|
OpenPayResponse openPayResponse = new OpenPayResponse();
|
|
OpenPayResponse openPayResponse = new OpenPayResponse();
|
|
- openPayResponse.setH5Url(subscription);
|
|
|
|
- openPayResponse.setQrCodeUrl(subscription);
|
|
|
|
|
|
+ openPayResponse.setH5Url(subscription.getSubscriptionHref());
|
|
|
|
+ openPayResponse.setQrCodeUrl(subscription.getSubscriptionHref());
|
|
openPayResponse.setOrderSn(order.getOrderSn());
|
|
openPayResponse.setOrderSn(order.getOrderSn());
|
|
openPayResponse.setPayType(5);
|
|
openPayResponse.setPayType(5);
|
|
openPayResponse.setAutoPay(1);
|
|
openPayResponse.setAutoPay(1);
|