use of com.braintreepayments.api.models.VenmoAccountNonce in project braintree_android by braintree.
the class VenmoUnitTest method onActivityResult_withSuccessfulVaultCall_returnsVenmoAccountNonce.
@Test
public void onActivityResult_withSuccessfulVaultCall_returnsVenmoAccountNonce() throws InvalidArgumentException {
Configuration configuration = getConfigurationFromFixture();
Authorization clientToken = Authorization.fromString(stringFromFixture("base_64_client_token.txt"));
disableSignatureVerification();
BraintreeFragment fragment = new MockFragmentBuilder().context(VenmoInstalledContextFactory.venmoInstalledContext(true, RuntimeEnvironment.application)).configuration(configuration).authorization(clientToken).sessionId("session-id").successResponse(stringFromFixture("payment_methods/venmo_account_response.json")).build();
Venmo.authorizeAccount(fragment, true);
ArgumentCaptor<PaymentMethodNonce> responseCaptor = ArgumentCaptor.forClass(PaymentMethodNonce.class);
Intent responseIntent = new Intent().putExtra(Venmo.EXTRA_PAYMENT_METHOD_NONCE, "nonce");
Venmo.onActivityResult(fragment, Activity.RESULT_OK, responseIntent);
verify(fragment).postCallback(responseCaptor.capture());
PaymentMethodNonce capturedNonce = responseCaptor.getValue();
assertTrue(capturedNonce instanceof VenmoAccountNonce);
VenmoAccountNonce venmoAccountNonce = (VenmoAccountNonce) capturedNonce;
assertEquals("Venmo", venmoAccountNonce.getTypeLabel());
assertEquals("fake-venmo-nonce", venmoAccountNonce.getNonce());
assertEquals("venmojoe", venmoAccountNonce.getUsername());
}
use of com.braintreepayments.api.models.VenmoAccountNonce in project braintree_android by braintree.
the class VenmoUnitTest method onActivityResult_postsPaymentMethodNonceOnSuccess.
@Test
public void onActivityResult_postsPaymentMethodNonceOnSuccess() {
BraintreeFragment fragment = new MockFragmentBuilder().build();
Intent intent = new Intent().putExtra(Venmo.EXTRA_PAYMENT_METHOD_NONCE, "123456-12345-12345-a-adfa").putExtra(Venmo.EXTRA_USERNAME, "username");
Venmo.onActivityResult(fragment, Activity.RESULT_OK, intent);
ArgumentCaptor<VenmoAccountNonce> captor = ArgumentCaptor.forClass(VenmoAccountNonce.class);
verify(fragment).postCallback(captor.capture());
assertEquals("123456-12345-12345-a-adfa", captor.getValue().getNonce());
assertEquals("username", captor.getValue().getDescription());
assertEquals("username", captor.getValue().getUsername());
}
use of com.braintreepayments.api.models.VenmoAccountNonce 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");
}
}
Aggregations