#mahraamir

1 messages · Page 1 of 1 (latest)

crisp nacelleBOT
hidden patrol
#

Hi! Let me help you with this.

#

What's the issue?

azure granite
#

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?

hidden patrol
#

What's the code behind the Submit button?

azure granite
#

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

hidden patrol
hidden patrol
azure granite
#

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

hidden patrol
#

Is you code reaching the const {error} = await stripe.confirmPayment({?

azure granite
#

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?

hidden patrol
#

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

azure granite
#

nothing changed but might be js wasn't loaded earlier

#

ok let me scan

#

ok got it I was redirected

#

Thank you

hidden patrol
#

Happy to help!