Stripe "Simple" Checkout - Detects that the close button is pressed

I have included Stripe Checkout on my website and everything works fine except for one aspect. I use the "Simple" checkout mode where Stripe displays my checkout button for me. But in the documents, I see no way to determine if the user clicks the close button (actually cancels the transaction - see Image).

enter image description here

Is there a way to detect this in "Simple" mode (unlike Custom)?

+8
javascript stripe-payments
source share
3 answers

(I am working on setting up Stripe Checkout)

"private" callback is available only in user integration .

+9
source share

Well, you can't have a callback, but what about if you create your own callback when stripe removes the iframe from your DOM.

$(document).on("DOMNodeRemoved",".stripe_checkout_app", close); function close(){ alert("close stripe"); } 

so while it’s true that his β€œclosed” skill is not available, this little hack can help you.

// this jQuery example.

--- EDIT ---

Since @artfulhacker commented on another way to do this, you need to use the setInterval timer and check if the .stripe_checkout_app class .stripe_checkout_app visible or not, it could be something like:

 setInterval(function(){ if(!$('.stripe_checkout_app').is(":visible")){ alert("Stripe modal is hidden"); } },1000) 
+16
source share

The easiest way I've found is to simply set the send variable that has been tested.

  var submittedForm = false; var handler = StripeCheckout.configure({ key: '{{ stripe.public_key }}', allowRememberMe: false, token: function(response, extradata) { var token = response.id; var card = response.card.id; submittedForm = true; $('#submit-text').html('Processing, stand by'); //etc functionality to submit back to your own form } }); //when actually triggering checkout.js handler.open({ name: 'myCompanyName', amount: 1999, closed: function () { if(submittedForm == false) $('#submit-text').html('Start your Trial'); } } }); 

This example changes the text for the submit button when checkout.js is called. If it is actually processed, then we get the token back, set to true. Closed tests. If this is not true, then they pressed X without sending, so we will return the text of the sending. If true, ignore it so that the "Processing" remains until our own ajax mail or something ends.

+7
source share

All Articles