#donut_code
1 messages ยท Page 1 of 1 (latest)
๐ Welcome to your new thread!
โฒ๏ธ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.
โฑ๏ธ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.
๐ This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1423276651151753259
๐ Have more to share? Add more details, code, screenshots, videos, etc. below.
Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.
- donut_docs, 21 hours ago, 26 messages
hi there!
hi
var createSubscription = new SubscriptionCreateOptions
{
Customer = customer.Id,
Items = new List<SubscriptionItemOptions> { new SubscriptionItemOptions { Price = price.Id } },
Metadata = createStripeSubscriptionPaymentRequest.Metadata,
Discounts = new List<SubscriptionDiscountOptions> { promotionCode == null ? new SubscriptionDiscountOptions { Coupon = coupon?.Id } : new SubscriptionDiscountOptions { PromotionCode = promotionCode?.Id } },
Currency = price.Currency
};
if (createStripeSubscriptionPaymentRequest.PaymentOptionId == PaymentOptionConstants.PayPal)
{
createSubscription.Expand = new List<string> { "latest_invoice.confirmation_secret" };
createSubscription.OffSession = true;
}
else if (createStripeSubscriptionPaymentRequest.PaymentOptionId == PaymentOptionConstants.ApplePay)
{
createSubscription.PaymentBehavior = "default_incomplete";
createSubscription.Expand = new List<string> { "latest_invoice.payment_intent" };
createSubscription.OffSession = true;
}
else
{
createSubscription.PaymentBehavior = "default_incomplete";
createSubscription.Expand = new List<string> { "latest_invoice.payment_intent" };
createSubscription.PaymentSettings = paymentSettings;
)
if you want ot start a Subscription, you don't need to create a SetupIntent.
directly create the Subscription, and then collect the payment details on the frontend, which by default supports Apple Pay.
or, for a simpler integration, directly use Checkout Session to create the Subscription for you (which also supports Apple Pay)
the frontend is using express checkout
and also is using stripe elements
but we dont use checkout sessions
Yes Subscription + Express Checkout also works and does support Apple Pay.
else if (createStripeSubscriptionPaymentRequest.PaymentOptionId == PaymentOptionConstants.ApplePay)
{
createSubscription.PaymentBehavior = "default_incomplete";
createSubscription.Expand = new List<string> { "latest_invoice.payment_intent" };
createSubscription.OffSession = true;
}
are these correct for apple pay
๐ taking over for my colleague. Let me catch up.
thank you
what do you mean here?
wryttd?
i am trying to create stripe recurring subscriptions using apple pay as a payment method
i had to make that if because for paypal i had to use diff params on expand
and no payment behavior
the last else is for card payments
you can always expand on multiple fields
for example both latest_invoice.payment_intent and pending_setup_intent
and depending on which of these aren't null
you can send that to the front end and either confirmPayment or confirmSetup accordingly
what is the difference
it depends on whether the first invoice has a due amount or not
yes so what I'm saying works for both free trial and immediate payment subscriptions
but what I'm still hesitatant to understand here is why you're using latest_invoice.confirmation_secret and latest_invoice.payment_intent
if you're using a newer API version (basil+) then you should not use the latter
since there won't be any PI directly on the Invoice
confirmation secret should work for all payment methods
okay i'll use confirmation secret from now on. But how is that gonna affect the frontend implementation
you just pass it as the client_secret
yes confirmPayment
here i should keep offsession true
right
else if (createStripeSubscriptionPaymentRequest.PaymentOptionId == PaymentOptionConstants.ApplePay)
{
createSubscription.PaymentBehavior = "default_incomplete";
createSubscription.Expand = new List<string> { "latest_invoice.confirmation_secret" };
createSubscription.OffSession = true;
}
no you never want to create your subscription off-session
for Paypal it's particular
we only allow you to use SetupIntents to create a Paypal PM that could be used for recurring Payments
this might change in the future, but for the time being, Paypal has this restriction