Advertisement
Guest User

Untitled

a guest
Jan 17th, 2020
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const dropinConfig = {
  2.   authorization: braintreeData.token,
  3.   selector: "#dropin-container",
  4.   threeDSecure: true
  5. };
  6.  
  7. dropin.create(dropinConfig, (err, dropinInstance) => {
  8.   if (err) {
  9.     // Handle error
  10.   }
  11.  
  12.   submit.addEventListener("click", event => {
  13.     event.preventDefault();
  14.     const amount = this.getAmount();
  15.  
  16.     const threeDSecure = {
  17.       amount,
  18.       email: user.email
  19.     };
  20.  
  21.     // This prints out just before the modal appears
  22.     console.log(
  23.       "going to request payment method",
  24.       threeDSecureRequestObject
  25.     );
  26.  
  27.     dropinInstance.requestPaymentMethod(
  28.       {
  29.         threeDSecure: threeDSecureRequestObject
  30.       },
  31.       (err, payload) => {
  32.         if (err) {
  33.           this.setPaymentError("Failed to connect to payment gateway");
  34.  
  35.           // Reinitialize the form
  36.           dropinInstance.teardown(() => {
  37.             this.initializeBraintreeForm(this.props.braintreeData);
  38.           });
  39.  
  40.           return;
  41.         }
  42.  
  43.         // This prints out just after the modal appears
  44.         console.log("done requesting, calling api...");
  45.  
  46.         // ... code that calls the API with the payment method nonce
  47.       });
  48.   }
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement