PaymentDataRequest.Builder

public final class PaymentDataRequest.Builder extends Object

Builder to create a PaymentDataRequest.

Public Method Summary

PaymentDataRequest.Builder
addAllowedPaymentMethod(int allowedPaymentMethod)
Adds an allowed payment method.
PaymentDataRequest.Builder
addAllowedPaymentMethods(Collection<Integer> allowedPaymentMethods)
Adds a collection of allowed payment methods.
PaymentDataRequest
PaymentDataRequest.Builder
setCardRequirements(CardRequirements cardRequirements)
Sets the card requirements.
PaymentDataRequest.Builder
setEmailRequired(boolean emailRequired)
Sets whether buyer's email is required.
PaymentDataRequest.Builder
setPaymentMethodTokenizationParameters(PaymentMethodTokenizationParameters paymentMethodTokenizationParameters)
Sets payment method tokenization parameters which will be used to tokenize the payment method returned within getPaymentMethodToken().
PaymentDataRequest.Builder
setPhoneNumberRequired(boolean phoneNumberRequired)
Sets whether a phone number is additionally required from the buyer in both shipping and billing addresses (the phone number will only be returned if an address is required, otherwise this is a no-op).
PaymentDataRequest.Builder
setShippingAddressRequired(boolean shippingAddressRequired)
Sets whether a shipping address is required from the buyer.
PaymentDataRequest.Builder
setShippingAddressRequirements(ShippingAddressRequirements shippingAddressRequirements)
Sets the shipping address requirements.
PaymentDataRequest.Builder
setTransactionInfo(TransactionInfo transactionInfo)
Sets detailed transaction info.
PaymentDataRequest.Builder
setUiRequired(boolean uiRequired)
Sets whether the UI to show the payment method or shipping address selection is required to be shown in the purchase flow.

Inherited Method Summary

Public Methods

public PaymentDataRequest.Builder addAllowedPaymentMethod (int allowedPaymentMethod)

Adds an allowed payment method. See WalletConstants.PaymentMethod for available options.

Note that at least one allowed payment method must be explicitly set using either this method or addAllowedPaymentMethods(Collection).

public PaymentDataRequest.Builder addAllowedPaymentMethods (Collection<Integer> allowedPaymentMethods)

Adds a collection of allowed payment methods. See WalletConstants.PaymentMethod for available options.

Note that at least one allowed payment method must be explicitly set using either this method or addAllowedPaymentMethod(int).

public PaymentDataRequest build ()

Returns

public PaymentDataRequest.Builder setCardRequirements (CardRequirements cardRequirements)

Sets the card requirements.

This is a required field.

public PaymentDataRequest.Builder setEmailRequired (boolean emailRequired)

Sets whether buyer's email is required. If omitted, defaults to false.

public PaymentDataRequest.Builder setPaymentMethodTokenizationParameters (PaymentMethodTokenizationParameters paymentMethodTokenizationParameters)

Sets payment method tokenization parameters which will be used to tokenize the payment method returned within getPaymentMethodToken().

This is an optional field. It should be set if the getPaymentMethodToken() is required. Otherwise, it can be left unset and the getPaymentMethodToken() won't be returned.

When the getPaymentMethodToken() is not required, this field should be left unset to minimize latency. This will be the case for example if you only want to provide a way for the buyer to change their payment selection when the UI is skipped during the purchase flow (see setUiRequired(boolean)).

public PaymentDataRequest.Builder setPhoneNumberRequired (boolean phoneNumberRequired)

Sets whether a phone number is additionally required from the buyer in both shipping and billing addresses (the phone number will only be returned if an address is required, otherwise this is a no-op). If omitted, defaults to false.

Note that you should only request the phone number when it's required to process the order since it can increase friction during the checkout process and can lead to a lower conversion rate.

public PaymentDataRequest.Builder setShippingAddressRequired (boolean shippingAddressRequired)

Sets whether a shipping address is required from the buyer. The returned shipping address could be retrieved from getShippingAddress(). If omitted, defaults to false.

Optionally, when shipping address is required, extra requirements of the returned shipping address could be set through setShippingAddressRequirements(ShippingAddressRequirements). If no requirements are set, shipping addresses from all supported countries may be returned.

public PaymentDataRequest.Builder setShippingAddressRequirements (ShippingAddressRequirements shippingAddressRequirements)

Sets the shipping address requirements. If omitted, shipping addresses from all supported countries may be returned.

public PaymentDataRequest.Builder setTransactionInfo (TransactionInfo transactionInfo)

Sets detailed transaction info.

This field is required if getPaymentMethodToken() is required. See setPaymentMethodTokenizationParameters(PaymentMethodTokenizationParameters).

public PaymentDataRequest.Builder setUiRequired (boolean uiRequired)

Sets whether the UI to show the payment method or shipping address selection is required to be shown in the purchase flow. If omitted, defaults to true and the UI will always be shown.

When this is set to false, loadPaymentData(PaymentDataRequest) will attempt to skip the UI and directly return the data from the buyer's previous selection, if the following conditions are met:

  • The buyer has made previous selections in this app before that still meet the requirements in this request.
  • The buyer has consented to reuse their previous selections in subsequent purchases.
  • The merchant is whitelisted for not showing UI. Please contact Google if you think your use case would benefit from skipping UI.

Note that even if all of the conditions above are met, UI may still be shown to the buyer (e.g. if an update to their selections is required or if further user authentication is needed).

When this is set to false, you should ensure the buyer can still change their selections within your app (e.g. providing an option on a confirmation page or on a settings page where this API can be called again with this field set to true).