#abhinav_best-practices

1 messages ยท Page 1 of 1 (latest)

clear oarBOT
#

๐Ÿ‘‹ 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.

bitter kelp
#

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.

stoic smelt
#

But we are using a payment link. How can we achieve this?

bitter kelp
#

Are you sending a different Payment Link for each product?

stoic smelt
#

No.

bitter kelp
#

How are you adding new products to the Subscription?

stoic smelt
#

We want to let the new users subscribe to products A and product C.

stoic smelt
#

But products A and product C are main subscriptions and the users have to subscribe during sign up.

bitter kelp
#

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.

stoic smelt
#

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.

bitter kelp
#

What's not working exactly?

stoic smelt
#

The payment link API doesn't give me any way to apply discounts.

bitter kelp
#

Your setup seems to get too complicated for Payment Links. I suggest you to start using Stripe Checkout or custom Stripe integration instead.

stoic smelt
#

For using Stripe Checkout, do we need to listen to events?

bitter kelp
#

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.

stoic smelt
#

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)
open mist
#

๐Ÿ‘‹ taking over for my colleague. Let me catch up.

stoic smelt
#

If I can get a customer created, I can then create as many subscriptions for this customer.

stoic smelt
open mist
#

yes sure!

#

I mean sending your customers the promotion code to use to apply the discount

stoic smelt
#

will they have to type it themselves?

open mist
#

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.

stoic smelt
#

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.

open mist
#

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

stoic smelt
#

I can't find any reference on how to do it.

open mist
#

it's just another param on the builder

stoic smelt
#

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?

open mist
#

oh maybe we don't support multiple promotion codes ๐Ÿฅน

stoic smelt
#

So it is now Checkout Session.

open mist
#

yep sorry

stoic smelt
#

I need to read into it. I have no idea about it yet.

#

Thanks.

open mist
#

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

stoic smelt
#

@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.

open mist
#

you apply the discounts on the Checkout Session as we agreed on yesterday

#

and you would pass 2 discounts

stoic smelt
#

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??

open mist
#

taking a look

clear oarBOT
bitter kelp
#

Hi! I'm taking over from my colleague. Please, give me a moment to catch up.

#

Still looking, sorry for delay

#

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.

stoic smelt
#

It is not that simple. We need to control it my no. of days per product.

bitter kelp
#

How would you achieve this with Discounts?

#

I thought you want to use trial initially

stoic smelt
#

Yes we need to use trials. It was your team mate's suggestion to use discounts.

#

Please read the problem statement again.

bitter kelp
#

I think you will need to create 2 parallel Subscriptions on the same Customer.
There's 2 approaches:

  1. Use custom UI to create one Subscription and then create the second one using the same PaymentMethod off-session.
  2. 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.
stoic smelt
#

I like approach 2.

bitter kelp