#red_api

1 messages ยท Page 1 of 1 (latest)

ornate pagodaBOT
#

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

๐Ÿ“ 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.

steel pewter
#

what am I missing?

snow bay
#

createPaymentMethod is a legacy flow. We can suggest a better flow if we know what you want to achieve ๐Ÿ™‚

#

Why do you want to collect card info before creating a PaymentIntent?

steel pewter
#

so, I am in the Surcharge Beta, so I am following instructions - and they use that flow (as whether surcharge is available is on the paymentIntent returned)

#

I had everything set up so I use confirmation token instead, but I can't see how to use that with surcharge beta

#

BUT I obviously need to know if a card was used so I can create the Intent

#

hopefully that makes sense!

#

I'm all ears if you can suggest something better!

snow bay
#

I am in the Surcharge Beta, so I am following instructions - and they use that flow
Can you share the Doc you are following here?

snow bay
#

Okie let's say you are following this step by step. In which step are you stucked?

#

Sorry I didn't know you are on a beta. When you are on a beta, it's best to follow the beta Doc

steel pewter
#

that's what I'm trying

#

ah I think I figured it out

#

I had included

                enabled: true,
                allow_redirects: 'never'
            },```
#

I removed that and now get the payment-specific intent!

#

any idea why confirmationToken won't work with surcharge implementation though?

snow bay
#

Technically it could work. Have you tried and which error do you encounter?

steel pewter
#

I would much prefer to use that method

#

but when I pass the confirmationToken to the server, I looked like I could only call stripe.paymentIntents.create with the confirmationToken and I have to confirm it at the same time?

#

whereas I need to apply the surcharge first - and to do that, I need the paymentIntent (hopefully that makes sense)

#

am I missing something?

#

also, going back to the documented implementation, if I have multiple payment options, how do I tell if a surcharge is available without a big if-else?

snow bay
#

Ah I see

#

when I pass the confirmationToken to the server, I looked like I could only call stripe.paymentIntents.create with the confirmationToken and I have to confirm it at the same time?
Yes because that's the "confirmationToken" ๐Ÿ™‚ It doesn't suit when you need to create the PI first with card info then confirm later

#

if I have multiple payment options, how do I tell if a surcharge is available without a big if-else?
I imagine you would check the returned PI with payment_method_options.card.surcharge 's status and maximum_amount, correct? Which if-else do you forsee?

steel pewter
#

ah, yep, so I guess only cards are surchargable at this time, even though things like CashApp have a fee associated with them

#

sounds like I should give up on the confirmationToken approach?

snow bay
#

Yes

steel pewter
#

ok

#

I think it's working

#

does this look right?

#

"id": "pi_3SNPVWBBPymgN3Ps0523XeaX",
"object": "payment_intent",
"amount": 125000,
"amount_capturable": 0,
"amount_details": {
"surcharge": {
"amount": 0
},
"tip": {}
},
"amount_received": 0,
"amount_surcharge": 3750,

#

I'm a bit surprised by:

#

"amount_details": {
"surcharge": {
"amount": 0
},

#

where can I see the surcharge details in the Stripe dashboard?

#

also, the payment shows as Incomplete?

snow bay
#

Let me look at the PI

#

Ok that's expected. PI is incomplete because it hasn't been confirmed yet. (Step 7)

steel pewter
#

ah

#

I need to do that server side - no issue, correct?

#

and because this is in an iFrame there's no return url

snow bay
#

Technically should work, after you have displayed the applied surcharge on step 6

steel pewter
#

I have things set up so I show the surcharge in the UI in the very first step ๐Ÿ™‚

#

that way customer see what they will charge - and can chose ACH if they prefer

#

hence having to bend the instructions a little

#

after I submit the UI, I create the PaymentIntent, update with surcharge (checking that the amount applied in the UI <= max allowed) and then confirm all in one backend step

#

ha, except I can't use stripe.confirmPayment on backend apparently

#

can I just do stripe.paymentIntents.confirm( 'pi_3MtweELkdIwHu7ix0Dt0gF2H')?

snow bay
#

Yes backend has its own version of Confirm Payment Intent

#

looks correct, depends on the backend SDK

steel pewter
#

node.js

#

do I need clientsecret?

#

struggling to find the right docs for it

#

would you have a link please for server-side node.js call?

#

so this:

        paymentIntent.id,
        {
            payment_method: paymentIntent.payment_method.id
        }
    );```
snow bay
#

Yes that should work

#

with the same Id

#

no client_secret needed. That's for client-side confirmation

steel pewter
#

and: This PaymentIntent is configured to accept payment methods enabled in your Dashboard. Because some of these payment methods might redirect your customer off of your page, you must provide a return_url. If you don't want to accept redirect-based payment methods, set automatic_payment_methods[enabled]totrueandautomatic_payment_methods[allow_redirects]tonever` when creating Setup Intents and Payment Intents."

#

will add

#

oh wait, I had to remove that to get the payment-specific intent?!

#

any ideas?

snow bay
#

hmm

#

Can you try the suggestion

set automatic_payment_methods[enabled] to true and automatic_payment_methods[allow_redirects] to never
When creating the Payment Intent?

#

Either this or specifying a returnUrl

steel pewter
#

qq before I answer that - how do I see the surcharge info in the dashboard?

#

I don't see it for some reason?

#

(for a successful payment)

snow bay
#

Yes we haven't shown that in Dashboard. You can leave it as a feedback to Support team if you already have a conversation with them on enabling this beta

steel pewter
#

hmm, that's problematic!

#

how am i supposed to understand after the fact?

snow bay
#

Listening to payment_intent.succeeded webhook event, and look up the surcharge properties there

steel pewter
#

historically?

#

can I look up a paymentIntent somehow on the dashboard?

snow bay
#

You can use the Retrieve PaymentIntent API. I think it's possible via API all kind, just Dashboard doesn't looks obvious

steel pewter
#

yeah, needs to be on dashboard

steel pewter
snow bay
#

I think surcharge is tighted to card and you will need a returnURL anyway. Just prepare an endpoint could be the easiest workaround

steel pewter
#

card doesn't need a returnUrl though?

snow bay
#

Let's try another thing, when you create the Payment Intent, can you explicitly send

payment_method_types: ['card']

?

steel pewter
#

how do I know that's what they chose?

#

could be ACH or CashApp

snow bay
#

So do you want to keep using Dynamic Payment Methods, which can enable all card, ACH and CashApp?

steel pewter
#

yes, have to on the front end

#

it does get set via Payment method - look at pi_3SNQBqBBPymgN3Ps1U1J3wi5

#

something funky going on

snow bay
steel pewter
#

I don't get back the PaymentMethod

#

oh - see where it shows card?

snow bay
ornate pagodaBOT
steel pewter
#

yes, that's what I tried the first time, but maybe I wasn't expanding the payment method in the call at that time?

snow bay
#

Sorry I am confused, have you tried including 2 parameters on the Create Payment Intent API? If you have, please share the request id (req_xxx)

automatic_payment_methods[enabled]=true
automatic_payment_methods[allow_redirects]=never
steel pewter
#

yes right at the beginning

#

trying it again

barren pasture
#

Hi! Stepping in for my colleague. Give me a while to catch up. Thanks!

steel pewter
#

ok that did work

#

pi_3SNQrSBBPymgN3Ps0tf2SqYD

#

can I send a receipt from the dashboard?

#

nm, I found it

#

but can I programmatically add to the receipt line items?

barren pasture
steel pewter
#

thanks, but I was looking for a way to affect the receipt by adding line items to it?