本文整理汇总了Java中com.google.android.gms.wallet.Wallet类的典型用法代码示例。如果您正苦于以下问题:Java Wallet类的具体用法?Java Wallet怎么用?Java Wallet使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Wallet类属于com.google.android.gms.wallet包,在下文中一共展示了Wallet类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onCreate
import com.google.android.gms.wallet.Wallet; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_card_form);
// Initialize simplify instance:
simplify = ((ShopApplication) getApplication()).getSimplify();
// Build Google API instance:
// API: Wallet
mGoogleApiClient = new GoogleApiClient.Builder(this)
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.addApi(Wallet.API, new Wallet.WalletOptions.Builder()
.setEnvironment(Constants.WALLET_ENVIRONMENT)
.setTheme(WalletConstants.THEME_LIGHT)
.build())
.build();
// Initialize view:
init_view();
// Wallet payment request:
readyToPayRequest();
}
示例2: onCreate
import com.google.android.gms.wallet.Wallet; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_android_pay);
mMaskedWallet = getIntent().getParcelableExtra(WalletConstants.EXTRA_MASKED_WALLET);
// Initialize simplify instance:
simplify = ((ShopApplication) getApplication()).getSimplify();
// Build Google API instance:
// API: Wallet
mGoogleApiClient = new GoogleApiClient.Builder(this)
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.addApi(Wallet.API, new Wallet.WalletOptions.Builder()
.setEnvironment(Constants.WALLET_ENVIRONMENT)
.setTheme(WalletConstants.THEME_LIGHT)
.build())
.build();
// Initialize view:
initView();
}
示例3: onCreate
import com.google.android.gms.wallet.Wallet; //导入依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mActivityLaunchIntent = getActivity().getIntent();
mMaskedWallet = mActivityLaunchIntent.getParcelableExtra(Constants.EXTRA_MASKED_WALLET);
productsList = fillProductListFromIntent(mActivityLaunchIntent);
orderTotal = mActivityLaunchIntent.getFloatExtra("orderTotal", 0);
// Set up an API client
FragmentActivity fragmentActivity = getActivity();
// [START build_google_api_client]
mGoogleApiClient = new GoogleApiClient.Builder(getActivity())
.enableAutoManage(fragmentActivity, this /* onConnectionFailedListener */)
.addApi(Wallet.API, new Wallet.WalletOptions.Builder()
.setEnvironment(Constants.WALLET_ENVIRONMENT)
.setTheme(WalletConstants.THEME_LIGHT)
.build())
.build();
// [END build_google_api_client]
}
示例4: AndroidPayCapability
import com.google.android.gms.wallet.Wallet; //导入依赖的package包/类
public AndroidPayCapability(final @NonNull PlayServicesCapability playServicesCapability,
final @ApplicationContext @NonNull Context applicationContext) {
if (playServicesCapability.isCapable()) {
final GoogleApiClient googleApiClient = new GoogleApiClient.Builder(applicationContext)
.addApi(Wallet.API, new Wallet.WalletOptions.Builder().build())
.build();
googleApiClient.connect();
Wallet.Payments.isReadyToPay(googleApiClient).setResultCallback(result -> {
this.isCapable = result.getStatus().isSuccess() && result.getValue();
googleApiClient.disconnect();
});
} else {
this.isCapable = false;
}
}
示例5: onCreate
import com.google.android.gms.wallet.Wallet; //导入依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Intent intent = getActivity().getIntent();
if (intent != null) {
mItemId = intent.getIntExtra(Constants.EXTRA_ITEM_ID, 0);
}
setRetainInstance(true);
String accountName = ((XyzApplication) getActivity().getApplication()).getAccountName();
// Set up an API client;
mGoogleApiClient = new GoogleApiClient.Builder(getActivity())
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.setAccountName(accountName)
.addApi(Wallet.API, new Wallet.WalletOptions.Builder()
.setEnvironment(Constants.WALLET_ENVIRONMENT)
.setTheme(WalletConstants.THEME_HOLO_LIGHT)
.build())
.build();
mRetryHandler = new RetryHandler(this);
}
示例6: fetchTransactionStatus
import com.google.android.gms.wallet.Wallet; //导入依赖的package包/类
/**
* Here the client should connect to their server, process the credit card/instrument
* and get back a status indicating whether charging the card was successful or not
*/
private void fetchTransactionStatus(FullWallet fullWallet) {
if (mProgressDialog.isShowing()) {
mProgressDialog.dismiss();
}
// Send back details such as fullWallet.getProxyCard() and fullWallet.getBillingAddress()
// and get back success or failure
// The following code assumes a successful response and calls notifyTransactionStatus
Wallet.notifyTransactionStatus(mGoogleApiClient,
WalletUtil.createNotifyTransactionStatusRequest(fullWallet.getGoogleTransactionId(),
NotifyTransactionStatusRequest.Status.SUCCESS));
Intent intent = new Intent(getActivity(), OrderCompleteActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
intent.putExtra(Constants.EXTRA_FULL_WALLET, mFullWallet);
startActivity(intent);
}
示例7: loadMaskedWallet
import com.google.android.gms.wallet.Wallet; //导入依赖的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);
}
示例8: fetchTransactionStatus
import com.google.android.gms.wallet.Wallet; //导入依赖的package包/类
/**
* Here the client should connect to their server, process the credit card/instrument
* and get back a status indicating whether charging the card was successful or not
*/
private void fetchTransactionStatus(FullWallet fullWallet) {
if (mProgressDialog.isShowing()) {
mProgressDialog.dismiss();
}
// Send back details such as fullWallet.getProxyCard() and fullWallet.getBillingAddress()
// and get back success or failure
// The following code assumes a successful response and calls notifyTransactionStatus
Wallet.Payments.notifyTransactionStatus(mGoogleApiClient,
WalletUtil.createNotifyTransactionStatusRequest(fullWallet.getGoogleTransactionId(),
NotifyTransactionStatusRequest.Status.SUCCESS));
Intent intent = new Intent(getActivity(), OrderCompleteActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
intent.putExtra(Constants.EXTRA_FULL_WALLET, fullWallet);
startActivity(intent);
}
示例9: getGoogleApiClient
import com.google.android.gms.wallet.Wallet; //导入依赖的package包/类
/**
* Return the Google API Client.
*
* @return {@link GoogleApiClient}
*/
@NonNull
public GoogleApiClient getGoogleApiClient() {
return new GoogleApiClient.Builder(this)
.addApi(Wallet.API, new Wallet.WalletOptions.Builder().build())
.addConnectionCallbacks(this)
.build();
}
示例10: checkAvailability
import com.google.android.gms.wallet.Wallet; //导入依赖的package包/类
@Override
@SuppressWarnings("unchecked")
public void checkAvailability(@NonNull final Context context, @NonNull PaymentMethod paymentMethod,
@NonNull final PaymentMethodAvailabilityCallback callback) {
Log.d(TAG, "checkAvailability");
GoogleApiAvailability googleAPI = GoogleApiAvailability.getInstance();
int result = googleAPI.isGooglePlayServicesAvailable(context);
if (result != ConnectionResult.SUCCESS) {
callback.onFail(new GoogleApiClientNotInitializedException("Google API not available"));
}
final GoogleApiClient googleApiClient = getGoogleApiClient(context);
if (googleApiClient != null) {
googleApiClient.connect();
Wallet.Payments.isReadyToPay(googleApiClient).setResultCallback(
new ResultCallback<BooleanResult>() {
@Override
public void onResult(@NonNull BooleanResult booleanResult) {
if (booleanResult.getStatus().isSuccess()) {
callback.onSuccess(booleanResult.getValue());
} else {
Log.e(TAG, "isReadyToPay:" + booleanResult.getStatus());
String errorMessage = booleanResult.getStatus().getStatusCode()
+ booleanResult.getStatus().getStatusMessage();
callback.onFail(new Throwable(errorMessage));
}
}
});
} else {
callback.onFail(new GoogleApiClientNotInitializedException(
"Google API client is null or not connected"));
}
}
示例11: getGoogleApiClient
import com.google.android.gms.wallet.Wallet; //导入依赖的package包/类
/**
* Return the Google API Client.
*
* @return {@link GoogleApiClient}
*/
@NonNull
private GoogleApiClient getGoogleApiClient(final Context context) {
return new GoogleApiClient.Builder(context)
.addApi(Wallet.API, new Wallet.WalletOptions.Builder().build())
.addConnectionCallbacks(this)
.build();
}
示例12: readyToPayRequest
import com.google.android.gms.wallet.Wallet; //导入依赖的package包/类
private void readyToPayRequest(){
IsReadyToPayRequest req = IsReadyToPayRequest.newBuilder()
.addAllowedCardNetwork(WalletConstants.CardNetwork.MASTERCARD)
.addAllowedCardNetwork(WalletConstants.CardNetwork.VISA)
.addAllowedCardNetwork(WalletConstants.CardNetwork.AMEX)
.addAllowedCardNetwork(WalletConstants.CardNetwork.DISCOVER)
.build();
Wallet.Payments.isReadyToPay(mGoogleApiClient, req)
.setResultCallback(new ResultCallback<BooleanResult>() {
@Override
public void onResult(@NonNull BooleanResult booleanResult) {
if (booleanResult.getStatus().isSuccess()) {
if (booleanResult.getValue()) {
//Log.i(TAG, "Android Pay is ready");
Toast.makeText(getBaseContext(), "Android Pay is ready", Toast.LENGTH_LONG).show();
showAndroidPayButton();
return;
}
}
//Log.i(TAG, "Android Pay not ready");
Toast.makeText(getBaseContext(), "Android Pay not ready", Toast.LENGTH_LONG).show();
hideAndroidPayButton();
}
});
}
示例13: confirmPurchase
import com.google.android.gms.wallet.Wallet; //导入依赖的package包/类
private void confirmPurchase() {
mPayButton.setEnabled(false);
if (mMaskedWallet == null) {
Toast.makeText(this, "No masked wallet, can't confirm", Toast.LENGTH_SHORT).show();
return;
}
Wallet.Payments.loadFullWallet(mGoogleApiClient, getFullWalletRequest(), Simplify.REQUEST_CODE_FULL_WALLET);
}
示例14: saveToAndroid
import com.google.android.gms.wallet.Wallet; //导入依赖的package包/类
public void saveToAndroid(View view) {
LoyaltyWalletObject wob = generateLoyaltyWalletObject();
CreateWalletObjectsRequest request = new CreateWalletObjectsRequest(wob);
Wallet.WalletOptions walletOptions = new Wallet.WalletOptions.Builder()
.setTheme(WalletConstants.THEME_LIGHT)
.setEnvironment(WalletConstants.ENVIRONMENT_PRODUCTION)
.build();
walletObjectsClient = Wallet.getWalletObjectsClient(this, walletOptions);
Task<AutoResolvableVoidResult> task = walletObjectsClient.createWalletObjects(request);
AutoResolveHelper.resolveTask(task, this, SAVE_TO_ANDROID);
}
示例15: createPaymentsClient
import com.google.android.gms.wallet.Wallet; //导入依赖的package包/类
/**
* Creates an instance of {@link PaymentsClient} for use in an {@link Activity} using the
* environment and theme set in {@link Constants}.
*
* @param activity is the caller's activity.
*/
public static PaymentsClient createPaymentsClient(Activity activity) {
Wallet.WalletOptions walletOptions = new Wallet.WalletOptions.Builder()
.setEnvironment(Constants.PAYMENTS_ENVIRONMENT)
.build();
return Wallet.getPaymentsClient(activity, walletOptions);
}