Skip to content

Commit

Permalink
feat(payment): always require to enter payment method
Browse files Browse the repository at this point in the history
  • Loading branch information
vihangpatil committed Oct 3, 2023
1 parent c224652 commit a13619e
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -120,12 +120,14 @@ object StripeClient {
.setLocale(CheckoutSessionCreateParams.Locale.AUTO)
// in case of duplicates we give priority to one created later
.setCustomer(customerId)
.setPaymentMethodCollection(CheckoutSessionCreateParams.PaymentMethodCollection.IF_REQUIRED)
// https://stripe.com/docs/api/checkout/sessions/create#create_checkout_session-payment_method_collection
.setPaymentMethodCollection(CheckoutSessionCreateParams.PaymentMethodCollection.ALWAYS)
.apply {
if (isProd
&& customerEmail.endsWith("@k33.com", ignoreCase = true)
&& productMap["pro"]?.stripeProductId == productId
) {
// https://stripe.com/docs/api/checkout/sessions/create#create_checkout_session-discounts
addDiscount(
CheckoutSessionCreateParams
.Discount
Expand All @@ -137,13 +139,15 @@ object StripeClient {
if (!hasCurrentOrPriorSubscription) {
setSubscriptionData(
CheckoutSessionCreateParams.SubscriptionData.builder()
// https://stripe.com/docs/api/checkout/sessions/create#create_checkout_session-subscription_data-trial_period_days
.setTrialPeriodDays(TRIAL_PERIOD_DAYS.toLong())
.setTrialSettings(
SessionCreateParams.SubscriptionData.TrialSettings
.builder()
.setEndBehavior(
SessionCreateParams.SubscriptionData.TrialSettings.EndBehavior
.builder()
// https://stripe.com/docs/api/checkout/sessions/create#create_checkout_session-subscription_data-trial_settings-end_behavior-missing_payment_method
.setMissingPaymentMethod(
SessionCreateParams.SubscriptionData.TrialSettings
.EndBehavior.MissingPaymentMethod.CANCEL
Expand Down

0 comments on commit a13619e

Please sign in to comment.