Taracque / cordova-plugin-braintree

:credit_card: A Cordova plugin for the Braintree mobile payment processing SDK.
MIT License
27 stars 42 forks source link

Ionic 3: presentDropInPaymentUI(paymentOptions) promise never resolved #54

Open giacomodeliberali opened 6 years ago

giacomodeliberali commented 6 years ago

I'm trying to integrate Braintree in an Ionic 3 iOS/Android application, but once i call presentDropInPaymentUI(paymentOptions) the promise is never resolved or rejected so I'm unable to get the nonce to send to my server. Any suggestion?

    try {
      this.httpClient.get(`${Defaults.servicesBaseUrl}/braintree/client_token`).subscribe(async (response: any) => {

        if (!response || response.hasError)
          throw new Error((response || {}).data);

        await this.braintree.initialize(response.data);

        this.braintree.presentDropInPaymentUI(paymentOptions)
          .then((result: PaymentUIResult) => {

            // Resolve #1. Get nonce and send back to my server, but the promise is never resolving or rejecting

            if (result.userCancelled) {
              console.log("User cancelled payment dialog.");
            } else {
              console.log("User successfully completed payment!");
              console.log("Payment Nonce: " + result.nonce);
              console.log("Payment Result.", result);
            }
          })
          .catch(ex => {
            // Exception #1
          });
      });
    } catch (ex) {
      // Exception #2
    }
schermata 2018-04-09 alle 14 05 54 schermata 2018-04-09 alle 14 06 03 schermata 2018-04-09 alle 14 06 20

Once filled the credit card form and clicking "Add card" the modal is simply closed and the promise is not resolved and not rejected. Am i missing something?

giacomodeliberali commented 6 years ago

Edit:

In sandbox environment, using a real credit card the result is described above, while using a test credit card number the flow is working fine.