Search in sources :

Example 1 with MaskedWalletRequest

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);
}
Also used : MaskedWalletRequest(com.google.android.gms.wallet.MaskedWalletRequest)

Example 2 with MaskedWalletRequest

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);
    }
}
Also used : GoogleApiClient(com.google.android.gms.common.api.GoogleApiClient) DialogInterface(android.content.DialogInterface) MaskedWalletRequest(com.google.android.gms.wallet.MaskedWalletRequest)

Example 3 with MaskedWalletRequest

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;
}
Also used : PaymentMethodTokenizationParameters(com.google.android.gms.wallet.PaymentMethodTokenizationParameters) MaskedWalletRequest(com.google.android.gms.wallet.MaskedWalletRequest)

Aggregations

MaskedWalletRequest (com.google.android.gms.wallet.MaskedWalletRequest)3 DialogInterface (android.content.DialogInterface)1 GoogleApiClient (com.google.android.gms.common.api.GoogleApiClient)1 PaymentMethodTokenizationParameters (com.google.android.gms.wallet.PaymentMethodTokenizationParameters)1