|
@@ -9,6 +9,7 @@ import com.fdkankan.pay.entity.*;
|
|
import com.fdkankan.pay.service.*;
|
|
import com.fdkankan.pay.service.*;
|
|
import com.fdkankan.pay.util.CacheUtil;
|
|
import com.fdkankan.pay.util.CacheUtil;
|
|
import com.fdkankan.rabbitmq.util.RabbitMqProducer;
|
|
import com.fdkankan.rabbitmq.util.RabbitMqProducer;
|
|
|
|
+import com.paypal.api.payments.Webhook;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
@@ -19,6 +20,7 @@ import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
import java.util.HashMap;
|
|
import java.util.HashMap;
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
|
|
+import java.util.concurrent.ConcurrentHashMap;
|
|
|
|
|
|
/**
|
|
/**
|
|
* <p>
|
|
* <p>
|
|
@@ -46,6 +48,8 @@ public class StripeController {
|
|
@Autowired
|
|
@Autowired
|
|
IStripeCustomerService stripeCustomerService;
|
|
IStripeCustomerService stripeCustomerService;
|
|
|
|
|
|
|
|
+ static ConcurrentHashMap<String, JSONObject> waitOrderMap = new ConcurrentHashMap<>();
|
|
|
|
+
|
|
@PostMapping("/webhook")
|
|
@PostMapping("/webhook")
|
|
public synchronized ResultData webhook(@RequestBody JSONObject webhookObj){
|
|
public synchronized ResultData webhook(@RequestBody JSONObject webhookObj){
|
|
|
|
|
|
@@ -138,16 +142,30 @@ public class StripeController {
|
|
}
|
|
}
|
|
if(autopayOrder.getSubscriptionId() == null){
|
|
if(autopayOrder.getSubscriptionId() == null){
|
|
autopayOrderService.setSubscriptionId(autopayOrder.getId(),subscriptionId);
|
|
autopayOrderService.setSubscriptionId(autopayOrder.getId(),subscriptionId);
|
|
|
|
+ JSONObject jsonObject2 = waitOrderMap.get(subscriptionId);
|
|
|
|
+ if(jsonObject2 != null){
|
|
|
|
+ sendMq(autoEven,autopayOrder,jsonObject2,subscriptionId,jsonObject2.getString("payment_intent"),state);
|
|
|
|
+ waitOrderMap.remove(subscriptionId);
|
|
|
|
+ }
|
|
return ResultData.ok();
|
|
return ResultData.ok();
|
|
}
|
|
}
|
|
return ResultData.ok();
|
|
return ResultData.ok();
|
|
}else {
|
|
}else {
|
|
autopayOrder = autopayOrderService.getBySubscriptionId(subscriptionId);
|
|
autopayOrder = autopayOrderService.getBySubscriptionId(subscriptionId);
|
|
if(autopayOrder == null ){
|
|
if(autopayOrder == null ){
|
|
|
|
+ if("invoice.payment_succeeded".equals(type)){
|
|
|
|
+ waitOrderMap.put(subscriptionId,jsonObject1);
|
|
|
|
+ }
|
|
return ResultData.ok();
|
|
return ResultData.ok();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ sendMq(autoEven,autopayOrder,jsonObject1,subscriptionId,trade_no,state);
|
|
|
|
+
|
|
|
|
+ return ResultData.ok();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private void sendMq(String autoEven,AutopayOrder autopayOrder,JSONObject jsonObject1,String subscriptionId,String trade_no,String state){
|
|
AutopayOrderSon orderSnSon = null;
|
|
AutopayOrderSon orderSnSon = null;
|
|
if("PAYMENT.SALE.COMPLETED".equals(autoEven)){
|
|
if("PAYMENT.SALE.COMPLETED".equals(autoEven)){
|
|
orderSnSon = autopayOrderSonService.addOrderByOrder(autopayOrder.getId(),jsonObject1,6);
|
|
orderSnSon = autopayOrderSonService.addOrderByOrder(autopayOrder.getId(),jsonObject1,6);
|
|
@@ -166,8 +184,6 @@ public class StripeController {
|
|
}
|
|
}
|
|
|
|
|
|
rabbitMqProducer.sendByWorkQueue(CacheUtil.autoPaypalQueue,map);
|
|
rabbitMqProducer.sendByWorkQueue(CacheUtil.autoPaypalQueue,map);
|
|
-
|
|
|
|
- return ResultData.ok();
|
|
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|