diff --git a/README.md b/README.md index 0cd6d3dafe..6f9fda766a 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ To give you as much flexibility as possible, our Android SDK can be integrated i Import the quick integration modules by adding these lines to your build.gradle file. ```groovy -final checkoutVersion = "2.3.2" +final checkoutVersion = "2.3.3" implementation "com.adyen.checkout:ui:${checkoutVersion}" implementation "com.adyen.checkout:nfc:${checkoutVersion}" // Optional; Integrates NFC card reader in card UI implementation "com.adyen.checkout:wechatpay:${checkoutVersion}" // Optional; Integrates support for WeChat Pay @@ -136,7 +136,7 @@ By default, we use the font that is declared in the theme that is used for check #### Installation Import the following modules by adding these line to your `build.gradle` file. ```groovy -final checkoutVersion = "2.3.2" +final checkoutVersion = "2.3.3" implementation "com.adyen.checkout:core:${checkoutVersion}" implementation "com.adyen.checkout:core-card:${checkoutVersion}" // Optional; Required for processing card payments. implementation "com.adyen.checkout:nfc:${checkoutVersion}" // Optional; Enables reading of card information with the device"s NFC chip. diff --git a/build.gradle b/build.gradle index 286056297c..b7910fe0d6 100644 --- a/build.gradle +++ b/build.gradle @@ -28,8 +28,8 @@ ext { "com.tencent.mm.opensdk:wechat-sdk-android-without-mta:9a15154c07c05eadba8351c110647c1754316e32d8f12f55e24679891b52739c:SHA-256", ] - versionCode = 208 - versionName = "2.3.2" + versionCode = 209 + versionName = "2.3.3" testCoverageEnabled = true } diff --git a/checkout-googlepay/src/main/java/com/adyen/checkout/googlepay/internal/GooglePayDetailsActivity.java b/checkout-googlepay/src/main/java/com/adyen/checkout/googlepay/internal/GooglePayDetailsActivity.java index b09ad59dd7..266616d7c3 100644 --- a/checkout-googlepay/src/main/java/com/adyen/checkout/googlepay/internal/GooglePayDetailsActivity.java +++ b/checkout-googlepay/src/main/java/com/adyen/checkout/googlepay/internal/GooglePayDetailsActivity.java @@ -11,9 +11,11 @@ import android.app.Activity; import android.content.Context; import android.content.Intent; +import android.content.pm.PackageManager; import android.os.Bundle; import android.support.annotation.NonNull; import android.support.annotation.Nullable; +import android.util.Log; import com.adyen.checkout.core.CheckoutException; import com.adyen.checkout.core.Observable; @@ -21,7 +23,9 @@ import com.adyen.checkout.core.PaymentHandler; import com.adyen.checkout.core.PaymentReference; import com.adyen.checkout.core.PaymentResult; +import com.adyen.checkout.core.RedirectDetails; import com.adyen.checkout.core.handler.ErrorHandler; +import com.adyen.checkout.core.handler.RedirectHandler; import com.adyen.checkout.core.model.GooglePayConfiguration; import com.adyen.checkout.core.model.GooglePayDetails; import com.adyen.checkout.core.model.PaymentMethod; @@ -36,14 +40,15 @@ import org.json.JSONException; public class GooglePayDetailsActivity extends Activity { + private static final String TAG = GooglePayDetails.class.getSimpleName(); private static final String EXTRA_PAYMENT_REFERENCE = "EXTRA_PAYMENT_REFERENCE"; private static final String EXTRA_PAYMENT_METHOD = "EXTRA_PAYMENT_METHOD"; private static final int REQUEST_CODE_GOOGLE_PAY = 1; + private PaymentReference mPaymentReference; private PaymentMethod mPaymentMethod; - private PaymentHandler mPaymentHandler; @NonNull @@ -61,9 +66,9 @@ protected void onCreate(@Nullable final Bundle savedInstanceState) { Intent intent = getIntent(); - PaymentReference paymentReference = intent.getParcelableExtra(EXTRA_PAYMENT_REFERENCE); + mPaymentReference = intent.getParcelableExtra(EXTRA_PAYMENT_REFERENCE); mPaymentMethod = intent.getParcelableExtra(EXTRA_PAYMENT_METHOD); - mPaymentHandler = paymentReference.getPaymentHandler(this); + mPaymentHandler = mPaymentReference.getPaymentHandler(this); final GooglePayConfiguration configuration; try { @@ -102,6 +107,34 @@ public void onChanged(@NonNull PaymentResult paymentResult) { finish(); } }); + mPaymentHandler.setRedirectHandler(this, new RedirectHandler() { + @Override + public void onRedirectRequired(@NonNull RedirectDetails redirectDetails) { + handleRedirect(redirectDetails); + } + }); + } + + private void handleRedirect(RedirectDetails redirectDetails) { + Class redirectActivityClass; + try { + redirectActivityClass = Class.forName("com.adyen.checkout.ui.internal.common.activity.RedirectHandlerActivity"); + } catch (ClassNotFoundException e) { + Log.e(TAG, "Failed to get redirect class.", e); + return; + } + + Intent redirectIntent = new Intent(GooglePayDetailsActivity.this, redirectActivityClass); + + redirectIntent.putExtra(EXTRA_PAYMENT_REFERENCE, mPaymentReference); + redirectIntent.putExtra("EXTRA_REDIRECT_DETAILS", redirectDetails); + + boolean isCallable = getPackageManager().queryIntentActivities(redirectIntent, PackageManager.MATCH_DEFAULT_ONLY).size() > 0; + if (isCallable) { + startActivity(redirectIntent); + } else { + Log.e(TAG, "RedirectHandlerActivity not callable."); + } } @Override diff --git a/checkout-ui/src/main/java/com/adyen/checkout/ui/internal/common/activity/CheckoutSessionActivity.java b/checkout-ui/src/main/java/com/adyen/checkout/ui/internal/common/activity/CheckoutSessionActivity.java index 90a06cee82..4d03426974 100644 --- a/checkout-ui/src/main/java/com/adyen/checkout/ui/internal/common/activity/CheckoutSessionActivity.java +++ b/checkout-ui/src/main/java/com/adyen/checkout/ui/internal/common/activity/CheckoutSessionActivity.java @@ -30,8 +30,8 @@ import com.adyen.checkout.ui.internal.common.fragment.ProgressDialogFragment; import com.adyen.checkout.ui.internal.common.model.CheckoutSessionProvider; -public abstract class CheckoutSessionActivity extends AppCompatActivity - implements CheckoutSessionProvider { +public abstract class CheckoutSessionActivity extends AppCompatActivity implements CheckoutSessionProvider { + @NonNull public static final String EXTRA_PAYMENT_REFERENCE = "EXTRA_PAYMENT_REFERENCE"; diff --git a/checkout-ui/src/main/java/com/adyen/checkout/ui/internal/common/activity/RedirectHandlerActivity.java b/checkout-ui/src/main/java/com/adyen/checkout/ui/internal/common/activity/RedirectHandlerActivity.java index 4a68cc5fec..75a52122db 100644 --- a/checkout-ui/src/main/java/com/adyen/checkout/ui/internal/common/activity/RedirectHandlerActivity.java +++ b/checkout-ui/src/main/java/com/adyen/checkout/ui/internal/common/activity/RedirectHandlerActivity.java @@ -30,6 +30,7 @@ import com.adyen.checkout.ui.internal.common.util.ThemeUtil; public class RedirectHandlerActivity extends AppCompatActivity { + private static final String EXTRA_PAYMENT_REFERENCE = "EXTRA_PAYMENT_REFERENCE"; private static final String EXTRA_REDIRECT_DETAILS = "EXTRA_REDIRECT_DETAILS"; diff --git a/example-app/src/main/java/com/adyen/example/model/PaymentSetupRequest.java b/example-app/src/main/java/com/adyen/example/model/PaymentSetupRequest.java index a4ff971517..b1249ee1db 100644 --- a/example-app/src/main/java/com/adyen/example/model/PaymentSetupRequest.java +++ b/example-app/src/main/java/com/adyen/example/model/PaymentSetupRequest.java @@ -76,6 +76,9 @@ public final class PaymentSetupRequest implements Serializable { @Json(name = "deliveryAddress") private Address mDeliveryAddress; + @Json(name = "executeThreeD") + private String mExecuteThreeD; + public static final class Builder { private final PaymentSetupRequest mPaymentSetupRequest; @@ -161,6 +164,11 @@ public Builder setDeliveryAddress(@Nullable Address deliveryAddress) { return this; } + public Builder setExecuteThreeD(@Nullable String executeThreeD) { + mPaymentSetupRequest.mExecuteThreeD = executeThreeD; + return this; + } + @NonNull public PaymentSetupRequest build() { return mPaymentSetupRequest;