本文整理汇总了Java中com.google.android.gms.wallet.MaskedWalletRequest类的典型用法代码示例。如果您正苦于以下问题:Java MaskedWalletRequest类的具体用法?Java MaskedWalletRequest怎么用?Java MaskedWalletRequest使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MaskedWalletRequest类属于com.google.android.gms.wallet包,在下文中一共展示了MaskedWalletRequest类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createMaskedWalletRequest
import com.google.android.gms.wallet.MaskedWalletRequest; //导入依赖的package包/类
/**
* Creates a MaskedWalletRequest for direct merchant integration (no payment processor).
*
* @param publicKey base64-encoded public encryption key. See instructions for more details.
* @return {@link MaskedWalletRequest} instance
*/
private MaskedWalletRequest createMaskedWalletRequest(@Nullable String publicKey) {
// Validate the public key
if (publicKey == null || publicKey.contains("REPLACE_ME")) {
throw new IllegalArgumentException("Invalid public key, see README for instructions.");
}
// Create direct integration parameters
// [START direct_integration_parameters]
PaymentMethodTokenizationParameters parameters =
PaymentMethodTokenizationParameters.newBuilder()
.setPaymentMethodTokenizationType(PaymentMethodTokenizationType.NETWORK_TOKEN)
.addParameter("publicKey", publicKey)
.build();
// [END direct_integration_parameters]
return createMaskedWalletRequest(parameters);
}
示例2: createMaskedWalletRequest
import com.google.android.gms.wallet.MaskedWalletRequest; //导入依赖的package包/类
/**
* Creates a MaskedWalletRequest for direct merchant integration (no payment processor)
*
* @param product {@link Product} containing details
* of an item.
* @param publicKey base64-encoded public encryption key. See instructions for more details.
* @return {@link MaskedWalletRequest} instance
*/
public static MaskedWalletRequest createMaskedWalletRequest(List<Product> product,
String orderTotal,
String publicKey,
Context context) {
// Validate the public key
if (publicKey == null || publicKey.contains("REPLACE_ME")) {
throw new IllegalArgumentException("Invalid public key, see README for instructions.");
}
// Create direct integration parameters
// [START direct_integration_parameters]
PaymentMethodTokenizationParameters parameters =
PaymentMethodTokenizationParameters.newBuilder()
.setPaymentMethodTokenizationType(PaymentMethodTokenizationType.NETWORK_TOKEN)
.addParameter("publicKey", publicKey)
.build();
// [END direct_integration_parameters]
return createMaskedWalletRequest(product, orderTotal, parameters, context);
}
示例3: showAndroidPaySheet
import com.google.android.gms.wallet.MaskedWalletRequest; //导入依赖的package包/类
/**
* Call when the android pay sheet should be shown.
*/
private void showAndroidPaySheet(final @NonNull AndroidPayPayload payload) {
if (this.walletFragment == null) {
return;
}
this.isInAndroidPayFlow = true;
final MaskedWalletRequest request = AndroidPayUtils.createMaskedWalletRequest(payload);
this.walletFragment.initialize(
WalletFragmentInitParams.newBuilder()
.setMaskedWalletRequest(request)
.setMaskedWalletRequestCode(ActivityRequestCodes.CHECKOUT_ACTIVITY_WALLET_REQUEST)
.build()
);
AndroidPayUtils.triggerAndroidPaySheet(this.walletFragment);
}
示例4: maskedWalletRequest
import com.google.android.gms.wallet.MaskedWalletRequest; //导入依赖的package包/类
/**
* Construct {@link MaskedWalletRequest} from this {@link PayCart}.
*
* @param androidPayPublicKey Android Pay public key
* @return {@link MaskedWalletRequest}
*/
public MaskedWalletRequest maskedWalletRequest(@NonNull final String androidPayPublicKey) {
PaymentMethodTokenizationParameters parameters =
PaymentMethodTokenizationParameters.newBuilder()
.setPaymentMethodTokenizationType(PaymentMethodTokenizationType.NETWORK_TOKEN)
.addParameter("publicKey", checkNotEmpty(androidPayPublicKey, "androidPayPublicKey can't be empty"))
.build();
MaskedWalletRequest.Builder builder = MaskedWalletRequest.newBuilder()
.setMerchantName(merchantName)
.setPhoneNumberRequired(phoneNumberRequired)
.setShippingAddressRequired(shippingAddressRequired)
.setCurrencyCode(currencyCode)
.setCountryCode(countryCode)
.setEstimatedTotalPrice(totalPrice.toString())
.setPaymentMethodTokenizationParameters(parameters)
.setCart(cartBuilder().build());
Collection<CountrySpecification> shippingCountrySpecifications = shippingCountrySpecifications(shipsToCountries);
builder.addAllowedCountrySpecificationsForShipping(shippingCountrySpecifications);
return builder.build();
}
示例5: createMaskedWalletRequest
import com.google.android.gms.wallet.MaskedWalletRequest; //导入依赖的package包/类
/**
* Creates a MaskedWalletRequest
*
* @param itemInfo {@link com.google.android.gms.samples.wallet.ItemInfo} containing details
* of an item.
* @return {@link MaskedWalletRequest} instance
*/
public static MaskedWalletRequest createMaskedWalletRequest(ItemInfo itemInfo) {
// Build a List of all line items
List<LineItem> lineItems = buildLineItems(itemInfo, true);
// Calculate the cart total by iterating over the line items.
String cartTotal = calculateCartTotal(lineItems);
return MaskedWalletRequest.newBuilder()
.setMerchantName(Constants.MERCHANT_NAME)
.setPhoneNumberRequired(true)
.setShippingAddressRequired(true)
.setCurrencyCode(Constants.CURRENCY_CODE_USD)
.setEstimatedTotalPrice(cartTotal)
// Create a Cart with the current line items. Provide all the information
// available up to this point with estimates for shipping and tax included.
.setCart(Cart.newBuilder()
.setCurrencyCode(Constants.CURRENCY_CODE_USD)
.setTotalPrice(cartTotal)
.setLineItems(lineItems)
.build())
// Indicate whether we need the Wallet Objects associated with the user.
.setShouldRetrieveWalletObjects(true)
.build();
}
示例6: loadMaskedWallet
import com.google.android.gms.wallet.MaskedWalletRequest; //导入依赖的package包/类
private void loadMaskedWallet() {
MaskedWalletRequest.Builder maskedWalletRequestBuilder = MaskedWalletRequest.newBuilder()
.setMerchantName(getIntent().getStringExtra(EXTRA_MERCHANT_NAME))
.setCurrencyCode(getCart().getCurrencyCode())
.setCart(getCart())
.setEstimatedTotalPrice(getCart().getTotalPrice())
.setShippingAddressRequired(getIntent().getBooleanExtra(EXTRA_SHIPPING_ADDRESS_REQUIRED, false))
.setPhoneNumberRequired(getIntent().getBooleanExtra(EXTRA_PHONE_NUMBER_REQUIRED, false))
.setPaymentMethodTokenizationParameters((PaymentMethodTokenizationParameters) getIntent()
.getParcelableExtra(EXTRA_TOKENIZATION_PARAMETERS))
.addAllowedCardNetworks(getIntent().getIntegerArrayListExtra(EXTRA_ALLOWED_CARD_NETWORKS))
.addAllowedCountrySpecificationsForShipping((ArrayList) getIntent()
.getParcelableArrayListExtra(EXTRA_ALLOWED_COUNTRIES));
Wallet.Payments.loadMaskedWallet(mGoogleApiClient, maskedWalletRequestBuilder.build(), AUTHORIZE);
}
示例7: generateMaskedWalletRequest
import com.google.android.gms.wallet.MaskedWalletRequest; //导入依赖的package包/类
private MaskedWalletRequest generateMaskedWalletRequest() {
MaskedWalletRequest maskedWalletRequest =
MaskedWalletRequest.newBuilder()
.setMerchantName("Google I/O Codelab")
.setPhoneNumberRequired(true)
.setShippingAddressRequired(true)
.setCurrencyCode("USD")
.setShouldRetrieveWalletObjects(true)
.setEstimatedTotalPrice("10.00")
.setCart(Cart.newBuilder()
.setCurrencyCode("USD")
.setTotalPrice("10.00")
.addLineItem(LineItem.newBuilder()
.setCurrencyCode("USD")
.setDescription("Google I/O Sticker")
.setQuantity("1")
.setUnitPrice("10.00")
.setTotalPrice("10.00")
.build())
.build())
.build();
return maskedWalletRequest;
}
示例8: createWalletFragment
import com.google.android.gms.wallet.MaskedWalletRequest; //导入依赖的package包/类
/**
* Creates the WalletFragment to be added to the UI in order to display the Android Pay button.
*
* @param walletEnvironment
* @param buyButtonAppearance
* @param walletTheme
* @return {@link SupportWalletFragment}
*/
@NonNull
public SupportWalletFragment createWalletFragment(int walletEnvironment,
int buyButtonAppearance,
int walletTheme) {
// [START fragment_style_and_options]
WalletFragmentStyle walletFragmentStyle = new WalletFragmentStyle()
.setBuyButtonText(WalletFragmentStyle.BuyButtonText.BUY_WITH)
.setBuyButtonAppearance(buyButtonAppearance)
.setBuyButtonHeight(150)
.setBuyButtonWidth(WalletFragmentStyle.Dimension.MATCH_PARENT);
WalletFragmentOptions walletFragmentOptions = WalletFragmentOptions.newBuilder()
.setEnvironment(walletEnvironment)
.setFragmentStyle(walletFragmentStyle)
.setTheme(walletTheme)
.setMode(WalletFragmentMode.BUY_BUTTON)
.build();
final SupportWalletFragment walletFragment = SupportWalletFragment.newInstance(walletFragmentOptions);
// [END fragment_style_and_options]
// Now initialize the Wallet Fragment
MaskedWalletRequest maskedWalletRequest;
// Direct integration
maskedWalletRequest = createMaskedWalletRequest(publicKey);
// [START params_builder]
WalletFragmentInitParams.Builder startParamsBuilder = WalletFragmentInitParams.newBuilder()
.setMaskedWalletRequest(maskedWalletRequest)
.setMaskedWalletRequestCode(REQUEST_CODE_MASKED_WALLET)
.setAccountName(null);
walletFragment.initialize(startParamsBuilder.build());
// [END params_builder]
return walletFragment;
}
示例9: getMaskedWalletRequest
import com.google.android.gms.wallet.MaskedWalletRequest; //导入依赖的package包/类
private MaskedWalletRequest getMaskedWalletRequest() {
PaymentMethodTokenizationParameters parameters =
PaymentMethodTokenizationParameters.newBuilder()
.setPaymentMethodTokenizationType(PaymentMethodTokenizationType.NETWORK_TOKEN)
.addParameter("publicKey", simplify.getAndroidPayPublicKey())
.build();
Cart cart = Cart.newBuilder()
.setCurrencyCode(Constants.DEFAULT_CURRENCY.getCode())
.setTotalPrice(mShopItem.priceToString())
.addLineItem(LineItem.newBuilder()
.setCurrencyCode(Constants.DEFAULT_CURRENCY.getCode())
.setDescription(mShopItem.getName())
.setQuantity("1")
.setUnitPrice("2.00")
.setTotalPrice("2.00")
.build())
.build();
return MaskedWalletRequest.newBuilder()
.setMerchantName("BookShelf")
.setPhoneNumberRequired(true)
.setShippingAddressRequired(true)
.setCurrencyCode(Constants.DEFAULT_CURRENCY.getCode())
.setCart(cart)
.setEstimatedTotalPrice(Item.priceToString(mShopItem.getTotalPrice()))
.setPaymentMethodTokenizationParameters(parameters)
.build();
}
示例10: createAndAddWalletFragment
import com.google.android.gms.wallet.MaskedWalletRequest; //导入依赖的package包/类
private void createAndAddWalletFragment() {
// [START fragment_style_and_options]
WalletFragmentStyle walletFragmentStyle = new WalletFragmentStyle()
.setBuyButtonText(WalletFragmentStyle.BuyButtonText.BUY_WITH)
.setBuyButtonAppearance(WalletFragmentStyle.BuyButtonAppearance.ANDROID_PAY_DARK)
.setBuyButtonWidth(WalletFragmentStyle.Dimension.MATCH_PARENT);
WalletFragmentOptions walletFragmentOptions = WalletFragmentOptions.newBuilder()
.setEnvironment(Constants.WALLET_ENVIRONMENT)
.setFragmentStyle(walletFragmentStyle)
.setTheme(WalletConstants.THEME_LIGHT)
.setMode(WalletFragmentMode.BUY_BUTTON)
.build();
mWalletFragment = SupportWalletFragment.newInstance(walletFragmentOptions);
// [END fragment_style_and_options]
// Now initialize the Wallet Fragment
//String accountName = ((AdyenShopApplication)getApplication()).getAccountName();
MaskedWalletRequest maskedWalletRequest;
// Direct integration
maskedWalletRequest = WalletUtil.createMaskedWalletRequest(
productsList,
String.valueOf(orderTotal),
getString(R.string.public_key),
getApplicationContext());
// [START params_builder]
WalletFragmentInitParams.Builder startParamsBuilder = WalletFragmentInitParams.newBuilder()
.setMaskedWalletRequest(maskedWalletRequest)
.setMaskedWalletRequestCode(REQUEST_CODE_MASKED_WALLET)
.setAccountName(null);
mWalletFragment.initialize(startParamsBuilder.build());
// add Wallet fragment to the UI
getSupportFragmentManager().beginTransaction()
.replace(R.id.checkout_fragment_container, mWalletFragment)
.commit();
// [END params_builder]
}
示例11: createMaskedWalletRequest
import com.google.android.gms.wallet.MaskedWalletRequest; //导入依赖的package包/类
public static @NonNull MaskedWalletRequest createMaskedWalletRequest(final @NonNull AndroidPayPayload payload) {
return MaskedWalletRequest.newBuilder()
.setMerchantName(payload.merchantName())
.setPhoneNumberRequired(payload.phoneNumberRequired())
.setShippingAddressRequired(payload.shippingAddressRequired())
.setCurrencyCode(payload.currencyCode())
.setAllowDebitCard(payload.allowDebitCard())
.setAllowPrepaidCard(payload.allowPrepaidCard())
.setEstimatedTotalPrice(payload.estimatedTotalPrice())
.setCart(
Cart.newBuilder()
.setCurrencyCode(payload.cart().currencyCode())
.setTotalPrice(payload.cart().totalPrice())
.setLineItems(lineItemsFromPayload(payload))
.build()
)
.setPaymentMethodTokenizationParameters(
PaymentMethodTokenizationParameters.newBuilder()
.setPaymentMethodTokenizationType(PaymentMethodTokenizationType.PAYMENT_GATEWAY)
.addParameter("gateway", "stripe")
.addParameter("stripe:publishableKey", payload.stripePublishableKey())
.addParameter("stripe:version", payload.stripeVersion())
.build()
)
.build();
}
示例12: getMaskedWalletRequest
import com.google.android.gms.wallet.MaskedWalletRequest; //导入依赖的package包/类
MaskedWalletRequest getMaskedWalletRequest() {
PaymentMethodTokenizationParameters parameters =
PaymentMethodTokenizationParameters.newBuilder()
.setPaymentMethodTokenizationType(PaymentMethodTokenizationType.NETWORK_TOKEN)
.addParameter("publicKey", simplify.getAndroidPayPublicKey())
.build();
Cart cart = Cart.newBuilder()
.setCurrencyCode(Constants.CURRENCY_CODE)
.setTotalPrice(Constants.AMOUNT)
.addLineItem(LineItem.newBuilder()
.setCurrencyCode(Constants.CURRENCY_CODE)
.setDescription("Iced Coffee")
.setQuantity("1")
.setUnitPrice(Constants.AMOUNT)
.setTotalPrice(Constants.AMOUNT)
.build())
.build();
return MaskedWalletRequest.newBuilder()
.setMerchantName("Overpriced Coffee Shop")
.setPhoneNumberRequired(true)
.setShippingAddressRequired(true)
.setCurrencyCode(Constants.CURRENCY_CODE)
.setCart(cart)
.setEstimatedTotalPrice(Constants.AMOUNT)
.setPaymentMethodTokenizationParameters(parameters)
.build();
}
示例13: createAndAddWalletFragment
import com.google.android.gms.wallet.MaskedWalletRequest; //导入依赖的package包/类
private void createAndAddWalletFragment() {
WalletFragmentStyle walletFragmentStyle = new WalletFragmentStyle()
.setBuyButtonText(BuyButtonText.BUY_WITH_GOOGLE)
.setBuyButtonWidth(Dimension.MATCH_PARENT);
WalletFragmentOptions walletFragmentOptions = WalletFragmentOptions.newBuilder()
.setEnvironment(WalletConstants.ENVIRONMENT_SANDBOX)
.setFragmentStyle(walletFragmentStyle)
.setTheme(WalletConstants.THEME_HOLO_LIGHT)
.setMode(WalletFragmentMode.BUY_BUTTON)
.build();
mWalletFragment = SupportWalletFragment.newInstance(walletFragmentOptions);
// Now initialize the Wallet Fragment
String accountName = ((BikestoreApplication) getApplication()).getAccountName();
MaskedWalletRequest maskedWalletRequest =
WalletUtil.createMaskedWalletRequest(Constants.ITEMS_FOR_SALE[mItemId]);
WalletFragmentInitParams.Builder startParamsBuilder = WalletFragmentInitParams.newBuilder()
.setMaskedWalletRequest(maskedWalletRequest)
.setMaskedWalletRequestCode(REQUEST_CODE_MASKED_WALLET)
.setAccountName(accountName);
mWalletFragment.initialize(startParamsBuilder.build());
// add Wallet fragment to the UI
getSupportFragmentManager().beginTransaction()
.replace(R.id.dynamic_wallet_button_fragment, mWalletFragment)
.commit();
}
示例14: createMaskedWalletRequest
import com.google.android.gms.wallet.MaskedWalletRequest; //导入依赖的package包/类
private MaskedWalletRequest createMaskedWalletRequest() {
ItemInfo itemInfo = Constants.ITEMS_FOR_SALE[mItemId];
return WalletUtil.createMaskedWalletRequest(itemInfo);
}
示例15: showAndroidPay
import com.google.android.gms.wallet.MaskedWalletRequest; //导入依赖的package包/类
private void showAndroidPay() {
if (getParentActivity() == null || androidPayContainer == null) {
return;
}
WalletFragmentOptions.Builder optionsBuilder = WalletFragmentOptions.newBuilder();
optionsBuilder.setEnvironment(paymentForm.invoice.test ? WalletConstants.ENVIRONMENT_TEST : WalletConstants.ENVIRONMENT_PRODUCTION);
optionsBuilder.setMode(WalletFragmentMode.BUY_BUTTON);
WalletFragmentStyle walletFragmentStyle;
if (androidPayPublicKey != null) {
androidPayContainer.setBackgroundColor(androidPayBackgroundColor);
walletFragmentStyle = new WalletFragmentStyle()
.setBuyButtonText(WalletFragmentStyle.BuyButtonText.BUY_WITH)
.setBuyButtonAppearance(androidPayBlackTheme ? WalletFragmentStyle.BuyButtonAppearance.ANDROID_PAY_LIGHT_WITH_BORDER : WalletFragmentStyle.BuyButtonAppearance.ANDROID_PAY_DARK)
.setBuyButtonWidth(WalletFragmentStyle.Dimension.MATCH_PARENT);
} else {
walletFragmentStyle = new WalletFragmentStyle()
.setBuyButtonText(WalletFragmentStyle.BuyButtonText.LOGO_ONLY)
.setBuyButtonAppearance(WalletFragmentStyle.BuyButtonAppearance.ANDROID_PAY_LIGHT_WITH_BORDER)
.setBuyButtonWidth(WalletFragmentStyle.Dimension.WRAP_CONTENT);
}
optionsBuilder.setFragmentStyle(walletFragmentStyle);
WalletFragment walletFragment = WalletFragment.newInstance(optionsBuilder.build());
FragmentManager fragmentManager = getParentActivity().getFragmentManager();
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
fragmentTransaction.replace(fragment_container_id, walletFragment);
fragmentTransaction.commit();
ArrayList<TLRPC.TL_labeledPrice> arrayList = new ArrayList<>();
arrayList.addAll(paymentForm.invoice.prices);
if (shippingOption != null) {
arrayList.addAll(shippingOption.prices);
}
totalPriceDecimal = getTotalPriceDecimalString(arrayList);
PaymentMethodTokenizationParameters parameters;
if (androidPayPublicKey != null) {
parameters = PaymentMethodTokenizationParameters.newBuilder()
.setPaymentMethodTokenizationType(PaymentMethodTokenizationType.NETWORK_TOKEN)
.addParameter("publicKey", androidPayPublicKey)
.build();
} else {
parameters = PaymentMethodTokenizationParameters.newBuilder()
.setPaymentMethodTokenizationType(PaymentMethodTokenizationType.PAYMENT_GATEWAY)
.addParameter("gateway", "stripe")
.addParameter("stripe:publishableKey", stripeApiKey)
.addParameter("stripe:version", StripeApiHandler.VERSION)
.build();
}
MaskedWalletRequest maskedWalletRequest = MaskedWalletRequest.newBuilder()
.setPaymentMethodTokenizationParameters(parameters)
.setEstimatedTotalPrice(totalPriceDecimal)
.setCurrencyCode(paymentForm.invoice.currency)
.build();
WalletFragmentInitParams initParams = WalletFragmentInitParams.newBuilder()
.setMaskedWalletRequest(maskedWalletRequest)
.setMaskedWalletRequestCode(LOAD_MASKED_WALLET_REQUEST_CODE)
.build();
walletFragment.initialize(initParams);
androidPayContainer.setVisibility(View.VISIBLE);
AnimatorSet animatorSet = new AnimatorSet();
animatorSet.playTogether(ObjectAnimator.ofFloat(androidPayContainer, "alpha", 0.0f, 1.0f));
animatorSet.setInterpolator(new DecelerateInterpolator());
animatorSet.setDuration(180);
animatorSet.start();
}