#mahraamir
1 messages · Page 1 of 1 (latest)
Element is showing but when I click on the button
it redirects me to my previous page
what it should supposed to do when I click on Submit button?
What's the code behind the Submit button?
I am using stripe code
Let me briefly tell you what I have so for acheived.
I have created payment intent and passed to
const elements = stripe.elements(options);
and here is my html
<form id="payment-form">
<div id="capp_payment-element">
<!-- Elements will create form elements here -->
</div>
<button id="submit"> Submit</button>
<div id="error-message">
<!-- Display error message to your customers here -->
</div>
</form>
Stripe is inserting it's iframe in it successfully
as I sent an image above
but when I click Submit button nothing happens
Nothing happens or you get redirected to the previous page?
What about JavaScript?
Yes, I am redirected to my previous page
const paymentElement = elements.create('payment');
paymentElement.mount('#capp_payment-element');
window.onload= async function(){
const form = document.getElementById('payment-form');
form.addEventListener('submit', async (event) => {
event.preventDefault();
const {error} = await stripe.confirmPayment({
//Elements instance that was used to create the Payment Element
elements,
confirmParams: {
return_url: capp_return_url,
},
});
if (error) {
// This point will only be reached if there is an immediate error when
// confirming the payment. Show error to your customer (for example, payment
// details incomplete)
const messageContainer = document.querySelector('#error-message');
messageContainer.textContent = error.message;
} else {
// Your customer will be redirected to your return_url. For some payment
// methods like iDEAL, your customer will be redirected to an intermediate
// site first to authorize the payment, then redirected to the return_url.
}
});
it should call confirmPayment
this is js file
Is you code reaching the const {error} = await stripe.confirmPayment({?
one sec
I can see QR code now
how can I redirect to my callback as I am in test mode and don't have cash app pay real account?
What did you change?
You need to scan the QR code and it will allow you to Approve/Decline the payment
Just with the camera, no need for Cash App
nothing changed but might be js wasn't loaded earlier
ok let me scan
ok got it I was redirected
Thank you
Happy to help!