use of com.google.android.gms.wallet.MaskedWalletRequest in project android-oss by kickstarter.
the class CheckoutActivity method showAndroidPaySheet.
/**
* Call when the android pay sheet should be shown.
*/
private void showAndroidPaySheet(@NonNull final AndroidPayPayload payload) {
if (walletFragment == null) {
return;
}
isInAndroidPayFlow = true;
final MaskedWalletRequest request = AndroidPayUtils.createMaskedWalletRequest(payload);
walletFragment.initialize(WalletFragmentInitParams.newBuilder().setMaskedWalletRequest(request).setMaskedWalletRequestCode(ActivityRequestCodes.CHECKOUT_ACTIVITY_WALLET_REQUEST).build());
AndroidPayUtils.triggerAndroidPaySheet(walletFragment);
}
use of com.google.android.gms.wallet.MaskedWalletRequest in project connect-sdk-client-android by Ingenico-ePayments.
the class AndroidPay method onPaymentProductNetworksCallComplete.
@Override
public void onPaymentProductNetworksCallComplete(PaymentProductNetworksResponse response) {
if (response != null && response.getNetworks() != null && !response.getNetworks().isEmpty()) {
// Connect to the Google API in order to be able to make Android Pay calls
GoogleApiClient googleApiClient = WalletUtil.generateGoogleApiClient(activity, session);
googleApiClient.connect();
// Create a MaskedWalletRequest, that will retrieve the masked wallet from Google
MaskedWalletRequest maskedWalletRequest = WalletUtil.generateMaskedWalletRequest(paymentContext, shoppingCart, publicKeyResponse.getPublicKey(), response.getNetworks());
// Hide the progressDialog before showing Android Pay
selectionView.hideLoadingIndicator();
// Load the masked wallet to start the transaction for the user, after the user has finished
// with the chooser, or the chooser did not pop up at all, "onActivityResult" will be
// called. This callback method is present in the Activity.
Wallet.Payments.loadMaskedWallet(googleApiClient, maskedWalletRequest, Constants.MASKED_WALLET_RETURN_CODE);
} else {
selectionView.hideLoadingIndicator();
selectionView.showTechnicalErrorDialog((DialogInterface.OnClickListener) activity);
}
}
use of com.google.android.gms.wallet.MaskedWalletRequest 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