#nizar-naasani_best-practices

1 messages · Page 1 of 1 (latest)

regal rapidsBOT
wheat copperBOT
#

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.

regal rapidsBOT
#

👋 Welcome to your new thread!

⏲️ We'll be here soon! We typically respond in a few minutes, but in some cases we might need a bit more time (e.g., server's busy, you've got a complex question, etc.).

⏱️ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can 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/1247779032993497142

📝 Have more to share? Add details, code, screenshots, videos, etc. below.

sullen canopy
#

You need to specify the promo code on the Subscription creation time, so it got applied to the first Invoice. If you only specify it in Update time then the first Invoice is finalized and can't be editted anymore

raven axle
#

I'm using a custom ui for the payment that's why i need to create the subscription first

#

do you suggest me to create another subscription and ditch the older one when they use a promo code?

sullen canopy
#

I'm not sure about your scenario, but why wouldn't a custom UI can't add the coupon? You can add the coupon on your backend API call

raven axle
#

yes I'm able to add a coupon

#

but I'm creating the subscription when the customer goes to the checkout page and I give it these options

#

`var subscriptionOptions = new SubscriptionCreateOptions
{
Customer = customerId,
Items = new List<SubscriptionItemOptions>
{
new SubscriptionItemOptions
{
Price = priceId,
},
},
PaymentSettings = paymentSettings,

                PaymentBehavior = "default_incomplete",
                Metadata = new Dictionary<string, string> {
                    { "email", viewModel.MemberEmail },
                    { "phoneNumber", member.Mobile },
                    { "memberId", member.Id.ToString() },
                    { "basketItems", string.Join(",", member.Basket?.Select(x => x.Id)) },
                    { "isMonthly", model.IsMonthly.ToString() },
                    { "monthlyPriceId", monthlyPriceId }
                },
            };
            subscriptionOptions.AddExpand("latest_invoice.payment_intent");`
#

that is beacuase I need the clientSecret to show the payment form

sullen canopy
raven axle
#

this is to update subscription or to create a new one?

#

sorry but what's the difference between this and applying a promo code?

sullen canopy
#

This is specifying coupon on Creating Subscription

raven axle
#

so this is not applying the promo code on it?

#

ok so how can I add it on creating the subscription? I can't seem to add it in SubscriptionCreateOptions

sullen canopy
#

Yeah do you see the discounts.promotion_code parameter in that link?

#

Should be Discounts parameter

raven axle
#

am I looking in the wrong place?

#

I think I'm using an old version of the sdk?

#

yup I updated the package and I can see it now

#

so this is not applying the promo code on the subscription? it's just to provide it as an option in case the customer use it?

sullen canopy
#

No it should be applying the promo code. Please test it in Test mode

raven axle
#

if it applys it then what's the difference between these two options?

raven axle
#

?

sullen canopy
raven axle
#

there is an option in the subscriptionCreateOptions called promotion code 🥲

sullen canopy
#

Ah that's an old and deprecated one. Please ignore it and use the Discounts instead