@@ -39,6 +39,7 @@ import java.math.RoundingMode;
import java.time.Instant ;
import java.time.LocalDateTime ;
import java.time.ZoneOffset ;
import java.time.temporal.ChronoUnit ;
import java.util.* ;
import java.util.stream.Collectors ;
@@ -95,9 +96,9 @@ public class StripeServiceImpl implements StripeService {
case " Year " :
productEnum = ProductEnum . AnnualSubscription ;
break ;
/* case "Day":
case " Day " :
productEnum = ProductEnum . DailySubscription ;
break;*/
break;
default :
throw new BusinessException ( " unknown subscription type " ) ;
}
@@ -106,14 +107,17 @@ public class StripeServiceImpl implements StripeService {
throw new BusinessException ( " unknown product type " ) ;
}
log . info ( " 生成订单 " ) ;
OrderInfo orderInfo = orderInfoService . createOrderByProductId ( productPurchaseDTO . getQuantity ( ) ,
PayTypeEnum . STRIPE . getType ( ) , productEnum , request ) ;
String payType ;
byte autoRenewal ;
if ( productPurchaseDTO . getAutoRenewal ( ) ) {
payType = " recurring " ;
autoRenewal = 1 ;
} else {
payType = " one_time " ;
autoRenewal = 0 ;
}
OrderInfo orderInfo = orderInfoService . createOrderByProductId ( productPurchaseDTO . getQuantity ( ) ,
PayTypeEnum . STRIPE . getType ( ) , productEnum , request , autoRenewal ) ;
try {
Long id = UserContext . getUserHolder ( ) . getId ( ) ;
@@ -139,7 +143,10 @@ public class StripeServiceImpl implements StripeService {
// one-time 手动创建发票;订阅会自动创建invoice
sessionBuilder . setInvoiceCreation ( SessionCreateParams . InvoiceCreation . builder ( ) . setEnabled ( Boolean . TRUE ) . build ( ) ) ;
}
// developer test
// sessionBuilder.setPaymentMethodConfiguration("pmc_1QIKyq02n1TEydyNKVEYvhW7");
// kim test
sessionBuilder . setPaymentMethodConfiguration ( " pmc_1LywTWH7nPZ8bkrN6FvdCUWG " ) ;
// sessionBuilder.addPaymentMethodType(SessionCreateParams.PaymentMethodType.ALIPAY);
// sessionBuilder.addPaymentMethodType(SessionCreateParams.PaymentMethodType.CARD);
sessionBuilder . setCustomer ( customerId ) ;
@@ -276,17 +283,17 @@ public class StripeServiceImpl implements StripeService {
return Boolean . FALSE ;
}
log . info ( " stripe验签成功 " ) ;
B oolean response = Boolean . TRUE ;
b oolean response = Boolean . TRUE ;
log . info ( " 回调事件 {} " , event . getType ( ) ) ;
if ( stripeObject instanceof Session ) {
Session session = ( Session ) stripeObject ;
if ( event . getType ( ) . equals ( " checkout.session.completed " ) ) {
processOrder ( session ) ;
response = processOrder( session ) ;
} else if ( event . getType ( ) . equals ( " checkout.session.expired " ) ) {
String orderNo = session . getMetadata ( ) . get ( " orderId " ) ;
// 会话过期 未支付 且之后没有支付成功的订单
processExpiredOrder ( orderNo ) ;
response = processExpiredOrder( orderNo ) ;
}
} else if ( stripeObject instanceof Subscription ) {
Subscription subscription = ( Subscription ) stripeObject ;
@@ -299,7 +306,7 @@ public class StripeServiceImpl implements StripeService {
SubscriptionInfo subscriptionInfo = updateSubscription ( subscription ) ;
log . info ( " 订阅更新 " ) ;
if ( subscription . getStatus ( ) . equals ( " active " ) ) {
response = sendEmail ( subscription . getId ( ) , null ) ;
response = sendEmail ( subscription . getId ( ) , null , null );
}
// 续订支付失败,邮件通知用户
if ( subscription . getStatus ( ) . equals ( " past_due " ) ) {
@@ -312,9 +319,14 @@ public class StripeServiceImpl implements StripeService {
log . info ( " 用户 {} 取消连续订阅 {} " , subscriptionInfo . getAccountId ( ) , subscription . getId ( ) ) ;
if ( subscriptionInfo . getCancelNotified ( ) = = ( byte ) 0 ) {
log . info ( " 取消订阅 邮件通知商家 " ) ;
response = sendEmail ( subscription . getId ( ) , " cancel " ) ;
subscriptionInfo . setCancelNotified ( ( byte ) 1 ) ;
subscriptionInfoMapper . updateById ( subscriptionInfo ) ;
response = sendEmail ( subscription . getId ( ) , " cancel " , null );
if ( response ) {
subscriptionInfo. setCancelNotified ( ( byte ) 1 ) ;
subscriptionInfoMapper . updateById ( subscriptionInfo ) ;
// 更新订单信息
OrderInfo orderInfo = orderInfoService . getOrderByOrderNo ( subscriptionInfo . getOrderNo ( ) ) ;
orderInfo . setAutoRenewal ( ( byte ) 0 ) ;
}
}
} /* else if (event.getType().equals("customer.subscription.paused")){
@@ -334,10 +346,20 @@ public class StripeServiceImpl implements StripeService {
// 更新t_order_info中的total_fee,记录该订单的累计付款金额
orderInfoService . updateTotalFeeByOrderNo ( paymentInfo . getOrderNo ( ) ) ;
// 邮件通知商家和用户
if ( invoice . getBillingReason ( ) . equals ( " subscription_create " ) ) {
response = sendEmail ( invoice . getSubscription ( ) , " new " ) ;
} else if ( invoice . getBillingReason ( ) . equals ( " subscription_cycl e " ) ) {
response = sendEmail ( invoice . getSubscription ( ) , " re newal " ) ;
String billingReason = invoice . getBillingReason ( ) ;
switch ( billingReason ) {
case " subscription_creat e " :
response = sendEmail ( invoice . getSubscription ( ) , " new " , null );
break ;
case " subscription_cycle " :
response = sendEmail ( invoice . getSubscription ( ) , " renewal " , null ) ;
break ;
case " manual " :
boolean b = invoice . getLines ( ) . getData ( ) . get ( 0 ) . getDescription ( ) . endsWith ( " Subscription " ) ;
if ( b ) {
response = sendEmail ( invoice . getSubscription ( ) , " new " , null ) ;
}
break ;
}
}
} else if ( event . getType ( ) . equals ( " invoice.payment_failed " ) ) {
@@ -386,28 +408,30 @@ public class StripeServiceImpl implements StripeService {
return response ;
}
public void processOrder ( Session session ) {
String orderId = session . getMetadata ( ) . get ( " orderId " ) ;
public boolean processOrder ( Session session ) {
Stripe . apiKey = privateKey ;
String orderNo = session . getMetadata ( ) . get ( " orderId " ) ;
float totalAmount = new BigDecimal ( session . getAmountTotal ( ) ) . divide ( new BigDecimal ( 100 ) , 2 , RoundingMode . HALF_UP ) . floatValue ( ) ;
boolean resp = true ;
try {
//处理重复通知
//接口调用的幂等性:无论接口被调用多少次,以下业务执行一次
// String orderStatus = orderInfoService.getOrderStatus(orderNo);
OrderInfo orderByOrderNo = orderInfoService . getOrderByOrderNo ( orderId ) ;
OrderInfo orderByOrderNo = orderInfoService . getOrderByOrderNo ( orderNo ) ;
String orderStatus = orderByOrderNo . getOrderStatus ( ) ;
// 当订单状态处于未支付或超时已关闭时,更新订单状态,其他状态均不更新订单状态
if ( ! OrderStatusEnum . NOT_PAY . getType ( ) . equals ( orderStatus ) & & ! OrderStatusEnum . TIMEOUT_CLOSED . getType ( ) . equals ( orderStatus ) ) {
log . info ( " 订单状态 : {} " , orderStatus ) ;
} else {
//更新订单状态
orderInfoService . updateStatusByOrderNo ( orderId , OrderStatusEnum . SUCCESS ) ;
log . info ( " Stripe 订单:{} 状态更新成功 " , orderId ) ;
orderInfoService . updateStatusByOrderNo ( orderNo , OrderStatusEnum . SUCCESS ) ;
log . info ( " Stripe 订单:{} 状态更新成功 " , orderNo ) ;
}
if ( orderByOrderNo . getTitle ( ) . startsWith ( " 积分购买 " ) ) {
// 查询当前订单的积分是否已添加
CreditsDetail creditsDetail = creditsService . queryDetailByTaskId ( orderId ) ;
CreditsDetail creditsDetail = creditsService . queryDetailByTaskId ( orderNo ) ;
if ( Objects . isNull ( creditsDetail ) ) {
float quantity = totalAmount / ProductEnum . CreditsProduct . getPrice ( ) ;
// 更新积分
@@ -416,21 +440,36 @@ public class StripeServiceImpl implements StripeService {
creditsService . insertToCreditsDetail ( orderByOrderNo . getAccountId ( ) ,
CreditsEventsEnum . BUY_CREDITS . getName ( ) + " --Stripe " ,
String . valueOf ( ( Long . parseLong ( CreditsEventsEnum . BUY_CREDITS . getValue ( ) ) * quantity ) ) ,
" positive " , orderId ) ;
" positive " , orderNo ) ;
log . info ( " 用户:{} 积分信息更新成功 " , orderByOrderNo . getAccountId ( ) ) ;
}
} else if ( orderByOrderNo . getTitle ( ) . endsWith ( " Subscription " ) & & orderByOrderNo . getAutoRenewal ( ) = = ( byte ) 0 ) {
String invoiceId = session . getInvoice ( ) ;
Invoice invoice = Invoice . retrieve ( invoiceId ) ;
InvoiceLineItem invoiceLineItem = invoice . getLines ( ) . getData ( ) . get ( 0 ) ;
String description = invoiceLineItem . getDescription ( ) ;
Long amount = invoiceLineItem . getAmount ( ) ;
boolean b = createSubscriptionAndUpdateAccount ( orderNo , orderByOrderNo . getAccountId ( ) , description , amount ) ;
// 邮件通知用户
if ( b ) {
resp = sendEmail ( null , " new " , orderNo ) ;
}
log . info ( " 单次订阅订单:{} 处理完成 " , orderNo ) ;
}
} catch ( Exception e ) {
log . info ( e . getMessage ( ) ) ;
resp = false ;
}
return resp ;
}
private void processExpiredOrder ( String orderNo ) {
private boolean processExpiredOrder ( String orderNo ) {
// 支付失败 通知商家的条件 1、会话过期 2、支付失败 3、这个用户在这个支付失败后再无支付成功的订阅
// 1、获取当前订单的支付状态
// String orderNo = session.getMetadata().get("orderId");
OrderInfo orderByOrderNo = orderInfoService . getOrderByOrderNo ( orderNo ) ;
// 2、确认订单状态为支付失败
boolean resp = true ;
if ( orderByOrderNo . getOrderStatus ( ) . equals ( OrderStatusEnum . FAILURE . getType ( ) ) ) {
// 3、判断失败订单之后再无成功的订单
QueryWrapper < OrderInfo > queryWrapper = new QueryWrapper < > ( ) ;
@@ -448,13 +487,14 @@ public class StripeServiceImpl implements StripeService {
if ( Objects . isNull ( subscriptionInfo )
| | subscriptionInfo . getStatus ( ) . equals ( " incomplete " )
| | subscriptionInfo . getStatus ( ) . equals ( " incomplete_expired " ) ) {
sendEmail ( orderNo ) ;
resp = sendEmail( orderNo ) ;
} else {
// todo 续订失败 应该不会走这里
sendEmail ( subscriptionInfo . getSubscriptionId ( ) , " fail_renewal " ) ;
resp = sendEmail( subscriptionInfo . getSubscriptionId ( ) , " fail_renewal " , null );
}
}
}
return resp ;
}
@@ -497,6 +537,60 @@ public class StripeServiceImpl implements StripeService {
return subscriptionInfo ;
}
/**
* 非自动续订订阅
* Stripe不会自动创建Subscription,所以没有subscription相关的回调, 无法触发订阅相关的处理代码
*/
public boolean createSubscriptionAndUpdateAccount ( String orderNo , Long accountId , String description , Long amount ) {
QueryWrapper < SubscriptionInfo > qw = new QueryWrapper < > ( ) ;
qw . eq ( " order_no " , orderNo ) ;
SubscriptionInfo subscriptionInfo = subscriptionInfoMapper . selectOne ( qw ) ;
if ( Objects . isNull ( subscriptionInfo ) ) {
String interval ;
// 获取当前时间戳(秒级)
long currentPeriodStart = Instant . now ( ) . getEpochSecond ( ) ; ;
long currentPeriodEnd ;
// InvoiceLineItem invoiceLineItem = invoice.getLines().getData().get(0);
if ( description . equals ( ProductEnum . DailySubscription . getName ( ) )
& & amount . equals ( ProductEnum . DailySubscription . getPrice ( ) * 100 ) ) {
interval = " day " ;
// 获取一天后的时间戳(秒级)
currentPeriodEnd = Instant . now ( ) . plus ( 1 , ChronoUnit . DAYS ) . getEpochSecond ( ) ;
} else if ( description . equals ( ProductEnum . MonthlySubscription . getName ( ) )
& & amount . equals ( ProductEnum . MonthlySubscription . getPrice ( ) * 100 ) ) {
interval = " month " ;
// 获取一天后的时间戳(秒级)
currentPeriodEnd = Instant . now ( ) . plus ( 1 , ChronoUnit . MONTHS ) . getEpochSecond ( ) ;
} else if ( description . equals ( ProductEnum . AnnualSubscription . getName ( ) )
& & amount . equals ( ProductEnum . AnnualSubscription . getPrice ( ) * 100 ) ) {
interval = " year " ;
// 获取一天后的时间戳(秒级)
currentPeriodEnd = Instant . now ( ) . plus ( 1 , ChronoUnit . YEARS ) . getEpochSecond ( ) ;
} else {
log . error ( " 未知订阅类型 " ) ;
return false ;
}
subscriptionInfo = new SubscriptionInfo ( ) ;
subscriptionInfo . setAccountId ( accountId ) ;
subscriptionInfo . setOrderNo ( orderNo ) ;
subscriptionInfo . setType ( interval ) ;
subscriptionInfo . setStatus ( " canceled " ) ;
subscriptionInfo . setCurrentPeriodStart ( currentPeriodStart ) ;
subscriptionInfo . setCurrentPeriodEnd ( currentPeriodEnd ) ;
subscriptionInfo . setCreateTime ( LocalDateTime . now ( ) ) ;
subscriptionInfoMapper . insertIgnore ( subscriptionInfo ) ;
log . info ( " 创建订阅更新账号信息 " ) ;
// 更新账号到期时间
boolean b = accountService . updateAccountValidity ( subscriptionInfo . getAccountId ( ) , subscriptionInfo . getCurrentPeriodEnd ( ) ) ;
// 更新账号身份和积分
if ( b ) accountService . updateUserRoleAndCredits ( subscriptionInfo . getAccountId ( ) , interval ) ;
return true ;
}
return true ;
}
public SubscriptionInfo getSubscriptionInfoBySubId ( String subId ) {
QueryWrapper < SubscriptionInfo > qw = new QueryWrapper < > ( ) ;
qw . eq ( " subscription_id " , subId ) ;
@@ -704,7 +798,8 @@ public class StripeServiceImpl implements StripeService {
try {
customerId = getCustomer ( username , userEmail ) ;
SubscriptionCollection list = Subscription . list ( SubscriptionListParams . builder ( )
. setCustomer ( customerId ) . build ( ) ) ;
. setCustomer ( customerId ) . setLimit ( 20L )
. build ( ) ) ;
return list . getData ( ) ;
} catch ( StripeException e ) {
throw new RuntimeException ( e ) ;
@@ -832,28 +927,42 @@ public class StripeServiceImpl implements StripeService {
// return null;
}
public boolean sendEmail ( String subscriptionId , String type ) {
SubscriptionEmailParamsDTO emailParamsDTO = new SubscriptionEmailParamsDTO ( ) ;
QueryWrapper < SubscriptionInfo > qwSI = new QueryWrapper < > ( ) ;
qwSI . eq ( " subscription_id " , subscriptionId ) ;
List < SubscriptionInfo > subscriptionInfoList = subscriptionInfoMapper . selectList ( qwSI ) ;
public boolean sendEmail ( String subscriptionId , String type , String orderNo ) {
SubscriptionInfo subscriptionInfo ;
if ( s ubscriptionInfoList . isEmpty ( ) ) {
return false ;
} else {
List < SubscriptionInfo > activeS ubscriptions = subscriptionInfoList . stream ( )
. filter ( subscription - > " active " . equals ( subscription . getStatus ( ) ) )
. collect ( Collectors . toList ( ) ) ;
if ( activeSubscriptions . isEmpty ( ) ) {
QueryWrapper < S ubscriptionInfo> qwSI = new QueryWrapper < > ( ) ;
if ( ! StringUtil . isNullOrEmpty ( subscriptionId ) ) {
qwSI . eq ( " subscription_id " , subscriptionId ) ;
List < SubscriptionInfo > s ubscriptionInfoList = subscriptionInfoMapper . selectList ( qwSI ) ;
if ( subscriptionInfoList . isEmpty ( ) ) {
log . info ( " 不发送邮件, 原因: 【subscriptionInfoList 为空】 " ) ;
return false ;
} else {
List < SubscriptionInfo > activeSubscriptions = subscriptionInfoList . stream ( )
. filter ( subscription - > " active " . equals ( subscription . getStatus ( ) ) )
. collect ( Collectors . toList ( ) ) ;
if ( ! StringUtil . isNullOrEmpty ( type ) & & type . equals ( " cancel " ) ) {
subscriptionInfo = subscriptionInfoList . get ( 0 ) ;
} else if ( activeSubscriptions . isEmpty ( ) ) {
log . info ( " 不发送邮件,原因:【当前邮件类型:{}, 但是状态为active的subscriptionInfo为空】 " , type ) ;
return false ;
} else {
subscriptionInfo = activeSubscriptions . get ( 0 ) ;
}
}
subscriptionInfo = activeSubscriptions . get ( 0 ) ;
} else if ( ! StringUtil . isNullOrEmpty ( orderNo ) ) {
qwSI . eq ( " order_no " , orderNo ) ;
subscriptionInfo = subscriptionInfoMapper . selectOne ( qwSI ) ;
} else {
log . info ( " 不发送邮件, 原因: 【入参中的subscriptionId, orderNo均为空】 " ) ;
return false ;
}
QueryWrapper < PaymentInfo > qwPI = new QueryWrapper < > ( ) ;
qwPI . eq ( " order_no " , subscriptionInfo . getOrderNo ( ) ) . orderByDesc ( " id " ) ;
List < PaymentInfo > paymentInfos = paymentInfoMapper . selectList ( qwPI ) ;
if ( paymentInfos . isEmpty ( ) ) {
log . info ( " 不发送邮件, 原因: 【根据order_no:{},查询到的paymentInfos为空】 " , orderNo ) ;
return false ;
}
PaymentInfo paymentInfo = paymentInfos . get ( 0 ) ;
@@ -864,6 +973,7 @@ public class StripeServiceImpl implements StripeService {
}
if ( ! type . equals ( " reminder " ) & & ! type . equals ( " cancel " ) & & paymentInfo . getNotified ( ) = = 1 ) {
// 已经邮件通知过,直接返回
log . info ( " 不发送邮件, 原因: 【type为: {}, order_no为: {},且已经已经进行邮件通知】 " , type , orderNo ) ;
return true ;
}
@@ -872,6 +982,7 @@ public class StripeServiceImpl implements StripeService {
String language = account . getLanguage ( ) ;
OrderInfo orderByOrderNo = orderInfoService . getOrderByOrderNo ( subscriptionInfo . getOrderNo ( ) ) ;
SubscriptionEmailParamsDTO emailParamsDTO = new SubscriptionEmailParamsDTO ( ) ;
emailParamsDTO . setUsername ( userName ) ;
emailParamsDTO . setOrderId ( paymentInfo . getId ( ) . toString ( ) ) ;
emailParamsDTO . setOrderRef ( " \" " + orderListLink + paymentInfo . getId ( ) . toString ( ) + " \" " ) ;
@@ -880,7 +991,7 @@ public class StripeServiceImpl implements StripeService {
emailParamsDTO . setTotalFee ( paymentInfo . getPayerTotal ( ) . toString ( ) ) ;
emailParamsDTO . setLastOrderDate ( DateUtil . changeTimeStampFormat ( subscriptionInfo . getCurrentPeriodStart ( ) , " seconds " , CommonConstant . TIME_FORMAT_MMM_dd_yyyy ) ) ;
emailParamsDTO . setEndOfPrepaidTerm ( DateUtil . changeTimeStampFormat ( subscriptionInfo . getCurrentPeriodEnd ( ) , " seconds " , CommonConstant . TIME_FORMAT_MMM_dd_yyyy ) ) ;
setSubscriptionParams ( paymentInfo , subscriptionInfo , orderByOrderNo , emailParamsDTO ) ;
setSubscriptionParams ( paymentInfo , subscriptionInfo , orderByOrderNo , emailParamsDTO , language );
SendEmailUtil . subscriptionEmailReminder ( type , emailParamsDTO , language , account . getUserEmail ( ) ) ;
@@ -906,6 +1017,7 @@ public class StripeServiceImpl implements StripeService {
qwPI . eq ( " order_no " , orderNo ) ;
List < PaymentInfo > paymentInfos = paymentInfoMapper . selectList ( qwPI ) ;
if ( paymentInfos . isEmpty ( ) ) {
log . info ( " 不发送邮件, 原因: 【根据order_no:{},查询到的paymentInfos为空】 " , orderNo ) ;
return false ;
}
PaymentInfo paymentInfo = paymentInfos . get ( 0 ) ;
@@ -976,7 +1088,7 @@ public class StripeServiceImpl implements StripeService {
emailParamsDTO . setCreateDate ( String . valueOf ( paymentInfo . getCreateTime ( ) ) . replace ( " T " , " " ) ) ;
emailParamsDTO . setQuantity ( String . valueOf ( 1 ) ) ;
emailParamsDTO . setTotalFee ( paymentInfo . getPayerTotal ( ) . toString ( ) ) ;
setSubscriptionParams ( paymentInfo , subscriptionInfo , orderByOrderNo , emailParamsDTO ) ;
setSubscriptionParams ( paymentInfo , subscriptionInfo , orderByOrderNo , emailParamsDTO , language );
// 4、发邮件
SendEmailUtil . subscriptionEmailReminder ( " fail_renewal " , emailParamsDTO , language , account . getUserEmail ( ) ) ;
@@ -989,14 +1101,28 @@ public class StripeServiceImpl implements StripeService {
return true ;
}
private void setSubscriptionParams ( PaymentInfo paymentInfo , SubscriptionInfo subscriptionInfo , OrderInfo orderByOrderNo , SubscriptionEmailParamsDTO emailParamsDTO ) {
private void setSubscriptionParams ( PaymentInfo paymentInfo , SubscriptionInfo subscriptionInfo , OrderInfo orderByOrderNo ,
SubscriptionEmailParamsDTO emailParamsDTO , String language ) {
emailParamsDTO . setPaymentMethod ( paymentInfo . getPaymentMethod ( ) ) ;
emailParamsDTO . setLast4 ( paymentInfo . getLast4 ( ) ) ;
emailParamsDTO . setSubscriptionId ( subscriptionInfo . getId ( ) . toString ( ) ) ;
emailParamsDTO . setFailMessage ( orderByOrderNo . getNote ( ) ) ;
emailParamsDTO . setSubscriptionType ( subscriptionInfo . getType ( ) ) ;
emailParamsDTO . setStartDate ( DateUtil . changeTimeStampFormat ( orderByOrderNo . getCreateTime ( ) ) ) ;
emailParamsDTO . setNextPayDate ( DateUtil . changeTimeStampFormat ( subscriptionInfo . getCurrentPeriodEnd ( ) , " seconds " , CommonConstant . TIME_FORMAT_MMM_dd_yyyy ) ) ;
if ( subscriptionInfo . getStatus ( ) . equals ( " active " ) ) {
if ( language . equals ( " ENGLISH " ) ) {
emailParamsDTO . setEndDate ( " When cancelled " ) ;
} else {
emailParamsDTO . setEndDate ( " 手动取消订阅时 " ) ;
}
} else {
emailParamsDTO . setEndDate ( DateUtil . changeTimeStampFormat ( subscriptionInfo . getCurrentPeriodEnd ( ) , " seconds " , CommonConstant . TIME_FORMAT_MMM_dd_yyyy_EEEE ) ) ;
}
if ( StringUtil . isNullOrEmpty ( subscriptionInfo . getNextPayDate ( ) ) ) {
emailParamsDTO . setNextPayDate ( " N/A " ) ;
} else {
emailParamsDTO . setNextPayDate ( DateUtil . changeTimeStampFormat ( subscriptionInfo . getCurrentPeriodEnd ( ) , " seconds " , CommonConstant . TIME_FORMAT_MMM_dd_yyyy ) ) ;
}
emailParamsDTO . setRenewalTime ( DateUtil . changeTimeStampFormat ( subscriptionInfo . getCurrentPeriodEnd ( ) , " seconds " , CommonConstant . TIME_FORMAT_MMM_dd_yyyy ) ) ;
}
@@ -1016,7 +1142,7 @@ public class StripeServiceImpl implements StripeService {
List < SubscriptionInfo > subscriptionInfos = subscriptionInfoMapper . selectList ( qw ) ;
for ( SubscriptionInfo subscriptionInfo : subscriptionInfos ) {
boolean b = sendEmail ( subscriptionInfo . getSubscriptionId ( ) , " reminder " ) ;
boolean b = sendEmail ( subscriptionInfo . getSubscriptionId ( ) , " reminder " , null );
if ( b ) log . info ( " 提前7天向用户 {} 发送续订通知邮件 " , subscriptionInfo . getAccountId ( ) ) ;
}
}
@@ -1040,7 +1166,7 @@ public class StripeServiceImpl implements StripeService {
public String createSubscriptionTemp ( String name , String email ) {
Stripe . apiKey = privateKey ;
try {
OrderInfo orderInfo = orderInfoService . createOrderByProductId ( 1 , PayTypeEnum . STRIPE . getType ( ) , ProductEnum . DailySubscription , null ) ;
OrderInfo orderInfo = orderInfoService . createOrderByProductId ( 1 , PayTypeEnum . STRIPE . getType ( ) , ProductEnum . DailySubscription , null , ( byte ) 0 );
// String customerId = getCustomer(name, email);
String paymentMethodCode = " pm_card_mastercard " ;