本文整理汇总了Java中com.google.android.gms.wallet.PaymentMethodToken类的典型用法代码示例。如果您正苦于以下问题:Java PaymentMethodToken类的具体用法?Java PaymentMethodToken怎么用?Java PaymentMethodToken使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PaymentMethodToken类属于com.google.android.gms.wallet包,在下文中一共展示了PaymentMethodToken类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handlePaymentSuccess
import com.google.android.gms.wallet.PaymentMethodToken; //导入依赖的package包/类
private void handlePaymentSuccess(PaymentData paymentData) {
// PaymentMethodToken contains the payment information, as well as any additional
// requested information, such as billing and shipping address.
//
// Refer to your processor's documentation on how to proceed from here.
PaymentMethodToken token = paymentData.getPaymentMethodToken();
// getPaymentMethodToken will only return null if PaymentMethodTokenizationParameters was
// not set in the PaymentRequest.
if (token != null) {
String billingName = paymentData.getCardInfo().getBillingAddress().getName();
Toast.makeText(this, getString(R.string.payments_show_name, billingName), Toast.LENGTH_LONG).show();
// Use token.getToken() to get the token string.
Log.d("PaymentData", "PaymentMethodToken received");
}
}
示例2: androidPaymentToken
import com.google.android.gms.wallet.PaymentMethodToken; //导入依赖的package包/类
@Test
public void androidPaymentToken() throws Exception {
final Constructor<PaymentMethodToken> paymentMethodTokenConstructor = PaymentMethodToken.class.getDeclaredConstructor(int.class,
int.class, String.class);
paymentMethodTokenConstructor.setAccessible(true);
PaymentMethodToken paymentMethodToken = paymentMethodTokenConstructor.newInstance(1, 1, PAYMENT_TOKEN);
final Constructor<FullWallet> fullWalletConstructor = FullWallet.class.getDeclaredConstructor(int.class, String.class, String.class,
ProxyCard.class, String.class, com.google.android.gms.wallet.Address.class, com.google.android.gms.wallet.Address.class,
String[].class, UserAddress.class, UserAddress.class, InstrumentInfo[].class, PaymentMethodToken.class);
fullWalletConstructor.setAccessible(true);
final FullWallet fullWallet = fullWalletConstructor.newInstance(1, null, null, null, null, null, null, null, null, null, null,
paymentMethodToken);
PaymentToken paymentToken = PayHelper.extractPaymentToken(fullWallet, PUBLIC_KEY);
final MessageDigest messageDigest = MessageDigest.getInstance("SHA-256");
final byte[] digest = messageDigest.digest(PUBLIC_KEY.getBytes("UTF-8"));
final String androidPayPublicKeyHash = Base64.encodeToString(digest, Base64.DEFAULT);
assertThat(paymentToken.token).isEqualTo(PAYMENT_TOKEN);
assertThat(paymentToken.publicKeyHash).isEqualTo(androidPayPublicKeyHash);
}
示例3: getPaymentData
import com.google.android.gms.wallet.PaymentMethodToken; //导入依赖的package包/类
private PaymentData getPaymentData(String email, UserAddress billingAddress, UserAddress shippingAddress,
String response) throws Exception {
Constructor<PaymentMethodToken> paymentMethodTokenConstructor = PaymentMethodToken.class
.getDeclaredConstructor(int.class, String.class);
paymentMethodTokenConstructor.setAccessible(true);
PaymentMethodToken paymentMethodToken = paymentMethodTokenConstructor.newInstance(0, response);
Constructor<CardInfo> cardInfoConstructor = CardInfo.class.getDeclaredConstructor(String.class, String.class,
String.class, int.class, UserAddress.class);
cardInfoConstructor.setAccessible(true);
CardInfo cardInfo = cardInfoConstructor.newInstance("MasterCard 0276", null, null, 0, billingAddress);
Constructor<PaymentData> paymentDataConstructor = PaymentData.class.getDeclaredConstructor(String.class,
CardInfo.class, UserAddress.class, PaymentMethodToken.class);
paymentDataConstructor.setAccessible(true);
return paymentDataConstructor.newInstance(email, cardInfo, shippingAddress, paymentMethodToken);
}
示例4: createFullWallet
import com.google.android.gms.wallet.PaymentMethodToken; //导入依赖的package包/类
private FullWallet createFullWallet() throws Exception {
Class paymentMethodTokenClass = PaymentMethodToken.class;
Class[] tokenParams = new Class[] { int.class, String.class };
Constructor<PaymentMethodToken> tokenConstructor = paymentMethodTokenClass.getDeclaredConstructor(tokenParams);
tokenConstructor.setAccessible(true);
PaymentMethodToken token = tokenConstructor.newInstance(0, stringFromFixture("payment_methods/android_pay_card.json"));
Class fullWalletClass = FullWallet.class;
Class[] walletParams = new Class[] { String.class, String.class, ProxyCard.class, String.class,
com.google.android.gms.wallet.zza.class, com.google.android.gms.wallet.zza.class, String[].class, UserAddress.class, UserAddress.class,
InstrumentInfo[].class, PaymentMethodToken.class };
Constructor<FullWallet> walletConstructor = fullWalletClass.getDeclaredConstructor(walletParams);
walletConstructor.setAccessible(true);
return walletConstructor.newInstance(null, null, null, null, null, null, null, null, null, null, token);
}
示例5: getFullWallet
import com.google.android.gms.wallet.PaymentMethodToken; //导入依赖的package包/类
private FullWallet getFullWallet(String response, UserAddress billingAddress, UserAddress shippingAddress) {
PaymentMethodToken paymentMethodToken = mock(PaymentMethodToken.class);
when(paymentMethodToken.getToken()).thenReturn(response);
FullWallet wallet = mock(FullWallet.class);
when(wallet.getPaymentMethodToken()).thenReturn(paymentMethodToken);
when(wallet.getPaymentDescriptions()).thenReturn(new String[] { "MasterCard 0276" });
when(wallet.getEmail()).thenReturn("[email protected]");
when(wallet.getBuyerBillingAddress()).thenReturn(billingAddress);
when(wallet.getBuyerShippingAddress()).thenReturn(shippingAddress);
when(wallet.getGoogleTransactionId()).thenReturn("google-transaction-id");
return wallet;
}