use of com.braintreepayments.api.interfaces.TokenizationParametersListener in project braintree_android by braintree.
the class AndroidPayTest method getTokenizationParameters_returnsCorrectParametersInCallback.
@Test(timeout = 5000)
public void getTokenizationParameters_returnsCorrectParametersInCallback() throws Exception {
String config = mBaseConfiguration.androidPay(mBaseConfiguration.androidPay().supportedNetworks(new String[] { "visa", "mastercard", "amex", "discover" })).build();
final Configuration configuration = Configuration.fromJson(config);
BraintreeFragment fragment = getFragment(mActivityTestRule.getActivity(), TOKENIZATION_KEY, config);
AndroidPay.getTokenizationParameters(fragment, new TokenizationParametersListener() {
@Override
public void onResult(PaymentMethodTokenizationParameters parameters, Collection<Integer> allowedCardNetworks) {
assertEquals("braintree", parameters.getParameters().getString("gateway"));
assertEquals(configuration.getMerchantId(), parameters.getParameters().getString("braintree:merchantId"));
assertEquals(configuration.getAndroidPay().getGoogleAuthorizationFingerprint(), parameters.getParameters().getString("braintree:authorizationFingerprint"));
assertEquals("v1", parameters.getParameters().getString("braintree:apiVersion"));
assertEquals(BuildConfig.VERSION_NAME, parameters.getParameters().getString("braintree:sdkVersion"));
try {
JSONObject metadata = new JSONObject(parameters.getParameters().getString("braintree:metadata"));
assertNotNull(metadata);
assertEquals(BuildConfig.VERSION_NAME, metadata.getString("version"));
assertNotNull(metadata.getString("sessionId"));
assertEquals("custom", metadata.getString("integration"));
assertEquals("android", metadata.get("platform"));
} catch (JSONException e) {
fail("Failed to unpack json from tokenization parameters: " + e.getMessage());
}
assertEquals(4, allowedCardNetworks.size());
assertTrue(allowedCardNetworks.contains(CardNetwork.VISA));
assertTrue(allowedCardNetworks.contains(CardNetwork.MASTERCARD));
assertTrue(allowedCardNetworks.contains(CardNetwork.AMEX));
assertTrue(allowedCardNetworks.contains(CardNetwork.DISCOVER));
mLatch.countDown();
}
});
mLatch.await();
}
use of com.braintreepayments.api.interfaces.TokenizationParametersListener in project braintree_android by braintree.
the class GooglePaymentTest method getTokenizationParameters_returnsCorrectParametersInCallback.
@Test(timeout = 5000)
public void getTokenizationParameters_returnsCorrectParametersInCallback() throws Exception {
String config = mBaseConfiguration.androidPay(mBaseConfiguration.androidPay().supportedNetworks(new String[] { "visa", "mastercard", "amex", "discover" })).build();
final Configuration configuration = Configuration.fromJson(config);
BraintreeFragment fragment = getFragment(mActivityTestRule.getActivity(), TOKENIZATION_KEY, config);
GooglePayment.getTokenizationParameters(fragment, new TokenizationParametersListener() {
@Override
public void onResult(PaymentMethodTokenizationParameters parameters, Collection<Integer> allowedCardNetworks) {
assertEquals("braintree", parameters.getParameters().getString("gateway"));
assertEquals(configuration.getMerchantId(), parameters.getParameters().getString("braintree:merchantId"));
assertEquals(configuration.getAndroidPay().getGoogleAuthorizationFingerprint(), parameters.getParameters().getString("braintree:authorizationFingerprint"));
assertEquals("v1", parameters.getParameters().getString("braintree:apiVersion"));
assertEquals(BuildConfig.VERSION_NAME, parameters.getParameters().getString("braintree:sdkVersion"));
try {
JSONObject metadata = new JSONObject(parameters.getParameters().getString("braintree:metadata"));
assertNotNull(metadata);
assertEquals(BuildConfig.VERSION_NAME, metadata.getString("version"));
assertNotNull(metadata.getString("sessionId"));
assertEquals("custom", metadata.getString("integration"));
assertEquals("android", metadata.get("platform"));
} catch (JSONException e) {
fail("Failed to unpack json from tokenization parameters: " + e.getMessage());
}
assertEquals(4, allowedCardNetworks.size());
assertTrue(allowedCardNetworks.contains(CardNetwork.VISA));
assertTrue(allowedCardNetworks.contains(CardNetwork.MASTERCARD));
assertTrue(allowedCardNetworks.contains(CardNetwork.AMEX));
assertTrue(allowedCardNetworks.contains(CardNetwork.DISCOVER));
mLatch.countDown();
}
});
mLatch.await();
}
Aggregations