为了在Android 12及更高版本上使用Adyen支付集成,您需要执行以下步骤:
dependencies {
implementation 'com.adyen.checkout:checkout:+'
}
Environment environment = new Environment( "https://checkout-test.adyen.com/checkout/v51/", // Endpoint for the test environment. "your_client_key"); // Your client key.
CheckoutSetupParameters checkoutSetupParameters = new CheckoutSetupParameters.Builder() .setShopperLocale(Locale.US) .setAmount(new Amount(Currency.USD, 1000L)) .setReference("Your Order Number") .build();
CheckoutController checkoutController = new CheckoutController(environment);
checkoutController.startCheckoutActivity(this, checkoutSetupParameters, REQUEST_CODE_CHECKOUT);
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { switch (requestCode) { case REQUEST_CODE_CHECKOUT: PaymentResult paymentResult = checkoutController.handleCheckoutResult(resultCode, data); if (paymentResult.isFinished()) { if (paymentResult.isSuccessful()) { // Payment has been completed successfully. } else if (paymentResult.isProcessed()) { // Payment was processed, but it is not yet paid (e.g. payment pending). } else { // Payment has failed. } } break; default: super.onActivityResult(requestCode, resultCode, data); break; } }
这样,您就可以在Android 12及更高版本上集成Adyen支付,并启用安全性能增强功能。