2017-07-25 2 views
0

Ich versuche die Stripe API & Funktionen, aber ich verdrehte meinen Kopf um dieses eine Problem - wie ein Formular nach der (Test-) Zahlung erfolgreich ist einreichen?Streifen benutzerdefinierte Kasse - Formular senden

Hier ist meine aktuellen Code:

<script> 
    var handler = StripeCheckout.configure({ 
     key: 'pk_test_mykey', 
     image: 'https://stripe.com/img/documentation/checkout/marketplace.png', 
     locale: 'sv', 
     token: function(token) { 
      // You can access the token ID with `token.id`. 
      // Get the token ID to your server-side code for use. 
     } 
    }); 


    document.getElementById('customButton').addEventListener('click', function(e) { 
     stripe_spots = document.getElementById("spots").value; 
     stripe_total = (stripe_spots) * 70; 
     // Open Checkout with further options: 
     handler.open({ 
      name: 'Revy!', 
      description: stripe_spots + " platser", 
      zipCode: true, 
      currency: 'sek', 
      amount: stripe_total * 100 
     }); 

     e.preventDefault(); 
    }); 

    // Close Checkout on page navigation: 
    window.addEventListener('popstate', function() { 
     handler.close(); 
    }); 
</script> 

Wo oder wann soll ich das Formular abzuschicken?

Danke!

Antwort

0

Sie senden Sie das Formular mit der Token-Callback-Funktion aktualisieren Sie Ihren Griff senden

var handler = StripeCheckout.configure({ 
key: 'pk_test_mykey', 
image: 'https://stripe.com/img/documentation/checkout/marketplace.png', 
locale: 'sv', 
token: function (token) { 
    $.ajax({ 
     type: 'POST', 
     url: '/checkout.php', 
     data: {stripeToken: token.id, stripeEmail: token.email}, 
     success: function (data) { 
      //handle success response here 
     }, 
     error: function(data){ 
      //handle error response here 
     } 
    }); 
    } 
});