Search in sources :

Example 6 with ClientToken

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

the class Venmo method onActivityResult.

static void onActivityResult(final BraintreeFragment fragment, int resultCode, Intent data) {
    if (resultCode == Activity.RESULT_OK) {
        fragment.sendAnalyticsEvent("pay-with-venmo.app-switch.success");
        String nonce = data.getStringExtra(EXTRA_PAYMENT_METHOD_NONCE);
        if (shouldVault(fragment.getApplicationContext()) && fragment.getAuthorization() instanceof ClientToken) {
            vault(fragment, nonce);
        } else {
            String venmoUsername = data.getStringExtra(EXTRA_USERNAME);
            VenmoAccountNonce venmoAccountNonce = new VenmoAccountNonce(nonce, venmoUsername, venmoUsername);
            fragment.postCallback(venmoAccountNonce);
        }
    } else if (resultCode == Activity.RESULT_CANCELED) {
        fragment.sendAnalyticsEvent("pay-with-venmo.app-switch.canceled");
    }
}
Also used : VenmoAccountNonce(com.braintreepayments.api.models.VenmoAccountNonce) ClientToken(com.braintreepayments.api.models.ClientToken)

Aggregations

ClientToken (com.braintreepayments.api.models.ClientToken)6 JSONObject (org.json.JSONObject)2 Test (org.junit.Test)2 Uri (android.net.Uri)1 InvalidArgumentException (com.braintreepayments.api.exceptions.InvalidArgumentException)1 UnexpectedException (com.braintreepayments.api.exceptions.UnexpectedException)1 ConfigurationListener (com.braintreepayments.api.interfaces.ConfigurationListener)1 Configuration (com.braintreepayments.api.models.Configuration)1 PostalAddress (com.braintreepayments.api.models.PostalAddress)1 VenmoAccountNonce (com.braintreepayments.api.models.VenmoAccountNonce)1 SharedPreferencesHelper.writeMockConfiguration (com.braintreepayments.testutils.SharedPreferencesHelper.writeMockConfiguration)1 CheckoutRequest (com.paypal.android.sdk.onetouch.core.CheckoutRequest)1 HttpURLConnection (java.net.HttpURLConnection)1 JSONArray (org.json.JSONArray)1