#abhinav_best-practices
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/1318905595759169568
๐ 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.
- abhinav_best-practices, 20 hours ago, 11 messages
- abhinav_best-practices, 21 hours ago, 54 messages
Hi, let me help you with this.
Trial period is per Subscription, not per Subscription Item. Therefore you will need to create a new Subscription for the same Customer to support this.
But we are using a payment link. How can we achieve this?
Are you sending a different Payment Link for each product?
No.
How are you adding new products to the Subscription?
We want to let the new users subscribe to products A and product C.
Those products can't be subscribed during sign up. They can be subscribed only from within the app so we are using subscription api to add new subscription item.
But products A and product C are main subscriptions and the users have to subscribe during sign up.
You can't create 2 Subscriptions using 1 Payment Link. You will need to create 1 Subscription via PL during signup, and then create another Sub via Subscriptions API.
Yesterday, @open mist was suggesting me to use discounts to achieve this.
I have created coupons for Product A and C. And I wanted to see how my payment link containing these 2 products will apply discounts. But it is not working.
What's not working exactly?
The payment link API doesn't give me any way to apply discounts.
Your setup seems to get too complicated for Payment Links. I suggest you to start using Stripe Checkout or custom Stripe integration instead.
For using Stripe Checkout, do we need to listen to events?
Yes. But you need to listen to webhook events even with Payment Links, if you want to synchronise it with your own system in any way.
Okay.
Is it possible that I create a customer using a checkout session.
val params = SessionCreateParams.builder()
.setMode(SessionCreateParams.Mode.SETUP)
.setCurrency("USD")
.setBillingAddressCollection(SessionCreateParams.BillingAddressCollection.REQUIRED)
.build()
val session = Session.create(params)
๐ taking over for my colleague. Let me catch up.
If I can get a customer created, I can then create as many subscriptions for this customer.
Hi @open mist . Can you please go through the problem statement. I am scratching my head since last 2 days on how to achieve this. Please help!!!
yes sure!
would promotion codes solve your problem? https://docs.stripe.com/api/payment-link/create#create_payment_link-allow_promotion_codes
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
I mean sending your customers the promotion code to use to apply the discount
will they have to type it themselves?
yes
if that's not possible, then you would have to revert to Checkout Sessions as my colleague suggested earlier
I appreciate you have a very complex use-case and we're trying to accomplish it using workarounds and cutting corners but that's the best we could offer you now.
I tried creating coupons but I think I didn't select customer coupons there. And I have seen I can only edit its name and nothing else.
I have just created 2 customer code coupons.
I still don't see it here.
Here's my code.
you're not allowing promotion codes on the Payment Link
once you do, you'll be able to type in and apply the promotion codes you just created
I can't find any reference on how to do it.
it's just another param on the builder
But it is getting applied on 1 product, but my sceanrio is provide 3 months trial on Product A and 1 month trial on Product B.
I need to give this $20 product free for first month as well.
@open mist Are you still with me?
oh maybe we don't support multiple promotion codes ๐ฅน
So it is now Checkout Session.
yep sorry
it's fairly similar
the only difference is that the PaymentLink has only one URL from which we create (automatically for you) Checkout Sessions for each time the URL is visited
@open mist So checkout session has modes - if I use the subscription mode, it will still put both products under same subscription which will defeat the purpose.
How exactly can I use checkout sessions to achieve my goal.
no it won't defeat the purpose
you apply the discounts on the Checkout Session as we agreed on yesterday
and you would pass 2 discounts
Interesting!!! Let me try this one.
val params = SessionCreateParams.builder()
.addLineItem(
SessionCreateParams.LineItem.builder()
.setPrice(BASE_PORTAL_PRICE_ID)
.setQuantity(1L)
.build()
)
.addDiscount(
SessionCreateParams.Discount.builder().setCoupon("OQ7GRcJx").build()
)
.addLineItem(
SessionCreateParams.LineItem.builder()
.setPrice(ENERGY_BENCHMARKING_PRICE_ID)
.setQuantity(1L)
.build()
)
.addDiscount(
SessionCreateParams.Discount.builder().setCoupon("999ls8o8").build()
)
.setMode(SessionCreateParams.Mode.SUBSCRIPTION)
.setSuccessUrl("https://example.com/success")
.setCancelUrl("https://example.com/cancel")
.build();
val session = Session.create(params)
Error - Array discounts exceeded maximum 1 allowed elements.; request-id: req_esL9VdsM9jG8T1
It is not allowing multiple discounts. Or may be syntax issue??
taking a look
Hi! I'm taking over from my colleague. Please, give me a moment to catch up.
Still looking, sorry for delay
Yeah, the docs suggest you might only use 1 discount item: https://docs.stripe.com/api/checkout/sessions/create#create_checkout_session-discounts
I suggest you to create a discount with for a custom fixed amount that will be a sum of the discounts for both products.
I.e. if both products are $100, and one discount is 20% and another is 30%, instead just create 1 one-time Coupon for $50.
It is not that simple. We need to control it my no. of days per product.
How would you achieve this with Discounts?
I thought you want to use trial initially
Yes we need to use trials. It was your team mate's suggestion to use discounts.
Please read the problem statement again.
That would be a solution, but multiple Discounts seem to not be supported.
I think you will need to create 2 parallel Subscriptions on the same Customer.
There's 2 approaches:
- Use custom UI to create one Subscription and then create the second one using the same PaymentMethod off-session.
- Save a payment method for future usage (using custom UI or Checkout in
mode=setup), and then create 2 Subscriptions for the same Customer simultaneously.
I like approach 2.
You can follow this guide to save and reuse the PaymentMethod: https://docs.stripe.com/payments/save-and-reuse