#dineshkumar_docs

1 messages ¡ Page 1 of 1 (latest)

native sirenBOT
cunning siloBOT
#

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.

native sirenBOT
#

👋 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/1253690067965444107

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

sharp egret
#

hi there!

#

how are you accepting payments? Checkout Session, Payment Element, something else?

frail sigil
#

subscription

sharp egret
#

ok, but how? with a Chekcout Session, Payment Link, the Subscription endpoint?

frail sigil
#

no , i need to check promocode FirstTimeTransaction customer

#

so i need to find the customer already payment done or not.

sharp egret
#

I'm sorry I don't understand. can you explain your flow in more details and exactly what is the issue?

frail sigil
#

i created this promocde promo_1PU5dxBUmBAZBIgtHYK1B6Hn

#

this is restirction is, ""first_time_transaction"": true,

#

i need to apply this coupn in subscription, but before i need to check this is valid promocode for customer

#

i need to check this customer cus_P5wQFfOOb4eTmS done firsttime transaction done or not?

sharp egret
frail sigil
#

i got this error "This promotion code cannot be redeemed because the associated customer has prior transactions."

sharp egret
#

then it means it's working as expected

#

what's the isse?

frail sigil
#

var subscriptionCreateOptions = new SubscriptionCreateOptions
{
Customer = "cus_P5wQFfOOb4eTmS",

            Items = new List<SubscriptionItemOptions>
            {
               
                new SubscriptionItemOptions
                {
                    Price = "price_1OHkS0BUmBAZBIgtbJL84FOb",
                },
            },
            
            PromotionCode = "promo_1PU5dxBUmBAZBIgtHYK1B6Hn"
        };
        subscriptionCreateOptions.AddExpand("latest_invoice.payment_intent");
        var subscriptionService = new SubscriptionService();
        try
        {
            Subscription subscription = subscriptionService.Create(subscriptionCreateOptions);

            return Json(new { clientSecret = subscription.LatestInvoice.PaymentIntent.ClientSecret });
        }
        catch (StripeException e)
        {
            Console.WriteLine($"Failed to create subscription.{e}");
            return BadRequest();
        }
#

this is my code

#

before sunscrition i want check the promocode is valid one "promo_1PU5dxBUmBAZBIgtHYK1B6Hn"

sharp egret
#

so you want to check if it's valid before creating the Subscription?

frail sigil
native sirenBOT
sharp egret
#

well the simplest option would be to create the Subscription, and if you get an error you know it's not valid. another option would be to check if that customer has made any transactions in the past.

frail sigil
#

i need to check before create subscription

#

when i try to create the subscribtip with promocode subscription created right?

sharp egret
#

i need to check before create subscription
yes I explained how to do it above

#

here:

check if that customer has made any transactions in the past.

frail sigil
#

first step promocode is check if valid or not
and then step 2 apply promocode in sunscription

sharp egret
#

yes, makes sense

frail sigil
#

How we check , check if that customer has made any transactions in the past.

sharp egret
#

so you'll need to track/check on your end if the customer made a transaction is the part or not.

frail sigil
#

please guide link send me

sharp egret
frail sigil
#

understood , i will check

rustic prawn
#

Why not just try to create the sub?

#

You'll get an error if it's not valid

#

Otherwise, no above is only option

frail sigil
#

if suppose valid promocode, the subscription created right? i need just check promocode valid or not before use it.

rustic prawn
#

if suppose valid promocode, the subscription created right?
yeah but why is this an issue?

#

Wouldn't you want to create it if it's valid?

frail sigil
#

flow is:
step 1: promocode is check if valid or not
step 2 : use promocode in sunscription if valid only.

#

if promocode is invalid we restict on UI to create a subscription(disabled subsription button on UI)

rustic prawn
#

Right, but a subscription won't be created if you pass an invalid coupon

#

The requirement is that it's two-separate steps?

#

If so, the solution my colleague provided is your only option

frail sigil
#

Yes two steps

#

step 1: promocode is check if valid or not
step 2 : use promocode in sunscription if valid only.

rustic prawn
frail sigil
#

See image Grren button is valid and red button is invalid

#

check out button is create a scbscription