#brunowilliang_code

1 messages ยท Page 1 of 1 (latest)

meager mossBOT
torn stoneBOT
#

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.

meager mossBOT
#

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

๐Ÿ“ Have more to share? Add more details, code, screenshots, videos, etc. below.

wicked crescent
#

@drifting rover

#

I got access, put it in an MD and separated the two endpoints it has...

#

Can I share it here?

drifting rover
#

Note it's a public forum.
As long as it doesn't contain any API keys it should be ok.

wicked crescent
wicked crescent
#

I can share the code that is also working in the Kotlin application

drifting rover
#

const payObj = await stripe.paymentIntents.capture(intent);
This line tries to capture the PaymentIntent.

wicked crescent
#

right

drifting rover
#

I don't know how else is this code supposed to be used, but if you are not aiming to capture the payments manually, this line shouldn't be there.

torn stoneBOT
wicked crescent
#

So, since the api is already ready, I'm just moving the app from Kotlin to React Native

drifting rover
wicked crescent
#

so I can share the payment flow code

#

if you want

buoyant owl
#

I don't think we need that right now. What exactly is blocking at the moment?

#

it's trivial to do

let pi = await stripe.paymentIntents.retrieve(intent)
if(pi.status === "requires_capture"){
    pi = await stripe.paymentIntents.capture(intent)
}

so I'm sort of lost here.

#

I assume you saw/understood this reply from my colleague yesterday?

#

I'm unclear what else we can explain here but please let me know what's unclear.

wicked crescent
#

so the old application code is working passing through the /terminal/capture endpoint

but not mine in react native it doesn't work

#

basically this

buoyant owl
#

I mean let's ignore that

#

you say

The PaymentIntent has already been confirmed and marked as 'succeeded', but the capture log fails with a 400 status: 'PaymentIntent already captured'.
, you've said that multiple times

wicked crescent
#

Do you want to see the payment flow of the old app in Kotlin?

buoyant owl
#

that is 100% expected to get that error

#

don't call .capture if the status is succeeded; it only makes sense to call it if the status is requires_capture , and that can be trivially checked via something like the snippet I posted above. If the status is succeeded, then the payment is already captured and you can skip to the next part of the logic.

#

that's it really! can I clarify that in any way?

wicked crescent
#

I don't know if I understand, I'll only call capturePayment if confirmedPaymentIntent.status === 'requiresCapture'

#

right?

buoyant owl
#

right

wicked crescent
#

one second, I'll try

#

another question, do I need to pass capturePayment to go to the database

#

right?

buoyant owl
#

I don't know what that question means, sorry.

wicked crescent
#

because in the android app flow it passes when successful

buoyant owl
#

sorry I still don't understand what specifically you're asking me about Stripe/its API/SDK, you just pasted a bunch of code from your own app.

wicked crescent
#

ok, I'll explain once again, I have an Android application working perfectly for payment...

I'm moving this android application to react native...

buoyant owl
#

yep I understand all that

buoyant owl
wicked crescent
#

one second

#

in the android app it uses capturePayment to capture the payment

#

and capturePaymentLog to capture the error

#

and in my react native application I do the same thing and get an error

#

That's what I don't understand

buoyant owl
#

and we've explained why โ€” the PaymentIntent is already captured when you call it

#

you can check that and look at the code where you create the PaymentIntent.

wicked crescent
#

So why does it generate logs in stripe, but not in my database?

buoyant owl
#

I'm not sure what that means sorry

wicked crescent
#

I don't know how I can explain more

#

the logs in stripe are generated... but in my database they are not

buoyant owl
#

show me an example of what a "log in stripe" is.

#

I can't tell you why something does or does not exist in your database, that is your code and your logic you developed

#

I'm more than happy to help you troubleshoot the part of your code that might have some bugs with handling the results from the Stripe API and that's what I've tried to clearly explain above(checking the status before calling the capture API; explaining how capture_method is involved and how you control that in the API call you make to create the PaymentIntent)

wicked crescent
#

I'll show you the log, one second

buoyant owl
#

that's a webhook event yep, those happen whenever you call the API or something happens on your account.

#

you can also see on line 17 that capture_method is automatic

#

do you understand?

wicked crescent
#

So do I have to go through the manual?

buoyant owl
#

I'm not sure what you mean by "go through"

#

like

wicked crescent
#

captureMethod: 'manual',

buoyant owl
#
  • you can change your code that creates the PaymentIntent in the new codebase so you explicitly pass capture_method:'manual' so that you have the behaviour of the old codebase
  • you can adjust the logic for your capture function to check the status before trying the capture API call(what I explained earlier) so that it works regardless of what capture_method the PI is using

either works

wicked crescent
#

one seocnd

#

By passing captureMethod: 'manual' I was able to call the capturePayment function

buoyant owl
#

yeah like I said, that's one of the approaches that would work

wicked crescent
#

I'm just going to check if the logs arrived

#

one second

#

It's workinggggggg

#

omg

#

thank yo

#

Thank you very much, everything worked fine here

buoyant owl
#

great!