当前位置: 首页>>代码示例>>Java>>正文


Java PaymentMethodToken类代码示例

本文整理汇总了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");
    }
}
 
开发者ID:android-pay,项目名称:paymentsapi-quickstart,代码行数:18,代码来源:CheckoutActivity.java

示例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);
}
 
开发者ID:Shopify,项目名称:mobile-buy-sdk-android,代码行数:24,代码来源:PayHelperTest.java

示例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);
}
 
开发者ID:braintree,项目名称:braintree_android,代码行数:18,代码来源:GooglePaymentCardNonceUnitTest.java

示例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);
}
 
开发者ID:braintree,项目名称:braintree_android,代码行数:16,代码来源:AndroidPayTest.java

示例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;
}
 
开发者ID:braintree,项目名称:braintree_android,代码行数:15,代码来源:AndroidPayCardNonceUnitTest.java


注:本文中的com.google.android.gms.wallet.PaymentMethodToken类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。