Детально погрузимся в то, как устроен Google Pay под капотом. Узнаем, как просто встроить возможность оплаты в ваше приложение и когда его можно (и главное, нужно) использовать.
method • Display all relevant purchase information including final price and items/services purchased, before confirming an order • If you display payment information on confirmation screens or emails, you may display the payment card description returned by Google Pay API • Use only the official button styles and logo assets in your app
mPaymentsClient.isReadyToPay(request); task.addOnCompleteListener( new OnCompleteListener<Boolean>() { @Override public void onComplete(@NonNull Task<Boolean> task) { try { boolean result = task.getResult(ApiException.class); if (result) { // show Google Pay as a payment option } } catch (ApiException e) { } } });
public void onClick(View v) { PaymentDataRequest request = PaymentDataRequest.fromJson(paymentDataRequest.toString()); if (request != null) { AutoResolveHelper.resolveTask( mPaymentsClient.loadPaymentData(request), this, // LOAD_PAYMENT_DATA_REQUEST_CODE is a constant integer value you define LOAD_PAYMENT_DATA_REQUEST_CODE); } } });
resultCode, Intent data) { switch (requestCode) { // value passed in AutoResolveHelper case LOAD_PAYMENT_DATA_REQUEST_CODE: switch (resultCode) { case Activity.RESULT_OK: PaymentData paymentData = PaymentData.getFromIntent(data); String json = paymentData.toJson(); // if using gateway tokenization, pass this token without modification String paymentMethodData = new JSONObject(json).getJSONObject(“paymentMethodData”); String paymentToken = paymentMethodData.getJSONObject("tokenizationData").getString("token"); break; case Activity.RESULT_CANCELED: break; case AutoResolveHelper.RESULT_ERROR: Status status = AutoResolveHelper.getStatusFromIntent(data); // Log the status for debugging. // Generally, there is no need to show an error to the user. // The Google Pay payment sheet will present any account errors. break; } break; } }
live chargeable tokens in the PaymentData response ◦ The environment value can be one of the following: WalletConstants.ENVIRONMENT_TEST WalletConstants.ENVIRONMENT_PRODUCTION ◦ Review branding requirements •Deploying to your production ◦ Get access to the production environment – https://services.google.com/fb/forms/googlepaymentAPI/ ◦ Sign your app with release keys ◦ Configure your app for production
Pay API Developer Site – https://g.co/pay/developers Demo – https://g.co/pay/demo One more reference https://g.co/pay/processors https://g.co/pay/autofill https://g.co/pay/loyalty https://g.co/pay/passes