#iavn_chh-Elements
1 messages · Page 1 of 1 (latest)
I am implementing the Stripe checkout with Elements, and when the user wants to pay for a product, they are not being redirected to the checkout process. Here I have my code, I do not know if I am missing something ... Or I am not understanding how to implement it.
var stripe = Stripe('pk_test_XXXX', {
betas: ['payment_element_beta_2']
});
var options = {
clientSecret: @ClientSecret,
};
var elements = stripe.elements(options);
var paymentElement = elements.create("payment");
Promise.resolve(
stripe.confirmPayment({
elements,
confirmParams: {
// Return URL where the customer should be redirected after the PaymentIntent is confirmed.
return_url: 'https://example.com',
},
})
).then(function (result) {
console.log(result);
}).catch(function (error) {
console.log(error)
}
);
Also, testing the code, what happens is that an exception is thrown, but the error object is empty.
Hello, could someone help me?
Hi, sorry for the late response. Let me TAL
Hi, sorry the Doc might be misleading. Could you try to pass in paymentElement instead of elements, on the call to stripe.confirmPayment?
Yes, I have tried that, the confirmPayment call does not allow the paymentElement object since it does not have the options object inside.
bad timing, I still need to watch our internal training on this new Element(it's not public yet)
what's the exact error you're getting though?
like to be clear, this is i a redirect(it's a payment form embedded in your own site) — redirects are Checkout (https://stripe.com/docs/payments/accept-a-payment?platform=web&ui=checkout) and not the Payment Element, so I'm a bit confused by what "they are not being redirected to the checkout process" means. The code looks correct as-is at least.
Ok, I was getting confused, so I have to paint the Iframe on my website and there is no redirection, would you have a guide how to implement this? Because the one that exists ( https://stripe.com/docs/payments/payment-element ) is quite poor
if you're in that beta then that page has the full details of using the Payment Element
presumably you're missing https://stripe.com/docs/payments/accept-a-payment?platform=web&ui=elements#add-the-payment-element-to-your-payment-page , the part for creating an empty div and then calling paymentElement.mount("#payment-element"); to add it to that div