-
-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Example of using the stripe-elements component with Stripe's PaymentIntent #57
Comments
like this one? https://bennypowers.dev/stripe-elements/?path=/docs/elements-stripe-payment-request--payment-request-with-payment-intent (may need to refresh due to storybook bug) |
Thanks @bennypowers ... That example shows using PaymentIntent with the Payment Request button, but I'm looking for an example using the fallback component. Here is what I did to get it working. Does this look right? // Load Stripe
this.stripe = await loadStripe(this.config.get('STRIPE_PUBLISHABLE_KEY'))
...
html`
<stripe-elements
?hidden="${!this.unsupported}"
generate="payment-method"
id="card-element"
publishable-key="${this.unsupported ? this.config.get('STRIPE_PUBLISHABLE_KEY') : undefined}"
@change="${this.onChange}"
@error="${this.onError}"
@payment-method="${this.onPaymentMethod}"
></stripe-elements>
`
onPaymentMethod = (e) => {
this.stripe.confirmCardPayment(this.paymentIntentsStore.clientSecret, {
payment_method: e.detail.id
}).then(result => {
if (result.error) {
this.cardErrors.textContent = result.error.message
} else {
// The payment has been processed!
if (result.paymentIntent.status === 'succeeded') {
this.onSuccess()
}
}
})
} |
yeah that looks about right at a glance, without getting in to the weeds of how you're managing the |
How's the weather in BC? |
It's raining, of course ;-) |
Hello again @bennypowers ... one more question for you. With the
I'm following the example you have for using this with a Stripe PaymentIntents. The thing I'm not clear on is what does passing the Thanks! |
you can do a bunch of stuff with that https://stripe.com/docs/api/setup_intents/object#setup_intent_object-client_secret One thing we do is expose confirmCardPayment for you stripe-elements/src/stripe-payment-request.ts Lines 458 to 463 in 208c159
|
Nice. Yes I removed So question... why not add a similar |
Good question, I'm not entirely sure why we don't do that 😂 If you can get it to work, PRs are welcome |
Thanks for this web component!
One request: It would be great to have an example of using the "stripe-elements" component with Stripe's PaymentIntent workflow. My team is struggling a little bit to figure out how to get it working.
Cheers.
The text was updated successfully, but these errors were encountered: