use of com.google.android.gms.wallet.PaymentMethodTokenizationParameters 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.google.android.gms.wallet.PaymentMethodTokenizationParameters 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();
}
use of com.google.android.gms.wallet.PaymentMethodTokenizationParameters in project connect-sdk-client-android by Ingenico-ePayments.
the class WalletUtil method generateMaskedWalletRequest.
public static MaskedWalletRequest generateMaskedWalletRequest(PaymentContext paymentContext, ShoppingCart shoppingCart, String publicKey, Collection<Integer> networks) {
PaymentMethodTokenizationParameters parameters = PaymentMethodTokenizationParameters.newBuilder().setPaymentMethodTokenizationType(PaymentMethodTokenizationType.NETWORK_TOKEN).addParameter(Constants.PAYMENT_METHOD_TOKENIZATION_PARAMETER_PUBLIC_KEY, publicKey).build();
MaskedWalletRequest maskedWalletRequest = MaskedWalletRequest.newBuilder().setMerchantName(Constants.APPLICATION_IDENTIFIER).setShippingAddressRequired(true).setCurrencyCode(paymentContext.getAmountOfMoney().getCurrencyCode().toString()).setCart(generateCart(paymentContext, shoppingCart)).setEstimatedTotalPrice(paymentContext.getAmountOfMoney().getAmount().toString()).addAllowedCardNetworks(networks).setPaymentMethodTokenizationParameters(parameters).build();
return maskedWalletRequest;
}
Aggregations