|
@@ -67,13 +67,14 @@ public class StripeController {
|
|
Order order = null;
|
|
Order order = null;
|
|
switch (type){
|
|
switch (type){
|
|
case "checkout.session.completed"://支付完成
|
|
case "checkout.session.completed"://支付完成
|
|
|
|
+ case "invoice.payment_succeeded":
|
|
jsonObject = webhookObj.getJSONObject("data");
|
|
jsonObject = webhookObj.getJSONObject("data");
|
|
jsonObject1 = jsonObject.getJSONObject("object");
|
|
jsonObject1 = jsonObject.getJSONObject("object");
|
|
String id = jsonObject1.getString("id");
|
|
String id = jsonObject1.getString("id");
|
|
trade_no = jsonObject1.getString("payment_intent");
|
|
trade_no = jsonObject1.getString("payment_intent");
|
|
String mode = jsonObject1.getString("mode");
|
|
String mode = jsonObject1.getString("mode");
|
|
subscriptionId = jsonObject1.getString("subscription");
|
|
subscriptionId = jsonObject1.getString("subscription");
|
|
- status = jsonObject1.getString("payment_status");
|
|
|
|
|
|
+ status = jsonObject1.getString("payment_status") == null ? jsonObject1.getString("status") : jsonObject1.getString("payment_status") ;
|
|
customer = jsonObject1.getString("customer");
|
|
customer = jsonObject1.getString("customer");
|
|
customer_email = jsonObject1.getString("customer_email");
|
|
customer_email = jsonObject1.getString("customer_email");
|
|
JSONObject jsonObject2 = jsonObject1.getJSONObject("metadata");
|
|
JSONObject jsonObject2 = jsonObject1.getJSONObject("metadata");
|
|
@@ -82,15 +83,14 @@ public class StripeController {
|
|
stripeCustomerService.saveByEmail(customer_email,customer);
|
|
stripeCustomerService.saveByEmail(customer_email,customer);
|
|
|
|
|
|
log.info("订单号为:id:{},trade_no:{},orderId:{},subscriptionId:{}",id,trade_no,orderId,subscriptionId);
|
|
log.info("订单号为:id:{},trade_no:{},orderId:{},subscriptionId:{}",id,trade_no,orderId,subscriptionId);
|
|
- order = orderService.getByOrderSn(orderId);
|
|
|
|
- if( order != null){
|
|
|
|
- if("subscription".equals(mode)){
|
|
|
|
- orderService.payResult(order,true,subscriptionId,null);
|
|
|
|
- }else {
|
|
|
|
- orderService.payResult(order,true,trade_no,null);
|
|
|
|
|
|
+ if(orderId != null){
|
|
|
|
+ order = orderService.getByOrderSn(orderId);
|
|
|
|
+ if( order != null){
|
|
|
|
+ orderService.payResult(order,true,trade_no,customer);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
break;
|
|
break;
|
|
|
|
+
|
|
case "checkout.session.expired"://过期
|
|
case "checkout.session.expired"://过期
|
|
break;
|
|
break;
|
|
case "payment_intent.created"://创建订单 这里事件就是图二选着的事件
|
|
case "payment_intent.created"://创建订单 这里事件就是图二选着的事件
|
|
@@ -122,13 +122,21 @@ public class StripeController {
|
|
String autoEven = AutoPayUtil.getAutoEven(type);
|
|
String autoEven = AutoPayUtil.getAutoEven(type);
|
|
String state = AutoPayUtil.getState(status);
|
|
String state = AutoPayUtil.getState(status);
|
|
|
|
|
|
- autopayOrder = autopayOrderService.getByOrderSn(orderId);
|
|
|
|
- if(autopayOrder == null ){
|
|
|
|
- return ResultData.ok();
|
|
|
|
- }
|
|
|
|
- if(autopayOrder.getSubscriptionId() == null){
|
|
|
|
- autopayOrderService.setSubscriptionId(autopayOrder.getId(),subscriptionId);
|
|
|
|
|
|
+ if(orderId != null){
|
|
|
|
+ autopayOrder = autopayOrderService.getByOrderSn(orderId);
|
|
|
|
+ if(autopayOrder == null ){
|
|
|
|
+ return ResultData.ok();
|
|
|
|
+ }
|
|
|
|
+ if(autopayOrder.getSubscriptionId() == null){
|
|
|
|
+ autopayOrderService.setSubscriptionId(autopayOrder.getId(),subscriptionId);
|
|
|
|
+ return ResultData.ok();
|
|
|
|
+ }
|
|
return ResultData.ok();
|
|
return ResultData.ok();
|
|
|
|
+ }else {
|
|
|
|
+ autopayOrder = autopayOrderService.getBySubscriptionId(subscriptionId);
|
|
|
|
+ if(autopayOrder == null ){
|
|
|
|
+ return ResultData.ok();
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
AutopayOrderSon orderSnSon = null;
|
|
AutopayOrderSon orderSnSon = null;
|