#deepstitch - Setup Intent

1 messages ยท Page 1 of 1 (latest)

strong jolt
#

Hi ๐Ÿ‘‹

rare pike
#

Hi!

strong jolt
rare pike
#

This is what I tried

#

that documentation states that the "elements" object must be passed in JSON, but the format doesn't seem correct

strong jolt
#

Can you share a code snippet?

rare pike
#

this isn't valid JSON

#

sending my implementation and the error

strong jolt
#

That is a functioning JS function signature. I've used it many many times

rare pike
#

here's how I've tried

strong jolt
#

I mean, I use async, await but otherwise it's the same

rare pike
#

Here's the card element being mounted

#

the SetupIntent comes from our server

#

this works fine

#

Here's where we attempt to confirm the setupIntent

#

The first block of code is fired when the user clicks "Change" to modify the payment method. The second block is triggered after clicking "Save" on the card info

strong jolt
#

That all makes sense.

#

Except the .confirmSetup syntax

rare pike
#

how should that be - using ES3/5?

strong jolt
#

Your call to confirmSetup fails, yes?

rare pike
#

it does

strong jolt
#

Okay. So your syntax is incorrect, as I said.

rare pike
#

how should I structure that? it's not clear as the syntax in the documentation is written for ES6

strong jolt
#

Looking into this

rare pike
#

thanks

strong jolt
#

Can you try not using the key and just passing the Element object?

rare pike
#

i tried that, but webpack won't compile with gulp

strong jolt
fair jackal
#

๐Ÿ‘‹ @rare pike stepping in here.

#

I think the issue actually is that you are attempting to pass your payment element to confirmSetup instead of your elements instance

#

Can you break out your elements instance creation and your payment element creation into two separate calls?

rare pike
#

ah

#

I'll try that

#

So, send this element:
corpstripe.elements({clientSecret : resp.token})

fair jackal
#

Yep

rare pike
#

Here's what I have now (please excuse the Angular-JS usage - this is an old application that works well and we've not migrated it to Angular 13)

fair jackal
#

Sure looks fine. Now pass $scope.billing_elements to confirmSetup

rare pike
fair jackal
#

Can you provide the full code snippet

#

You are seeing Payment Element mount, yes?

rare pike
#

yes, and here's a little more from the debugger - element object info on the right

fair jackal
#

It should be elements not element

rare pike
#

ah...

#

Great - Thank you both for the guidance. This did it.

fair jackal
#

๐ŸŽ‰

rare pike
#

And, may I say, again this Discord is the best I've ever been a part of.

fair jackal
#

If you don't mind taking a moment, can you try removing elements and just passing the $scope.billing_elements object?

#

I'm curious if that errors or not

#

So instead of confirmSetup({elements: $scope.billing_elements}) just do confirmSeetup({$scope.billing_elements})

rare pike
#

you mean like this:
confirmSetup($scope.billing_elements)

fair jackal
#

Hmm actually you might be right

#

You might not include {} in this case

rare pike
#

same error as before, method doesn't read the object when called. "expected either elements or ..."

fair jackal
#

Was that with {} or without or both?

rare pike
#

that's without the {}, if I exclude the braces, syntax errors occur

#

ES5

fair jackal
#

right makes sense

#

Thanks for testing!

rare pike
#

you're welcome. thanks for the help. have a great day.