SHARE
TWEET

Untitled

a guest Sep 17th, 2019 156 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // CUSTOMER CLICKS PAY NOW //
  2. // FORM IS VALIDATED IN CLIENT SIDE ///
  3. //THEN ///
  4. // STEP 1 ///
  5. var datastring = $("#payInvoiceAmountForm").serialize();
  6. stripe
  7.             .handleCardPayment(client_secret, card)
  8.             .then(function(result) {
  9.               if (result.error && result.error.payment_intent.status!='succeeded') {
  10.                 // show error message // STEP 2 ///
  11.  
  12.                 // then enable button
  13.                 reportError(result.error.message);
  14.                 //send this response to server for resons
  15.                 $.ajax({
  16.                   type: "POST",
  17.                   url: baseUrl + "/booking/confirmbooking/saveintentresponse",
  18.                   data:
  19.                     datastring + "&intent_response=" + JSON.stringify(result),
  20.                   dataType: "json",
  21.                   success: function(data) {},
  22.                   error: function(data) {
  23.                     // reportError(data.responseText);
  24.                   }
  25.                 });
  26.               } else {
  27.                 // Submit formdata to server // STEP 3 ///
  28.                 $.ajax({
  29.                   type: "POST",
  30.                   url: baseUrl + "/invoice/default/payinvoiceamount",
  31.                   data:
  32.                     datastring + "&intent_response=" + JSON.stringify(result),
  33.                   dataType: "json",
  34.                   success: function(data) {
  35.                     // // STEP 4 ///  EVERY THING IS FINE
  36.                     if (data.status) {
  37.                       window.location.href = window.location.pathname;
  38.                     } else {
  39.                       reportError(data.message);
  40.                       // ANY SERVER RESPONSE // STEP 5 //
  41.                     }
  42.                   },
  43.                   error: function(data) {
  44.                     reportError(data.responseText);
  45.                     // AJAX ERROR // STEP 7 //
  46.                   }
  47.                 });
  48.               }
  49.             });
  50. // STEP 9 ///
  51. // Customer fixes the form and re-submits the form ...
  52. // then Step 1 continues
  53. // 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.
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top