#Adi - redirect to checkout

1 messages · Page 1 of 1 (latest)

indigo pulsar
#

Hello. One moment

#

For the customer portal, are you just making a request to your backend to retrieve the URL?

wide robin
#

yes

#

sorry from backend I am just sending customer billing portal session id

#

like this

router.post('/create-customer-portal-session', isAuth, async (req, res) => {

    const user_id = req.userId;
    const sessionData = req.body;
    console.log("sessionData", sessionData)

    // Authenticate your user.
    const session = await stripe.billingPortal.sessions.create({
        customer: sessionData.customerId,
        return_url: 'http://localhost:3000/upgrade',
    });

    res.send({ id: session.id });
});
indigo pulsar
#

You should return session.url and then use javascript to redirect

wide robin
#

ok let me check once from my end

#

thanks a lot session.url worked for me.

#

I have one question:
I have added 3 plans for my application.
$0 -> free plan
$10 -> basic plan + 7 day trial period
$20 -> standard plan + 7 day trial period
If user starts with free plan on 1st March and on 2nd March if user upgrades to $10 plan then trial period will get over on 9th March. Now what if user just cancels subscription on 8th March then he will not be charged is that correct? So in my application if subscription is cancelled then he will automatically be switched to free plan $0 per month this logic I have added. But next day i.e 9th March if user again come up and tries to subscribe $10 plan then will trial period again start? or he will be charged immediately because last time he started trial period but cancelled it later?

wide robin
normal axle
#

HI 👋 I'm stepping in for @indigo pulsar let me get caught up

wide robin
#

I did not get what this message is Non-INR transactions in India should have shipping/billing address outside India. More info here: https://stripe.com/docs/india-exports
on dashboard do I need to update export information on dashboard?

#

this is current dashboard setting

normal axle
#

This is a known error relating to the default billing features of our US test cards

wide robin
#

while using built in checkout I dont get this message but on customer billing portal I get this

#

so which test cards should I use?

normal axle
wide robin
normal axle
#

I think, in this case, your system would need to keep track of this user's behavior and specifically eliminate the free trial period when creating the second subscription. Since it is a new subscription as far as Stripe is concerned.

wide robin
#

ok got it

wide robin
#

what if I don't want to take customers billing address, name & description?

#

or is that mandatory?

#

I am facing this issue in customer billing portal only. For pre built checkout it does not happen i.e upgrade/downgrading plan

normal axle
#

Or setting a different country

wide robin
#

setting different country did not work

#

I tried Indian card but after 3D secure it shows same msg

#

with USA card 3D secure was also not coming

normal axle
#

Was it this card? 4000003560000008

wide robin
#

yes

normal axle
#

And this was a customer portal, you were tying to update a payment method?

wide robin
#

yes correct

#

I have 3 plans free plan basic and standard plan

#

Initially when user is on free plan for first time I force user to go through stripe prebuilt checkout and it works fine for me I have done testing. Now on every subsequent plan upgrade or downgrade I dont force user to go through prebuilt stripe checkout but instead I navigate user to customer billing portal and there I am facing this issue

normal axle
#

Right, that makes sense.

wide robin
#

is this default behaviour of stripe or am I missing something from my end?

normal axle
#

Can you send me the ID for the customer portal session?

#

or the request you made to create the customer portal session?

wide robin
#

Can you send me the ID for the customer portal session?
I have not written any code for this I have configured directly from dashboard

normal axle
#

You can find the request ID in the dashboard

wide robin
#

Let me share code snippet for better understanding:

router.post('/create-customer-portal-session', isAuth, async (req, res) => {
    const sessionData = req.body;

    // Authenticate your user.
    const session = await stripe.billingPortal.sessions.create({
        customer: sessionData.customerId,
        return_url: 'http://localhost:3000/upgrade',
    });

    res.send({ url: session.url });
});
wide robin
#

any update?

normal axle
#

Yes, a question. Which customer are you making this portal for? Do you always select India as the country when you are updating?

wide robin
#

yes India country selected

normal axle
#

And the customer?

wide robin
#

customer is dummy I don't have customer billing address only using customer id and email

fair path
#

Yes, but even if it's a customer you created just for testing having the customer ID to look at on our end will still be helpful. Also, if you select a different country (not India) from the dropdown do you still see the same error?

wide robin
#

wait let me explain what I am doing

#
  1. User A register on my application & there are 3 plans: free $0 , basic $14 and standard $24 plan
  2. on successful register in DB I am storing user details and priceId of $0 plan
  3. Now user wants to upgrade or downgrade plan i.e switch to basic or standard now this is for first time so I dont navigate user to customer billing portal instead I navigate him to prebuilt checkout session there after successful checkout I add user and payment data in DB after checkout completed event. From this step I also have customer id with me.
  4. Next time user comes back he is navigated to customer billing portal and not prebuilt checkout why customer portal ?? because this time I have customer id which is used in above nodejs code.
  5. Now for customer portal checkout I am facing issues which I explained earlier
#

^^^ Please let me know if you have any questions

fair path
#

Yes, this all makes sense - but my question is why are you selecting India as the country when updating the Payment Method? Based on the error message it sounds like this is a non-INR subscription, so I'm wondering if you still see the same error if you don't select India in the dropdown

wide robin
#

let me confirm once again

#

this is customer id cus_LF0bo9Nx4f8h0Y incase you want to check something

wide robin
#

Is this issue specific to test cards?

#

or am I missing something from customer billing portal?

fair path
#

Hmm.. let me do some more digging - give me a few minutes

wide robin
#

only changing of plans i.e downgrade upgrade not working. Cancel subscription of customer billing portal working fine'

fair path
#

How did you create this customer? It looks like you created it with an India-based address, and so actually attempting to charge the customer is failing because you can't have an India billing address with a non-INR payment

wide robin
#

How did you create this customer?
It gets automatically created if I use prebuilt checkout I just use that customer id later for customer billing portal

fair path
#

Gotcha - so I don't think we should've allowed you to save a India billing address in that Checkout Session (I'll flag this to the team). In the meantime, you should update that Customer to a non-India billing address (which you can do through the API, dashboard, or billing customer portal)

wide robin
#

oh ok got it

#

so does that mean if customer is from India then prebuilt checkout will work for him but customer billing portal will not work for him because amount is in USD is this correct understanding?

fair path
#

Kind of - I think the only reason your India customer was able to work with Checkout was because the subscription was starting with a trial (so no payment was actually collected). I believe it should have actually failed at that point, but that's someting I need to take up with the team.

Essentially, you should never have an India based customer paying for things in USD

wide robin
#

Why not Indian customer can pay in USD actually he should be able to pay in USD even if billing address is India right?

fair path
#

On your frontend you should be prompting your customer for their country and then based on that information you can subscribe them to a price of the correct currency

#

And no, we wouldn't allow an Indian customer (with an India billing address) to pay in USD at all

wide robin
#

But how will USD to INR conversion happen?? Do I need to handle that logic?? Or will stripe handle it?

fair path
#

What conversion are you specifically talking about? If you're talking about needing to have an INR price to charge your India customers, that would be something you create yourself (you'd create a new price object specifically in INR). If you're talking about the conversion of USD funds to INR in your Stripe account that would be something that happens automatically

wide robin
#

No my question is using prebuilt checkout and customer billing portal will I be able to accept payments from Indian customers in USD or not?

fair path
#

No, as I said earlier - if your customer has an India billing address you will not be able to accept payment in USD from them. You would need to charge them in INR

wide robin
#

So that means I will have to create another product with pricing in INR instead of USD right??

fair path
#

Correct

wide robin
#

If I charge $14 USD then how should I do conversion in INR for entering value on stripe product dashboard ?? 1USD = 74 or sometimes more or less than that so there will be some price variation always

fair path
#

That's something you'd have to do yourself - you'd do the conversion on your end (there should be various tools for this online) and then create a price based on that

wide robin
#

Ok got it

#

Thanks a lot for your help and support

heavy boneBOT
#

This thread has been archived. If you need help with anything else please ask in #dev-help or contact Stripe Support: https://support.stripe.com/contact

wide robin
#

Actually I did talk to support but they said it is currently not possible