#emmann_48287

1 messages · Page 1 of 1 (latest)

acoustic burrowBOT
#

Hello! We'll be with you shortly. 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.

rapid horizon
#

Hello

#

You would need to calculate that just before you actually create the Checkout Session.

marble cloak
#

hii

rapid horizon
#

You can't set a variable in your Checkout Session URLs

marble cloak
#

what you suggest instead?

rapid horizon
#

Actually wait... I think that should work fine -- are you seeing an error?

marble cloak
#

yes i see error on the callback when it return seller url DOMAIN on CANCEL and SUCCESS

#

but with platform url it works fine

#

as i allow seller to have their domain

#

now it becomes a problem

#

you get it?

#

i'm using NODEJS

rapid horizon
#

Hmmm no not really... what is the error?

#

Do you have a request ID for that error?

marble cloak
#

i mean to let you know the payment was successfull

#

but the callback not wokring because it's not dynamic

#

you get it?

#

in my head i'm wondering if Stripe save partially the origin REQUEST URL

rapid horizon
#

No sorry, I don't get it. Do you mean that the redirect doesn't contain the Checkout Session ID?

#

Like we just use whatever you pass to your Checkout Session creation request

marble cloak
#

if so i could use it for dynamic callback

#

okay

#

but is there a way to make dynamic callback

#

that is my question

#

success_url: ${process.env.BASE_URL}/payment/success,
cancel_url: ${process.env.BASE_URL}/payment/cancel,

#

based on origin URL?

#

OR SOURCE

rapid horizon
#

Yes that should work fine. As long as ${process.env.BASE_URL}/payment/success actually outputs an HTTPS URL then there should be no issue

marble cloak
#

no you don't get it

#

i would like to change this part of the code: ${process.env.BASE_URL} to make it dynamic

#

so that the callback success or cancel return in the URTL that sent the request

rapid horizon
#

Can you give me an example of exactly what you are trying to do? I think we are speaking past each other.

marble cloak
#

okay let me grab the code

#

//direct charges to a standard connected account
exports.directChargesStandardAccount = async (req, res) => {

try {

    const session = await stripe.checkout.sessions.create({
        mode: 'payment',
        line_items,
        customer_email: req?.user?.email,
        client_reference_id: req?.user?._id.toString(),
        payment_intent_data: {
            application_fee_amount: calculateApplicationFeeAmount(plan, itemsPrice),
        },
        metadata: {
            shippingAddress: req?.body?.cart?.shippingAddress,
            slug: req?.body?.cart?.slug,
            sendingMethod: req?.body?.cart?.sendingMethod       
        },
        shipping_options: [
            {
                shipping_rate_data: {
                    type: 'fixed_amount',
                    fixed_amount: {
                        amount: req.body.cart.shippingPrice * 100,
                        currency: 'brl',
                    },
                    display_name: 'Frete',
                },
            },
        ],
        success_url: `${process.env.BASE_URL}/payment/success`,
        cancel_url: `${process.env.BASE_URL}/payment/cancel`,
    },
        { stripeAccount: req.body.cart.stripeAccountId }
    );

    res.send({ url: session.url })
} catch (error) {
    console.log(error);
}

}

#

i'm interested in dynamic callback URL

#

instead of hard coded URL using .env

#

which is this part of the code: ${process.env.BASE_URL}

rapid horizon
#

What is that BASE_URL? What would be an example of it?

marble cloak
#

you get it now?

rapid horizon
#

Yeah okay we have been talking about the same thing all along. Yeah I mean that is totally up to how you want to handle the confirmation page. If the success URL is a page that you don't control then indeed you aren't going to be able to handle anything there in terms of what you display to the customer. However, you can still just use Webhooks for fulfillment purposes.

marble cloak
#

i'm using webhooks for managing confirmation payment and generate order

#

dynamically

rapid horizon
#

That works totally fine. You can use any legitimate HTTPS URL for the success and cancel URLs... you don't have to directly control that URL yourself. You just won't be able to action that page.

#

So yeah now we are back to the beginning

marble cloak
#

humm, it would be nicer to me and to end user

#

you suggest to achieve that with webhooks i don't see how

#

because striope direct checkout remember the callback registred

rapid horizon
#

You use Webhooks for your own internal processes server-side.

#

Not for client-side actions.

marble cloak
#

yes

#

how it should be handle in a webhooks context

#

i just don't know and don't see how

rapid horizon
#

What is "it"?

marble cloak
#

you suggested earlier that something that could be achieved with webhokks

#

but i'm asking if you could give a clear exemple of that plz

rapid horizon
#

I was saying you can handle your fulfillment with Webhooks.

#

Which is how you could use a URL that you don't control and still be able to have a complete flow (other than having control of the client-side success page)