#BRData

1 messages · Page 1 of 1 (latest)

naive remnantBOT
desert pike
#

Also please don't expose api secret keys in here

#

That's sensitive data

rancid zinc
#

Whoops sorry

#

It was only a test keyt

desert pike
#

Yeah. You still need to roll it

rancid zinc
#

Will do

#

How is that possible?

#

No such payment intent when I am looking at it

desert pike
#

Can you share the request id?

#

I linked above how to find it

rancid zinc
#

maybe this is it?

#

req_WNFx9P90b1FIMv

desert pike
#

No that's a request to create a payment intent

#

Do you have multiple accounts?

#

Usually the no such payment intent errors come when you either use the wrong api key

#

Or use the stripe account header incorrectly

rancid zinc
#

Yes I have a "connected" test account

#

and I have my main account

#

Connected standard account

desert pike
#

pi_3NGjkgEVoNb8mE9201du68Lk exists on the
acct_1N5blfEVoNb8mE92 connect account

#

So you'll need to pass the stripe account header too when retrieving it

rancid zinc
#

What do you mean by that?

#

How do I pass that in when using this:

#

var service = new PaymentIntentService();
service.Get(paymentIntent);

desert pike
#

The same way you passed it to create the payment intent

rancid zinc
#

Like that?

desert pike
#

Well looks like there's an error

#

What does the message say? requestOptions is underlined in red

rancid zinc
#

I tried to do it as I would if it was a payment intent create

desert pike
#

One sec let me get back to you with the proper syntax

#

Oh ok so issue looks like the second argument is supposed to be the parameters sent to the request (like expand if you're using expansion). However, since you're not using any params in the request, you'd still need to send an empty object for the params. Try: service.Get(paymentIntent, new PaymentIntentGetOptions(), requestOptions)

rancid zinc
#

Got it that seemed to have worked

#

How do I get the status so I can check if the payment was successful or not from the service.Get method?

desert pike
#

status should be a param on the intent that you get back

rancid zinc
#

thats everything inside of service

desert pike
#

Yeah because service isn't the payment intent

#

the result of service.Get is the payment intent

#

So assign it to a variable and print it out

rancid zinc
#

ahhhhhhhhh

#

Hmm so for some reason the status is "requires payment method"

desert pike
#

Well did you provide a payment method to charge?

rancid zinc
#

What I am doing is as soon as the pay button is hit it calls a custom function on my backend the check the payment status

#

I am using the test card number so I know its a successful payment

desert pike
#

Can you share the payment intent id you just printed out?

rancid zinc
#

whoops i think I know the issue

#

stripe.confirmPayment(): the confirmParams.return_url argument is required unless passing redirect: 'if_required'

#

I removed the return url from this method because I dont want the page to redirect at all

desert pike
#

Ah yep

rancid zinc
#

what can I put in there to stop it from redirecting?

desert pike
#

You can't

rancid zinc
#

the return URL needs to redirect somewhere?

desert pike
#

So you need to also pass redirect: if_required. But return_url is necessary because some payment methods absolutely require a redirect. Card payments don't. So if you pass the return_url and redirect: if_required w/ a card payment then you won't be redirected

rancid zinc
#

Does that look right?

desert pike
#

No

#

param is called redirect

rancid zinc
#

Okay i fixed that i believe

#

But now its throwing this:

desert pike
#

What's the message/response body?

rancid zinc
#

It has to do with the redirect

desert pike
#

What does it say

rancid zinc
#

When I removed it, it worked

desert pike
#

That's because redirect isn't supposed to be in confirmParams

#

Look at the docs I sent

rancid zinc
#

I am trying

#

Not sure I understand

#

I see "elements" as a method param

desert pike
#

That should be right

rancid zinc
#

So i put it in as a method param

desert pike
#

Is ^ not working?

rancid zinc
#

I dont think so.

desert pike
#

What's the response this time?

rancid zinc
desert pike
#

Also receipt_email isn't a valid param

#

It's not in the docs I sent

rancid zinc
#

Hmm that came with the sample code

#

and its working

desert pike
#

Which sample code out of curiosity?

rancid zinc
#

Wait I am figuring out what is happening

#

I think its a race condition

#

Yeah 100% a race condition

#

That is the javascript - if you look at reportrequest that is when it is calling the service.Get function to check the status of the payment

#

Is there a better time that this should be called?

desert pike
#

Ah yeah that's why you should use webhooks

#

That'll enable you to receive a request on your endpoint from Stripe's servers when the payment intent succeeds

rancid zinc
#

Yeah I was hoping there was a way I could do it without webhooks

desert pike
#

No we always recommend webhooks

#

Alternative could be building logic on the return_url

#

But that comes with risks since there's no guarantee the return_url will ever be loaded (ie browser crashes, network issues, etc)