Search in sources :

Example 16 with PayPalAccountNonce

use of com.braintreepayments.api.models.PayPalAccountNonce in project braintree_android by braintree.

the class PayPal method onSuccess.

private static void onSuccess(final BraintreeFragment fragment, Intent data, Request request, Result result) {
    PayPalRequest paypalRequest = getPersistedPayPalRequest(fragment.getApplicationContext());
    TokenizationClient.tokenize(fragment, parseResponse(paypalRequest, request, result, data), new PaymentMethodNonceCallback() {

        @Override
        public void success(PaymentMethodNonce paymentMethodNonce) {
            if (paymentMethodNonce instanceof PayPalAccountNonce && ((PayPalAccountNonce) paymentMethodNonce).getCreditFinancing() != null) {
                fragment.sendAnalyticsEvent("paypal.credit.accepted");
            }
            fragment.postCallback(paymentMethodNonce);
        }

        @Override
        public void failure(Exception exception) {
            fragment.postCallback(exception);
        }
    });
}
Also used : PaymentMethodNonceCallback(com.braintreepayments.api.interfaces.PaymentMethodNonceCallback) PayPalAccountNonce(com.braintreepayments.api.models.PayPalAccountNonce) PaymentMethodNonce(com.braintreepayments.api.models.PaymentMethodNonce) PayPalRequest(com.braintreepayments.api.models.PayPalRequest) BraintreeException(com.braintreepayments.api.exceptions.BraintreeException) JSONException(org.json.JSONException) BrowserSwitchException(com.braintreepayments.api.exceptions.BrowserSwitchException)

Aggregations

PayPalAccountNonce (com.braintreepayments.api.models.PayPalAccountNonce)16 Test (org.junit.Test)15 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)15 PaymentMethodNonceCallback (com.braintreepayments.api.interfaces.PaymentMethodNonceCallback)14 Intent (android.content.Intent)13 PaymentMethodBuilder (com.braintreepayments.api.models.PaymentMethodBuilder)13 InvocationOnMock (org.mockito.invocation.InvocationOnMock)13 Answer (org.mockito.stubbing.Answer)13 PowerMockito.doAnswer (org.powermock.api.mockito.PowerMockito.doAnswer)13 PayPalRequest (com.braintreepayments.api.models.PayPalRequest)11 JSONObject (org.json.JSONObject)10 AuthorizationRequest (com.paypal.android.sdk.onetouch.core.AuthorizationRequest)6 PaymentMethodNonce (com.braintreepayments.api.models.PaymentMethodNonce)5 PayPalApprovalCallback (com.braintreepayments.api.interfaces.PayPalApprovalCallback)3 PayPalApprovalHandler (com.braintreepayments.api.interfaces.PayPalApprovalHandler)3 Request (com.paypal.android.sdk.onetouch.core.Request)3 SharedPreferences (android.content.SharedPreferences)2 BraintreeSharedPreferences (com.braintreepayments.api.internal.BraintreeSharedPreferences)2 AndroidPayCardNonce (com.braintreepayments.api.models.AndroidPayCardNonce)2 CardNonce (com.braintreepayments.api.models.CardNonce)2