Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // CUSTOMER CLICKS PAY NOW //
- // FORM IS VALIDATED IN CLIENT SIDE ///
- //THEN ///
- // STEP 1 ///
- var datastring = $("#payInvoiceAmountForm").serialize();
- stripe
- .handleCardPayment(client_secret, card)
- .then(function(result) {
- if (result.error && result.error.payment_intent.status!='succeeded') {
- // show error message // STEP 2 ///
- // then enable button
- reportError(result.error.message);
- //send this response to server for resons
- $.ajax({
- type: "POST",
- url: baseUrl + "/booking/confirmbooking/saveintentresponse",
- data:
- datastring + "&intent_response=" + JSON.stringify(result),
- dataType: "json",
- success: function(data) {},
- error: function(data) {
- // reportError(data.responseText);
- }
- });
- } else {
- // Submit formdata to server // STEP 3 ///
- $.ajax({
- type: "POST",
- url: baseUrl + "/invoice/default/payinvoiceamount",
- data:
- datastring + "&intent_response=" + JSON.stringify(result),
- dataType: "json",
- success: function(data) {
- // // STEP 4 /// EVERY THING IS FINE
- if (data.status) {
- window.location.href = window.location.pathname;
- } else {
- reportError(data.message);
- // ANY SERVER RESPONSE // STEP 5 //
- }
- },
- error: function(data) {
- reportError(data.responseText);
- // AJAX ERROR // STEP 7 //
- }
- });
- }
- });
- // STEP 9 ///
- // Customer fixes the form and re-submits the form ...
- // then Step 1 continues
- // Then from Step 2 I get this error ... You cannot provide a new payment method to a PaymentIntent when it has a status of requires_capture. You should either capture the remaining funds, or cancel this PaymentIntent and try again with a new PaymentIntent.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement