PaymentDataRequest.Builder

public final class PaymentDataRequest.Builder extends Object

This class is deprecated.
Use the JSON request format instead, see PaymentDataRequest.fromJson(String).

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 PaymentData.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 buyer must provide a shipping address.
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 PaymentData.getPaymentMethodToken().

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

When the PaymentData.getPaymentMethodToken() isn't required, leave this field 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 buyer must provide a shipping address. PaymentData.getShippingAddress() can retrieve the returned shipping address. If omitted, defaults to false.

Optionally, if the shipping address is required, it can be set with setShippingAddressRequirements(ShippingAddressRequirements). If no requirements are set, the API may return shipping addresses from all supported countries.

public PaymentDataRequest.Builder setShippingAddressRequirements (ShippingAddressRequirements shippingAddressRequirements)

Sets the shipping address requirements. If omitted, the API may return shipping addresses from all supported countries.

public PaymentDataRequest.Builder setTransactionInfo (TransactionInfo transactionInfo)

Sets detailed transaction info.

This field is required if PaymentData.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, PaymentsClient.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 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).