diff --git a/3ds2/src/main/java/com/adyen/checkout/adyen3ds2/Adyen3DS2Component.java b/3ds2/src/main/java/com/adyen/checkout/adyen3ds2/Adyen3DS2Component.java
index 08a3658b74..12c3f1a26c 100644
--- a/3ds2/src/main/java/com/adyen/checkout/adyen3ds2/Adyen3DS2Component.java
+++ b/3ds2/src/main/java/com/adyen/checkout/adyen3ds2/Adyen3DS2Component.java
@@ -30,8 +30,8 @@
import com.adyen.checkout.base.model.payments.response.Threeds2FingerprintAction;
import com.adyen.checkout.core.api.ThreadManager;
import com.adyen.checkout.core.code.Lint;
-import com.adyen.checkout.core.exeption.CheckoutException;
-import com.adyen.checkout.core.exeption.ComponentException;
+import com.adyen.checkout.core.exception.CheckoutException;
+import com.adyen.checkout.core.exception.ComponentException;
import com.adyen.checkout.core.log.LogUtil;
import com.adyen.checkout.core.log.Logger;
import com.adyen.checkout.core.util.StringUtil;
diff --git a/3ds2/src/main/java/com/adyen/checkout/adyen3ds2/exception/Authentication3DS2Exception.java b/3ds2/src/main/java/com/adyen/checkout/adyen3ds2/exception/Authentication3DS2Exception.java
index 4bc12e6009..0ba72b3842 100644
--- a/3ds2/src/main/java/com/adyen/checkout/adyen3ds2/exception/Authentication3DS2Exception.java
+++ b/3ds2/src/main/java/com/adyen/checkout/adyen3ds2/exception/Authentication3DS2Exception.java
@@ -10,7 +10,7 @@
import android.support.annotation.NonNull;
-import com.adyen.checkout.core.exeption.ComponentException;
+import com.adyen.checkout.core.exception.ComponentException;
/**
* This exception is just an indication that the 3DS2 Authentication did not finish as expected.
diff --git a/3ds2/src/main/java/com/adyen/checkout/adyen3ds2/model/ChallengeToken.java b/3ds2/src/main/java/com/adyen/checkout/adyen3ds2/model/ChallengeToken.java
index 8547e8bc61..92d24343cf 100644
--- a/3ds2/src/main/java/com/adyen/checkout/adyen3ds2/model/ChallengeToken.java
+++ b/3ds2/src/main/java/com/adyen/checkout/adyen3ds2/model/ChallengeToken.java
@@ -12,7 +12,7 @@
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
-import com.adyen.checkout.core.exeption.ModelSerializationException;
+import com.adyen.checkout.core.exception.ModelSerializationException;
import com.adyen.checkout.core.model.JsonUtils;
import com.adyen.checkout.core.model.ModelObject;
diff --git a/3ds2/src/main/java/com/adyen/checkout/adyen3ds2/model/FingerprintToken.java b/3ds2/src/main/java/com/adyen/checkout/adyen3ds2/model/FingerprintToken.java
index d1f39acbab..b14442d8e5 100644
--- a/3ds2/src/main/java/com/adyen/checkout/adyen3ds2/model/FingerprintToken.java
+++ b/3ds2/src/main/java/com/adyen/checkout/adyen3ds2/model/FingerprintToken.java
@@ -12,7 +12,7 @@
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
-import com.adyen.checkout.core.exeption.ModelSerializationException;
+import com.adyen.checkout.core.exception.ModelSerializationException;
import com.adyen.checkout.core.model.JsonUtils;
import com.adyen.checkout.core.model.ModelObject;
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 9ef311ead4..033bf86c5e 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -13,6 +13,19 @@
[//]: <> (Add changes that not released yet into `Unreleased` section)
[//]: <> (Comment `Unreleased` section if there are no changes)
[//]: <> (## [Unreleased])
+## [3.4.1] - 2019-10-07
+### Added
+- MolpayComponents can how handle multiple MolPay PaymentMethods (molpay_ebanking_fpx_MY, molpay_ebanking_TH, molpay_ebanking_VN)
+- You can check which payment methods a Component can handle by calling `getSupportedPaymentMethodTypes()`
+- Added option to show payment Amount on the DropIn pay button.
+### Changed
+- Deprecated `getPaymentMethodType()` in favor of `getSupportedPaymentMethodTypes()`.
+- Merge Loading Activity into DropIn Activity to have single Activity for DropIn component.
+- Configuration interface removed in favor of base class plus minor code improvements.
+### Fixed
+- Add margin left to CardListAdapter's layout.
+- Fixed typo on package `com.adyen.checkout.core.exeption` to `com.adyen.checkout.core.exception`
+
## [3.4.0] - 2019-09-23
### Added
- Created standard style pattern for customizing XML layouts of the Components.
diff --git a/README.md b/README.md
index 4b7aa45696..98e3060cd2 100644
--- a/README.md
+++ b/README.md
@@ -13,11 +13,11 @@ The Components are available through [jcenter][dl], you only need to add the Gra
Import the Component module for the Payment Method you want to use by adding it to your `build.gradle` file.
For example, for the Drop-in solution you should add:
```groovy
-implementation "com.adyen.checkout:drop-in:3.4.0"
+implementation "com.adyen.checkout:drop-in:3.4.1"
```
For a Credit Card component you should add:
```groovy
-implementation "com.adyen.checkout:card-ui:3.4.0"
+implementation "com.adyen.checkout:card-ui:3.4.1"
```
## Drop-in
diff --git a/RELEASE_NOTES b/RELEASE_NOTES
index 5afa41eea8..58d6ce2811 100644
--- a/RELEASE_NOTES
+++ b/RELEASE_NOTES
@@ -1,5 +1,5 @@
-- Created theming structure.
-- Created BCMC component.
-- Bug Fixes.
+- UI Updates
+- Update Molpay component to support Thailand and Vietnam
+- Bug Fixes
diff --git a/base-ui/src/main/java/com/adyen/checkout/base/ComponentView.java b/base-ui/src/main/java/com/adyen/checkout/base/ComponentView.java
index a1fa914c99..93d1394d83 100644
--- a/base-ui/src/main/java/com/adyen/checkout/base/ComponentView.java
+++ b/base-ui/src/main/java/com/adyen/checkout/base/ComponentView.java
@@ -3,7 +3,7 @@
*
* This file is open source and available under the MIT license. See the LICENSE file for more info.
*
- * Created by arman on 20/2/2019.
+ * Created by arman on 30/9/2019.
*/
package com.adyen.checkout.base;
@@ -21,11 +21,30 @@ public interface ComponentView {
/**
* Attach the {@link PaymentComponent} to the view to interact with.
*
- * @param component The component.
+ * @param component The component.
* @param lifecycleOwner The lifecycle owner where the view is.
*/
void attach(@NonNull ComponentT component, @NonNull LifecycleOwner lifecycleOwner);
+ /**
+ * This function will be called when the component got attached to the View.
+ * It's better to init ViewLess objects like ImageLoader here.
+ */
+ void onComponentAttached();
+
+ /**
+ * This function will be called when the component is attached and the view is ready to get initialized.
+ * It's better to find sub views here and add listeners to inputs changes or make the view Visible or Gone depends on the configration of a
+ * component.
+ */
+ void initView();
+
+ /**
+ * This function will be called after the component got attach and the view got initialize.
+ * It's better to Observer on live data objects here.
+ */
+ void observeComponentChanges(@NonNull LifecycleOwner lifecycleOwner);
+
/**
* Tells if the view interaction requires confirmation from the user to start the payment flow.
* Confirmation usually is obtained by a "Pay" button the user need to press to start processing the payment.
diff --git a/base-ui/src/main/java/com/adyen/checkout/base/ui/util/ThemeUtil.java b/base-ui/src/main/java/com/adyen/checkout/base/ui/util/ThemeUtil.java
index e7d9362206..8a6cce8b14 100644
--- a/base-ui/src/main/java/com/adyen/checkout/base/ui/util/ThemeUtil.java
+++ b/base-ui/src/main/java/com/adyen/checkout/base/ui/util/ThemeUtil.java
@@ -16,7 +16,7 @@
import android.util.TypedValue;
import com.adyen.checkout.base.ui.R;
-import com.adyen.checkout.core.exeption.NoConstructorException;
+import com.adyen.checkout.core.exception.NoConstructorException;
public final class ThemeUtil {
diff --git a/base-ui/src/main/java/com/adyen/checkout/base/ui/view/AdyenLinearLayout.java b/base-ui/src/main/java/com/adyen/checkout/base/ui/view/AdyenLinearLayout.java
new file mode 100644
index 0000000000..c04c85ab70
--- /dev/null
+++ b/base-ui/src/main/java/com/adyen/checkout/base/ui/view/AdyenLinearLayout.java
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2019 Adyen N.V.
+ *
+ * This file is open source and available under the MIT license. See the LICENSE file for more info.
+ *
+ * Created by arman on 30/9/2019.
+ */
+
+package com.adyen.checkout.base.ui.view;
+
+import android.arch.lifecycle.LifecycleOwner;
+import android.content.Context;
+import android.support.annotation.NonNull;
+import android.support.annotation.Nullable;
+import android.util.AttributeSet;
+import android.widget.LinearLayout;
+
+import com.adyen.checkout.base.ComponentView;
+import com.adyen.checkout.base.component.BasePaymentComponent;
+
+public abstract class AdyenLinearLayout extends LinearLayout implements
+ ComponentView {
+
+ private ComponentT mComponent;
+
+ public AdyenLinearLayout(@NonNull Context context) {
+ super(context);
+ }
+
+ public AdyenLinearLayout(@NonNull Context context, @Nullable AttributeSet attrs) {
+ super(context, attrs);
+ }
+
+ public AdyenLinearLayout(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
+ super(context, attrs, defStyleAttr);
+ setVisibility(isInEditMode() ? VISIBLE : GONE);
+ }
+
+ @Override
+ public void attach(@NonNull ComponentT component, @NonNull LifecycleOwner lifecycleOwner) {
+ this.mComponent = component;
+
+ this.onComponentAttached();
+ this.initView();
+ setVisibility(VISIBLE);
+ mComponent.sendAnalyticsEvent(getContext());
+ this.observeComponentChanges(lifecycleOwner);
+ }
+
+ @NonNull
+ public ComponentT getComponent() {
+ return mComponent;
+ }
+}
diff --git a/base-v3/src/androidTest/java/com/adyen/checkout/base/util/FilesUtils.java b/base-v3/src/androidTest/java/com/adyen/checkout/base/util/FilesUtils.java
index 084607961e..7767871309 100644
--- a/base-v3/src/androidTest/java/com/adyen/checkout/base/util/FilesUtils.java
+++ b/base-v3/src/androidTest/java/com/adyen/checkout/base/util/FilesUtils.java
@@ -13,7 +13,7 @@
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
-import com.adyen.checkout.core.exeption.NoConstructorException;
+import com.adyen.checkout.core.exception.NoConstructorException;
import java.io.IOException;
import java.io.InputStream;
diff --git a/base-v3/src/main/java/com/adyen/checkout/base/ActionComponentData.java b/base-v3/src/main/java/com/adyen/checkout/base/ActionComponentData.java
index 5fc13030d6..625b000d2e 100644
--- a/base-v3/src/main/java/com/adyen/checkout/base/ActionComponentData.java
+++ b/base-v3/src/main/java/com/adyen/checkout/base/ActionComponentData.java
@@ -12,7 +12,7 @@
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
-import com.adyen.checkout.core.exeption.ModelSerializationException;
+import com.adyen.checkout.core.exception.ModelSerializationException;
import com.adyen.checkout.core.model.JsonUtils;
import com.adyen.checkout.core.model.ModelObject;
diff --git a/base-v3/src/main/java/com/adyen/checkout/base/ComponentAvailableCallback.java b/base-v3/src/main/java/com/adyen/checkout/base/ComponentAvailableCallback.java
index e6f29ef751..93e9931e45 100644
--- a/base-v3/src/main/java/com/adyen/checkout/base/ComponentAvailableCallback.java
+++ b/base-v3/src/main/java/com/adyen/checkout/base/ComponentAvailableCallback.java
@@ -11,6 +11,7 @@
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
+import com.adyen.checkout.base.component.Configuration;
import com.adyen.checkout.base.model.paymentmethods.PaymentMethod;
public interface ComponentAvailableCallback {
diff --git a/base-v3/src/main/java/com/adyen/checkout/base/ComponentError.java b/base-v3/src/main/java/com/adyen/checkout/base/ComponentError.java
index 76135d21ca..1b3dec7a8f 100644
--- a/base-v3/src/main/java/com/adyen/checkout/base/ComponentError.java
+++ b/base-v3/src/main/java/com/adyen/checkout/base/ComponentError.java
@@ -10,7 +10,7 @@
import android.support.annotation.NonNull;
-import com.adyen.checkout.core.exeption.CheckoutException;
+import com.adyen.checkout.core.exception.CheckoutException;
/**
* Data about an error that happened inside a component.
diff --git a/base-v3/src/main/java/com/adyen/checkout/base/Configuration.java b/base-v3/src/main/java/com/adyen/checkout/base/Configuration.java
deleted file mode 100644
index 303f58eb0c..0000000000
--- a/base-v3/src/main/java/com/adyen/checkout/base/Configuration.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright (c) 2019 Adyen N.V.
- *
- * This file is open source and available under the MIT license. See the LICENSE file for more info.
- *
- * Created by caiof on 7/3/2019.
- */
-
-package com.adyen.checkout.base;
-
-import android.support.annotation.NonNull;
-
-import com.adyen.checkout.core.api.Environment;
-
-import java.util.Locale;
-
-/**
- * Configuration class with extra information the merchant can or should provide to change the {@link PaymentComponent} behavior.
- */
-public interface Configuration {
-
- /**
- * Get shopper's locale.
- *
- * @return {@link Locale}
- */
- @NonNull
- Locale getShopperLocale();
-
- /**
- * Get the {@link Environment} to be used for network calls to Adyen.
- *
- * @return The Environment
- */
- @NonNull
- Environment getEnvironment();
-}
diff --git a/base-v3/src/main/java/com/adyen/checkout/base/PaymentComponent.java b/base-v3/src/main/java/com/adyen/checkout/base/PaymentComponent.java
index 1c529f79b9..dcbe244b1d 100644
--- a/base-v3/src/main/java/com/adyen/checkout/base/PaymentComponent.java
+++ b/base-v3/src/main/java/com/adyen/checkout/base/PaymentComponent.java
@@ -23,11 +23,21 @@
public interface PaymentComponent extends Component {
/**
- * @return The "type" of payment method supported by this Component.
+ * @deprecated Use {@link #getSupportedPaymentMethodTypes()} instead with a list of the supported payment method types.
+ * This method will only return the first value of the list.
+ *
+ * @return The first value of "type" of payment method supported by this Component.
*/
+ @Deprecated
@NonNull
String getPaymentMethodType();
+ /**
+ * @return An array of the supported {@link com.adyen.checkout.base.util.PaymentMethodTypes}
+ */
+ @NonNull
+ String[] getSupportedPaymentMethodTypes();
+
/**
* @return The last {@link PaymentComponentState} of this Component.
*/
diff --git a/base-v3/src/main/java/com/adyen/checkout/base/PaymentComponentProvider.java b/base-v3/src/main/java/com/adyen/checkout/base/PaymentComponentProvider.java
index 0c182418e4..bb4eb8c01e 100644
--- a/base-v3/src/main/java/com/adyen/checkout/base/PaymentComponentProvider.java
+++ b/base-v3/src/main/java/com/adyen/checkout/base/PaymentComponentProvider.java
@@ -13,8 +13,9 @@
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
+import com.adyen.checkout.base.component.Configuration;
import com.adyen.checkout.base.model.paymentmethods.PaymentMethod;
-import com.adyen.checkout.core.exeption.CheckoutException;
+import com.adyen.checkout.core.exception.CheckoutException;
public interface PaymentComponentProvider
extends ComponentProvider {
diff --git a/base-v3/src/main/java/com/adyen/checkout/base/analytics/AnalyticEvent.java b/base-v3/src/main/java/com/adyen/checkout/base/analytics/AnalyticEvent.java
index 691af31960..b4de40b311 100644
--- a/base-v3/src/main/java/com/adyen/checkout/base/analytics/AnalyticEvent.java
+++ b/base-v3/src/main/java/com/adyen/checkout/base/analytics/AnalyticEvent.java
@@ -17,7 +17,7 @@
import android.webkit.URLUtil;
import com.adyen.checkout.base.BuildConfig;
-import com.adyen.checkout.core.exeption.CheckoutException;
+import com.adyen.checkout.core.exception.CheckoutException;
import com.adyen.checkout.core.util.LocaleUtil;
import com.adyen.checkout.core.util.ParcelUtils;
diff --git a/base-v3/src/main/java/com/adyen/checkout/base/component/BaseActionComponent.java b/base-v3/src/main/java/com/adyen/checkout/base/component/BaseActionComponent.java
index a0a5712d9e..c86b653f42 100644
--- a/base-v3/src/main/java/com/adyen/checkout/base/component/BaseActionComponent.java
+++ b/base-v3/src/main/java/com/adyen/checkout/base/component/BaseActionComponent.java
@@ -22,8 +22,8 @@
import com.adyen.checkout.base.ActionComponentData;
import com.adyen.checkout.base.ComponentError;
import com.adyen.checkout.base.model.payments.response.Action;
-import com.adyen.checkout.core.exeption.CheckoutException;
-import com.adyen.checkout.core.exeption.ComponentException;
+import com.adyen.checkout.core.exception.CheckoutException;
+import com.adyen.checkout.core.exception.ComponentException;
import com.adyen.checkout.core.log.LogUtil;
import com.adyen.checkout.core.log.Logger;
import com.adyen.checkout.core.util.StringUtil;
diff --git a/base-v3/src/main/java/com/adyen/checkout/base/component/BaseConfigurationBuilder.java b/base-v3/src/main/java/com/adyen/checkout/base/component/BaseConfigurationBuilder.java
index 1962072892..c7c1660b9a 100644
--- a/base-v3/src/main/java/com/adyen/checkout/base/component/BaseConfigurationBuilder.java
+++ b/base-v3/src/main/java/com/adyen/checkout/base/component/BaseConfigurationBuilder.java
@@ -11,7 +11,6 @@
import android.content.Context;
import android.support.annotation.NonNull;
-import com.adyen.checkout.base.Configuration;
import com.adyen.checkout.core.api.Environment;
import com.adyen.checkout.core.util.LocaleUtil;
diff --git a/base-v3/src/main/java/com/adyen/checkout/base/component/BasePaymentComponent.java b/base-v3/src/main/java/com/adyen/checkout/base/component/BasePaymentComponent.java
index ef40824d47..74ce930c34 100644
--- a/base-v3/src/main/java/com/adyen/checkout/base/component/BasePaymentComponent.java
+++ b/base-v3/src/main/java/com/adyen/checkout/base/component/BasePaymentComponent.java
@@ -18,7 +18,6 @@
import android.support.annotation.WorkerThread;
import com.adyen.checkout.base.ComponentError;
-import com.adyen.checkout.base.Configuration;
import com.adyen.checkout.base.PaymentComponentState;
import com.adyen.checkout.base.analytics.AnalyticEvent;
import com.adyen.checkout.base.analytics.AnalyticsDispatcher;
@@ -26,9 +25,10 @@
import com.adyen.checkout.base.model.paymentmethods.PaymentMethod;
import com.adyen.checkout.core.api.ThreadManager;
import com.adyen.checkout.core.code.Lint;
-import com.adyen.checkout.core.exeption.CheckoutException;
+import com.adyen.checkout.core.exception.CheckoutException;
import com.adyen.checkout.core.log.LogUtil;
import com.adyen.checkout.core.log.Logger;
+import com.adyen.checkout.core.util.StringUtil;
public abstract class BasePaymentComponent
extends PaymentComponentViewModel {
@@ -61,6 +61,18 @@ public BasePaymentComponent(@NonNull PaymentMethod paymentMethod, @NonNull Confi
mOutputLiveData.setValue(mOutputData);
}
+ @SuppressWarnings("MissingDeprecated")
+ @Deprecated
+ @NonNull
+ @Override
+ public String getPaymentMethodType() {
+ if (getSupportedPaymentMethodTypes().length > 0) {
+ return getSupportedPaymentMethodTypes()[0];
+ } else {
+ throw new CheckoutException("Component supported types is empty");
+ }
+ }
+
@Override
public void observe(@NonNull LifecycleOwner lifecycleOwner, @NonNull Observer observer) {
mPaymentComponentStateLiveData.observe(lifecycleOwner, observer);
@@ -115,7 +127,12 @@ public void sendAnalyticsEvent(@NonNull Context context) {
flavor = AnalyticEvent.Flavor.COMPONENT;
}
- final AnalyticEvent analyticEvent = AnalyticEvent.create(context, flavor, getPaymentMethodType(), getConfiguration().getShopperLocale());
+ final String type = getPaymentMethod().getType();
+ if (!StringUtil.hasContent(type)) {
+ throw new CheckoutException("Payment method has empty or null type");
+ }
+
+ final AnalyticEvent analyticEvent = AnalyticEvent.create(context, flavor, type, getConfiguration().getShopperLocale());
AnalyticsDispatcher.dispatchEvent(context, getConfiguration().getEnvironment(), analyticEvent);
}
}
@@ -168,7 +185,12 @@ private void assertSupported(@NonNull PaymentMethod paymentMethod) {
}
private boolean isSupported(@NonNull PaymentMethod paymentMethod) {
- return getPaymentMethodType().equals(paymentMethod.getType());
+ for (String paymentMethodType : getSupportedPaymentMethodTypes()) {
+ if (paymentMethodType.equals(paymentMethod.getType())) {
+ return true;
+ }
+ }
+ return false;
}
public void setCreatedForDropIn() {
diff --git a/base-v3/src/main/java/com/adyen/checkout/base/component/BaseConfiguration.java b/base-v3/src/main/java/com/adyen/checkout/base/component/Configuration.java
similarity index 80%
rename from base-v3/src/main/java/com/adyen/checkout/base/component/BaseConfiguration.java
rename to base-v3/src/main/java/com/adyen/checkout/base/component/Configuration.java
index c1adefdc2e..8166c3c086 100644
--- a/base-v3/src/main/java/com/adyen/checkout/base/component/BaseConfiguration.java
+++ b/base-v3/src/main/java/com/adyen/checkout/base/component/Configuration.java
@@ -12,23 +12,22 @@
import android.os.Parcelable;
import android.support.annotation.NonNull;
-import com.adyen.checkout.base.Configuration;
import com.adyen.checkout.core.api.Environment;
import com.adyen.checkout.core.util.ParcelUtils;
import java.util.Locale;
-public abstract class BaseConfiguration implements Configuration, Parcelable {
+public abstract class Configuration implements Parcelable {
private final Locale mShopperLocale;
private final Environment mEnvironment;
- protected BaseConfiguration(@NonNull Locale shopperLocale, @NonNull Environment environment) {
+ protected Configuration(@NonNull Locale shopperLocale, @NonNull Environment environment) {
mShopperLocale = shopperLocale;
mEnvironment = environment;
}
- protected BaseConfiguration(@NonNull Parcel in) {
+ protected Configuration(@NonNull Parcel in) {
mShopperLocale = (Locale) in.readSerializable();
mEnvironment = in.readParcelable(Environment.class.getClassLoader());
}
@@ -39,7 +38,6 @@ public Environment getEnvironment() {
}
@NonNull
- @Override
public Locale getShopperLocale() {
return mShopperLocale;
}
diff --git a/base-v3/src/main/java/com/adyen/checkout/base/component/PaymentComponentProviderImpl.java b/base-v3/src/main/java/com/adyen/checkout/base/component/PaymentComponentProviderImpl.java
index 3061fa1978..27f40147ff 100644
--- a/base-v3/src/main/java/com/adyen/checkout/base/component/PaymentComponentProviderImpl.java
+++ b/base-v3/src/main/java/com/adyen/checkout/base/component/PaymentComponentProviderImpl.java
@@ -15,11 +15,10 @@
import android.support.v4.app.FragmentActivity;
import com.adyen.checkout.base.ComponentAvailableCallback;
-import com.adyen.checkout.base.Configuration;
import com.adyen.checkout.base.PaymentComponentProvider;
import com.adyen.checkout.base.component.lifecycle.ComponentViewModelFactory;
import com.adyen.checkout.base.model.paymentmethods.PaymentMethod;
-import com.adyen.checkout.core.exeption.CheckoutException;
+import com.adyen.checkout.core.exception.CheckoutException;
public final class PaymentComponentProviderImpl
implements PaymentComponentProvider {
diff --git a/base-v3/src/main/java/com/adyen/checkout/base/component/lifecycle/ComponentViewModelFactory.java b/base-v3/src/main/java/com/adyen/checkout/base/component/lifecycle/ComponentViewModelFactory.java
index 6d24645ad7..8126d6e503 100644
--- a/base-v3/src/main/java/com/adyen/checkout/base/component/lifecycle/ComponentViewModelFactory.java
+++ b/base-v3/src/main/java/com/adyen/checkout/base/component/lifecycle/ComponentViewModelFactory.java
@@ -12,7 +12,7 @@
import android.arch.lifecycle.ViewModelProvider;
import android.support.annotation.NonNull;
-import com.adyen.checkout.base.Configuration;
+import com.adyen.checkout.base.component.Configuration;
import com.adyen.checkout.base.model.paymentmethods.PaymentMethod;
public final class ComponentViewModelFactory implements ViewModelProvider.Factory {
diff --git a/base-v3/src/main/java/com/adyen/checkout/base/component/lifecycle/PaymentComponentViewModel.java b/base-v3/src/main/java/com/adyen/checkout/base/component/lifecycle/PaymentComponentViewModel.java
index f946a1aef7..c06184d0dc 100644
--- a/base-v3/src/main/java/com/adyen/checkout/base/component/lifecycle/PaymentComponentViewModel.java
+++ b/base-v3/src/main/java/com/adyen/checkout/base/component/lifecycle/PaymentComponentViewModel.java
@@ -11,8 +11,8 @@
import android.arch.lifecycle.ViewModel;
import android.support.annotation.NonNull;
-import com.adyen.checkout.base.Configuration;
import com.adyen.checkout.base.PaymentComponent;
+import com.adyen.checkout.base.component.Configuration;
import com.adyen.checkout.base.model.paymentmethods.PaymentMethod;
public abstract class PaymentComponentViewModel extends ViewModel implements PaymentComponent {
@@ -27,7 +27,7 @@ public PaymentComponentViewModel(@NonNull PaymentMethod paymentMethod, @NonNull
}
@NonNull
- protected PaymentMethod getPaymentMethod() {
+ public PaymentMethod getPaymentMethod() {
return mPaymentMethod;
}
diff --git a/base-v3/src/main/java/com/adyen/checkout/base/encoding/Base64Encoder.java b/base-v3/src/main/java/com/adyen/checkout/base/encoding/Base64Encoder.java
index 112e349a4d..d714c8f291 100644
--- a/base-v3/src/main/java/com/adyen/checkout/base/encoding/Base64Encoder.java
+++ b/base-v3/src/main/java/com/adyen/checkout/base/encoding/Base64Encoder.java
@@ -11,7 +11,7 @@
import android.support.annotation.NonNull;
import android.util.Base64;
-import com.adyen.checkout.core.exeption.NoConstructorException;
+import com.adyen.checkout.core.exception.NoConstructorException;
import java.nio.charset.Charset;
diff --git a/base-v3/src/main/java/com/adyen/checkout/base/model/PaymentMethodsApiResponse.java b/base-v3/src/main/java/com/adyen/checkout/base/model/PaymentMethodsApiResponse.java
index 59ab8ff316..ce64b0c6fd 100644
--- a/base-v3/src/main/java/com/adyen/checkout/base/model/PaymentMethodsApiResponse.java
+++ b/base-v3/src/main/java/com/adyen/checkout/base/model/PaymentMethodsApiResponse.java
@@ -15,7 +15,7 @@
import com.adyen.checkout.base.model.paymentmethods.PaymentMethod;
import com.adyen.checkout.base.model.paymentmethods.PaymentMethodsGroup;
import com.adyen.checkout.base.model.paymentmethods.RecurringDetail;
-import com.adyen.checkout.core.exeption.ModelSerializationException;
+import com.adyen.checkout.core.exception.ModelSerializationException;
import com.adyen.checkout.core.model.JsonUtils;
import com.adyen.checkout.core.model.ModelObject;
import com.adyen.checkout.core.model.ModelUtils;
diff --git a/base-v3/src/main/java/com/adyen/checkout/base/model/paymentmethods/Bank.java b/base-v3/src/main/java/com/adyen/checkout/base/model/paymentmethods/Bank.java
index cb16d56ae1..3c3a78fb7d 100644
--- a/base-v3/src/main/java/com/adyen/checkout/base/model/paymentmethods/Bank.java
+++ b/base-v3/src/main/java/com/adyen/checkout/base/model/paymentmethods/Bank.java
@@ -12,7 +12,7 @@
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
-import com.adyen.checkout.core.exeption.ModelSerializationException;
+import com.adyen.checkout.core.exception.ModelSerializationException;
import com.adyen.checkout.core.model.JsonUtils;
import com.adyen.checkout.core.model.ModelObject;
diff --git a/base-v3/src/main/java/com/adyen/checkout/base/model/paymentmethods/Card.java b/base-v3/src/main/java/com/adyen/checkout/base/model/paymentmethods/Card.java
index 409aa6ac49..23694bb6f9 100644
--- a/base-v3/src/main/java/com/adyen/checkout/base/model/paymentmethods/Card.java
+++ b/base-v3/src/main/java/com/adyen/checkout/base/model/paymentmethods/Card.java
@@ -12,7 +12,7 @@
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
-import com.adyen.checkout.core.exeption.ModelSerializationException;
+import com.adyen.checkout.core.exception.ModelSerializationException;
import com.adyen.checkout.core.model.JsonUtils;
import com.adyen.checkout.core.model.ModelObject;
diff --git a/base-v3/src/main/java/com/adyen/checkout/base/model/paymentmethods/Group.java b/base-v3/src/main/java/com/adyen/checkout/base/model/paymentmethods/Group.java
index d9a5922881..ee596eb4b0 100644
--- a/base-v3/src/main/java/com/adyen/checkout/base/model/paymentmethods/Group.java
+++ b/base-v3/src/main/java/com/adyen/checkout/base/model/paymentmethods/Group.java
@@ -12,7 +12,7 @@
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
-import com.adyen.checkout.core.exeption.ModelSerializationException;
+import com.adyen.checkout.core.exception.ModelSerializationException;
import com.adyen.checkout.core.model.JsonUtils;
import com.adyen.checkout.core.model.ModelObject;
diff --git a/base-v3/src/main/java/com/adyen/checkout/base/model/paymentmethods/InputDetail.java b/base-v3/src/main/java/com/adyen/checkout/base/model/paymentmethods/InputDetail.java
index 8964a83f5d..97ba3078be 100644
--- a/base-v3/src/main/java/com/adyen/checkout/base/model/paymentmethods/InputDetail.java
+++ b/base-v3/src/main/java/com/adyen/checkout/base/model/paymentmethods/InputDetail.java
@@ -12,7 +12,7 @@
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
-import com.adyen.checkout.core.exeption.ModelSerializationException;
+import com.adyen.checkout.core.exception.ModelSerializationException;
import com.adyen.checkout.core.model.JsonUtils;
import com.adyen.checkout.core.model.ModelObject;
import com.adyen.checkout.core.model.ModelUtils;
diff --git a/base-v3/src/main/java/com/adyen/checkout/base/model/paymentmethods/Item.java b/base-v3/src/main/java/com/adyen/checkout/base/model/paymentmethods/Item.java
index b7635b043c..f225c88e71 100644
--- a/base-v3/src/main/java/com/adyen/checkout/base/model/paymentmethods/Item.java
+++ b/base-v3/src/main/java/com/adyen/checkout/base/model/paymentmethods/Item.java
@@ -12,7 +12,7 @@
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
-import com.adyen.checkout.core.exeption.ModelSerializationException;
+import com.adyen.checkout.core.exception.ModelSerializationException;
import com.adyen.checkout.core.model.JsonUtils;
import com.adyen.checkout.core.model.ModelObject;
diff --git a/base-v3/src/main/java/com/adyen/checkout/base/model/paymentmethods/PaymentMethod.java b/base-v3/src/main/java/com/adyen/checkout/base/model/paymentmethods/PaymentMethod.java
index 7f5abe2786..05b80aff52 100644
--- a/base-v3/src/main/java/com/adyen/checkout/base/model/paymentmethods/PaymentMethod.java
+++ b/base-v3/src/main/java/com/adyen/checkout/base/model/paymentmethods/PaymentMethod.java
@@ -12,7 +12,7 @@
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
-import com.adyen.checkout.core.exeption.ModelSerializationException;
+import com.adyen.checkout.core.exception.ModelSerializationException;
import com.adyen.checkout.core.model.JsonUtils;
import com.adyen.checkout.core.model.ModelObject;
import com.adyen.checkout.core.model.ModelUtils;
diff --git a/base-v3/src/main/java/com/adyen/checkout/base/model/paymentmethods/PaymentMethodsGroup.java b/base-v3/src/main/java/com/adyen/checkout/base/model/paymentmethods/PaymentMethodsGroup.java
index bd593e23e7..6e2fbf6057 100644
--- a/base-v3/src/main/java/com/adyen/checkout/base/model/paymentmethods/PaymentMethodsGroup.java
+++ b/base-v3/src/main/java/com/adyen/checkout/base/model/paymentmethods/PaymentMethodsGroup.java
@@ -12,7 +12,7 @@
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
-import com.adyen.checkout.core.exeption.ModelSerializationException;
+import com.adyen.checkout.core.exception.ModelSerializationException;
import com.adyen.checkout.core.model.JsonUtils;
import com.adyen.checkout.core.model.ModelObject;
diff --git a/base-v3/src/main/java/com/adyen/checkout/base/model/paymentmethods/RecurringDetail.java b/base-v3/src/main/java/com/adyen/checkout/base/model/paymentmethods/RecurringDetail.java
index 77314fe2b6..dff1a07f2f 100644
--- a/base-v3/src/main/java/com/adyen/checkout/base/model/paymentmethods/RecurringDetail.java
+++ b/base-v3/src/main/java/com/adyen/checkout/base/model/paymentmethods/RecurringDetail.java
@@ -12,7 +12,7 @@
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
-import com.adyen.checkout.core.exeption.ModelSerializationException;
+import com.adyen.checkout.core.exception.ModelSerializationException;
import com.adyen.checkout.core.model.JsonUtils;
import org.json.JSONArray;
diff --git a/base-v3/src/main/java/com/adyen/checkout/base/model/paymentmethods/StoredDetails.java b/base-v3/src/main/java/com/adyen/checkout/base/model/paymentmethods/StoredDetails.java
index e72c6ac742..c8041e67a7 100644
--- a/base-v3/src/main/java/com/adyen/checkout/base/model/paymentmethods/StoredDetails.java
+++ b/base-v3/src/main/java/com/adyen/checkout/base/model/paymentmethods/StoredDetails.java
@@ -12,7 +12,7 @@
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
-import com.adyen.checkout.core.exeption.ModelSerializationException;
+import com.adyen.checkout.core.exception.ModelSerializationException;
import com.adyen.checkout.core.model.JsonUtils;
import com.adyen.checkout.core.model.ModelObject;
import com.adyen.checkout.core.model.ModelUtils;
diff --git a/base-v3/src/main/java/com/adyen/checkout/base/model/payments/Amount.java b/base-v3/src/main/java/com/adyen/checkout/base/model/payments/Amount.java
index 6fcd581388..cec5f8e093 100644
--- a/base-v3/src/main/java/com/adyen/checkout/base/model/payments/Amount.java
+++ b/base-v3/src/main/java/com/adyen/checkout/base/model/payments/Amount.java
@@ -12,19 +12,31 @@
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
-import com.adyen.checkout.core.exeption.ModelSerializationException;
+import com.adyen.checkout.core.exception.ModelSerializationException;
import com.adyen.checkout.core.model.JsonUtils;
import com.adyen.checkout.core.model.ModelObject;
import org.json.JSONException;
import org.json.JSONObject;
-@SuppressWarnings("MemberName")
+@SuppressWarnings({"MemberName", "PMD.DataClass"})
public class Amount extends ModelObject {
@NonNull
public static final Creator CREATOR = new Creator<>(Amount.class);
+ @NonNull
+ public static final Amount EMPTY;
+
+ private static final String EMPTY_CURRENCY = "NONE";
+ private static final int EMPTY_VALUE = -1;
+
+ static {
+ EMPTY = new Amount();
+ EMPTY.setCurrency(EMPTY_CURRENCY);
+ EMPTY.setValue(EMPTY_VALUE);
+ }
+
private static final String CURRENCY = "currency";
private static final String VALUE = "value";
@@ -71,12 +83,15 @@ public void setCurrency(@Nullable String currency) {
this.currency = currency;
}
- @Nullable
public int getValue() {
return value;
}
- public void setValue(@Nullable int value) {
+ public void setValue(int value) {
this.value = value;
}
+
+ public boolean isEmpty() {
+ return EMPTY_CURRENCY.equals(currency) || value == EMPTY_VALUE;
+ }
}
diff --git a/base-v3/src/main/java/com/adyen/checkout/base/model/payments/request/CardPaymentMethod.java b/base-v3/src/main/java/com/adyen/checkout/base/model/payments/request/CardPaymentMethod.java
index 508e534a76..8d5bc256a2 100644
--- a/base-v3/src/main/java/com/adyen/checkout/base/model/payments/request/CardPaymentMethod.java
+++ b/base-v3/src/main/java/com/adyen/checkout/base/model/payments/request/CardPaymentMethod.java
@@ -13,7 +13,7 @@
import android.support.annotation.Nullable;
import com.adyen.checkout.base.util.PaymentMethodTypes;
-import com.adyen.checkout.core.exeption.ModelSerializationException;
+import com.adyen.checkout.core.exception.ModelSerializationException;
import com.adyen.checkout.core.model.JsonUtils;
import org.json.JSONException;
diff --git a/base-v3/src/main/java/com/adyen/checkout/base/model/payments/request/DotpayPaymentMethod.java b/base-v3/src/main/java/com/adyen/checkout/base/model/payments/request/DotpayPaymentMethod.java
index 69087e95e6..39bc25bf26 100644
--- a/base-v3/src/main/java/com/adyen/checkout/base/model/payments/request/DotpayPaymentMethod.java
+++ b/base-v3/src/main/java/com/adyen/checkout/base/model/payments/request/DotpayPaymentMethod.java
@@ -12,7 +12,7 @@
import android.support.annotation.NonNull;
import com.adyen.checkout.base.util.PaymentMethodTypes;
-import com.adyen.checkout.core.exeption.ModelSerializationException;
+import com.adyen.checkout.core.exception.ModelSerializationException;
import com.adyen.checkout.core.model.JsonUtils;
import org.json.JSONException;
diff --git a/base-v3/src/main/java/com/adyen/checkout/base/model/payments/request/EPSPaymentMethod.java b/base-v3/src/main/java/com/adyen/checkout/base/model/payments/request/EPSPaymentMethod.java
index 40932f1f34..42eed93b99 100644
--- a/base-v3/src/main/java/com/adyen/checkout/base/model/payments/request/EPSPaymentMethod.java
+++ b/base-v3/src/main/java/com/adyen/checkout/base/model/payments/request/EPSPaymentMethod.java
@@ -12,7 +12,7 @@
import android.support.annotation.NonNull;
import com.adyen.checkout.base.util.PaymentMethodTypes;
-import com.adyen.checkout.core.exeption.ModelSerializationException;
+import com.adyen.checkout.core.exception.ModelSerializationException;
import com.adyen.checkout.core.model.JsonUtils;
import org.json.JSONException;
diff --git a/base-v3/src/main/java/com/adyen/checkout/base/model/payments/request/EntercashPaymentMethod.java b/base-v3/src/main/java/com/adyen/checkout/base/model/payments/request/EntercashPaymentMethod.java
index 18efe98f74..7bc23d3ab3 100644
--- a/base-v3/src/main/java/com/adyen/checkout/base/model/payments/request/EntercashPaymentMethod.java
+++ b/base-v3/src/main/java/com/adyen/checkout/base/model/payments/request/EntercashPaymentMethod.java
@@ -12,7 +12,7 @@
import android.support.annotation.NonNull;
import com.adyen.checkout.base.util.PaymentMethodTypes;
-import com.adyen.checkout.core.exeption.ModelSerializationException;
+import com.adyen.checkout.core.exception.ModelSerializationException;
import com.adyen.checkout.core.model.JsonUtils;
import org.json.JSONException;
diff --git a/base-v3/src/main/java/com/adyen/checkout/base/model/payments/request/GenericPaymentMethod.java b/base-v3/src/main/java/com/adyen/checkout/base/model/payments/request/GenericPaymentMethod.java
index 7d24567365..13fa04fffa 100644
--- a/base-v3/src/main/java/com/adyen/checkout/base/model/payments/request/GenericPaymentMethod.java
+++ b/base-v3/src/main/java/com/adyen/checkout/base/model/payments/request/GenericPaymentMethod.java
@@ -12,7 +12,7 @@
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
-import com.adyen.checkout.core.exeption.ModelSerializationException;
+import com.adyen.checkout.core.exception.ModelSerializationException;
import com.adyen.checkout.core.model.JsonUtils;
import org.json.JSONException;
diff --git a/base-v3/src/main/java/com/adyen/checkout/base/model/payments/request/GooglePayPaymentMethod.java b/base-v3/src/main/java/com/adyen/checkout/base/model/payments/request/GooglePayPaymentMethod.java
index 365e56d1c9..4ea3676e18 100644
--- a/base-v3/src/main/java/com/adyen/checkout/base/model/payments/request/GooglePayPaymentMethod.java
+++ b/base-v3/src/main/java/com/adyen/checkout/base/model/payments/request/GooglePayPaymentMethod.java
@@ -13,7 +13,7 @@
import android.support.annotation.Nullable;
import com.adyen.checkout.base.util.PaymentMethodTypes;
-import com.adyen.checkout.core.exeption.ModelSerializationException;
+import com.adyen.checkout.core.exception.ModelSerializationException;
import com.adyen.checkout.core.model.JsonUtils;
import org.json.JSONException;
diff --git a/base-v3/src/main/java/com/adyen/checkout/base/model/payments/request/IdealPaymentMethod.java b/base-v3/src/main/java/com/adyen/checkout/base/model/payments/request/IdealPaymentMethod.java
index de01e9b0cf..e16677e4e9 100644
--- a/base-v3/src/main/java/com/adyen/checkout/base/model/payments/request/IdealPaymentMethod.java
+++ b/base-v3/src/main/java/com/adyen/checkout/base/model/payments/request/IdealPaymentMethod.java
@@ -11,7 +11,7 @@
import android.os.Parcel;
import android.support.annotation.NonNull;
-import com.adyen.checkout.core.exeption.ModelSerializationException;
+import com.adyen.checkout.core.exception.ModelSerializationException;
import com.adyen.checkout.core.model.JsonUtils;
import org.json.JSONException;
diff --git a/base-v3/src/main/java/com/adyen/checkout/base/model/payments/request/MolpayPaymentMethod.java b/base-v3/src/main/java/com/adyen/checkout/base/model/payments/request/MolpayPaymentMethod.java
index e38188e37d..e4a10f9bd0 100644
--- a/base-v3/src/main/java/com/adyen/checkout/base/model/payments/request/MolpayPaymentMethod.java
+++ b/base-v3/src/main/java/com/adyen/checkout/base/model/payments/request/MolpayPaymentMethod.java
@@ -11,8 +11,7 @@
import android.os.Parcel;
import android.support.annotation.NonNull;
-import com.adyen.checkout.base.util.PaymentMethodTypes;
-import com.adyen.checkout.core.exeption.ModelSerializationException;
+import com.adyen.checkout.core.exception.ModelSerializationException;
import com.adyen.checkout.core.model.JsonUtils;
import org.json.JSONException;
@@ -22,7 +21,7 @@ public final class MolpayPaymentMethod extends IssuerListPaymentMethod {
@NonNull
public static final Creator CREATOR = new Creator<>(MolpayPaymentMethod.class);
- public static final String PAYMENT_METHOD_TYPE = PaymentMethodTypes.MOLPAY;
+ // TODO: 2019-09-26 refactor SERIALIZER of parent to support multiple TxVariants
@NonNull
public static final Serializer SERIALIZER = new Serializer() {
diff --git a/base-v3/src/main/java/com/adyen/checkout/base/model/payments/request/OpenBankingPaymentMethod.java b/base-v3/src/main/java/com/adyen/checkout/base/model/payments/request/OpenBankingPaymentMethod.java
index d818d2b1ac..11bdaf7962 100644
--- a/base-v3/src/main/java/com/adyen/checkout/base/model/payments/request/OpenBankingPaymentMethod.java
+++ b/base-v3/src/main/java/com/adyen/checkout/base/model/payments/request/OpenBankingPaymentMethod.java
@@ -12,7 +12,7 @@
import android.support.annotation.NonNull;
import com.adyen.checkout.base.util.PaymentMethodTypes;
-import com.adyen.checkout.core.exeption.ModelSerializationException;
+import com.adyen.checkout.core.exception.ModelSerializationException;
import com.adyen.checkout.core.model.JsonUtils;
import org.json.JSONException;
diff --git a/base-v3/src/main/java/com/adyen/checkout/base/model/payments/request/PaymentComponentData.java b/base-v3/src/main/java/com/adyen/checkout/base/model/payments/request/PaymentComponentData.java
index 34504d2bef..154cb6afd0 100644
--- a/base-v3/src/main/java/com/adyen/checkout/base/model/payments/request/PaymentComponentData.java
+++ b/base-v3/src/main/java/com/adyen/checkout/base/model/payments/request/PaymentComponentData.java
@@ -12,7 +12,7 @@
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
-import com.adyen.checkout.core.exeption.ModelSerializationException;
+import com.adyen.checkout.core.exception.ModelSerializationException;
import com.adyen.checkout.core.model.JsonUtils;
import com.adyen.checkout.core.model.ModelObject;
import com.adyen.checkout.core.model.ModelUtils;
diff --git a/base-v3/src/main/java/com/adyen/checkout/base/model/payments/request/PaymentMethodDetails.java b/base-v3/src/main/java/com/adyen/checkout/base/model/payments/request/PaymentMethodDetails.java
index d6210abd29..205ae91192 100644
--- a/base-v3/src/main/java/com/adyen/checkout/base/model/payments/request/PaymentMethodDetails.java
+++ b/base-v3/src/main/java/com/adyen/checkout/base/model/payments/request/PaymentMethodDetails.java
@@ -11,8 +11,9 @@
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
+import com.adyen.checkout.base.util.PaymentMethodTypes;
import com.adyen.checkout.core.code.Lint;
-import com.adyen.checkout.core.exeption.CheckoutException;
+import com.adyen.checkout.core.exception.CheckoutException;
import com.adyen.checkout.core.model.ModelObject;
import com.adyen.checkout.core.util.StringUtil;
@@ -68,7 +69,10 @@ static Serializer extends PaymentMethodDetails> getChildSerializer(@NonNull St
return IdealPaymentMethod.SERIALIZER;
case CardPaymentMethod.PAYMENT_METHOD_TYPE:
return CardPaymentMethod.SERIALIZER;
- case MolpayPaymentMethod.PAYMENT_METHOD_TYPE:
+ //Intentional fallthrough of different flavors o Molpay
+ case PaymentMethodTypes.MOLPAY_MALAYSIA:
+ case PaymentMethodTypes.MOLPAY_THAILAND:
+ case PaymentMethodTypes.MOLPAY_VIETNAM:
return MolpayPaymentMethod.SERIALIZER;
case DotpayPaymentMethod.PAYMENT_METHOD_TYPE:
return DotpayPaymentMethod.SERIALIZER;
diff --git a/base-v3/src/main/java/com/adyen/checkout/base/model/payments/request/SepaPaymentMethod.java b/base-v3/src/main/java/com/adyen/checkout/base/model/payments/request/SepaPaymentMethod.java
index d1185f1d65..09933b2556 100644
--- a/base-v3/src/main/java/com/adyen/checkout/base/model/payments/request/SepaPaymentMethod.java
+++ b/base-v3/src/main/java/com/adyen/checkout/base/model/payments/request/SepaPaymentMethod.java
@@ -13,7 +13,7 @@
import android.support.annotation.Nullable;
import com.adyen.checkout.base.util.PaymentMethodTypes;
-import com.adyen.checkout.core.exeption.ModelSerializationException;
+import com.adyen.checkout.core.exception.ModelSerializationException;
import com.adyen.checkout.core.model.JsonUtils;
import org.json.JSONException;
diff --git a/base-v3/src/main/java/com/adyen/checkout/base/model/payments/response/Action.java b/base-v3/src/main/java/com/adyen/checkout/base/model/payments/response/Action.java
index eeec694040..79fea157f5 100644
--- a/base-v3/src/main/java/com/adyen/checkout/base/model/payments/response/Action.java
+++ b/base-v3/src/main/java/com/adyen/checkout/base/model/payments/response/Action.java
@@ -12,7 +12,7 @@
import android.support.annotation.Nullable;
import com.adyen.checkout.core.code.Lint;
-import com.adyen.checkout.core.exeption.CheckoutException;
+import com.adyen.checkout.core.exception.CheckoutException;
import com.adyen.checkout.core.model.ModelObject;
import com.adyen.checkout.core.util.StringUtil;
diff --git a/base-v3/src/main/java/com/adyen/checkout/base/model/payments/response/QrCodeAction.java b/base-v3/src/main/java/com/adyen/checkout/base/model/payments/response/QrCodeAction.java
index 025bd5a04d..7e3bf16086 100644
--- a/base-v3/src/main/java/com/adyen/checkout/base/model/payments/response/QrCodeAction.java
+++ b/base-v3/src/main/java/com/adyen/checkout/base/model/payments/response/QrCodeAction.java
@@ -12,7 +12,7 @@
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
-import com.adyen.checkout.core.exeption.ModelSerializationException;
+import com.adyen.checkout.core.exception.ModelSerializationException;
import com.adyen.checkout.core.model.JsonUtils;
import org.json.JSONException;
diff --git a/base-v3/src/main/java/com/adyen/checkout/base/model/payments/response/RedirectAction.java b/base-v3/src/main/java/com/adyen/checkout/base/model/payments/response/RedirectAction.java
index 2274fdc307..8d966142c1 100644
--- a/base-v3/src/main/java/com/adyen/checkout/base/model/payments/response/RedirectAction.java
+++ b/base-v3/src/main/java/com/adyen/checkout/base/model/payments/response/RedirectAction.java
@@ -12,7 +12,7 @@
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
-import com.adyen.checkout.core.exeption.ModelSerializationException;
+import com.adyen.checkout.core.exception.ModelSerializationException;
import com.adyen.checkout.core.model.JsonUtils;
import org.json.JSONException;
diff --git a/base-v3/src/main/java/com/adyen/checkout/base/model/payments/response/Threeds2ChallengeAction.java b/base-v3/src/main/java/com/adyen/checkout/base/model/payments/response/Threeds2ChallengeAction.java
index 33429148d2..80f2237429 100644
--- a/base-v3/src/main/java/com/adyen/checkout/base/model/payments/response/Threeds2ChallengeAction.java
+++ b/base-v3/src/main/java/com/adyen/checkout/base/model/payments/response/Threeds2ChallengeAction.java
@@ -12,7 +12,7 @@
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
-import com.adyen.checkout.core.exeption.ModelSerializationException;
+import com.adyen.checkout.core.exception.ModelSerializationException;
import com.adyen.checkout.core.model.JsonUtils;
import org.json.JSONException;
diff --git a/base-v3/src/main/java/com/adyen/checkout/base/model/payments/response/Threeds2FingerprintAction.java b/base-v3/src/main/java/com/adyen/checkout/base/model/payments/response/Threeds2FingerprintAction.java
index 6d0f624edd..30981d7c34 100644
--- a/base-v3/src/main/java/com/adyen/checkout/base/model/payments/response/Threeds2FingerprintAction.java
+++ b/base-v3/src/main/java/com/adyen/checkout/base/model/payments/response/Threeds2FingerprintAction.java
@@ -12,7 +12,7 @@
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
-import com.adyen.checkout.core.exeption.ModelSerializationException;
+import com.adyen.checkout.core.exception.ModelSerializationException;
import com.adyen.checkout.core.model.JsonUtils;
import org.json.JSONException;
diff --git a/base-v3/src/main/java/com/adyen/checkout/base/model/payments/response/VoucherAction.java b/base-v3/src/main/java/com/adyen/checkout/base/model/payments/response/VoucherAction.java
index 124816b748..c2584c8831 100644
--- a/base-v3/src/main/java/com/adyen/checkout/base/model/payments/response/VoucherAction.java
+++ b/base-v3/src/main/java/com/adyen/checkout/base/model/payments/response/VoucherAction.java
@@ -13,7 +13,7 @@
import android.support.annotation.Nullable;
import com.adyen.checkout.base.model.payments.Amount;
-import com.adyen.checkout.core.exeption.ModelSerializationException;
+import com.adyen.checkout.core.exception.ModelSerializationException;
import com.adyen.checkout.core.model.JsonUtils;
import com.adyen.checkout.core.model.ModelUtils;
diff --git a/base-v3/src/main/java/com/adyen/checkout/base/util/AmountFormat.java b/base-v3/src/main/java/com/adyen/checkout/base/util/AmountFormat.java
index a3f8e5bdd8..330f81ddf9 100644
--- a/base-v3/src/main/java/com/adyen/checkout/base/util/AmountFormat.java
+++ b/base-v3/src/main/java/com/adyen/checkout/base/util/AmountFormat.java
@@ -11,7 +11,8 @@
import android.support.annotation.NonNull;
import com.adyen.checkout.base.model.payments.Amount;
-import com.adyen.checkout.core.exeption.NoConstructorException;
+import com.adyen.checkout.core.exception.CheckoutException;
+import com.adyen.checkout.core.exception.NoConstructorException;
import com.adyen.checkout.core.log.LogUtil;
import com.adyen.checkout.core.log.Logger;
@@ -51,10 +52,10 @@ private static int getFractionDigits(@NonNull String currencyCode) {
final String normalizedCurrencyCode = currencyCode.replaceAll("[^A-Z]", "").toUpperCase(Locale.ROOT);
try {
- final CheckoutCurrency checkoutCurrency = CheckoutCurrency.valueOf(normalizedCurrencyCode);
+ final CheckoutCurrency checkoutCurrency = CheckoutCurrency.find(normalizedCurrencyCode);
return checkoutCurrency.getFractionDigits();
- } catch (IllegalArgumentException e) {
- Logger.e(TAG, normalizedCurrencyCode + " is an unsupported currency. Falling back to information from java.util.Currency.");
+ } catch (CheckoutException e) {
+ Logger.e(TAG, normalizedCurrencyCode + " is an unsupported currency. Falling back to information from java.util.Currency.", e);
}
try {
diff --git a/base-v3/src/main/java/com/adyen/checkout/base/util/CheckoutCurrency.java b/base-v3/src/main/java/com/adyen/checkout/base/util/CheckoutCurrency.java
index f835bf5072..cd67aae385 100644
--- a/base-v3/src/main/java/com/adyen/checkout/base/util/CheckoutCurrency.java
+++ b/base-v3/src/main/java/com/adyen/checkout/base/util/CheckoutCurrency.java
@@ -8,6 +8,15 @@
package com.adyen.checkout.base.util;
+import android.support.annotation.NonNull;
+import android.support.annotation.Nullable;
+
+import com.adyen.checkout.core.util.StringUtil;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
/**
* Utility class holding currency information.
* @see Adyen currency codes
@@ -152,8 +161,40 @@ public enum CheckoutCurrency {
ZAR(2),
ZMW(2);
+ private static final Map CURRENCIES_HASHMAP;
+ static {
+ final HashMap hashMap = new HashMap<>();
+ for (CheckoutCurrency checkoutCurrency : CheckoutCurrency.values()) {
+ hashMap.put(checkoutCurrency.name(), checkoutCurrency);
+ }
+ CURRENCIES_HASHMAP = Collections.unmodifiableMap(hashMap);
+ }
+
private final int mFractionDigits;
+ /**
+ * Check if the currency code is supported by Adyen.
+ *
+ * @param currency the 3 letter code of the currency.
+ * @return if the currency exists and is supported by Adyen
+ */
+ public static boolean isSupported(@Nullable String currency) {
+ return StringUtil.hasContent(currency) && CURRENCIES_HASHMAP.containsKey(currency);
+ }
+
+ /**
+ * Find the instance of {@link CheckoutCurrency} based on the currency code.
+ *
+ * @param currency The currency code.
+ * @return The CheckoutCurrency instance, or throws a {@link com.adyen.checkout.core.exeption.CheckoutException} if the code is not supported.
+ */
+ @NonNull
+ public static CheckoutCurrency find(@Nullable String currency) {
+ CurrencyUtils.assertCurrency(currency);
+ //noinspection ConstantConditions
+ return CURRENCIES_HASHMAP.get(currency);
+ }
+
CheckoutCurrency(int fractionDigits) {
mFractionDigits = fractionDigits;
}
diff --git a/base-v3/src/main/java/com/adyen/checkout/base/util/CurrencyUtils.java b/base-v3/src/main/java/com/adyen/checkout/base/util/CurrencyUtils.java
new file mode 100644
index 0000000000..a233814665
--- /dev/null
+++ b/base-v3/src/main/java/com/adyen/checkout/base/util/CurrencyUtils.java
@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 2019 Adyen N.V.
+ *
+ * This file is open source and available under the MIT license. See the LICENSE file for more info.
+ *
+ * Created by caiof on 30/9/2019.
+ */
+
+package com.adyen.checkout.base.util;
+
+import android.support.annotation.NonNull;
+import android.support.annotation.Nullable;
+
+import com.adyen.checkout.base.model.payments.Amount;
+import com.adyen.checkout.core.exception.CheckoutException;
+import com.adyen.checkout.core.exception.NoConstructorException;
+import com.adyen.checkout.core.log.LogUtil;
+
+import java.math.BigDecimal;
+import java.text.DecimalFormat;
+import java.text.NumberFormat;
+import java.util.Currency;
+import java.util.Locale;
+
+public final class CurrencyUtils {
+ public static final String TAG = LogUtil.getTag();
+
+ /**
+ * Format the {@link Amount} to be displayed to the user based on the Locale.
+ *
+ * @param amount The amount with currency and value.
+ * @param locale The locale the amount will be formatted with.
+ * @return A formatted string displaying currency and value.
+ */
+ @NonNull
+ public static String formatAmount(@NonNull Amount amount, @NonNull Locale locale) {
+
+ final String currencyCode = amount.getCurrency();
+ final CheckoutCurrency checkoutCurrency = CheckoutCurrency.find(currencyCode);
+
+ final Currency currency = Currency.getInstance(currencyCode);
+ final NumberFormat currencyFormat = DecimalFormat.getCurrencyInstance(locale);
+ currencyFormat.setCurrency(currency);
+ currencyFormat.setMinimumFractionDigits(checkoutCurrency.getFractionDigits());
+ currencyFormat.setMaximumFractionDigits(checkoutCurrency.getFractionDigits());
+
+ final BigDecimal value = BigDecimal.valueOf(amount.getValue(), checkoutCurrency.getFractionDigits());
+ return currencyFormat.format(value);
+ }
+
+ static void assertCurrency(@Nullable String currencyCode) {
+ if (!CheckoutCurrency.isSupported(currencyCode)) {
+ throw new CheckoutException("Currency " + currencyCode + " not supported");
+ }
+ }
+
+ private CurrencyUtils() {
+ throw new NoConstructorException();
+ }
+}
diff --git a/base-v3/src/main/java/com/adyen/checkout/base/util/DateUtils.java b/base-v3/src/main/java/com/adyen/checkout/base/util/DateUtils.java
index c10587aa57..86d801d145 100644
--- a/base-v3/src/main/java/com/adyen/checkout/base/util/DateUtils.java
+++ b/base-v3/src/main/java/com/adyen/checkout/base/util/DateUtils.java
@@ -10,7 +10,7 @@
import android.support.annotation.NonNull;
-import com.adyen.checkout.core.exeption.NoConstructorException;
+import com.adyen.checkout.core.exception.NoConstructorException;
public final class DateUtils {
diff --git a/base-v3/src/main/java/com/adyen/checkout/base/util/PaymentMethodTypes.java b/base-v3/src/main/java/com/adyen/checkout/base/util/PaymentMethodTypes.java
index 5551f379b9..0d522751d5 100644
--- a/base-v3/src/main/java/com/adyen/checkout/base/util/PaymentMethodTypes.java
+++ b/base-v3/src/main/java/com/adyen/checkout/base/util/PaymentMethodTypes.java
@@ -10,7 +10,7 @@
import android.support.annotation.StringDef;
-import com.adyen.checkout.core.exeption.NoConstructorException;
+import com.adyen.checkout.core.exception.NoConstructorException;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@@ -25,7 +25,9 @@ public final class PaymentMethodTypes {
// Type of the payment method as received by the paymentMethods/ API
public static final String IDEAL = "ideal";
- public static final String MOLPAY = "molpay_ebanking_fpx_MY";
+ public static final String MOLPAY_MALAYSIA = "molpay_ebanking_fpx_MY";
+ public static final String MOLPAY_THAILAND = "molpay_ebanking_TH";
+ public static final String MOLPAY_VIETNAM = "molpay_ebanking_VN";
public static final String DOTPAY = "dotpay";
public static final String EPS = "eps";
public static final String ENTERCASH = "entercash";
@@ -35,12 +37,11 @@ public final class PaymentMethodTypes {
public static final String SEPA = "sepadirectdebit";
public static final String BCMC = "bcmc";
-
// List of all payment method types.
public static final List SUPPORTED_PAYMENT_METHODS;
// Helper annotation to enforce use of a constant from here when needed.
- @StringDef({IDEAL, MOLPAY, DOTPAY, EPS, ENTERCASH, OPEN_BANKING, SCHEME, GOOGLE_PAY, SEPA, BCMC})
+ @StringDef({IDEAL, MOLPAY_MALAYSIA, MOLPAY_THAILAND, MOLPAY_VIETNAM, DOTPAY, EPS, ENTERCASH, OPEN_BANKING, SCHEME, GOOGLE_PAY, SEPA, BCMC})
@Retention(RetentionPolicy.SOURCE)
public @interface SupportedPaymentMethod {
}
@@ -49,7 +50,9 @@ public final class PaymentMethodTypes {
final ArrayList paymentMethods = new ArrayList<>();
paymentMethods.add(IDEAL);
- paymentMethods.add(MOLPAY);
+ paymentMethods.add(MOLPAY_MALAYSIA);
+ paymentMethods.add(MOLPAY_THAILAND);
+ paymentMethods.add(MOLPAY_VIETNAM);
paymentMethods.add(DOTPAY);
paymentMethods.add(EPS);
paymentMethods.add(ENTERCASH);
diff --git a/base-v3/src/test/java/com/adyen/checkout/base/component/BaseComponentTest.java b/base-v3/src/test/java/com/adyen/checkout/base/component/BaseComponentTest.java
index f68db25c8c..5e04ab5d78 100644
--- a/base-v3/src/test/java/com/adyen/checkout/base/component/BaseComponentTest.java
+++ b/base-v3/src/test/java/com/adyen/checkout/base/component/BaseComponentTest.java
@@ -19,11 +19,11 @@
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
-import com.adyen.checkout.base.Configuration;
import com.adyen.checkout.base.DataProvider;
import com.adyen.checkout.base.PaymentComponentState;
import com.adyen.checkout.base.model.paymentmethods.PaymentMethod;
import com.adyen.checkout.base.model.payments.request.PaymentComponentData;
+import com.adyen.checkout.base.models.TestConfiguration;
import com.adyen.checkout.base.models.TestInputData;
import com.adyen.checkout.base.models.TestOutputData;
import com.adyen.checkout.base.models.TestPaymentMethod;
@@ -42,7 +42,7 @@ public class BaseComponentTest {
@Rule
public TestRule rule = new InstantTaskExecutorRule();
- BasePaymentComponent mBaseComponent;
+ BasePaymentComponent mBaseComponent;
PaymentMethod paymentMethod;
ClassLoader classLoader;
@@ -55,7 +55,7 @@ public void init() throws IOException, JSONException {
@Test(expected = IllegalArgumentException.class)
public void initBaseComponent_notSupportedPaymentMethod_expectException() throws IOException, JSONException {
- mBaseComponent = new BasePaymentComponent(DataProvider.getPaymentMethodResponse(
+ mBaseComponent = new BasePaymentComponent(DataProvider.getPaymentMethodResponse(
classLoader).getPaymentMethods().get(0),
null) {
@NonNull
@@ -78,8 +78,8 @@ protected PaymentComponentState createComponentState() {
@NonNull
@Override
- public String getPaymentMethodType() {
- return "something";
+ public String[] getSupportedPaymentMethodTypes() {
+ return new String[]{"something"};
}
};
}
@@ -125,7 +125,7 @@ public void onChanged(@Nullable PaymentComponentState paymentComponentState) {
}
private BasePaymentComponent getBaseComponent() {
- BasePaymentComponent baseComponent = new BasePaymentComponent(paymentMethod, null) {
+ BasePaymentComponent baseComponent = new BasePaymentComponent(paymentMethod, null) {
@NonNull
@Override
protected TestOutputData onInputDataChanged(@NonNull TestInputData inputData) {
@@ -149,8 +149,8 @@ protected PaymentComponentState createComponentState() {
@NonNull
@Override
- public String getPaymentMethodType() {
- return paymentMethod.getType();
+ public String[] getSupportedPaymentMethodTypes() {
+ return new String[]{paymentMethod.getType()};
}
};
diff --git a/base-v3/src/test/java/com/adyen/checkout/base/models/TestConfiguration.java b/base-v3/src/test/java/com/adyen/checkout/base/models/TestConfiguration.java
index c0c7b7a085..545e2ec0df 100644
--- a/base-v3/src/test/java/com/adyen/checkout/base/models/TestConfiguration.java
+++ b/base-v3/src/test/java/com/adyen/checkout/base/models/TestConfiguration.java
@@ -8,23 +8,21 @@
package com.adyen.checkout.base.models;
+import android.os.Parcel;
import android.support.annotation.NonNull;
-import com.adyen.checkout.base.Configuration;
+import com.adyen.checkout.base.component.Configuration;
import com.adyen.checkout.core.api.Environment;
import java.util.Locale;
-public class TestConfiguration implements Configuration {
- @NonNull
- @Override
- public Locale getShopperLocale() {
- return new Locale("en");
+public class TestConfiguration extends Configuration {
+
+ public TestConfiguration() {
+ super(Locale.US, Environment.TEST);
}
- @NonNull
- @Override
- public Environment getEnvironment() {
- return Environment.TEST;
+ protected TestConfiguration(@NonNull Parcel in) {
+ super(in);
}
}
diff --git a/bcmc-base/src/main/java/com/adyen/checkout/bcmc/BcmcComponent.java b/bcmc-base/src/main/java/com/adyen/checkout/bcmc/BcmcComponent.java
index 5946694a00..54ef40bd09 100644
--- a/bcmc-base/src/main/java/com/adyen/checkout/bcmc/BcmcComponent.java
+++ b/bcmc-base/src/main/java/com/adyen/checkout/bcmc/BcmcComponent.java
@@ -36,6 +36,8 @@
public final class BcmcComponent extends BasePaymentComponent {
private static final String TAG = LogUtil.getTag();
+ private static final String[] PAYMENT_METHOD_TYPES = {PaymentMethodTypes.BCMC};
+
public static final PaymentComponentProvider PROVIDER = new BcmcComponentProvider();
public static final CardType SUPPORTED_CARD_TYPE = CardType.BCMC;
@@ -71,6 +73,12 @@ public String getPaymentMethodType() {
return PaymentMethodTypes.BCMC;
}
+ @NonNull
+ @Override
+ public String[] getSupportedPaymentMethodTypes() {
+ return PAYMENT_METHOD_TYPES;
+ }
+
@NonNull
@Override
protected PaymentComponentState createComponentState() {
@@ -131,7 +139,6 @@ protected BcmcOutputData createEmptyOutputData() {
return new BcmcOutputData();
}
- @NonNull
protected boolean isCardNumberSupported(@Nullable String cardNumber) {
if (cardNumber == null || cardNumber.isEmpty()) {
diff --git a/bcmc-base/src/main/java/com/adyen/checkout/bcmc/BcmcConfiguration.java b/bcmc-base/src/main/java/com/adyen/checkout/bcmc/BcmcConfiguration.java
index cc50634888..6a5f571ee4 100644
--- a/bcmc-base/src/main/java/com/adyen/checkout/bcmc/BcmcConfiguration.java
+++ b/bcmc-base/src/main/java/com/adyen/checkout/bcmc/BcmcConfiguration.java
@@ -15,8 +15,7 @@
import android.support.annotation.Nullable;
import android.util.DisplayMetrics;
-import com.adyen.checkout.base.Configuration;
-import com.adyen.checkout.base.component.BaseConfiguration;
+import com.adyen.checkout.base.component.Configuration;
import com.adyen.checkout.base.component.BaseConfigurationBuilder;
import com.adyen.checkout.core.api.Environment;
@@ -25,7 +24,7 @@
/**
* {@link Configuration} class required by {@link BcmcComponent} to change it's behavior. Pass it to the {@link BcmcComponent#PROVIDER}.
*/
-public class BcmcConfiguration extends BaseConfiguration {
+public class BcmcConfiguration extends Configuration {
private final String mPublicKey;
diff --git a/bcmc-ui/src/main/java/com/adyen/checkout/bcmc/BcmcView.java b/bcmc-ui/src/main/java/com/adyen/checkout/bcmc/BcmcView.java
index 598d07f31c..24375a6ef3 100644
--- a/bcmc-ui/src/main/java/com/adyen/checkout/bcmc/BcmcView.java
+++ b/bcmc-ui/src/main/java/com/adyen/checkout/bcmc/BcmcView.java
@@ -20,8 +20,8 @@
import android.view.View;
import android.widget.LinearLayout;
-import com.adyen.checkout.base.ComponentView;
import com.adyen.checkout.base.api.ImageLoader;
+import com.adyen.checkout.base.ui.view.AdyenLinearLayout;
import com.adyen.checkout.base.ui.view.AdyenTextInputEditText;
import com.adyen.checkout.base.ui.view.RoundCornerImageView;
import com.adyen.checkout.base.validation.ValidatedField;
@@ -36,23 +36,20 @@
* CardView for {@link BcmcComponent}.
*/
@SuppressWarnings("SyntheticAccessor")
-public final class BcmcView extends LinearLayout implements ComponentView, Observer {
+public final class BcmcView extends AdyenLinearLayout implements Observer {
private RoundCornerImageView mCardBrandLogoImageView;
- private final CardNumberInput mCardNumberEditText;
- private final ExpiryDateInput mExpiryDateEditText;
+ private CardNumberInput mCardNumberEditText;
+ private ExpiryDateInput mExpiryDateEditText;
- private final TextInputLayout mExpiryDateInput;
- private final TextInputLayout mCardNumberInput;
+ private TextInputLayout mExpiryDateInput;
+ private TextInputLayout mCardNumberInput;
- private final BcmcInputData mCardInputData;
+ private BcmcInputData mCardInputData;
private ImageLoader mImageLoader;
- @Nullable
- private BcmcComponent mComponent;
-
public BcmcView(@NonNull Context context) {
this(context, null);
}
@@ -65,14 +62,16 @@ public BcmcView(@NonNull Context context, @Nullable AttributeSet attrs) {
@SuppressWarnings("JavadocMethod")
public BcmcView(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
-
setOrientation(LinearLayout.VERTICAL);
- LayoutInflater.from(context).inflate(R.layout.bcmc_view, this, true);
+ LayoutInflater.from(getContext()).inflate(R.layout.bcmc_view, this, true);
final int padding = (int) getResources().getDimension(R.dimen.standard_margin);
setPadding(padding, padding, padding, 0);
+ }
+ @Override
+ public void initView() {
mCardBrandLogoImageView = findViewById(R.id.cardBrandLogo_imageView);
mCardNumberInput = findViewById(R.id.textInputLayout_cardNumber);
@@ -89,7 +88,7 @@ public void onTextChanged(Editable editable) {
public void onFocusChange(View v, boolean hasFocus) {
mCardNumberInput.setErrorEnabled(!hasFocus);
- if (!hasFocus && (isOutputEmpty() || !mComponent.getOutputData().getCardNumberField().isValid())) {
+ if (!hasFocus && (isOutputEmpty() || !getComponent().getOutputData().getCardNumberField().isValid())) {
mCardNumberInput.setError(getContext().getString(R.string.checkout_card_number_not_valid));
}
}
@@ -110,7 +109,7 @@ public void onTextChanged(Editable editable) {
public void onFocusChange(View v, boolean hasFocus) {
mExpiryDateInput.setErrorEnabled(!hasFocus);
- if (!hasFocus && (isOutputEmpty() || !mComponent.getOutputData().getExpiryDateField().isValid())) {
+ if (!hasFocus && (isOutputEmpty() || !getComponent().getOutputData().getExpiryDateField().isValid())) {
mExpiryDateInput.setError(getContext().getString(R.string.checkout_expiry_date_not_valid));
}
}
@@ -119,7 +118,11 @@ public void onFocusChange(View v, boolean hasFocus) {
mCardInputData = new BcmcInputData();
}
- @SuppressWarnings("NullableProblems")
+ @Override
+ public void onComponentAttached() {
+ mImageLoader = ImageLoader.getInstance(getContext(), getComponent().getConfiguration().getEnvironment());
+ }
+
@Override
public void onChanged(@NonNull BcmcOutputData cardOutputData) {
if (!cardOutputData.isEmpty()) {
@@ -128,14 +131,8 @@ public void onChanged(@NonNull BcmcOutputData cardOutputData) {
}
@Override
- public void attach(@NonNull BcmcComponent component, @NonNull LifecycleOwner lifecycleOwner) {
- mComponent = component;
-
- mImageLoader = ImageLoader.getInstance(getContext(), component.getConfiguration().getEnvironment());
-
- mComponent.observeOutputData(lifecycleOwner, this);
-
- mComponent.sendAnalyticsEvent(getContext());
+ public void observeComponentChanges(@NonNull LifecycleOwner lifecycleOwner) {
+ getComponent().observeOutputData(lifecycleOwner, this);
}
@Override
@@ -144,9 +141,7 @@ public boolean isConfirmationRequired() {
}
private void notifyInputDataChanged() {
- if (mComponent != null) {
- mComponent.inputDataChanged(mCardInputData);
- }
+ getComponent().inputDataChanged(mCardInputData);
}
private void onCardNumberValidated(@NonNull ValidatedField validatedNumber) {
@@ -154,7 +149,7 @@ private void onCardNumberValidated(@NonNull ValidatedField validatedNumb
changeFocusOfInput(validatedNumber.getValue());
}
- if (!mComponent.isCardNumberSupported(validatedNumber.getValue())) {
+ if (!getComponent().isCardNumberSupported(validatedNumber.getValue())) {
mCardBrandLogoImageView.setStrokeWidth(0f);
mCardBrandLogoImageView.setImageResource(R.drawable.ic_card);
} else {
@@ -164,7 +159,7 @@ private void onCardNumberValidated(@NonNull ValidatedField validatedNumb
}
private boolean isOutputEmpty() {
- return mComponent.getOutputData().isEmpty();
+ return getComponent().getOutputData().isEmpty();
}
private void changeFocusOfInput(String numberValue) {
diff --git a/build.gradle b/build.gradle
index b4b34e3355..cb112fc4c9 100644
--- a/build.gradle
+++ b/build.gradle
@@ -35,7 +35,7 @@ allprojects {
// just for example app, don't need to increment
ext.version_code = 1
// The version_name format is "major.minor.patch(-(alpha|beta|rc)[0-9]{2}){0,1}" (e.g. 3.0.0, 3.1.1-alpha04 or 3.1.4-rc01 etc).
- ext.version_name = "3.4.0"
+ ext.version_name = "3.4.1"
// Code quality
ext.version_ktlint = '0.34.2'
diff --git a/card-base-core/src/main/java/com/adyen/checkout/card/CardValidationUtils.java b/card-base-core/src/main/java/com/adyen/checkout/card/CardValidationUtils.java
index 2f1905b457..e68a5cf37f 100644
--- a/card-base-core/src/main/java/com/adyen/checkout/card/CardValidationUtils.java
+++ b/card-base-core/src/main/java/com/adyen/checkout/card/CardValidationUtils.java
@@ -14,7 +14,7 @@
import com.adyen.checkout.base.validation.ValidatedField;
import com.adyen.checkout.card.data.CardType;
import com.adyen.checkout.card.data.ExpiryDate;
-import com.adyen.checkout.core.exeption.NoConstructorException;
+import com.adyen.checkout.core.exception.NoConstructorException;
import com.adyen.checkout.core.util.StringUtil;
import java.util.Calendar;
diff --git a/card-base-core/src/main/java/com/adyen/checkout/card/data/CardType.java b/card-base-core/src/main/java/com/adyen/checkout/card/data/CardType.java
index 0ca094b2de..b513a203e8 100644
--- a/card-base-core/src/main/java/com/adyen/checkout/card/data/CardType.java
+++ b/card-base-core/src/main/java/com/adyen/checkout/card/data/CardType.java
@@ -12,6 +12,7 @@
import android.support.annotation.Nullable;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -61,12 +62,14 @@ public enum CardType {
private final Pattern mPattern;
- private static final Map MAPPED_BY_NAME = new HashMap<>();
+ private static final Map MAPPED_BY_NAME;
static {
+ final Map hashMap = new HashMap<>();
for (CardType type : CardType.values()) {
- MAPPED_BY_NAME.put(type.mTxVariant, type);
+ hashMap.put(type.mTxVariant, type);
}
+ MAPPED_BY_NAME = Collections.unmodifiableMap(hashMap);
}
/**
diff --git a/card-base/src/main/java/com/adyen/checkout/card/CardComponent.java b/card-base/src/main/java/com/adyen/checkout/card/CardComponent.java
index 70c870a899..2a9509d9ba 100644
--- a/card-base/src/main/java/com/adyen/checkout/card/CardComponent.java
+++ b/card-base/src/main/java/com/adyen/checkout/card/CardComponent.java
@@ -44,6 +44,8 @@ public final class CardComponent extends BasePaymentComponent PROVIDER = new CardComponentProvider();
+ private static final String[] PAYMENT_METHOD_TYPES = {PaymentMethodTypes.SCHEME};
+
private final List mFilteredSupportedCards = new ArrayList<>();
private CardInputData mStoredPaymentInputData;
@@ -130,8 +132,8 @@ protected CardOutputData onInputDataChanged(@NonNull CardInputData inputData) {
@NonNull
@Override
- public String getPaymentMethodType() {
- return PaymentMethodTypes.SCHEME;
+ public String[] getSupportedPaymentMethodTypes() {
+ return PAYMENT_METHOD_TYPES;
}
@NonNull
diff --git a/card-base/src/main/java/com/adyen/checkout/card/CardConfiguration.java b/card-base/src/main/java/com/adyen/checkout/card/CardConfiguration.java
index 9598a0462e..99deb4b821 100644
--- a/card-base/src/main/java/com/adyen/checkout/card/CardConfiguration.java
+++ b/card-base/src/main/java/com/adyen/checkout/card/CardConfiguration.java
@@ -15,11 +15,11 @@
import android.support.annotation.Nullable;
import android.util.DisplayMetrics;
-import com.adyen.checkout.base.Configuration;
-import com.adyen.checkout.base.component.BaseConfiguration;
+import com.adyen.checkout.base.component.Configuration;
import com.adyen.checkout.base.component.BaseConfigurationBuilder;
import com.adyen.checkout.card.data.CardType;
import com.adyen.checkout.core.api.Environment;
+import com.adyen.checkout.core.exception.CheckoutException;
import com.adyen.checkout.core.util.ParcelUtils;
import java.util.ArrayList;
@@ -27,11 +27,12 @@
import java.util.Collections;
import java.util.List;
import java.util.Locale;
+import java.util.regex.Pattern;
/**
* {@link Configuration} class required by {@link CardComponent} to change it's behavior. Pass it to the {@link CardComponent#PROVIDER}.
*/
-public class CardConfiguration extends BaseConfiguration {
+public class CardConfiguration extends Configuration {
private static final CardType[] DEFAULT_SUPPORTED_CARDS =
new CardType[]{CardType.VISA, CardType.AMERICAN_EXPRESS, CardType.MASTERCARD};
@@ -322,6 +323,11 @@ public Builder setShopperReference(@NonNull String shopperReference) {
*/
@NonNull
public CardConfiguration build() {
+
+ if (!isPublicKeyValid()) {
+ throw new CheckoutException("Invalid Public Key. Please find the valid public key on the Customer Area.");
+ }
+
return new CardConfiguration(
mBuilderShopperLocale,
mBuilderEnvironment,
@@ -332,6 +338,11 @@ public CardConfiguration build() {
mBuilderSupportedCardTypes
);
}
+
+ private boolean isPublicKeyValid() {
+ final Pattern pubKeyPattern = Pattern.compile("([0-9]){5}\\|([A-Z]|[0-9]){512}");
+ return pubKeyPattern.matcher(mBuilderPublicKey).find();
+ }
}
}
diff --git a/card-ui/src/main/java/com/adyen/checkout/card/CardView.java b/card-ui/src/main/java/com/adyen/checkout/card/CardView.java
index 50457deb2b..fb2328bb90 100644
--- a/card-ui/src/main/java/com/adyen/checkout/card/CardView.java
+++ b/card-ui/src/main/java/com/adyen/checkout/card/CardView.java
@@ -22,8 +22,8 @@
import android.widget.CompoundButton;
import android.widget.LinearLayout;
-import com.adyen.checkout.base.ComponentView;
import com.adyen.checkout.base.api.ImageLoader;
+import com.adyen.checkout.base.ui.view.AdyenLinearLayout;
import com.adyen.checkout.base.ui.view.AdyenTextInputEditText;
import com.adyen.checkout.base.ui.view.RoundCornerImageView;
import com.adyen.checkout.base.validation.ValidatedField;
@@ -42,26 +42,22 @@
* CardView for {@link CardComponent}.
*/
@SuppressWarnings("SyntheticAccessor")
-public final class CardView extends LinearLayout implements ComponentView, Observer {
+public final class CardView extends AdyenLinearLayout implements Observer {
private RoundCornerImageView mCardBrandLogoImageView;
- private final CardNumberInput mCardNumberEditText;
- private final ExpiryDateInput mExpiryDateEditText;
+ private CardNumberInput mCardNumberEditText;
+ private ExpiryDateInput mExpiryDateEditText;
- private final TextInputLayout mExpiryDateInput;
- private final TextInputLayout mSecurityCodeInput;
- private final TextInputLayout mCardNumberInput;
- private final TextInputLayout mCardHolderInput;
- private final SwitchCompat mStorePaymentMethod;
+ private TextInputLayout mExpiryDateInput;
+ private TextInputLayout mSecurityCodeInput;
+ private TextInputLayout mCardNumberInput;
+ private TextInputLayout mCardHolderInput;
- private final CardInputData mCardInputData;
+ private CardInputData mCardInputData;
private ImageLoader mImageLoader;
- @Nullable
- private CardComponent mComponent;
-
public CardView(@NonNull Context context) {
this(context, null);
}
@@ -70,21 +66,24 @@ public CardView(@NonNull Context context, @Nullable AttributeSet attrs) {
this(context, attrs, 0);
}
- // Regular View constructor
- @SuppressWarnings("JavadocMethod")
+ /**
+ * View for CardComponent.
+ */
public CardView(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
-
setOrientation(LinearLayout.VERTICAL);
- LayoutInflater.from(context).inflate(R.layout.card_view, this, true);
+ LayoutInflater.from(getContext()).inflate(R.layout.card_view, this, true);
final int padding = (int) getResources().getDimension(R.dimen.standard_margin);
setPadding(padding, padding, padding, 0);
+ }
+ @Override
+ public void initView() {
mCardBrandLogoImageView = findViewById(R.id.cardBrandLogo_imageView);
- mStorePaymentMethod = findViewById(R.id.switch_storePaymentMethod);
+ final SwitchCompat storePaymentMethod = findViewById(R.id.switch_storePaymentMethod);
mCardNumberInput = findViewById(R.id.textInputLayout_cardNumber);
mCardNumberEditText = (CardNumberInput) mCardNumberInput.getEditText();
@@ -98,17 +97,17 @@ public void onTextChanged(Editable editable) {
mCardNumberEditText.setOnFocusChangeListener(new OnFocusChangeListener() {
@Override
public void onFocusChange(View v, boolean hasFocus) {
- if (!mComponent.isStoredPaymentMethod()) {
+ if (!getComponent().isStoredPaymentMethod()) {
mCardNumberInput.setErrorEnabled(!hasFocus);
- if (!hasFocus && (isOutputEmpty() || !mComponent.getOutputData().getCardNumberField().isValid())) {
+ if (!hasFocus && (isOutputEmpty() || !getComponent().getOutputData().getCardNumberField().isValid())) {
mCardNumberInput.setError(getContext().getString(R.string.checkout_card_number_not_valid));
}
}
}
});
- mStorePaymentMethod.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
+ storePaymentMethod.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
mCardInputData.setStorePayment(isChecked);
@@ -131,7 +130,7 @@ public void onTextChanged(Editable editable) {
public void onFocusChange(View v, boolean hasFocus) {
mExpiryDateInput.setErrorEnabled(!hasFocus);
- if (!hasFocus && (isOutputEmpty() || !mComponent.getOutputData().getExpiryDateField().isValid())) {
+ if (!hasFocus && (isOutputEmpty() || !getComponent().getOutputData().getExpiryDateField().isValid())) {
mExpiryDateInput.setError(getContext().getString(R.string.checkout_expiry_date_not_valid));
}
}
@@ -151,7 +150,7 @@ public void onTextChanged(Editable editable) {
public void onFocusChange(View v, boolean hasFocus) {
mSecurityCodeInput.setErrorEnabled(!hasFocus);
- if (!hasFocus && (isOutputEmpty() || !mComponent.getOutputData().getSecurityCodeField().isValid())) {
+ if (!hasFocus && (isOutputEmpty() || !getComponent().getOutputData().getSecurityCodeField().isValid())) {
mSecurityCodeInput.setError(getContext().getString(R.string.checkout_security_code_not_valid));
}
}
@@ -171,34 +170,16 @@ public void onTextChanged(Editable editable) {
public void onFocusChange(View v, boolean hasFocus) {
mCardHolderInput.setErrorEnabled(!hasFocus);
- if (!hasFocus && (isOutputEmpty() || !mComponent.getOutputData().getHolderNameField().isValid())) {
+ if (!hasFocus && (isOutputEmpty() || !getComponent().getOutputData().getHolderNameField().isValid())) {
mCardHolderInput.setError(getContext().getString(R.string.checkout_holder_name_not_valid));
}
}
});
mCardInputData = new CardInputData();
- }
-
- @SuppressWarnings("NullableProblems")
- @Override
- public void onChanged(@NonNull CardOutputData cardOutputData) {
- if (!cardOutputData.isEmpty()) {
- onCardNumberValidated(cardOutputData.getCardNumberField());
- onExpiryDateValidated(cardOutputData.getExpiryDateField());
- }
-
- if (mComponent != null && mComponent.isStoredPaymentMethod()) {
- mSecurityCodeInput.getEditText().requestFocus();
- }
- }
- @Override
- public void attach(@NonNull CardComponent component, @NonNull LifecycleOwner lifecycleOwner) {
- mComponent = component;
-
- if (mComponent.isStoredPaymentMethod()) {
- final CardInputData storedCardInput = mComponent.getStoredPaymentInputData();
+ if (getComponent().isStoredPaymentMethod()) {
+ final CardInputData storedCardInput = getComponent().getStoredPaymentInputData();
mCardNumberEditText.setText(
getContext().getString(R.string.card_number_4digit, storedCardInput.getCardNumber()));
@@ -207,18 +188,34 @@ public void attach(@NonNull CardComponent component, @NonNull LifecycleOwner lif
mExpiryDateEditText.setDate(storedCardInput.getExpiryDate());
mExpiryDateEditText.setEnabled(false);
- mStorePaymentMethod.setVisibility(GONE);
+ storePaymentMethod.setVisibility(GONE);
mCardHolderInput.setVisibility(GONE);
} else {
- mCardHolderInput.setVisibility(mComponent.isHolderNameRequire() ? VISIBLE : GONE);
- mStorePaymentMethod.setVisibility(mComponent.showStorePaymentField() ? VISIBLE : GONE);
+ mCardHolderInput.setVisibility(getComponent().isHolderNameRequire() ? VISIBLE : GONE);
+ storePaymentMethod.setVisibility(getComponent().showStorePaymentField() ? VISIBLE : GONE);
}
+ }
- mImageLoader = ImageLoader.getInstance(getContext(), component.getConfiguration().getEnvironment());
+ @Override
+ public void onComponentAttached() {
+ mImageLoader = ImageLoader.getInstance(getContext(), getComponent().getConfiguration().getEnvironment());
+ }
- mComponent.observeOutputData(lifecycleOwner, this);
+ @Override
+ public void onChanged(@Nullable CardOutputData cardOutputData) {
+ if (!cardOutputData.isEmpty()) {
+ onCardNumberValidated(cardOutputData.getCardNumberField());
+ onExpiryDateValidated(cardOutputData.getExpiryDateField());
+ }
- mComponent.sendAnalyticsEvent(getContext());
+ if (getComponent().isStoredPaymentMethod()) {
+ mSecurityCodeInput.getEditText().requestFocus();
+ }
+ }
+
+ @Override
+ public void observeComponentChanges(@NonNull LifecycleOwner lifecycleOwner) {
+ getComponent().observeOutputData(lifecycleOwner, this);
}
@Override
@@ -227,9 +224,7 @@ public boolean isConfirmationRequired() {
}
private void notifyInputDataChanged() {
- if (mComponent != null) {
- mComponent.inputDataChanged(mCardInputData);
- }
+ getComponent().inputDataChanged(mCardInputData);
}
private void onCardNumberValidated(@NonNull ValidatedField validatedNumber) {
@@ -237,7 +232,7 @@ private void onCardNumberValidated(@NonNull ValidatedField validatedNumb
changeFocusOfInput(validatedNumber.getValue());
}
- final List supportedCardType = mComponent.getSupportedFilterCards(validatedNumber.getValue());
+ final List supportedCardType = getComponent().getSupportedFilterCards(validatedNumber.getValue());
if (supportedCardType.isEmpty()) {
mCardBrandLogoImageView.setStrokeWidth(0f);
mCardBrandLogoImageView.setImageResource(R.drawable.ic_card);
@@ -249,13 +244,13 @@ private void onCardNumberValidated(@NonNull ValidatedField validatedNumb
}
private void onExpiryDateValidated(@Nullable ValidatedField validatedExpiryDate) {
- if (validatedExpiryDate != null && validatedExpiryDate.getValidation() == ValidatedField.Validation.VALID) {
+ if (validatedExpiryDate.getValidation() == ValidatedField.Validation.VALID) {
goToNextInputIfFocus(mExpiryDateEditText);
}
}
private boolean isOutputEmpty() {
- return mComponent.getOutputData().isEmpty();
+ return getComponent().getOutputData().isEmpty();
}
private void changeFocusOfInput(String numberValue) {
diff --git a/card-ui/src/main/res/layout/brand_logo.xml b/card-ui/src/main/res/layout/brand_logo.xml
index cd8a35e692..5c8d3fdad4 100644
--- a/card-ui/src/main/res/layout/brand_logo.xml
+++ b/card-ui/src/main/res/layout/brand_logo.xml
@@ -11,4 +11,6 @@
style="@style/AdyenCheckout.Image.CardLogo"
android:layout_width="@dimen/brand_logo_width"
android:layout_height="@dimen/brand_logo_height"
+ android:layout_marginStart="@dimen/standard_quarter_margin"
+ android:layout_marginLeft="@dimen/standard_quarter_margin"
app:strokeColor="@color/stroke_color" />
\ No newline at end of file
diff --git a/core-v3/src/main/java/com/adyen/checkout/core/api/Environment.java b/core-v3/src/main/java/com/adyen/checkout/core/api/Environment.java
index bbce5f67d7..cc270454ae 100644
--- a/core-v3/src/main/java/com/adyen/checkout/core/api/Environment.java
+++ b/core-v3/src/main/java/com/adyen/checkout/core/api/Environment.java
@@ -12,7 +12,7 @@
import android.os.Parcelable;
import android.support.annotation.NonNull;
-import com.adyen.checkout.core.exeption.CheckoutException;
+import com.adyen.checkout.core.exception.CheckoutException;
import com.adyen.checkout.core.util.ParcelUtils;
import java.net.MalformedURLException;
diff --git a/core-v3/src/main/java/com/adyen/checkout/core/api/ThreadManager.java b/core-v3/src/main/java/com/adyen/checkout/core/api/ThreadManager.java
index 9f3c6d4477..e71498f87c 100644
--- a/core-v3/src/main/java/com/adyen/checkout/core/api/ThreadManager.java
+++ b/core-v3/src/main/java/com/adyen/checkout/core/api/ThreadManager.java
@@ -11,7 +11,7 @@
import android.os.Handler;
import android.os.Looper;
-import com.adyen.checkout.core.exeption.NoConstructorException;
+import com.adyen.checkout.core.exception.NoConstructorException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
diff --git a/core-v3/src/main/java/com/adyen/checkout/core/code/Lint.java b/core-v3/src/main/java/com/adyen/checkout/core/code/Lint.java
index d90255141a..dac05cbe97 100644
--- a/core-v3/src/main/java/com/adyen/checkout/core/code/Lint.java
+++ b/core-v3/src/main/java/com/adyen/checkout/core/code/Lint.java
@@ -8,7 +8,7 @@
package com.adyen.checkout.core.code;
-import com.adyen.checkout.core.exeption.NoConstructorException;
+import com.adyen.checkout.core.exception.NoConstructorException;
/**
* Utility class for constants related to Lint.
diff --git a/core-v3/src/main/java/com/adyen/checkout/core/exeption/BadModelException.java b/core-v3/src/main/java/com/adyen/checkout/core/exception/BadModelException.java
similarity index 95%
rename from core-v3/src/main/java/com/adyen/checkout/core/exeption/BadModelException.java
rename to core-v3/src/main/java/com/adyen/checkout/core/exception/BadModelException.java
index 328fce1e4c..133f3298ea 100644
--- a/core-v3/src/main/java/com/adyen/checkout/core/exeption/BadModelException.java
+++ b/core-v3/src/main/java/com/adyen/checkout/core/exception/BadModelException.java
@@ -6,7 +6,7 @@
* Created by caiof on 15/4/2019.
*/
-package com.adyen.checkout.core.exeption;
+package com.adyen.checkout.core.exception;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
diff --git a/core-v3/src/main/java/com/adyen/checkout/core/exeption/CheckoutException.java b/core-v3/src/main/java/com/adyen/checkout/core/exception/CheckoutException.java
similarity index 94%
rename from core-v3/src/main/java/com/adyen/checkout/core/exeption/CheckoutException.java
rename to core-v3/src/main/java/com/adyen/checkout/core/exception/CheckoutException.java
index 10aac8251c..8b608de0b1 100644
--- a/core-v3/src/main/java/com/adyen/checkout/core/exeption/CheckoutException.java
+++ b/core-v3/src/main/java/com/adyen/checkout/core/exception/CheckoutException.java
@@ -6,7 +6,7 @@
* Created by caiof on 24/4/2019.
*/
-package com.adyen.checkout.core.exeption;
+package com.adyen.checkout.core.exception;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
diff --git a/core-v3/src/main/java/com/adyen/checkout/core/exeption/ComponentException.java b/core-v3/src/main/java/com/adyen/checkout/core/exception/ComponentException.java
similarity index 93%
rename from core-v3/src/main/java/com/adyen/checkout/core/exeption/ComponentException.java
rename to core-v3/src/main/java/com/adyen/checkout/core/exception/ComponentException.java
index d47b1928da..90f78354ee 100644
--- a/core-v3/src/main/java/com/adyen/checkout/core/exeption/ComponentException.java
+++ b/core-v3/src/main/java/com/adyen/checkout/core/exception/ComponentException.java
@@ -6,7 +6,7 @@
* Created by caiof on 3/7/2019.
*/
-package com.adyen.checkout.core.exeption;
+package com.adyen.checkout.core.exception;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
diff --git a/core-v3/src/main/java/com/adyen/checkout/core/exeption/ModelSerializationException.java b/core-v3/src/main/java/com/adyen/checkout/core/exception/ModelSerializationException.java
similarity index 94%
rename from core-v3/src/main/java/com/adyen/checkout/core/exeption/ModelSerializationException.java
rename to core-v3/src/main/java/com/adyen/checkout/core/exception/ModelSerializationException.java
index 3a2d23d156..d480da7ffc 100644
--- a/core-v3/src/main/java/com/adyen/checkout/core/exeption/ModelSerializationException.java
+++ b/core-v3/src/main/java/com/adyen/checkout/core/exception/ModelSerializationException.java
@@ -6,7 +6,7 @@
* Created by caiof on 24/4/2019.
*/
-package com.adyen.checkout.core.exeption;
+package com.adyen.checkout.core.exception;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
diff --git a/core-v3/src/main/java/com/adyen/checkout/core/exeption/NoConstructorException.java b/core-v3/src/main/java/com/adyen/checkout/core/exception/NoConstructorException.java
similarity index 91%
rename from core-v3/src/main/java/com/adyen/checkout/core/exeption/NoConstructorException.java
rename to core-v3/src/main/java/com/adyen/checkout/core/exception/NoConstructorException.java
index 571c88b114..b6b984093f 100644
--- a/core-v3/src/main/java/com/adyen/checkout/core/exeption/NoConstructorException.java
+++ b/core-v3/src/main/java/com/adyen/checkout/core/exception/NoConstructorException.java
@@ -6,7 +6,7 @@
* Created by caiof on 4/3/2019.
*/
-package com.adyen.checkout.core.exeption;
+package com.adyen.checkout.core.exception;
/**
* Exception to prevent instantiation of utility classes.
diff --git a/core-v3/src/main/java/com/adyen/checkout/core/log/LogUtil.java b/core-v3/src/main/java/com/adyen/checkout/core/log/LogUtil.java
index 2ca500a592..d53f3fefd0 100644
--- a/core-v3/src/main/java/com/adyen/checkout/core/log/LogUtil.java
+++ b/core-v3/src/main/java/com/adyen/checkout/core/log/LogUtil.java
@@ -11,7 +11,7 @@
import android.os.Build;
import android.support.annotation.NonNull;
-import com.adyen.checkout.core.exeption.NoConstructorException;
+import com.adyen.checkout.core.exception.NoConstructorException;
/**
* Utility class with methods related to logs.
diff --git a/core-v3/src/main/java/com/adyen/checkout/core/log/Logger.java b/core-v3/src/main/java/com/adyen/checkout/core/log/Logger.java
index 739acc10b7..07660d50a3 100644
--- a/core-v3/src/main/java/com/adyen/checkout/core/log/Logger.java
+++ b/core-v3/src/main/java/com/adyen/checkout/core/log/Logger.java
@@ -14,7 +14,7 @@
import android.util.Log;
import com.adyen.checkout.core.BuildConfig;
-import com.adyen.checkout.core.exeption.NoConstructorException;
+import com.adyen.checkout.core.exception.NoConstructorException;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
diff --git a/core-v3/src/main/java/com/adyen/checkout/core/model/JsonUtils.java b/core-v3/src/main/java/com/adyen/checkout/core/model/JsonUtils.java
index 872786541e..59ec129107 100644
--- a/core-v3/src/main/java/com/adyen/checkout/core/model/JsonUtils.java
+++ b/core-v3/src/main/java/com/adyen/checkout/core/model/JsonUtils.java
@@ -12,7 +12,7 @@
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
-import com.adyen.checkout.core.exeption.NoConstructorException;
+import com.adyen.checkout.core.exception.NoConstructorException;
import com.adyen.checkout.core.util.StringUtil;
import org.json.JSONArray;
diff --git a/core-v3/src/main/java/com/adyen/checkout/core/model/ModelObject.java b/core-v3/src/main/java/com/adyen/checkout/core/model/ModelObject.java
index bf757a8cb2..f58acc7fbd 100644
--- a/core-v3/src/main/java/com/adyen/checkout/core/model/ModelObject.java
+++ b/core-v3/src/main/java/com/adyen/checkout/core/model/ModelObject.java
@@ -12,7 +12,7 @@
import android.os.Parcelable;
import android.support.annotation.NonNull;
-import com.adyen.checkout.core.exeption.CheckoutException;
+import com.adyen.checkout.core.exception.CheckoutException;
import com.adyen.checkout.core.util.ParcelUtils;
import org.json.JSONException;
diff --git a/core-v3/src/main/java/com/adyen/checkout/core/model/ModelUtils.java b/core-v3/src/main/java/com/adyen/checkout/core/model/ModelUtils.java
index 878008e911..d904ab5ea3 100644
--- a/core-v3/src/main/java/com/adyen/checkout/core/model/ModelUtils.java
+++ b/core-v3/src/main/java/com/adyen/checkout/core/model/ModelUtils.java
@@ -11,8 +11,8 @@
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
-import com.adyen.checkout.core.exeption.BadModelException;
-import com.adyen.checkout.core.exeption.NoConstructorException;
+import com.adyen.checkout.core.exception.BadModelException;
+import com.adyen.checkout.core.exception.NoConstructorException;
import org.json.JSONArray;
import org.json.JSONObject;
diff --git a/core-v3/src/main/java/com/adyen/checkout/core/util/LocaleUtil.java b/core-v3/src/main/java/com/adyen/checkout/core/util/LocaleUtil.java
index c520829d83..567853d88d 100644
--- a/core-v3/src/main/java/com/adyen/checkout/core/util/LocaleUtil.java
+++ b/core-v3/src/main/java/com/adyen/checkout/core/util/LocaleUtil.java
@@ -12,7 +12,7 @@
import android.os.Build;
import android.support.annotation.NonNull;
-import com.adyen.checkout.core.exeption.NoConstructorException;
+import com.adyen.checkout.core.exception.NoConstructorException;
import java.util.Locale;
diff --git a/core-v3/src/main/java/com/adyen/checkout/core/util/ParcelUtils.java b/core-v3/src/main/java/com/adyen/checkout/core/util/ParcelUtils.java
index 09deafbc38..eb64206c1a 100644
--- a/core-v3/src/main/java/com/adyen/checkout/core/util/ParcelUtils.java
+++ b/core-v3/src/main/java/com/adyen/checkout/core/util/ParcelUtils.java
@@ -11,7 +11,7 @@
import android.os.Parcel;
import android.support.annotation.NonNull;
-import com.adyen.checkout.core.exeption.NoConstructorException;
+import com.adyen.checkout.core.exception.NoConstructorException;
public final class ParcelUtils {
diff --git a/core-v3/src/main/java/com/adyen/checkout/core/util/StringUtil.java b/core-v3/src/main/java/com/adyen/checkout/core/util/StringUtil.java
index d76983c3f2..48a600c0e4 100644
--- a/core-v3/src/main/java/com/adyen/checkout/core/util/StringUtil.java
+++ b/core-v3/src/main/java/com/adyen/checkout/core/util/StringUtil.java
@@ -11,7 +11,7 @@
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
-import com.adyen.checkout.core.exeption.NoConstructorException;
+import com.adyen.checkout.core.exception.NoConstructorException;
public final class StringUtil {
diff --git a/cse/src/main/java/com/adyen/checkout/cse/EncryptionException.java b/cse/src/main/java/com/adyen/checkout/cse/EncryptionException.java
index e51c614f9d..748d4924ed 100644
--- a/cse/src/main/java/com/adyen/checkout/cse/EncryptionException.java
+++ b/cse/src/main/java/com/adyen/checkout/cse/EncryptionException.java
@@ -11,7 +11,7 @@
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
-import com.adyen.checkout.core.exeption.CheckoutException;
+import com.adyen.checkout.core.exception.CheckoutException;
public class EncryptionException extends CheckoutException {
diff --git a/dotpay-base/src/main/java/com/adyen/checkout/dotpay/DotpayComponent.java b/dotpay-base/src/main/java/com/adyen/checkout/dotpay/DotpayComponent.java
index e80c1a91b2..6aef1d2845 100644
--- a/dotpay-base/src/main/java/com/adyen/checkout/dotpay/DotpayComponent.java
+++ b/dotpay-base/src/main/java/com/adyen/checkout/dotpay/DotpayComponent.java
@@ -29,14 +29,16 @@ public final class DotpayComponent extends IssuerListComponent PROVIDER =
new PaymentComponentProviderImpl<>(DotpayComponent.class);
+ private static final String[] PAYMENT_METHOD_TYPES = {PaymentMethodTypes.DOTPAY};
+
public DotpayComponent(@NonNull PaymentMethod paymentMethod, @NonNull DotpayConfiguration configuration) {
super(paymentMethod, configuration);
}
@NonNull
@Override
- public String getPaymentMethodType() {
- return PaymentMethodTypes.DOTPAY;
+ public String[] getSupportedPaymentMethodTypes() {
+ return PAYMENT_METHOD_TYPES;
}
@Override
diff --git a/dotpay-ui/src/main/java/com/adyen/checkout/dotpay/DotpayRecyclerView.java b/dotpay-ui/src/main/java/com/adyen/checkout/dotpay/DotpayRecyclerView.java
index d2fcc3047a..39220d3924 100644
--- a/dotpay-ui/src/main/java/com/adyen/checkout/dotpay/DotpayRecyclerView.java
+++ b/dotpay-ui/src/main/java/com/adyen/checkout/dotpay/DotpayRecyclerView.java
@@ -8,20 +8,15 @@
package com.adyen.checkout.dotpay;
-import android.arch.lifecycle.LifecycleOwner;
import android.content.Context;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
-import com.adyen.checkout.core.log.LogUtil;
-import com.adyen.checkout.core.log.Logger;
import com.adyen.checkout.issuerlist.IssuerListRecyclerView;
public class DotpayRecyclerView extends IssuerListRecyclerView {
- private static final String TAG = LogUtil.getTag();
-
public DotpayRecyclerView(@NonNull Context context) {
super(context);
}
@@ -33,11 +28,4 @@ public DotpayRecyclerView(@NonNull Context context, @Nullable AttributeSet attrs
public DotpayRecyclerView(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
-
- @Override
- public void attach(@NonNull DotpayComponent component, @NonNull LifecycleOwner lifecycleOwner) {
- super.attach(component, lifecycleOwner);
- Logger.d(TAG, "attach");
- mComponent.observeOutputData(lifecycleOwner, createOutputDataObserver());
- }
}
diff --git a/dotpay-ui/src/main/java/com/adyen/checkout/dotpay/DotpaySpinnerView.java b/dotpay-ui/src/main/java/com/adyen/checkout/dotpay/DotpaySpinnerView.java
index 163fd1ff71..22d7bb3326 100644
--- a/dotpay-ui/src/main/java/com/adyen/checkout/dotpay/DotpaySpinnerView.java
+++ b/dotpay-ui/src/main/java/com/adyen/checkout/dotpay/DotpaySpinnerView.java
@@ -8,18 +8,14 @@
package com.adyen.checkout.dotpay;
-import android.arch.lifecycle.LifecycleOwner;
import android.content.Context;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
-import com.adyen.checkout.core.log.LogUtil;
-import com.adyen.checkout.core.log.Logger;
import com.adyen.checkout.issuerlist.IssuerListSpinnerView;
public final class DotpaySpinnerView extends IssuerListSpinnerView {
- private static final String TAG = LogUtil.getTag();
public DotpaySpinnerView(@NonNull Context context) {
super(context);
@@ -32,11 +28,4 @@ public DotpaySpinnerView(@NonNull Context context, @Nullable AttributeSet attrs)
public DotpaySpinnerView(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
-
- @Override
- public void attach(@NonNull DotpayComponent component, @NonNull LifecycleOwner lifecycleOwner) {
- super.attach(component, lifecycleOwner);
- Logger.d(TAG, "attach");
- mComponent.observeOutputData(lifecycleOwner, createOutputDataObserver());
- }
}
diff --git a/drop-in/src/main/AndroidManifest.xml b/drop-in/src/main/AndroidManifest.xml
index 64678e4f1f..a728050a2e 100644
--- a/drop-in/src/main/AndroidManifest.xml
+++ b/drop-in/src/main/AndroidManifest.xml
@@ -7,18 +7,15 @@
-
+ android:theme="@style/AdyenCheckout.Translucent">
+
diff --git a/drop-in/src/main/java/com/adyen/checkout/card/DropInCardView.kt b/drop-in/src/main/java/com/adyen/checkout/card/DropInCardView.kt
index 354bd17325..3405c4519e 100644
--- a/drop-in/src/main/java/com/adyen/checkout/card/DropInCardView.kt
+++ b/drop-in/src/main/java/com/adyen/checkout/card/DropInCardView.kt
@@ -13,18 +13,16 @@ import android.arch.lifecycle.Observer
import android.content.Context
import android.util.AttributeSet
import android.view.LayoutInflater
-import android.widget.LinearLayout
-import com.adyen.checkout.base.ComponentView
import com.adyen.checkout.base.api.ImageLoader
+import com.adyen.checkout.base.ui.view.AdyenLinearLayout
import com.adyen.checkout.card.data.CardOutputData
import kotlinx.android.synthetic.main.view_card_component_dropin.view.cardView
import kotlinx.android.synthetic.main.view_card_component_dropin.view.recyclerView_cardList
import com.adyen.checkout.dropin.R as dropInR
-class DropInCardView : LinearLayout, ComponentView, Observer {
+class DropInCardView : AdyenLinearLayout, Observer {
lateinit var mCardListAdapter: CardListAdapter
- lateinit var component: CardComponent
constructor(context: Context) : this(context, null)
@@ -35,20 +33,11 @@ class DropInCardView : LinearLayout, ComponentView, Observer, Observer getDefaultConfigFor(
PaymentMethodTypes.IDEAL -> {
IdealConfiguration.Builder(context)
}
- PaymentMethodTypes.MOLPAY -> {
+ PaymentMethodTypes.MOLPAY_THAILAND,
+ PaymentMethodTypes.MOLPAY_MALAYSIA,
+ PaymentMethodTypes.MOLPAY_VIETNAM -> {
MolpayConfiguration.Builder(context)
}
PaymentMethodTypes.EPS -> {
@@ -133,7 +135,9 @@ internal fun getProviderForType(type: String): PaymentComponentProvider {
IdealComponent.PROVIDER as PaymentComponentProvider
}
- PaymentMethodTypes.MOLPAY -> {
+ PaymentMethodTypes.MOLPAY_THAILAND,
+ PaymentMethodTypes.MOLPAY_MALAYSIA,
+ PaymentMethodTypes.MOLPAY_VIETNAM -> {
MolpayComponent.PROVIDER as PaymentComponentProvider
}
PaymentMethodTypes.EPS -> {
@@ -173,7 +177,7 @@ internal fun getProviderForType(type: String): PaymentComponentProvider {
- val molpayConfig: MolpayConfiguration = dropInConfiguration.getConfigurationFor(PaymentMethodTypes.MOLPAY, context)
+ PaymentMethodTypes.MOLPAY_THAILAND -> {
+ val molpayConfig: MolpayConfiguration = dropInConfiguration.getConfigurationFor(PaymentMethodTypes.MOLPAY_THAILAND, context)
+ MolpayComponent.PROVIDER.get(fragment, paymentMethod, molpayConfig)
+ }
+ PaymentMethodTypes.MOLPAY_MALAYSIA -> {
+ val molpayConfig: MolpayConfiguration = dropInConfiguration.getConfigurationFor(PaymentMethodTypes.MOLPAY_MALAYSIA, context)
+ MolpayComponent.PROVIDER.get(fragment, paymentMethod, molpayConfig)
+ }
+ PaymentMethodTypes.MOLPAY_VIETNAM -> {
+ val molpayConfig: MolpayConfiguration = dropInConfiguration.getConfigurationFor(PaymentMethodTypes.MOLPAY_VIETNAM, context)
MolpayComponent.PROVIDER.get(fragment, paymentMethod, molpayConfig)
}
PaymentMethodTypes.EPS -> {
@@ -233,7 +245,7 @@ internal fun getComponentFor(
/**
* Provides a [ComponentView] to be used in Drop-in using the [PaymentMethod] reference.
* View type is defined by our UI specifications.
- *
+ *MolpayRecyclerView.java
* @param context The context used to create the View
* @param paymentMethod The payment method to be parsed.
*/
@@ -244,7 +256,9 @@ internal fun getViewFor(context: Context, paymentMethod: PaymentMethod): Compone
PaymentMethodTypes.IDEAL -> {
IdealRecyclerView(context) as ComponentView
}
- PaymentMethodTypes.MOLPAY -> {
+ PaymentMethodTypes.MOLPAY_THAILAND,
+ PaymentMethodTypes.MOLPAY_MALAYSIA,
+ PaymentMethodTypes.MOLPAY_VIETNAM -> {
MolpayRecyclerView(context) as ComponentView
}
PaymentMethodTypes.EPS -> {
diff --git a/drop-in/src/main/java/com/adyen/checkout/dropin/DropIn.kt b/drop-in/src/main/java/com/adyen/checkout/dropin/DropIn.kt
index b7eed28e24..6c0f9f6d48 100644
--- a/drop-in/src/main/java/com/adyen/checkout/dropin/DropIn.kt
+++ b/drop-in/src/main/java/com/adyen/checkout/dropin/DropIn.kt
@@ -109,8 +109,10 @@ class DropIn private constructor() {
dropInConfiguration: DropInConfiguration,
resultHandlerIntent: Intent
) {
- dropInConfiguration.resultHandlerIntent = resultHandlerIntent
- startPayment(context, paymentMethodsApiResponse, dropInConfiguration)
+ val newConfigurationBuilder = DropInConfiguration.Builder(dropInConfiguration)
+ newConfigurationBuilder.setResultHandlerIntent(resultHandlerIntent)
+
+ startPayment(context, paymentMethodsApiResponse, newConfigurationBuilder.build())
}
}
}
diff --git a/drop-in/src/main/java/com/adyen/checkout/dropin/DropInConfiguration.kt b/drop-in/src/main/java/com/adyen/checkout/dropin/DropInConfiguration.kt
index 2e6982b2ad..b25ec34d21 100644
--- a/drop-in/src/main/java/com/adyen/checkout/dropin/DropInConfiguration.kt
+++ b/drop-in/src/main/java/com/adyen/checkout/dropin/DropInConfiguration.kt
@@ -13,13 +13,16 @@ import android.content.Context
import android.content.Intent
import android.os.Parcel
import android.os.Parcelable
-import com.adyen.checkout.base.Configuration
+import com.adyen.checkout.base.component.Configuration
+import com.adyen.checkout.base.model.payments.Amount
+import com.adyen.checkout.base.util.CheckoutCurrency
import com.adyen.checkout.base.util.PaymentMethodTypes
import com.adyen.checkout.bcmc.BcmcConfiguration
import com.adyen.checkout.card.CardConfiguration
import com.adyen.checkout.core.api.Environment
+import com.adyen.checkout.core.exception.CheckoutException
import com.adyen.checkout.core.log.LogUtil
-import com.adyen.checkout.core.log.Logger
+import com.adyen.checkout.core.model.JsonUtils
import com.adyen.checkout.core.util.LocaleUtil
import com.adyen.checkout.core.util.ParcelUtils
import com.adyen.checkout.dotpay.DotpayConfiguration
@@ -41,11 +44,10 @@ import java.util.Locale
@SuppressWarnings("TooManyFunctions")
class DropInConfiguration : Configuration, Parcelable {
- private val shopperLocale: Locale
- private val environment: Environment
val availableConfigs: HashMap
val serviceComponentName: ComponentName
- var resultHandlerIntent: Intent = Intent()
+ val resultHandlerIntent: Intent
+ val amount: Amount
companion object {
@JvmField
@@ -55,44 +57,40 @@ class DropInConfiguration : Configuration, Parcelable {
}
}
- constructor(builder: Builder) {
- availableConfigs = builder.availableConfigs
- shopperLocale = builder.shopperLocale
- environment = builder.mEnvironment
- serviceComponentName = builder.serviceComponentName
- builder.resultHandlerIntent?.let {
- resultHandlerIntent = it
- }
+ constructor(
+ shopperLocale: Locale,
+ environment: Environment,
+ availableConfigs: HashMap,
+ serviceComponentName: ComponentName,
+ resultHandlerIntent: Intent,
+ amount: Amount
+ ) : super(shopperLocale, environment) {
+ this.availableConfigs = availableConfigs
+ this.serviceComponentName = serviceComponentName
+ this.resultHandlerIntent = resultHandlerIntent
+ this.amount = amount
}
- constructor(parcel: Parcel) {
+ constructor(parcel: Parcel) : super(parcel) {
+ @Suppress("UNCHECKED_CAST")
availableConfigs = parcel.readHashMap(Configuration::class.java.classLoader) as HashMap
- shopperLocale = parcel.readSerializable() as Locale
- environment = parcel.readParcelable(Environment::class.java.classLoader)
- serviceComponentName = parcel.readParcelable(ComponentName::class.java.classLoader)
- resultHandlerIntent = parcel.readParcelable(Intent::class.java.classLoader)
+ serviceComponentName = parcel.readParcelable(ComponentName::class.java.classLoader)!!
+ resultHandlerIntent = parcel.readParcelable(Intent::class.java.classLoader)!!
+ amount = Amount.CREATOR.createFromParcel(parcel)
}
override fun writeToParcel(dest: Parcel, flags: Int) {
+ super.writeToParcel(dest, flags)
dest.writeMap(availableConfigs)
- dest.writeSerializable(shopperLocale)
- dest.writeParcelable(environment, flags)
dest.writeParcelable(serviceComponentName, flags)
dest.writeParcelable(resultHandlerIntent, flags)
+ JsonUtils.writeToParcel(dest, Amount.SERIALIZER.serialize(amount))
}
override fun describeContents(): Int {
return ParcelUtils.NO_FILE_DESCRIPTOR
}
- override fun getShopperLocale(): Locale {
- return shopperLocale
- }
-
- override fun getEnvironment(): Environment {
- return environment
- }
-
fun getConfigurationFor(@PaymentMethodTypes.SupportedPaymentMethod paymentMethod: String, context: Context): T {
return if (PaymentMethodTypes.SUPPORTED_PAYMENT_METHODS.contains(paymentMethod) && availableConfigs.containsKey(paymentMethod)) {
@Suppress("UNCHECKED_CAST")
@@ -111,38 +109,74 @@ class DropInConfiguration : Configuration, Parcelable {
val TAG = LogUtil.getTag()
}
- var serviceComponentName: ComponentName
- var shopperLocale: Locale
- var mEnvironment: Environment = Environment.EUROPE
- var resultHandlerIntent: Intent? = null
+ private val availableConfigs = HashMap()
+
+ private var serviceComponentName: ComponentName
+ private var shopperLocale: Locale
+ private var resultHandlerIntent: Intent
+ private var environment: Environment = Environment.EUROPE
+ private var amount: Amount = Amount.EMPTY
private val packageName: String
private val serviceClassName: String
- private val context: Context
@Deprecated("You need to pass resultHandlerIntent to drop-in configuration")
- constructor(context: Context, serviceClass: Class) : this(context, null, serviceClass)
+ constructor(context: Context, serviceClass: Class) : this(context, Intent(), serviceClass)
/**
* @param context
* @param resultHandlerIntent The Intent used with [Activity.startActivity] that will contain the payment result extra with key [RESULT_KEY].
* @param serviceClass Service that extended from [DropInService] that would handle network requests.
*/
- constructor(context: Context, resultHandlerIntent: Intent?, serviceClass: Class) {
+ constructor(context: Context, resultHandlerIntent: Intent, serviceClass: Class) {
this.packageName = context.packageName
this.serviceClassName = serviceClass.name
+
this.resultHandlerIntent = resultHandlerIntent
- this.context = context
+ this.serviceComponentName = ComponentName(packageName, serviceClassName)
+ this.shopperLocale = LocaleUtil.getLocale(context)
+ }
+
+ /**
+ * Create a Builder with the same values of an existing Configuration object.
+ */
+ constructor(dropInConfiguration: DropInConfiguration) {
+ this.packageName = dropInConfiguration.serviceComponentName.packageName
+ this.serviceClassName = dropInConfiguration.serviceComponentName.className
- Logger.d(TAG, "class name - $serviceClassName")
- serviceComponentName = ComponentName(packageName, serviceClassName)
- shopperLocale = LocaleUtil.getLocale(context)
+ this.serviceComponentName = dropInConfiguration.serviceComponentName
+ this.shopperLocale = dropInConfiguration.shopperLocale
+ this.environment = dropInConfiguration.environment
+ this.resultHandlerIntent = dropInConfiguration.resultHandlerIntent
+ this.amount = dropInConfiguration.amount
}
- internal val availableConfigs = HashMap()
+ fun setServiceComponentName(serviceComponentName: ComponentName): Builder {
+ this.serviceComponentName = serviceComponentName
+ return this
+ }
- fun build(): DropInConfiguration {
- return DropInConfiguration(this)
+ fun setShopperLocale(shopperLocale: Locale): Builder {
+ this.shopperLocale = shopperLocale
+ return this
+ }
+
+ fun setResultHandlerIntent(resultHandlerIntent: Intent): Builder {
+ this.resultHandlerIntent = resultHandlerIntent
+ return this
+ }
+
+ fun setEnvironment(environment: Environment): Builder {
+ this.environment = environment
+ return this
+ }
+
+ fun setAmount(amount: Amount): Builder {
+ if (!CheckoutCurrency.isSupported(amount.currency) || amount.value < 0) {
+ throw CheckoutException("Currency is not valid.")
+ }
+ this.amount = amount
+ return this
}
/**
@@ -162,10 +196,26 @@ class DropInConfiguration : Configuration, Parcelable {
}
/**
- * Add configuration for MolPay payment method.
+ * Add configuration for MolPay Thailand payment method.
+ */
+ fun addMolpayThailandConfiguration(molpayConfiguration: MolpayConfiguration): Builder {
+ availableConfigs[PaymentMethodTypes.MOLPAY_THAILAND] = molpayConfiguration
+ return this
+ }
+
+ /**
+ * Add configuration for MolPay Malasya payment method.
*/
- fun addMolpayConfiguration(molpayConfiguration: MolpayConfiguration): Builder {
- availableConfigs[PaymentMethodTypes.MOLPAY] = molpayConfiguration
+ fun addMolpayMalasyaConfiguration(molpayConfiguration: MolpayConfiguration): Builder {
+ availableConfigs[PaymentMethodTypes.MOLPAY_MALAYSIA] = molpayConfiguration
+ return this
+ }
+
+ /**
+ * Add configuration for MolPay Vietnam payment method.
+ */
+ fun addMolpayVietnamConfiguration(molpayConfiguration: MolpayConfiguration): Builder {
+ availableConfigs[PaymentMethodTypes.MOLPAY_VIETNAM] = molpayConfiguration
return this
}
@@ -224,5 +274,19 @@ class DropInConfiguration : Configuration, Parcelable {
availableConfigs[PaymentMethodTypes.BCMC] = bcmcConfiguration
return this
}
+
+ /**
+ * Create the [DropInConfiguration] instance.
+ */
+ fun build(): DropInConfiguration {
+ return DropInConfiguration(
+ shopperLocale,
+ environment,
+ availableConfigs,
+ serviceComponentName,
+ resultHandlerIntent,
+ amount
+ )
+ }
}
}
diff --git a/drop-in/src/main/java/com/adyen/checkout/dropin/service/DropInService.kt b/drop-in/src/main/java/com/adyen/checkout/dropin/service/DropInService.kt
index 57b8f9bed7..7e477a8bea 100644
--- a/drop-in/src/main/java/com/adyen/checkout/dropin/service/DropInService.kt
+++ b/drop-in/src/main/java/com/adyen/checkout/dropin/service/DropInService.kt
@@ -15,7 +15,7 @@ import android.support.v4.app.JobIntentService
import android.support.v4.content.LocalBroadcastManager
import com.adyen.checkout.base.model.payments.request.PaymentComponentData
import com.adyen.checkout.base.model.payments.request.PaymentMethodDetails
-import com.adyen.checkout.core.exeption.CheckoutException
+import com.adyen.checkout.core.exception.CheckoutException
import com.adyen.checkout.core.log.LogUtil
import com.adyen.checkout.core.log.Logger
import org.json.JSONObject
diff --git a/drop-in/src/main/java/com/adyen/checkout/dropin/ui/DropInActivity.kt b/drop-in/src/main/java/com/adyen/checkout/dropin/ui/DropInActivity.kt
index 72d72a38e1..415fd10c6e 100644
--- a/drop-in/src/main/java/com/adyen/checkout/dropin/ui/DropInActivity.kt
+++ b/drop-in/src/main/java/com/adyen/checkout/dropin/ui/DropInActivity.kt
@@ -10,12 +10,16 @@ package com.adyen.checkout.dropin.ui
import android.arch.lifecycle.Observer
import android.arch.lifecycle.ViewModelProviders
+import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
+import android.content.IntentFilter
import android.os.Bundle
-import android.os.PersistableBundle
import android.support.v4.app.DialogFragment
+import android.support.v4.content.LocalBroadcastManager
import android.support.v7.app.AppCompatActivity
+import android.widget.Toast
+import com.adyen.checkout.base.ActionComponentData
import com.adyen.checkout.base.ComponentError
import com.adyen.checkout.base.PaymentComponentState
import com.adyen.checkout.base.analytics.AnalyticEvent
@@ -24,40 +28,47 @@ import com.adyen.checkout.base.model.PaymentMethodsApiResponse
import com.adyen.checkout.base.model.paymentmethods.PaymentMethod
import com.adyen.checkout.base.model.payments.request.PaymentComponentData
import com.adyen.checkout.base.model.payments.request.PaymentMethodDetails
+import com.adyen.checkout.base.model.payments.response.Action
import com.adyen.checkout.base.util.PaymentMethodTypes
+import com.adyen.checkout.core.code.Lint
+import com.adyen.checkout.core.exception.CheckoutException
import com.adyen.checkout.core.log.LogUtil
import com.adyen.checkout.core.log.Logger
+import com.adyen.checkout.dropin.ActionHandler
import com.adyen.checkout.dropin.DropIn
import com.adyen.checkout.dropin.DropInConfiguration
import com.adyen.checkout.dropin.R
+import com.adyen.checkout.dropin.service.CallResult
+import com.adyen.checkout.dropin.service.DropInService
import com.adyen.checkout.dropin.ui.base.DropInBottomSheetDialogFragment
import com.adyen.checkout.dropin.ui.component.CardComponentDialogFragment
import com.adyen.checkout.dropin.ui.component.GenericComponentDialogFragment
import com.adyen.checkout.dropin.ui.paymentmethods.PaymentMethodListDialogFragment
import com.adyen.checkout.googlepay.GooglePayComponent
import com.adyen.checkout.googlepay.GooglePayConfiguration
+import com.adyen.checkout.redirect.RedirectUtil
+import org.json.JSONObject
/**
* Activity that presents the available PaymentMethods to the Shopper.
*/
-@Suppress("TooManyFunctions")
-class DropInActivity : AppCompatActivity(), DropInBottomSheetDialogFragment.Protocol {
+@Suppress("TooManyFunctions", "SyntheticAccessor")
+class DropInActivity : AppCompatActivity(), DropInBottomSheetDialogFragment.Protocol, ActionHandler.DetailsRequestedInterface {
companion object {
private val TAG = LogUtil.getTag()
private const val PAYMENT_METHOD_FRAGMENT_TAG = "PAYMENT_METHODS_DIALOG_FRAGMENT"
private const val COMPONENT_FRAGMENT_TAG = "COMPONENT_DIALOG_FRAGMENT"
+ private const val LOADING_FRAGMENT_TAG = "LOADING_DIALOG_FRAGMENT"
private const val PAYMENT_METHODS_RESPONSE_KEY = "PAYMENT_METHODS_RESPONSE_KEY"
private const val DROP_IN_CONFIGURATION_KEY = "DROP_IN_CONFIGURATION_KEY"
+ private const val IS_LOADING_DIALOG_VISIBLE = "IS_LOADING_DIALOG_VISIBLE"
private const val DROP_IN_INTENT = "DROP_IN_INTENT"
private const val GOOGLE_PAY_REQUEST_CODE = 1
- const val CALL_RESULT_KEY_FROM_RESULT = "CALL_RESULT_KEY_FROM_RESULT"
- const val CALL_RESULT_REQUEST_CODE = 2
-
fun createIntent(context: Context, dropInConfiguration: DropInConfiguration, paymentMethodsApiResponse: PaymentMethodsApiResponse): Intent {
val intent = Intent(context, DropInActivity::class.java)
intent.putExtra(PAYMENT_METHODS_RESPONSE_KEY, paymentMethodsApiResponse)
@@ -72,6 +83,35 @@ class DropInActivity : AppCompatActivity(), DropInBottomSheetDialogFragment.Prot
private lateinit var resultIntent: Intent
private lateinit var googlePayComponent: GooglePayComponent
+ private lateinit var callResultIntentFilter: IntentFilter
+
+ private lateinit var localBroadcastManager: LocalBroadcastManager
+
+ @Suppress(Lint.PROTECTED_IN_FINAL)
+ protected lateinit var actionHandler: ActionHandler
+
+ // If a new intent is received we can continue processing, otherwise we might need to time out
+ @Suppress(Lint.PROTECTED_IN_FINAL)
+ private var newIntentReceived = false
+
+ private val loadingDialog = LoadingDialogFragment.newInstance()
+ private var isLoadingVisible = false
+
+ private val callResultReceiver = object : BroadcastReceiver() {
+ override fun onReceive(context: Context?, intent: Intent?) {
+ Logger.d(TAG, "callResultReceiver onReceive")
+ if (context != null && intent != null) {
+ newIntentReceived = false
+ if (intent.hasExtra(DropInService.API_CALL_RESULT_KEY)) {
+ val callResult = intent.getParcelableExtra(DropInService.API_CALL_RESULT_KEY)
+ handleCallResult(callResult)
+ } else {
+ throw CheckoutException("No extra on callResultReceiver")
+ }
+ }
+ }
+ }
+
private val googlePayObserver: Observer> = Observer {
if (it!!.isValid) {
sendPaymentRequest(it.data)
@@ -116,6 +156,17 @@ class DropInActivity : AppCompatActivity(), DropInBottomSheetDialogFragment.Prot
intent.getParcelableExtra(DROP_IN_INTENT)
}
+ savedInstanceState?.let { isLoadingVisible = it.getBoolean(IS_LOADING_DIALOG_VISIBLE, false) }
+
+ callResultIntentFilter = IntentFilter(DropInService.getCallResultAction(this))
+
+ // registerBroadcastReceivers
+ localBroadcastManager = LocalBroadcastManager.getInstance(this)
+ localBroadcastManager.registerReceiver(callResultReceiver, callResultIntentFilter)
+
+ actionHandler = ActionHandler(this, this)
+ actionHandler.restoreState(savedInstanceState)
+
sendAnalyticsEvent()
}
@@ -123,35 +174,61 @@ class DropInActivity : AppCompatActivity(), DropInBottomSheetDialogFragment.Prot
super.onActivityResult(requestCode, resultCode, data)
when (requestCode) {
GOOGLE_PAY_REQUEST_CODE -> googlePayComponent.handleActivityResult(resultCode, data)
- CALL_RESULT_REQUEST_CODE -> {
- data?.let {
- dropInConfiguration.resultHandlerIntent.putExtra(DropIn.RESULT_KEY,
- it.getStringExtra(CALL_RESULT_KEY_FROM_RESULT)).let { intent ->
- startActivity(intent)
- overridePendingTransition(0, R.anim.fade_out)
- }
- }
- }
}
}
override fun sendPaymentRequest(paymentComponentData: PaymentComponentData) {
- val loadingActivity = LoadingActivity.getIntentForPayments(this, paymentComponentData, dropInConfiguration)
- startActivityForResult(loadingActivity, CALL_RESULT_REQUEST_CODE)
+ loadingDialog.show(supportFragmentManager, LOADING_FRAGMENT_TAG)
+ isLoadingVisible = true
+ DropInService.requestPaymentsCall(this, paymentComponentData, dropInConfiguration.serviceComponentName)
+ }
+
+ override fun onNewIntent(intent: Intent?) {
+ super.onNewIntent(intent)
+ Logger.d(TAG, "onNewIntent")
+ if (intent != null) {
+ handleIntent(intent)
+ } else {
+ Logger.e(TAG, "Null intent")
+ }
}
- override fun onSaveInstanceState(outState: Bundle?, outPersistentState: PersistableBundle?) {
- super.onSaveInstanceState(outState, outPersistentState)
+ override fun requestDetailsCall(actionComponentData: ActionComponentData) {
+ DropInService.requestDetailsCall(this,
+ ActionComponentData.SERIALIZER.serialize(actionComponentData),
+ dropInConfiguration.serviceComponentName)
+ }
+
+ override fun onError(errorMessage: String) {
+ Toast.makeText(this, R.string.action_failed, Toast.LENGTH_LONG).show()
+ finish()
+ }
+
+ override fun onSaveInstanceState(outState: Bundle?) {
+ super.onSaveInstanceState(outState)
Logger.d(TAG, "onSaveInstanceState")
- outState?.putParcelable(PAYMENT_METHODS_RESPONSE_KEY, dropInViewModel.paymentMethodsApiResponse)
- outState?.putParcelable(DROP_IN_CONFIGURATION_KEY, dropInConfiguration)
+ outState?.let {
+ it.putParcelable(PAYMENT_METHODS_RESPONSE_KEY, dropInViewModel.paymentMethodsApiResponse)
+ it.putParcelable(DROP_IN_CONFIGURATION_KEY, dropInConfiguration)
+ it.putBoolean(IS_LOADING_DIALOG_VISIBLE, isLoadingVisible)
+
+ actionHandler.saveState(it)
+ }
+ }
+
+ override fun onResume() {
+ super.onResume()
+ if (!newIntentReceived && isLoadingVisible) {
+ getFragmentByTag(LOADING_FRAGMENT_TAG)?.dismiss()
+ }
}
override fun onDestroy() {
super.onDestroy()
Logger.d(TAG, "onDestroy")
+ localBroadcastManager.unregisterReceiver(callResultReceiver)
}
override fun showComponentDialog(paymentMethod: PaymentMethod, wasInExpandMode: Boolean) {
@@ -187,6 +264,54 @@ class DropInActivity : AppCompatActivity(), DropInBottomSheetDialogFragment.Prot
googlePayComponent.startGooglePayScreen(this, GOOGLE_PAY_REQUEST_CODE)
}
+ @Suppress(Lint.PROTECTED_IN_FINAL)
+ protected fun handleCallResult(callResult: CallResult) {
+ Logger.d(TAG, "handleCallResult - ${callResult.type.name}")
+ when (callResult.type) {
+ CallResult.ResultType.FINISHED -> {
+ this.sendResult(callResult.content)
+ }
+ CallResult.ResultType.ACTION -> {
+ val action = Action.SERIALIZER.deserialize(JSONObject(callResult.content))
+ actionHandler.handleAction(this, action, this::sendResult)
+ }
+ CallResult.ResultType.ERROR -> {
+ Logger.d(TAG, "ERROR - ${callResult.content}")
+ Toast.makeText(this, R.string.payment_failed, Toast.LENGTH_LONG).show()
+ finish()
+ }
+ CallResult.ResultType.WAIT -> {
+ throw CheckoutException("WAIT CallResult is not expected to be propagated.")
+ }
+ }
+ }
+
+ private fun sendResult(content: String) {
+ dropInConfiguration.resultHandlerIntent.putExtra(DropIn.RESULT_KEY, content).let { intent ->
+ startActivity(intent)
+ terminateDropIn()
+ }
+ }
+
+ private fun handleIntent(intent: Intent) {
+ Logger.d(TAG, "handleIntent - ${intent.action}")
+ newIntentReceived = true
+ when (intent.action) {
+ // Redirect response
+ Intent.ACTION_VIEW -> {
+ val data = intent.data
+ if (data != null && data.toString().startsWith(RedirectUtil.REDIRECT_RESULT_SCHEME)) {
+ actionHandler.handleRedirectResponse(data)
+ } else {
+ Logger.e(TAG, "Unexpected response from ACTION_VIEW - ${intent.data}")
+ }
+ }
+ else -> {
+ Logger.e(TAG, "Unable to find action")
+ }
+ }
+ }
+
private fun sendAnalyticsEvent() {
Logger.d(TAG, "sendAnalyticsEvent")
val analyticEvent = AnalyticEvent.create(this, AnalyticEvent.Flavor.DROPIN,
diff --git a/drop-in/src/main/java/com/adyen/checkout/dropin/ui/DropInViewModel.kt b/drop-in/src/main/java/com/adyen/checkout/dropin/ui/DropInViewModel.kt
index 4a2447f6f0..61f334769b 100644
--- a/drop-in/src/main/java/com/adyen/checkout/dropin/ui/DropInViewModel.kt
+++ b/drop-in/src/main/java/com/adyen/checkout/dropin/ui/DropInViewModel.kt
@@ -12,7 +12,7 @@ import android.app.Application
import android.arch.lifecycle.AndroidViewModel
import android.arch.lifecycle.MutableLiveData
import com.adyen.checkout.base.ComponentAvailableCallback
-import com.adyen.checkout.base.Configuration
+import com.adyen.checkout.base.component.Configuration
import com.adyen.checkout.base.model.PaymentMethodsApiResponse
import com.adyen.checkout.base.model.paymentmethods.PaymentMethod
import com.adyen.checkout.base.model.paymentmethods.RecurringDetail
diff --git a/drop-in/src/main/java/com/adyen/checkout/dropin/ui/LoadingActivity.kt b/drop-in/src/main/java/com/adyen/checkout/dropin/ui/LoadingActivity.kt
deleted file mode 100644
index f05bf2608b..0000000000
--- a/drop-in/src/main/java/com/adyen/checkout/dropin/ui/LoadingActivity.kt
+++ /dev/null
@@ -1,240 +0,0 @@
-/*
- * Copyright (c) 2019 Adyen N.V.
- *
- * This file is open source and available under the MIT license. See the LICENSE file for more info.
- *
- * Created by caiof on 4/4/2019.
- */
-
-package com.adyen.checkout.dropin.ui
-
-import android.content.BroadcastReceiver
-import android.content.Context
-import android.content.Intent
-import android.content.IntentFilter
-import android.os.Bundle
-import android.os.Handler
-import android.support.v4.content.LocalBroadcastManager
-import android.support.v7.app.AppCompatActivity
-import android.widget.Toast
-import com.adyen.checkout.base.ActionComponentData
-import com.adyen.checkout.base.model.payments.request.PaymentComponentData
-import com.adyen.checkout.base.model.payments.request.PaymentMethodDetails
-import com.adyen.checkout.base.model.payments.response.Action
-import com.adyen.checkout.core.code.Lint
-import com.adyen.checkout.core.exeption.CheckoutException
-import com.adyen.checkout.core.log.LogUtil
-import com.adyen.checkout.core.log.Logger
-import com.adyen.checkout.dropin.ActionHandler
-import com.adyen.checkout.dropin.DropInConfiguration
-import com.adyen.checkout.dropin.R
-import com.adyen.checkout.dropin.service.CallResult
-import com.adyen.checkout.dropin.service.DropInService
-import com.adyen.checkout.redirect.RedirectUtil
-import org.json.JSONObject
-
-/**
- * Activity that presents a loading state to the user. Used to wait for API calls and handle Redirects.
- */
-@Suppress("TooManyFunctions")
-class LoadingActivity : AppCompatActivity(), ActionHandler.DetailsRequestedInterface {
-
- companion object {
- @Suppress(Lint.PROTECTED_IN_FINAL)
- protected val TAG = LogUtil.getTag()
-
- private const val PAYMENT_COMPONENT_DATA_REQUEST_KEY = "payment_component_data_request"
- private const val DROP_IN_COMPONENT_CONFIG_KEY = "drop_in_component_config_key"
- private const val ACTION_PAYMENTS = "payments"
-
- private const val TIME_OUT_DELAY = 10000L
-
- // False positive
- @Suppress("FunctionParameterNaming")
- fun getIntentForPayments(
- context: Context,
- paymentComponentData: PaymentComponentData,
- dropInConfiguration: DropInConfiguration
- ): Intent {
- val intent = Intent(context, LoadingActivity::class.java)
- intent.putExtra(PAYMENT_COMPONENT_DATA_REQUEST_KEY, paymentComponentData)
- intent.putExtra(DROP_IN_COMPONENT_CONFIG_KEY, dropInConfiguration)
- intent.action = ACTION_PAYMENTS
- return intent
- }
- }
-
- private lateinit var dropInConfiguration: DropInConfiguration
-
- private val timeoutHandler = Handler()
- private val timeoutRunnable = Runnable {
- Logger.e(TAG, "Timed out without a response.")
- Toast.makeText(this@LoadingActivity, R.string.time_out_error, Toast.LENGTH_LONG).show()
- finish()
- }
-
- private lateinit var callResultIntentFilter: IntentFilter
-
- @Suppress(Lint.PROTECTED_IN_FINAL)
- protected lateinit var actionHandler: ActionHandler
-
- // If a new intent is received we can continue processing, otherwise we might need to time out
- @Suppress(Lint.PROTECTED_IN_FINAL)
- protected var newIntentReceived = false
-
- private val callResultReceiver = object : BroadcastReceiver() {
- override fun onReceive(context: Context?, intent: Intent?) {
- Logger.d(TAG, "callResultReceiver onReceive")
- if (context != null && intent != null) {
- newIntentReceived = false
- if (intent.hasExtra(DropInService.API_CALL_RESULT_KEY)) {
- val callResult = intent.getParcelableExtra(DropInService.API_CALL_RESULT_KEY)
- handleCallResult(callResult)
- } else {
- throw CheckoutException("No extra on callResultReceiver")
- }
- }
- }
- }
-
- override fun onCreate(savedInstanceState: Bundle?) {
- super.onCreate(savedInstanceState)
- Logger.d(TAG, "onCreate - $savedInstanceState")
-
- setContentView(R.layout.loading)
- overridePendingTransition(0, 0)
-
- callResultIntentFilter = IntentFilter(DropInService.getCallResultAction(this))
-
- // registerBroadcastReceivers
- val localBroadcastManager = LocalBroadcastManager.getInstance(this)
- localBroadcastManager.registerReceiver(callResultReceiver, callResultIntentFilter)
-
- dropInConfiguration = if (savedInstanceState != null && savedInstanceState.containsKey(DROP_IN_COMPONENT_CONFIG_KEY)) {
- savedInstanceState.getParcelable(DROP_IN_COMPONENT_CONFIG_KEY)!!
- } else {
- intent.getParcelableExtra(DROP_IN_COMPONENT_CONFIG_KEY)
- }
-
- actionHandler = ActionHandler(this, this)
- actionHandler.restoreState(savedInstanceState)
-
- if (savedInstanceState == null) {
- handleIntent(intent)
- } else {
- Logger.d(TAG, "Restoring saved stave from ${intent.action}")
- }
- }
-
- override fun onResume() {
- super.onResume()
- // Back from other Activity
- if (!newIntentReceived) {
- Logger.d(TAG, "onResume without response, setting time out")
- timeoutHandler.postDelayed(timeoutRunnable, TIME_OUT_DELAY)
- }
- }
-
- override fun onSaveInstanceState(outState: Bundle?) {
- actionHandler.saveState(outState)
- super.onSaveInstanceState(outState)
- }
-
- override fun onPause() {
- super.onPause()
- Logger.d(TAG, "onPause")
- timeoutHandler.removeCallbacks(timeoutRunnable)
- }
-
- override fun onDestroy() {
- super.onDestroy()
- Logger.d(TAG, "onDestroy")
- // unregisterBroadcastReceivers
- val localBroadcastManager = LocalBroadcastManager.getInstance(this)
- localBroadcastManager.unregisterReceiver(callResultReceiver)
- }
-
- override fun onNewIntent(intent: Intent?) {
- super.onNewIntent(intent)
- Logger.d(TAG, "onNewIntent")
- if (intent != null) {
- handleIntent(intent)
- } else {
- Logger.e(TAG, "Null intent")
- }
- }
-
- override fun onBackPressed() {
- // Don't finish here, instead wait for onNewIntent() or to be finished in onResume().
- // TODO create time out?
- }
-
- override fun requestDetailsCall(actionComponentData: ActionComponentData) {
- DropInService.requestDetailsCall(this@LoadingActivity,
- ActionComponentData.SERIALIZER.serialize(actionComponentData),
- dropInConfiguration.serviceComponentName)
- }
-
- private fun handleIntent(intent: Intent) {
- Logger.d(TAG, "handleIntent - ${intent.action}")
- newIntentReceived = true
- when (intent.action) {
- ACTION_PAYMENTS -> {
- val paymentComponentData: PaymentComponentData =
- intent.getParcelableExtra(PAYMENT_COMPONENT_DATA_REQUEST_KEY)
- DropInService.requestPaymentsCall(this, paymentComponentData, dropInConfiguration.serviceComponentName)
- }
- // Redirect response
- Intent.ACTION_VIEW -> {
- val data = intent.data
- if (data != null && data.toString().startsWith(RedirectUtil.REDIRECT_RESULT_SCHEME)) {
- actionHandler.handleRedirectResponse(data)
- } else {
- Logger.e(TAG, "Unexpected response from ACTION_VIEW - ${intent.data}")
- }
- }
- else -> {
- Logger.e(TAG, "Unable to find action")
- }
- }
- }
-
- @Suppress(Lint.PROTECTED_IN_FINAL)
- protected fun handleCallResult(callResult: CallResult) {
- Logger.d(TAG, "handleCallResult - ${callResult.type.name}")
- when (callResult.type) {
- CallResult.ResultType.FINISHED -> {
- this.sendResult(callResult.content)
- }
- CallResult.ResultType.ACTION -> {
- val action = Action.SERIALIZER.deserialize(JSONObject(callResult.content))
- actionHandler.handleAction(this@LoadingActivity, action, this::sendResult)
- }
- CallResult.ResultType.ERROR -> {
- Logger.d(TAG, "ERROR - ${callResult.content}")
- Toast.makeText(this@LoadingActivity, R.string.payment_failed, Toast.LENGTH_LONG).show()
- finish()
- }
- CallResult.ResultType.WAIT -> {
- throw CheckoutException("WAIT CallResult is not expected to be propagated.")
- }
- }
- }
-
- override fun onError(errorMessage: String) {
- Toast.makeText(this@LoadingActivity, R.string.action_failed, Toast.LENGTH_LONG).show()
- finish()
- }
-
- override fun finish() {
- super.finish()
- overridePendingTransition(0, R.anim.fade_out)
- }
-
- private fun sendResult(content: String) {
- val data = Intent()
- data.putExtra(DropInActivity.CALL_RESULT_KEY_FROM_RESULT, content)
- setResult(RESULT_OK, data)
- finish()
- }
-}
diff --git a/drop-in/src/main/java/com/adyen/checkout/dropin/ui/LoadingDialogFragment.kt b/drop-in/src/main/java/com/adyen/checkout/dropin/ui/LoadingDialogFragment.kt
new file mode 100644
index 0000000000..45e638c5c6
--- /dev/null
+++ b/drop-in/src/main/java/com/adyen/checkout/dropin/ui/LoadingDialogFragment.kt
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2019 Adyen N.V.
+ *
+ * This file is open source and available under the MIT license. See the LICENSE file for more info.
+ *
+ * Created by arman on 25/9/2019.
+ */
+
+package com.adyen.checkout.dropin.ui
+
+import android.graphics.Color
+import android.graphics.drawable.ColorDrawable
+import android.os.Bundle
+import android.support.v4.app.DialogFragment
+import android.view.LayoutInflater
+import android.view.View
+import android.view.ViewGroup
+import com.adyen.checkout.dropin.R
+
+class LoadingDialogFragment : DialogFragment() {
+
+ companion object {
+ fun newInstance(): LoadingDialogFragment {
+ return LoadingDialogFragment()
+ }
+ }
+
+ override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
+ dialog.window.setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT))
+ isCancelable = false
+ return inflater.inflate(R.layout.loading, container, false)
+ }
+}
diff --git a/drop-in/src/main/java/com/adyen/checkout/dropin/ui/base/BaseComponentDialogFragment.kt b/drop-in/src/main/java/com/adyen/checkout/dropin/ui/base/BaseComponentDialogFragment.kt
index 26378c738e..af4911cbba 100644
--- a/drop-in/src/main/java/com/adyen/checkout/dropin/ui/base/BaseComponentDialogFragment.kt
+++ b/drop-in/src/main/java/com/adyen/checkout/dropin/ui/base/BaseComponentDialogFragment.kt
@@ -20,7 +20,7 @@ import com.adyen.checkout.base.PaymentComponent
import com.adyen.checkout.base.PaymentComponentState
import com.adyen.checkout.base.model.paymentmethods.PaymentMethod
import com.adyen.checkout.base.model.payments.request.PaymentMethodDetails
-import com.adyen.checkout.core.exeption.CheckoutException
+import com.adyen.checkout.core.exception.CheckoutException
import com.adyen.checkout.core.log.LogUtil
import com.adyen.checkout.core.log.Logger
import com.adyen.checkout.dropin.DropInConfiguration
diff --git a/drop-in/src/main/java/com/adyen/checkout/dropin/ui/component/CardComponentDialogFragment.kt b/drop-in/src/main/java/com/adyen/checkout/dropin/ui/component/CardComponentDialogFragment.kt
index e0323fc0c2..f13632c288 100644
--- a/drop-in/src/main/java/com/adyen/checkout/dropin/ui/component/CardComponentDialogFragment.kt
+++ b/drop-in/src/main/java/com/adyen/checkout/dropin/ui/component/CardComponentDialogFragment.kt
@@ -15,8 +15,9 @@ import android.view.View
import android.view.ViewGroup
import com.adyen.checkout.base.PaymentComponentState
import com.adyen.checkout.base.model.payments.request.PaymentMethodDetails
+import com.adyen.checkout.base.util.CurrencyUtils
import com.adyen.checkout.card.CardComponent
-import com.adyen.checkout.core.exeption.CheckoutException
+import com.adyen.checkout.core.exception.CheckoutException
import com.adyen.checkout.core.log.LogUtil
import com.adyen.checkout.core.log.Logger
import com.adyen.checkout.dropin.R
@@ -45,6 +46,11 @@ class CardComponentDialogFragment : BaseComponentDialogFragment() {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
Logger.d(TAG, "onViewCreated")
+ if (!dropInConfiguration.amount.isEmpty) {
+ val value = CurrencyUtils.formatAmount(dropInConfiguration.amount, dropInConfiguration.shopperLocale)
+ dropInCardView.payButton.text = String.format(resources.getString(R.string.pay_button_with_value), value)
+ }
+
component.observe(this, this)
component.observeErrors(this, createErrorHandlerObserver())
diff --git a/drop-in/src/main/java/com/adyen/checkout/dropin/ui/component/GenericComponentDialogFragment.kt b/drop-in/src/main/java/com/adyen/checkout/dropin/ui/component/GenericComponentDialogFragment.kt
index fd254ca4d7..47bb796b70 100644
--- a/drop-in/src/main/java/com/adyen/checkout/dropin/ui/component/GenericComponentDialogFragment.kt
+++ b/drop-in/src/main/java/com/adyen/checkout/dropin/ui/component/GenericComponentDialogFragment.kt
@@ -18,7 +18,8 @@ import com.adyen.checkout.base.ComponentView
import com.adyen.checkout.base.PaymentComponent
import com.adyen.checkout.base.PaymentComponentState
import com.adyen.checkout.base.model.payments.request.PaymentMethodDetails
-import com.adyen.checkout.core.exeption.CheckoutException
+import com.adyen.checkout.base.util.CurrencyUtils
+import com.adyen.checkout.core.exception.CheckoutException
import com.adyen.checkout.core.log.LogUtil
import com.adyen.checkout.core.log.Logger
import com.adyen.checkout.dropin.R
@@ -44,6 +45,11 @@ class GenericComponentDialogFragment : BaseComponentDialogFragment() {
Logger.d(TAG, "onViewCreated")
view.header.text = paymentMethod.name
+ if (!dropInConfiguration.amount.isEmpty) {
+ val value = CurrencyUtils.formatAmount(dropInConfiguration.amount, dropInConfiguration.shopperLocale)
+ payButton.text = String.format(resources.getString(R.string.pay_button_with_value), value)
+ }
+
payButton.setOnClickListener {
startPayment()
}
diff --git a/drop-in/src/main/java/com/adyen/checkout/dropin/ui/paymentmethods/PaymentMethodListDialogFragment.kt b/drop-in/src/main/java/com/adyen/checkout/dropin/ui/paymentmethods/PaymentMethodListDialogFragment.kt
index 188386e309..a36a8ce45c 100644
--- a/drop-in/src/main/java/com/adyen/checkout/dropin/ui/paymentmethods/PaymentMethodListDialogFragment.kt
+++ b/drop-in/src/main/java/com/adyen/checkout/dropin/ui/paymentmethods/PaymentMethodListDialogFragment.kt
@@ -23,7 +23,7 @@ import com.adyen.checkout.base.model.payments.request.GenericPaymentMethod
import com.adyen.checkout.base.model.payments.request.PaymentComponentData
import com.adyen.checkout.base.model.payments.request.PaymentMethodDetails
import com.adyen.checkout.base.util.PaymentMethodTypes
-import com.adyen.checkout.core.exeption.CheckoutException
+import com.adyen.checkout.core.exception.CheckoutException
import com.adyen.checkout.core.log.LogUtil
import com.adyen.checkout.core.log.Logger
import com.adyen.checkout.dropin.R
diff --git a/drop-in/src/main/res/values/strings.xml b/drop-in/src/main/res/values/strings.xml
index 5e3bb83b7c..b3a2ca314b 100644
--- a/drop-in/src/main/res/values/strings.xml
+++ b/drop-in/src/main/res/values/strings.xml
@@ -8,6 +8,7 @@
Pay
+ Pay %s
Payment methods
Error sending payment. Please try again.
Error proceeding with payment. Please try again.
diff --git a/entercash-base/src/main/java/com/adyen/checkout/entercash/EntercashComponent.java b/entercash-base/src/main/java/com/adyen/checkout/entercash/EntercashComponent.java
index 9e468c1e0b..54cb4de661 100644
--- a/entercash-base/src/main/java/com/adyen/checkout/entercash/EntercashComponent.java
+++ b/entercash-base/src/main/java/com/adyen/checkout/entercash/EntercashComponent.java
@@ -29,14 +29,16 @@ public final class EntercashComponent extends IssuerListComponent PROVIDER =
new PaymentComponentProviderImpl<>(EntercashComponent.class);
+ private static final String[] PAYMENT_METHOD_TYPES = {PaymentMethodTypes.ENTERCASH};
+
public EntercashComponent(@NonNull PaymentMethod paymentMethod, @NonNull EntercashConfiguration configuration) {
super(paymentMethod, configuration);
}
@NonNull
@Override
- public String getPaymentMethodType() {
- return PaymentMethodTypes.ENTERCASH;
+ public String[] getSupportedPaymentMethodTypes() {
+ return PAYMENT_METHOD_TYPES;
}
@Override
diff --git a/entercash-ui/src/main/java/com/adyen/checkout/entercash/EntercashRecyclerView.java b/entercash-ui/src/main/java/com/adyen/checkout/entercash/EntercashRecyclerView.java
index a72c73f0b7..323d117945 100644
--- a/entercash-ui/src/main/java/com/adyen/checkout/entercash/EntercashRecyclerView.java
+++ b/entercash-ui/src/main/java/com/adyen/checkout/entercash/EntercashRecyclerView.java
@@ -8,20 +8,15 @@
package com.adyen.checkout.entercash;
-import android.arch.lifecycle.LifecycleOwner;
import android.content.Context;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
-import com.adyen.checkout.core.log.LogUtil;
-import com.adyen.checkout.core.log.Logger;
import com.adyen.checkout.issuerlist.IssuerListRecyclerView;
public class EntercashRecyclerView extends IssuerListRecyclerView {
- private static final String TAG = LogUtil.getTag();
-
public EntercashRecyclerView(@NonNull Context context) {
super(context);
}
@@ -33,11 +28,4 @@ public EntercashRecyclerView(@NonNull Context context, @Nullable AttributeSet at
public EntercashRecyclerView(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
-
- @Override
- public void attach(@NonNull EntercashComponent component, @NonNull LifecycleOwner lifecycleOwner) {
- super.attach(component, lifecycleOwner);
- Logger.d(TAG, "attach");
- mComponent.observeOutputData(lifecycleOwner, createOutputDataObserver());
- }
}
diff --git a/entercash-ui/src/main/java/com/adyen/checkout/entercash/EntercashSpinnerView.java b/entercash-ui/src/main/java/com/adyen/checkout/entercash/EntercashSpinnerView.java
index 4ca1637341..9384cbaec7 100644
--- a/entercash-ui/src/main/java/com/adyen/checkout/entercash/EntercashSpinnerView.java
+++ b/entercash-ui/src/main/java/com/adyen/checkout/entercash/EntercashSpinnerView.java
@@ -8,18 +8,14 @@
package com.adyen.checkout.entercash;
-import android.arch.lifecycle.LifecycleOwner;
import android.content.Context;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
-import com.adyen.checkout.core.log.LogUtil;
-import com.adyen.checkout.core.log.Logger;
import com.adyen.checkout.issuerlist.IssuerListSpinnerView;
public final class EntercashSpinnerView extends IssuerListSpinnerView {
- private static final String TAG = LogUtil.getTag();
public EntercashSpinnerView(@NonNull Context context) {
super(context);
@@ -32,11 +28,4 @@ public EntercashSpinnerView(@NonNull Context context, @Nullable AttributeSet att
public EntercashSpinnerView(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
-
- @Override
- public void attach(@NonNull EntercashComponent component, @NonNull LifecycleOwner lifecycleOwner) {
- super.attach(component, lifecycleOwner);
- Logger.d(TAG, "attach");
- mComponent.observeOutputData(lifecycleOwner, createOutputDataObserver());
- }
}
diff --git a/eps-base/src/main/java/com/adyen/checkout/eps/EPSComponent.java b/eps-base/src/main/java/com/adyen/checkout/eps/EPSComponent.java
index 3d66228ebc..e570e1f6f4 100644
--- a/eps-base/src/main/java/com/adyen/checkout/eps/EPSComponent.java
+++ b/eps-base/src/main/java/com/adyen/checkout/eps/EPSComponent.java
@@ -30,14 +30,16 @@ public final class EPSComponent extends IssuerListComponent {
public static final PaymentComponentProvider PROVIDER =
new PaymentComponentProviderImpl<>(EPSComponent.class);
+ private static final String[] PAYMENT_METHOD_TYPES = {PaymentMethodTypes.EPS};
+
public EPSComponent(@NonNull PaymentMethod paymentMethod, @NonNull EPSConfiguration configuration) {
super(paymentMethod, configuration);
}
@NonNull
@Override
- public String getPaymentMethodType() {
- return PaymentMethodTypes.EPS;
+ public String[] getSupportedPaymentMethodTypes() {
+ return PAYMENT_METHOD_TYPES;
}
@Override
diff --git a/eps-ui/src/main/java/com/adyen/checkout/eps/EPSRecyclerView.java b/eps-ui/src/main/java/com/adyen/checkout/eps/EPSRecyclerView.java
index 492367ce91..16b0c0598b 100644
--- a/eps-ui/src/main/java/com/adyen/checkout/eps/EPSRecyclerView.java
+++ b/eps-ui/src/main/java/com/adyen/checkout/eps/EPSRecyclerView.java
@@ -8,21 +8,16 @@
package com.adyen.checkout.eps;
-import android.arch.lifecycle.LifecycleOwner;
import android.content.Context;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
-import com.adyen.checkout.core.log.LogUtil;
-import com.adyen.checkout.core.log.Logger;
import com.adyen.checkout.issuerlist.IssuerListRecyclerView;
@SuppressWarnings("AbbreviationAsWordInName")
public class EPSRecyclerView extends IssuerListRecyclerView {
- private static final String TAG = LogUtil.getTag();
-
public EPSRecyclerView(@NonNull Context context) {
super(context);
}
@@ -35,13 +30,6 @@ public EPSRecyclerView(@NonNull Context context, @Nullable AttributeSet attrs, i
super(context, attrs, defStyleAttr);
}
- @Override
- public void attach(@NonNull EPSComponent component, @NonNull LifecycleOwner lifecycleOwner) {
- super.attach(component, lifecycleOwner);
- Logger.d(TAG, "attach");
- mComponent.observeOutputData(lifecycleOwner, createOutputDataObserver());
- }
-
@Override
public boolean hideIssuersLogo() {
return true;
diff --git a/eps-ui/src/main/java/com/adyen/checkout/eps/EPSSpinnerView.java b/eps-ui/src/main/java/com/adyen/checkout/eps/EPSSpinnerView.java
index e5025556af..cfd16ef34f 100644
--- a/eps-ui/src/main/java/com/adyen/checkout/eps/EPSSpinnerView.java
+++ b/eps-ui/src/main/java/com/adyen/checkout/eps/EPSSpinnerView.java
@@ -8,19 +8,15 @@
package com.adyen.checkout.eps;
-import android.arch.lifecycle.LifecycleOwner;
import android.content.Context;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
-import com.adyen.checkout.core.log.LogUtil;
-import com.adyen.checkout.core.log.Logger;
import com.adyen.checkout.issuerlist.IssuerListSpinnerView;
@SuppressWarnings("AbbreviationAsWordInName")
public final class EPSSpinnerView extends IssuerListSpinnerView {
- private static final String TAG = LogUtil.getTag();
public EPSSpinnerView(@NonNull Context context) {
super(context);
@@ -34,13 +30,6 @@ public EPSSpinnerView(@NonNull Context context, @Nullable AttributeSet attrs, in
super(context, attrs, defStyleAttr);
}
- @Override
- public void attach(@NonNull EPSComponent component, @NonNull LifecycleOwner lifecycleOwner) {
- super.attach(component, lifecycleOwner);
- Logger.d(TAG, "attach");
- mComponent.observeOutputData(lifecycleOwner, createOutputDataObserver());
- }
-
@Override
public boolean hideIssuersLogo() {
return true;
diff --git a/example-app/src/main/java/com/adyen/checkout/example/ExampleDropInService.kt b/example-app/src/main/java/com/adyen/checkout/example/ExampleDropInService.kt
index 1f0537da18..fb114fec62 100644
--- a/example-app/src/main/java/com/adyen/checkout/example/ExampleDropInService.kt
+++ b/example-app/src/main/java/com/adyen/checkout/example/ExampleDropInService.kt
@@ -10,6 +10,7 @@ package com.adyen.checkout.example
import com.adyen.checkout.base.model.payments.request.*
import com.adyen.checkout.base.model.payments.response.Action
+import com.adyen.checkout.base.util.PaymentMethodTypes
import com.adyen.checkout.core.log.LogUtil
import com.adyen.checkout.core.log.Logger
import com.adyen.checkout.core.model.JsonUtils
@@ -117,7 +118,9 @@ class ExampleDropInService : DropInService() {
.add(PolymorphicJsonAdapterFactory.of(PaymentMethodDetails::class.java, PaymentMethodDetails.TYPE)
.withSubtype(CardPaymentMethod::class.java, CardPaymentMethod.PAYMENT_METHOD_TYPE)
.withSubtype(IdealPaymentMethod::class.java, IdealPaymentMethod.PAYMENT_METHOD_TYPE)
- .withSubtype(MolpayPaymentMethod::class.java, MolpayPaymentMethod.PAYMENT_METHOD_TYPE)
+ .withSubtype(MolpayPaymentMethod::class.java, PaymentMethodTypes.MOLPAY_VIETNAM)
+// .withSubtype(MolpayPaymentMethod::class.java, PaymentMethodTypes.MOLPAY_MALAYSIA)
+// .withSubtype(MolpayPaymentMethod::class.java, PaymentMethodTypes.MOLPAY_THAILAND)
.withSubtype(EPSPaymentMethod::class.java, EPSPaymentMethod.PAYMENT_METHOD_TYPE)
.withSubtype(DotpayPaymentMethod::class.java, DotpayPaymentMethod.PAYMENT_METHOD_TYPE)
.withSubtype(EntercashPaymentMethod::class.java, EntercashPaymentMethod.PAYMENT_METHOD_TYPE)
diff --git a/example-app/src/main/java/com/adyen/checkout/example/MainActivity.kt b/example-app/src/main/java/com/adyen/checkout/example/MainActivity.kt
index c0b73643d9..3c57ff9d9b 100644
--- a/example-app/src/main/java/com/adyen/checkout/example/MainActivity.kt
+++ b/example-app/src/main/java/com/adyen/checkout/example/MainActivity.kt
@@ -22,11 +22,13 @@ import android.widget.Toast
import com.adyen.checkout.base.model.PaymentMethodsApiResponse
import com.adyen.checkout.bcmc.BcmcConfiguration
import com.adyen.checkout.card.CardConfiguration
+import com.adyen.checkout.core.exception.CheckoutException
import com.adyen.checkout.core.log.LogUtil
import com.adyen.checkout.core.log.Logger
import com.adyen.checkout.dropin.DropIn
import com.adyen.checkout.dropin.DropInConfiguration
import com.adyen.checkout.example.api.model.createPaymentMethodsRequest
+import com.adyen.checkout.example.api.model.getAmountFromPreferences
import com.adyen.checkout.example.arch.PaymentMethodsViewModel
import com.adyen.checkout.googlepay.GooglePayConfiguration
import kotlinx.android.synthetic.main.activity_main.progressBar
@@ -126,13 +128,19 @@ class MainActivity : AppCompatActivity() {
val resultIntent = Intent(this, MainActivity::class.java)
resultIntent.flags = Intent.FLAG_ACTIVITY_CLEAR_TOP
- val dropInConfiguration = DropInConfiguration.Builder(this@MainActivity, resultIntent, ExampleDropInService::class.java)
+ val dropInConfigurationBuilder = DropInConfiguration.Builder(this@MainActivity, resultIntent, ExampleDropInService::class.java)
.addCardConfiguration(cardConfiguration)
.addBcmcConfiguration(bcmcConfiguration)
.addGooglePayConfiguration(googlePayConfig)
- .build()
- DropIn.startPayment(this@MainActivity, paymentMethodsApiResponse, dropInConfiguration)
+ val amount = getAmountFromPreferences(this@MainActivity)
+ try {
+ dropInConfigurationBuilder.setAmount(amount)
+ } catch (e: CheckoutException) {
+ Logger.e(TAG, "Amount $amount not valid", e)
+ }
+
+ DropIn.startPayment(this@MainActivity, paymentMethodsApiResponse, dropInConfigurationBuilder.build())
}
private fun setLoading(isLoading: Boolean) {
diff --git a/example-app/src/main/java/com/adyen/checkout/example/api/CheckoutApiService.kt b/example-app/src/main/java/com/adyen/checkout/example/api/CheckoutApiService.kt
index ea58ee230d..b579a6575e 100644
--- a/example-app/src/main/java/com/adyen/checkout/example/api/CheckoutApiService.kt
+++ b/example-app/src/main/java/com/adyen/checkout/example/api/CheckoutApiService.kt
@@ -10,21 +10,14 @@ package com.adyen.checkout.example.api
import android.os.Build
import com.adyen.checkout.base.model.PaymentMethodsApiResponse
-import com.adyen.checkout.base.model.payments.request.CardPaymentMethod
-import com.adyen.checkout.base.model.payments.request.DotpayPaymentMethod
-import com.adyen.checkout.base.model.payments.request.EPSPaymentMethod
-import com.adyen.checkout.base.model.payments.request.EntercashPaymentMethod
-import com.adyen.checkout.base.model.payments.request.GenericPaymentMethod
-import com.adyen.checkout.base.model.payments.request.IdealPaymentMethod
-import com.adyen.checkout.base.model.payments.request.MolpayPaymentMethod
-import com.adyen.checkout.base.model.payments.request.OpenBankingPaymentMethod
-import com.adyen.checkout.base.model.payments.request.PaymentMethodDetails
+import com.adyen.checkout.base.model.payments.request.*
import com.adyen.checkout.base.model.payments.response.Action
import com.adyen.checkout.base.model.payments.response.QrCodeAction
import com.adyen.checkout.base.model.payments.response.RedirectAction
import com.adyen.checkout.base.model.payments.response.Threeds2ChallengeAction
import com.adyen.checkout.base.model.payments.response.Threeds2FingerprintAction
import com.adyen.checkout.base.model.payments.response.VoucherAction
+import com.adyen.checkout.base.util.PaymentMethodTypes
import com.adyen.checkout.core.api.SSLSocketUtil
import com.adyen.checkout.example.BuildConfig
import com.adyen.checkout.example.api.model.PaymentMethodsRequest
@@ -57,11 +50,15 @@ interface CheckoutApiService {
.add(PolymorphicJsonAdapterFactory.of(PaymentMethodDetails::class.java, PaymentMethodDetails.TYPE)
.withSubtype(CardPaymentMethod::class.java, CardPaymentMethod.PAYMENT_METHOD_TYPE)
.withSubtype(IdealPaymentMethod::class.java, IdealPaymentMethod.PAYMENT_METHOD_TYPE)
- .withSubtype(MolpayPaymentMethod::class.java, MolpayPaymentMethod.PAYMENT_METHOD_TYPE)
+ .withSubtype(MolpayPaymentMethod::class.java, PaymentMethodTypes.MOLPAY_VIETNAM)
+// .withSubtype(MolpayPaymentMethod::class.java, PaymentMethodTypes.MOLPAY_MALAYSIA)
+// .withSubtype(MolpayPaymentMethod::class.java, PaymentMethodTypes.MOLPAY_THAILAND)
.withSubtype(EPSPaymentMethod::class.java, EPSPaymentMethod.PAYMENT_METHOD_TYPE)
.withSubtype(DotpayPaymentMethod::class.java, DotpayPaymentMethod.PAYMENT_METHOD_TYPE)
.withSubtype(EntercashPaymentMethod::class.java, EntercashPaymentMethod.PAYMENT_METHOD_TYPE)
.withSubtype(OpenBankingPaymentMethod::class.java, OpenBankingPaymentMethod.PAYMENT_METHOD_TYPE)
+ .withSubtype(GooglePayPaymentMethod::class.java, GooglePayPaymentMethod.PAYMENT_METHOD_TYPE)
+ .withSubtype(SepaPaymentMethod::class.java, SepaPaymentMethod.PAYMENT_METHOD_TYPE)
.withSubtype(GenericPaymentMethod::class.java, "other")
)
.add(PolymorphicJsonAdapterFactory.of(Action::class.java, Action.TYPE)
diff --git a/example-app/src/main/java/com/adyen/checkout/example/api/model/Extensions.kt b/example-app/src/main/java/com/adyen/checkout/example/api/model/Extensions.kt
index 7e40220b1f..ab9d4c0de7 100644
--- a/example-app/src/main/java/com/adyen/checkout/example/api/model/Extensions.kt
+++ b/example-app/src/main/java/com/adyen/checkout/example/api/model/Extensions.kt
@@ -63,6 +63,10 @@ fun createPaymentsRequest(context: Context, paymentComponentData: PaymentCompone
)
}
+fun getAmountFromPreferences(context: Context): Amount {
+ return getAmount(context, PreferenceManager.getDefaultSharedPreferences(context))
+}
+
private fun getAmount(context: Context, preferences: SharedPreferences): Amount {
val amountValue = preferences.getInt(context.getString(R.string.value_key), DEFAULT_VALUE)
val amountCurrency = preferences.getString(context.getString(R.string.currency_key), DEFAULT_CURRENCY) ?: DEFAULT_CURRENCY
diff --git a/example-app/src/main/java/com/adyen/checkout/example/api/model/PaymentsRequest.kt b/example-app/src/main/java/com/adyen/checkout/example/api/model/PaymentsRequest.kt
index 4b52ee9337..7d94a2e3a5 100644
--- a/example-app/src/main/java/com/adyen/checkout/example/api/model/PaymentsRequest.kt
+++ b/example-app/src/main/java/com/adyen/checkout/example/api/model/PaymentsRequest.kt
@@ -18,8 +18,8 @@ data class PaymentsRequest(
val storePaymentMethod: Boolean,
val amount: Amount,
val merchantAccount: String,
- // unique reference of the payment
val returnUrl: String,
+ // unique reference of the payment
val reference: String = "android-test-components",
val channel: String = "android",
val additionalData: AdditionalData = AdditionalData(allow3DS2 = "false")
diff --git a/googlepay-base/src/main/java/com/adyen/checkout/googlepay/GooglePayComponent.java b/googlepay-base/src/main/java/com/adyen/checkout/googlepay/GooglePayComponent.java
index 7267d9782f..ba280247e7 100644
--- a/googlepay-base/src/main/java/com/adyen/checkout/googlepay/GooglePayComponent.java
+++ b/googlepay-base/src/main/java/com/adyen/checkout/googlepay/GooglePayComponent.java
@@ -20,7 +20,7 @@
import com.adyen.checkout.base.model.payments.request.GooglePayPaymentMethod;
import com.adyen.checkout.base.model.payments.request.PaymentComponentData;
import com.adyen.checkout.base.util.PaymentMethodTypes;
-import com.adyen.checkout.core.exeption.ComponentException;
+import com.adyen.checkout.core.exception.ComponentException;
import com.adyen.checkout.core.log.LogUtil;
import com.adyen.checkout.core.log.Logger;
import com.adyen.checkout.googlepay.util.GooglePayUtils;
@@ -36,6 +36,8 @@ public class GooglePayComponent extends BasePaymentComponent PROVIDER = new GooglePayProvider();
+ private static final String[] PAYMENT_METHOD_TYPES = {PaymentMethodTypes.GOOGLE_PAY};
+
public GooglePayComponent(@NonNull PaymentMethod paymentMethod, @NonNull GooglePayConfiguration configuration) {
super(paymentMethod, configuration);
}
@@ -69,8 +71,8 @@ protected PaymentComponentState createComponentState() {
@NonNull
@Override
- public String getPaymentMethodType() {
- return PaymentMethodTypes.GOOGLE_PAY;
+ public String[] getSupportedPaymentMethodTypes() {
+ return PAYMENT_METHOD_TYPES;
}
/**
diff --git a/googlepay-base/src/main/java/com/adyen/checkout/googlepay/GooglePayConfiguration.java b/googlepay-base/src/main/java/com/adyen/checkout/googlepay/GooglePayConfiguration.java
index 7d172d350a..6b36927f39 100644
--- a/googlepay-base/src/main/java/com/adyen/checkout/googlepay/GooglePayConfiguration.java
+++ b/googlepay-base/src/main/java/com/adyen/checkout/googlepay/GooglePayConfiguration.java
@@ -14,12 +14,12 @@
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
-import com.adyen.checkout.base.component.BaseConfiguration;
+import com.adyen.checkout.base.component.Configuration;
import com.adyen.checkout.base.component.BaseConfigurationBuilder;
import com.adyen.checkout.base.model.payments.Amount;
import com.adyen.checkout.base.util.CheckoutCurrency;
import com.adyen.checkout.core.api.Environment;
-import com.adyen.checkout.core.exeption.CheckoutException;
+import com.adyen.checkout.core.exception.CheckoutException;
import com.adyen.checkout.core.util.ParcelUtils;
import com.adyen.checkout.googlepay.model.BillingAddressParameters;
import com.adyen.checkout.googlepay.model.MerchantInfo;
@@ -31,7 +31,7 @@
import java.util.List;
import java.util.Locale;
-public class GooglePayConfiguration extends BaseConfiguration {
+public class GooglePayConfiguration extends Configuration {
private final String mMerchantAccount;
private final int mGooglePayEnvironment;
diff --git a/googlepay-base/src/main/java/com/adyen/checkout/googlepay/GooglePayProvider.java b/googlepay-base/src/main/java/com/adyen/checkout/googlepay/GooglePayProvider.java
index fc12905519..8d420aa731 100644
--- a/googlepay-base/src/main/java/com/adyen/checkout/googlepay/GooglePayProvider.java
+++ b/googlepay-base/src/main/java/com/adyen/checkout/googlepay/GooglePayProvider.java
@@ -18,7 +18,7 @@
import com.adyen.checkout.base.PaymentComponentProvider;
import com.adyen.checkout.base.component.lifecycle.ComponentViewModelFactory;
import com.adyen.checkout.base.model.paymentmethods.PaymentMethod;
-import com.adyen.checkout.core.exeption.CheckoutException;
+import com.adyen.checkout.core.exception.CheckoutException;
import com.adyen.checkout.googlepay.util.GooglePayUtils;
import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.GoogleApiAvailability;
diff --git a/googlepay-base/src/main/java/com/adyen/checkout/googlepay/model/BillingAddressParameters.java b/googlepay-base/src/main/java/com/adyen/checkout/googlepay/model/BillingAddressParameters.java
index 0bd5f490c5..ebdd7c4fc6 100644
--- a/googlepay-base/src/main/java/com/adyen/checkout/googlepay/model/BillingAddressParameters.java
+++ b/googlepay-base/src/main/java/com/adyen/checkout/googlepay/model/BillingAddressParameters.java
@@ -12,7 +12,7 @@
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
-import com.adyen.checkout.core.exeption.ModelSerializationException;
+import com.adyen.checkout.core.exception.ModelSerializationException;
import com.adyen.checkout.core.model.JsonUtils;
import com.adyen.checkout.core.model.ModelObject;
diff --git a/googlepay-base/src/main/java/com/adyen/checkout/googlepay/model/CardParameters.java b/googlepay-base/src/main/java/com/adyen/checkout/googlepay/model/CardParameters.java
index cb6576c39a..0a5248186a 100644
--- a/googlepay-base/src/main/java/com/adyen/checkout/googlepay/model/CardParameters.java
+++ b/googlepay-base/src/main/java/com/adyen/checkout/googlepay/model/CardParameters.java
@@ -12,7 +12,7 @@
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
-import com.adyen.checkout.core.exeption.ModelSerializationException;
+import com.adyen.checkout.core.exception.ModelSerializationException;
import com.adyen.checkout.core.model.JsonUtils;
import com.adyen.checkout.core.model.ModelObject;
import com.adyen.checkout.core.model.ModelUtils;
diff --git a/googlepay-base/src/main/java/com/adyen/checkout/googlepay/model/GooglePayPaymentMethodModel.java b/googlepay-base/src/main/java/com/adyen/checkout/googlepay/model/GooglePayPaymentMethodModel.java
index eecb661cb9..468809a29b 100644
--- a/googlepay-base/src/main/java/com/adyen/checkout/googlepay/model/GooglePayPaymentMethodModel.java
+++ b/googlepay-base/src/main/java/com/adyen/checkout/googlepay/model/GooglePayPaymentMethodModel.java
@@ -12,7 +12,7 @@
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
-import com.adyen.checkout.core.exeption.ModelSerializationException;
+import com.adyen.checkout.core.exception.ModelSerializationException;
import com.adyen.checkout.core.model.JsonUtils;
import com.adyen.checkout.core.model.ModelObject;
import com.adyen.checkout.core.model.ModelUtils;
diff --git a/googlepay-base/src/main/java/com/adyen/checkout/googlepay/model/IsReadyToPayRequestModel.java b/googlepay-base/src/main/java/com/adyen/checkout/googlepay/model/IsReadyToPayRequestModel.java
index 5a6c1276b2..212668c8df 100644
--- a/googlepay-base/src/main/java/com/adyen/checkout/googlepay/model/IsReadyToPayRequestModel.java
+++ b/googlepay-base/src/main/java/com/adyen/checkout/googlepay/model/IsReadyToPayRequestModel.java
@@ -12,7 +12,7 @@
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
-import com.adyen.checkout.core.exeption.ModelSerializationException;
+import com.adyen.checkout.core.exception.ModelSerializationException;
import com.adyen.checkout.core.model.JsonUtils;
import com.adyen.checkout.core.model.ModelObject;
import com.adyen.checkout.core.model.ModelUtils;
diff --git a/googlepay-base/src/main/java/com/adyen/checkout/googlepay/model/MerchantInfo.java b/googlepay-base/src/main/java/com/adyen/checkout/googlepay/model/MerchantInfo.java
index 483648be37..323f73c703 100644
--- a/googlepay-base/src/main/java/com/adyen/checkout/googlepay/model/MerchantInfo.java
+++ b/googlepay-base/src/main/java/com/adyen/checkout/googlepay/model/MerchantInfo.java
@@ -12,7 +12,7 @@
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
-import com.adyen.checkout.core.exeption.ModelSerializationException;
+import com.adyen.checkout.core.exception.ModelSerializationException;
import com.adyen.checkout.core.model.JsonUtils;
import com.adyen.checkout.core.model.ModelObject;
diff --git a/googlepay-base/src/main/java/com/adyen/checkout/googlepay/model/PaymentDataRequestModel.java b/googlepay-base/src/main/java/com/adyen/checkout/googlepay/model/PaymentDataRequestModel.java
index d7fbc4850b..fefad009b7 100644
--- a/googlepay-base/src/main/java/com/adyen/checkout/googlepay/model/PaymentDataRequestModel.java
+++ b/googlepay-base/src/main/java/com/adyen/checkout/googlepay/model/PaymentDataRequestModel.java
@@ -12,7 +12,7 @@
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
-import com.adyen.checkout.core.exeption.ModelSerializationException;
+import com.adyen.checkout.core.exception.ModelSerializationException;
import com.adyen.checkout.core.model.JsonUtils;
import com.adyen.checkout.core.model.ModelObject;
import com.adyen.checkout.core.model.ModelUtils;
diff --git a/googlepay-base/src/main/java/com/adyen/checkout/googlepay/model/PaymentMethodTokenizationSpecification.java b/googlepay-base/src/main/java/com/adyen/checkout/googlepay/model/PaymentMethodTokenizationSpecification.java
index 6ecaaf74ec..f86bfc0739 100644
--- a/googlepay-base/src/main/java/com/adyen/checkout/googlepay/model/PaymentMethodTokenizationSpecification.java
+++ b/googlepay-base/src/main/java/com/adyen/checkout/googlepay/model/PaymentMethodTokenizationSpecification.java
@@ -12,7 +12,7 @@
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
-import com.adyen.checkout.core.exeption.ModelSerializationException;
+import com.adyen.checkout.core.exception.ModelSerializationException;
import com.adyen.checkout.core.model.JsonUtils;
import com.adyen.checkout.core.model.ModelObject;
import com.adyen.checkout.core.model.ModelUtils;
diff --git a/googlepay-base/src/main/java/com/adyen/checkout/googlepay/model/ShippingAddressParameters.java b/googlepay-base/src/main/java/com/adyen/checkout/googlepay/model/ShippingAddressParameters.java
index 709001dd2f..c7c63aa529 100644
--- a/googlepay-base/src/main/java/com/adyen/checkout/googlepay/model/ShippingAddressParameters.java
+++ b/googlepay-base/src/main/java/com/adyen/checkout/googlepay/model/ShippingAddressParameters.java
@@ -12,7 +12,7 @@
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
-import com.adyen.checkout.core.exeption.ModelSerializationException;
+import com.adyen.checkout.core.exception.ModelSerializationException;
import com.adyen.checkout.core.model.JsonUtils;
import com.adyen.checkout.core.model.ModelObject;
diff --git a/googlepay-base/src/main/java/com/adyen/checkout/googlepay/model/TokenizationParameters.java b/googlepay-base/src/main/java/com/adyen/checkout/googlepay/model/TokenizationParameters.java
index 4140b68269..1771eb2da8 100644
--- a/googlepay-base/src/main/java/com/adyen/checkout/googlepay/model/TokenizationParameters.java
+++ b/googlepay-base/src/main/java/com/adyen/checkout/googlepay/model/TokenizationParameters.java
@@ -12,7 +12,7 @@
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
-import com.adyen.checkout.core.exeption.ModelSerializationException;
+import com.adyen.checkout.core.exception.ModelSerializationException;
import com.adyen.checkout.core.model.JsonUtils;
import com.adyen.checkout.core.model.ModelObject;
diff --git a/googlepay-base/src/main/java/com/adyen/checkout/googlepay/model/TransactionInfoModel.java b/googlepay-base/src/main/java/com/adyen/checkout/googlepay/model/TransactionInfoModel.java
index f1c7fbaa86..cb6f4a564c 100644
--- a/googlepay-base/src/main/java/com/adyen/checkout/googlepay/model/TransactionInfoModel.java
+++ b/googlepay-base/src/main/java/com/adyen/checkout/googlepay/model/TransactionInfoModel.java
@@ -12,7 +12,7 @@
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
-import com.adyen.checkout.core.exeption.ModelSerializationException;
+import com.adyen.checkout.core.exception.ModelSerializationException;
import com.adyen.checkout.core.model.JsonUtils;
import com.adyen.checkout.core.model.ModelObject;
diff --git a/googlepay-base/src/main/java/com/adyen/checkout/googlepay/util/AllowedAuthMethods.java b/googlepay-base/src/main/java/com/adyen/checkout/googlepay/util/AllowedAuthMethods.java
index b9d780a579..254de71c1c 100644
--- a/googlepay-base/src/main/java/com/adyen/checkout/googlepay/util/AllowedAuthMethods.java
+++ b/googlepay-base/src/main/java/com/adyen/checkout/googlepay/util/AllowedAuthMethods.java
@@ -10,7 +10,7 @@
import android.support.annotation.NonNull;
-import com.adyen.checkout.core.exeption.NoConstructorException;
+import com.adyen.checkout.core.exception.NoConstructorException;
import java.util.ArrayList;
import java.util.List;
diff --git a/googlepay-base/src/main/java/com/adyen/checkout/googlepay/util/AllowedCardNetworks.java b/googlepay-base/src/main/java/com/adyen/checkout/googlepay/util/AllowedCardNetworks.java
index 077257c189..590f2b68af 100644
--- a/googlepay-base/src/main/java/com/adyen/checkout/googlepay/util/AllowedCardNetworks.java
+++ b/googlepay-base/src/main/java/com/adyen/checkout/googlepay/util/AllowedCardNetworks.java
@@ -10,7 +10,7 @@
import android.support.annotation.NonNull;
-import com.adyen.checkout.core.exeption.NoConstructorException;
+import com.adyen.checkout.core.exception.NoConstructorException;
import java.util.ArrayList;
import java.util.List;
diff --git a/googlepay-base/src/main/java/com/adyen/checkout/googlepay/util/GooglePayUtils.java b/googlepay-base/src/main/java/com/adyen/checkout/googlepay/util/GooglePayUtils.java
index 00b639410b..55c107b5ae 100644
--- a/googlepay-base/src/main/java/com/adyen/checkout/googlepay/util/GooglePayUtils.java
+++ b/googlepay-base/src/main/java/com/adyen/checkout/googlepay/util/GooglePayUtils.java
@@ -12,8 +12,8 @@
import com.adyen.checkout.base.model.payments.Amount;
import com.adyen.checkout.base.util.AmountFormat;
-import com.adyen.checkout.core.exeption.CheckoutException;
-import com.adyen.checkout.core.exeption.NoConstructorException;
+import com.adyen.checkout.core.exception.CheckoutException;
+import com.adyen.checkout.core.exception.NoConstructorException;
import com.adyen.checkout.googlepay.GooglePayConfiguration;
import com.adyen.checkout.googlepay.model.CardParameters;
import com.adyen.checkout.googlepay.model.TokenizationParameters;
diff --git a/ideal-base/src/main/java/com/adyen/checkout/ideal/IdealComponent.java b/ideal-base/src/main/java/com/adyen/checkout/ideal/IdealComponent.java
index 95a21cb78b..5a29bb2ee1 100644
--- a/ideal-base/src/main/java/com/adyen/checkout/ideal/IdealComponent.java
+++ b/ideal-base/src/main/java/com/adyen/checkout/ideal/IdealComponent.java
@@ -29,14 +29,16 @@ public final class IdealComponent extends IssuerListComponent PROVIDER =
new PaymentComponentProviderImpl<>(IdealComponent.class);
+ private static final String[] PAYMENT_METHOD_TYPES = {PaymentMethodTypes.IDEAL};
+
public IdealComponent(@NonNull PaymentMethod paymentMethod, @NonNull IdealConfiguration configuration) {
super(paymentMethod, configuration);
}
@NonNull
@Override
- public String getPaymentMethodType() {
- return PaymentMethodTypes.IDEAL;
+ public String[] getSupportedPaymentMethodTypes() {
+ return PAYMENT_METHOD_TYPES;
}
@Override
diff --git a/ideal-ui/src/main/java/com/adyen/checkout/ideal/IdealRecyclerView.java b/ideal-ui/src/main/java/com/adyen/checkout/ideal/IdealRecyclerView.java
index 242fb3c028..86790ccb2f 100644
--- a/ideal-ui/src/main/java/com/adyen/checkout/ideal/IdealRecyclerView.java
+++ b/ideal-ui/src/main/java/com/adyen/checkout/ideal/IdealRecyclerView.java
@@ -8,20 +8,15 @@
package com.adyen.checkout.ideal;
-import android.arch.lifecycle.LifecycleOwner;
import android.content.Context;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
-import com.adyen.checkout.core.log.LogUtil;
-import com.adyen.checkout.core.log.Logger;
import com.adyen.checkout.issuerlist.IssuerListRecyclerView;
public class IdealRecyclerView extends IssuerListRecyclerView {
- private static final String TAG = LogUtil.getTag();
-
public IdealRecyclerView(@NonNull Context context) {
super(context);
}
@@ -33,11 +28,4 @@ public IdealRecyclerView(@NonNull Context context, @Nullable AttributeSet attrs)
public IdealRecyclerView(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
-
- @Override
- public void attach(@NonNull IdealComponent component, @NonNull LifecycleOwner lifecycleOwner) {
- super.attach(component, lifecycleOwner);
- Logger.d(TAG, "attach");
- mComponent.observeOutputData(lifecycleOwner, createOutputDataObserver());
- }
}
diff --git a/ideal-ui/src/main/java/com/adyen/checkout/ideal/IdealSpinnerView.java b/ideal-ui/src/main/java/com/adyen/checkout/ideal/IdealSpinnerView.java
index 8d31629802..7d8f6ddefb 100644
--- a/ideal-ui/src/main/java/com/adyen/checkout/ideal/IdealSpinnerView.java
+++ b/ideal-ui/src/main/java/com/adyen/checkout/ideal/IdealSpinnerView.java
@@ -8,18 +8,14 @@
package com.adyen.checkout.ideal;
-import android.arch.lifecycle.LifecycleOwner;
import android.content.Context;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
-import com.adyen.checkout.core.log.LogUtil;
-import com.adyen.checkout.core.log.Logger;
import com.adyen.checkout.issuerlist.IssuerListSpinnerView;
public final class IdealSpinnerView extends IssuerListSpinnerView {
- private static final String TAG = LogUtil.getTag();
public IdealSpinnerView(@NonNull Context context) {
super(context);
@@ -32,11 +28,4 @@ public IdealSpinnerView(@NonNull Context context, @Nullable AttributeSet attrs)
public IdealSpinnerView(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
-
- @Override
- public void attach(@NonNull IdealComponent component, @NonNull LifecycleOwner lifecycleOwner) {
- super.attach(component, lifecycleOwner);
- Logger.d(TAG, "attach");
- mComponent.observeOutputData(lifecycleOwner, createOutputDataObserver());
- }
}
diff --git a/issuer-list-base/src/main/java/com/adyen/checkout/issuerlist/IssuerListComponent.java b/issuer-list-base/src/main/java/com/adyen/checkout/issuerlist/IssuerListComponent.java
index 4247ce968e..4971978876 100644
--- a/issuer-list-base/src/main/java/com/adyen/checkout/issuerlist/IssuerListComponent.java
+++ b/issuer-list-base/src/main/java/com/adyen/checkout/issuerlist/IssuerListComponent.java
@@ -79,7 +79,7 @@ protected PaymentComponentState createComponentState()
final IssuerModel selectedIssuer = getOutputData().getSelectedIssuer();
- issuerListPaymentMethod.setType(getPaymentMethodType());
+ issuerListPaymentMethod.setType(getPaymentMethod().getType());
issuerListPaymentMethod.setIssuer(selectedIssuer != null ? selectedIssuer.getId() : "");
final boolean isValid = getOutputData().isValid();
diff --git a/issuer-list-base/src/main/java/com/adyen/checkout/issuerlist/IssuerListConfiguration.java b/issuer-list-base/src/main/java/com/adyen/checkout/issuerlist/IssuerListConfiguration.java
index 66bacf0597..a2f93dd5e5 100644
--- a/issuer-list-base/src/main/java/com/adyen/checkout/issuerlist/IssuerListConfiguration.java
+++ b/issuer-list-base/src/main/java/com/adyen/checkout/issuerlist/IssuerListConfiguration.java
@@ -12,13 +12,13 @@
import android.os.Parcel;
import android.support.annotation.NonNull;
-import com.adyen.checkout.base.component.BaseConfiguration;
+import com.adyen.checkout.base.component.Configuration;
import com.adyen.checkout.base.component.BaseConfigurationBuilder;
import com.adyen.checkout.core.api.Environment;
import java.util.Locale;
-public abstract class IssuerListConfiguration extends BaseConfiguration {
+public abstract class IssuerListConfiguration extends Configuration {
protected IssuerListConfiguration(
@NonNull Locale shopperLocale,
diff --git a/issuer-list-ui/src/main/java/com/adyen/checkout/issuerlist/IssuerListRecyclerView.java b/issuer-list-ui/src/main/java/com/adyen/checkout/issuerlist/IssuerListRecyclerView.java
index f3cafbfed0..76d7942199 100644
--- a/issuer-list-ui/src/main/java/com/adyen/checkout/issuerlist/IssuerListRecyclerView.java
+++ b/issuer-list-ui/src/main/java/com/adyen/checkout/issuerlist/IssuerListRecyclerView.java
@@ -11,18 +11,16 @@
import android.arch.lifecycle.LifecycleOwner;
import android.arch.lifecycle.Observer;
import android.content.Context;
-import android.support.annotation.CallSuper;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.AttributeSet;
import android.view.LayoutInflater;
-import android.widget.LinearLayout;
-import com.adyen.checkout.base.ComponentView;
import com.adyen.checkout.base.api.ImageLoader;
import com.adyen.checkout.base.ui.adapter.ClickableListRecyclerAdapter;
+import com.adyen.checkout.base.ui.view.AdyenLinearLayout;
import com.adyen.checkout.core.log.LogUtil;
import com.adyen.checkout.core.log.Logger;
import com.adyen.checkout.issuerlist.ui.R;
@@ -30,14 +28,11 @@
import java.util.Collections;
import java.util.List;
-public abstract class IssuerListRecyclerView extends LinearLayout implements
- ComponentView, Observer>, ClickableListRecyclerAdapter.OnItemCLickedListener {
+public abstract class IssuerListRecyclerView extends
+ AdyenLinearLayout implements Observer>, ClickableListRecyclerAdapter.OnItemCLickedListener {
private static final String TAG = LogUtil.getTag();
- @Nullable
- protected IssuerListComponentT mComponent;
-
- private final RecyclerView mIssuersRecyclerView;
+ private RecyclerView mIssuersRecyclerView;
private IssuerListRecyclerAdapter mIssuersAdapter;
private final IssuerListInputData mIdealInputData = new IssuerListInputData();
@@ -54,27 +49,30 @@ public IssuerListRecyclerView(@NonNull Context context, @Nullable AttributeSet a
@SuppressWarnings("JavadocMethod")
public IssuerListRecyclerView(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
-
LayoutInflater.from(getContext()).inflate(R.layout.issuer_list_recycler_view, this, true);
+ }
+ @Override
+ public void initView() {
mIssuersRecyclerView = findViewById(R.id.recycler_issuers);
mIssuersRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
+
+ mIssuersAdapter.setItemCLickListener(this);
+ mIssuersRecyclerView.setAdapter(mIssuersAdapter);
}
- @CallSuper
@Override
- public void attach(@NonNull IssuerListComponentT component, @NonNull LifecycleOwner lifecycleOwner) {
- mComponent = component;
-
+ public void onComponentAttached() {
mIssuersAdapter = new IssuerListRecyclerAdapter(Collections.emptyList(),
- ImageLoader.getInstance(getContext(), component.getConfiguration().getEnvironment()), component.getPaymentMethodType(),
+ ImageLoader.getInstance(getContext(), getComponent().getConfiguration().getEnvironment()),
+ getComponent().getPaymentMethod().getType(),
hideIssuersLogo());
- mIssuersAdapter.setItemCLickListener(this);
- mIssuersRecyclerView.setAdapter(mIssuersAdapter);
+ }
- mComponent.getIssuersLiveData().observe(lifecycleOwner, this);
+ @Override
+ public void observeComponentChanges(@NonNull LifecycleOwner lifecycleOwner) {
+ getComponent().getIssuersLiveData().observe(lifecycleOwner, this);
- mComponent.sendAnalyticsEvent(getContext());
}
@Override
@@ -117,10 +115,6 @@ public void onChanged(@Nullable IssuerListOutputData idealOutputData) {
public void onItemClicked(int position) {
Logger.d(TAG, "onItemClicked - " + position);
mIdealInputData.setSelectedIssuer(mIssuersAdapter.getIssuerAt(position));
- if (mComponent != null) {
- mComponent.inputDataChanged(mIdealInputData);
- } else {
- Logger.e(TAG, "component null");
- }
+ getComponent().inputDataChanged(mIdealInputData);
}
}
diff --git a/issuer-list-ui/src/main/java/com/adyen/checkout/issuerlist/IssuerListSpinnerView.java b/issuer-list-ui/src/main/java/com/adyen/checkout/issuerlist/IssuerListSpinnerView.java
index 21c9f3fec4..9fe47c2719 100644
--- a/issuer-list-ui/src/main/java/com/adyen/checkout/issuerlist/IssuerListSpinnerView.java
+++ b/issuer-list-ui/src/main/java/com/adyen/checkout/issuerlist/IssuerListSpinnerView.java
@@ -11,7 +11,6 @@
import android.arch.lifecycle.LifecycleOwner;
import android.arch.lifecycle.Observer;
import android.content.Context;
-import android.support.annotation.CallSuper;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v7.widget.AppCompatSpinner;
@@ -19,10 +18,9 @@
import android.view.LayoutInflater;
import android.view.View;
import android.widget.AdapterView;
-import android.widget.LinearLayout;
-import com.adyen.checkout.base.ComponentView;
import com.adyen.checkout.base.api.ImageLoader;
+import com.adyen.checkout.base.ui.view.AdyenLinearLayout;
import com.adyen.checkout.core.log.LogUtil;
import com.adyen.checkout.core.log.Logger;
import com.adyen.checkout.issuerlist.ui.R;
@@ -30,14 +28,11 @@
import java.util.Collections;
import java.util.List;
-public abstract class IssuerListSpinnerView extends LinearLayout implements
- ComponentView, AdapterView.OnItemSelectedListener {
+public abstract class IssuerListSpinnerView extends
+ AdyenLinearLayout implements AdapterView.OnItemSelectedListener {
private static final String TAG = LogUtil.getTag();
- @Nullable
- protected IssuerListComponentT mComponent;
-
- private final AppCompatSpinner mIssuersSpinner;
+ private AppCompatSpinner mIssuersSpinner;
private final IssuerListInputData mIdealInputData = new IssuerListInputData();
@@ -55,27 +50,28 @@ public IssuerListSpinnerView(@NonNull Context context, @Nullable AttributeSet at
@SuppressWarnings("JavadocMethod")
public IssuerListSpinnerView(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
-
LayoutInflater.from(getContext()).inflate(R.layout.issuer_list_spinner_view, this, true);
+ }
+ @Override
+ public void initView() {
mIssuersSpinner = findViewById(R.id.spinner_issuers);
+ mIssuersSpinner.setAdapter(mIssuersAdapter);
+ mIssuersSpinner.setOnItemSelectedListener(this);
}
- @CallSuper
@Override
- public void attach(@NonNull IssuerListComponentT component, @NonNull LifecycleOwner lifecycleOwner) {
- mComponent = component;
-
- mIssuersSpinner.setOnItemSelectedListener(this);
+ public void onComponentAttached() {
mIssuersAdapter = new IssuerListSpinnerAdapter(getContext(),
Collections.emptyList(),
- ImageLoader.getInstance(getContext(), component.getConfiguration().getEnvironment()), component.getPaymentMethodType(),
+ ImageLoader.getInstance(getContext(), getComponent().getConfiguration().getEnvironment()),
+ getComponent().getPaymentMethod().getType(),
hideIssuersLogo());
- mIssuersSpinner.setAdapter(mIssuersAdapter);
-
- mComponent.getIssuersLiveData().observe(lifecycleOwner, createIssuersObserver());
+ }
- mComponent.sendAnalyticsEvent(getContext());
+ @Override
+ public void observeComponentChanges(@NonNull LifecycleOwner lifecycleOwner) {
+ getComponent().getIssuersLiveData().observe(lifecycleOwner, createIssuersObserver());
}
@Override
@@ -95,7 +91,7 @@ void onIssuersChanged(@Nullable List issuerList) {
public void onItemSelected(@NonNull AdapterView> parent, @NonNull View view, int position, long id) {
Logger.d(TAG, "onItemSelected - " + mIssuersAdapter.getItem(position).getName());
mIdealInputData.setSelectedIssuer(mIssuersAdapter.getItem(position));
- mComponent.inputDataChanged(mIdealInputData);
+ getComponent().inputDataChanged(mIdealInputData);
}
@Override
diff --git a/molpay-base/src/main/java/com/adyen/checkout/molpay/MolpayComponent.java b/molpay-base/src/main/java/com/adyen/checkout/molpay/MolpayComponent.java
index 317575331a..37a0c8e0fc 100644
--- a/molpay-base/src/main/java/com/adyen/checkout/molpay/MolpayComponent.java
+++ b/molpay-base/src/main/java/com/adyen/checkout/molpay/MolpayComponent.java
@@ -29,14 +29,20 @@ public final class MolpayComponent extends IssuerListComponent PROVIDER =
new PaymentComponentProviderImpl<>(MolpayComponent.class);
+ private static final String[] PAYMENT_METHOD_TYPES = {
+ PaymentMethodTypes.MOLPAY_THAILAND,
+ PaymentMethodTypes.MOLPAY_MALAYSIA,
+ PaymentMethodTypes.MOLPAY_VIETNAM
+ };
+
public MolpayComponent(@NonNull PaymentMethod paymentMethod, @NonNull MolpayConfiguration configuration) {
super(paymentMethod, configuration);
}
@NonNull
@Override
- public String getPaymentMethodType() {
- return PaymentMethodTypes.MOLPAY;
+ public String[] getSupportedPaymentMethodTypes() {
+ return PAYMENT_METHOD_TYPES;
}
@Override
diff --git a/molpay-ui/src/main/java/com/adyen/checkout/molpay/MolpayRecyclerView.java b/molpay-ui/src/main/java/com/adyen/checkout/molpay/MolpayRecyclerView.java
index bbce828c84..a5e1292d1b 100644
--- a/molpay-ui/src/main/java/com/adyen/checkout/molpay/MolpayRecyclerView.java
+++ b/molpay-ui/src/main/java/com/adyen/checkout/molpay/MolpayRecyclerView.java
@@ -8,20 +8,15 @@
package com.adyen.checkout.molpay;
-import android.arch.lifecycle.LifecycleOwner;
import android.content.Context;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
-import com.adyen.checkout.core.log.LogUtil;
-import com.adyen.checkout.core.log.Logger;
import com.adyen.checkout.issuerlist.IssuerListRecyclerView;
public class MolpayRecyclerView extends IssuerListRecyclerView {
- private static final String TAG = LogUtil.getTag();
-
public MolpayRecyclerView(@NonNull Context context) {
super(context);
}
@@ -33,11 +28,4 @@ public MolpayRecyclerView(@NonNull Context context, @Nullable AttributeSet attrs
public MolpayRecyclerView(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
-
- @Override
- public void attach(@NonNull MolpayComponent component, @NonNull LifecycleOwner lifecycleOwner) {
- super.attach(component, lifecycleOwner);
- Logger.d(TAG, "attach");
- mComponent.observeOutputData(lifecycleOwner, createOutputDataObserver());
- }
}
diff --git a/molpay-ui/src/main/java/com/adyen/checkout/molpay/MolpaySpinnerView.java b/molpay-ui/src/main/java/com/adyen/checkout/molpay/MolpaySpinnerView.java
index 5ea09aa495..bc32bf4c12 100644
--- a/molpay-ui/src/main/java/com/adyen/checkout/molpay/MolpaySpinnerView.java
+++ b/molpay-ui/src/main/java/com/adyen/checkout/molpay/MolpaySpinnerView.java
@@ -8,18 +8,14 @@
package com.adyen.checkout.molpay;
-import android.arch.lifecycle.LifecycleOwner;
import android.content.Context;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
-import com.adyen.checkout.core.log.LogUtil;
-import com.adyen.checkout.core.log.Logger;
import com.adyen.checkout.issuerlist.IssuerListSpinnerView;
public final class MolpaySpinnerView extends IssuerListSpinnerView {
- private static final String TAG = LogUtil.getTag();
public MolpaySpinnerView(@NonNull Context context) {
super(context);
@@ -32,11 +28,4 @@ public MolpaySpinnerView(@NonNull Context context, @Nullable AttributeSet attrs)
public MolpaySpinnerView(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
-
- @Override
- public void attach(@NonNull MolpayComponent component, @NonNull LifecycleOwner lifecycleOwner) {
- super.attach(component, lifecycleOwner);
- Logger.d(TAG, "attach");
- mComponent.observeOutputData(lifecycleOwner, createOutputDataObserver());
- }
}
diff --git a/openbanking-base/src/main/java/com/adyen/checkout/openbanking/OpenBankingComponent.java b/openbanking-base/src/main/java/com/adyen/checkout/openbanking/OpenBankingComponent.java
index b1b452bd7c..3648880619 100644
--- a/openbanking-base/src/main/java/com/adyen/checkout/openbanking/OpenBankingComponent.java
+++ b/openbanking-base/src/main/java/com/adyen/checkout/openbanking/OpenBankingComponent.java
@@ -29,14 +29,16 @@ public final class OpenBankingComponent extends IssuerListComponent PROVIDER =
new PaymentComponentProviderImpl<>(OpenBankingComponent.class);
+ private static final String[] PAYMENT_METHOD_TYPES = {PaymentMethodTypes.OPEN_BANKING};
+
public OpenBankingComponent(@NonNull PaymentMethod paymentMethod, @NonNull OpenBankingConfiguration configuration) {
super(paymentMethod, configuration);
}
@NonNull
@Override
- public String getPaymentMethodType() {
- return PaymentMethodTypes.OPEN_BANKING;
+ public String[] getSupportedPaymentMethodTypes() {
+ return PAYMENT_METHOD_TYPES;
}
@Override
diff --git a/openbanking-ui/src/main/java/com/adyen/checkout/openbanking/OpenBankingRecyclerView.java b/openbanking-ui/src/main/java/com/adyen/checkout/openbanking/OpenBankingRecyclerView.java
index 12063774de..ddd39c068d 100644
--- a/openbanking-ui/src/main/java/com/adyen/checkout/openbanking/OpenBankingRecyclerView.java
+++ b/openbanking-ui/src/main/java/com/adyen/checkout/openbanking/OpenBankingRecyclerView.java
@@ -8,20 +8,15 @@
package com.adyen.checkout.openbanking;
-import android.arch.lifecycle.LifecycleOwner;
import android.content.Context;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
-import com.adyen.checkout.core.log.LogUtil;
-import com.adyen.checkout.core.log.Logger;
import com.adyen.checkout.issuerlist.IssuerListRecyclerView;
public class OpenBankingRecyclerView extends IssuerListRecyclerView {
- private static final String TAG = LogUtil.getTag();
-
public OpenBankingRecyclerView(@NonNull Context context) {
super(context);
}
@@ -33,11 +28,4 @@ public OpenBankingRecyclerView(@NonNull Context context, @Nullable AttributeSet
public OpenBankingRecyclerView(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
-
- @Override
- public void attach(@NonNull OpenBankingComponent component, @NonNull LifecycleOwner lifecycleOwner) {
- super.attach(component, lifecycleOwner);
- Logger.d(TAG, "attach");
- mComponent.observeOutputData(lifecycleOwner, createOutputDataObserver());
- }
}
diff --git a/openbanking-ui/src/main/java/com/adyen/checkout/openbanking/OpenBankingSpinnerView.java b/openbanking-ui/src/main/java/com/adyen/checkout/openbanking/OpenBankingSpinnerView.java
index abd2071406..bcb73c2e12 100644
--- a/openbanking-ui/src/main/java/com/adyen/checkout/openbanking/OpenBankingSpinnerView.java
+++ b/openbanking-ui/src/main/java/com/adyen/checkout/openbanking/OpenBankingSpinnerView.java
@@ -8,18 +8,14 @@
package com.adyen.checkout.openbanking;
-import android.arch.lifecycle.LifecycleOwner;
import android.content.Context;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
-import com.adyen.checkout.core.log.LogUtil;
-import com.adyen.checkout.core.log.Logger;
import com.adyen.checkout.issuerlist.IssuerListSpinnerView;
public final class OpenBankingSpinnerView extends IssuerListSpinnerView {
- private static final String TAG = LogUtil.getTag();
public OpenBankingSpinnerView(@NonNull Context context) {
super(context);
@@ -32,11 +28,4 @@ public OpenBankingSpinnerView(@NonNull Context context, @Nullable AttributeSet a
public OpenBankingSpinnerView(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
-
- @Override
- public void attach(@NonNull OpenBankingComponent component, @NonNull LifecycleOwner lifecycleOwner) {
- super.attach(component, lifecycleOwner);
- Logger.d(TAG, "attach");
- mComponent.observeOutputData(lifecycleOwner, createOutputDataObserver());
- }
}
diff --git a/redirect/src/main/java/com/adyen/checkout/redirect/RedirectComponent.java b/redirect/src/main/java/com/adyen/checkout/redirect/RedirectComponent.java
index 7f5f1a848c..9c99e3eebf 100644
--- a/redirect/src/main/java/com/adyen/checkout/redirect/RedirectComponent.java
+++ b/redirect/src/main/java/com/adyen/checkout/redirect/RedirectComponent.java
@@ -20,8 +20,8 @@
import com.adyen.checkout.base.component.ActionComponentProviderImpl;
import com.adyen.checkout.base.model.payments.response.Action;
import com.adyen.checkout.base.model.payments.response.RedirectAction;
-import com.adyen.checkout.core.exeption.CheckoutException;
-import com.adyen.checkout.core.exeption.ComponentException;
+import com.adyen.checkout.core.exception.CheckoutException;
+import com.adyen.checkout.core.exception.ComponentException;
import com.adyen.checkout.core.log.LogUtil;
import com.adyen.checkout.core.log.Logger;
import com.adyen.checkout.core.util.StringUtil;
diff --git a/redirect/src/main/java/com/adyen/checkout/redirect/RedirectUtil.java b/redirect/src/main/java/com/adyen/checkout/redirect/RedirectUtil.java
index bb240a3df1..bd0a511b87 100644
--- a/redirect/src/main/java/com/adyen/checkout/redirect/RedirectUtil.java
+++ b/redirect/src/main/java/com/adyen/checkout/redirect/RedirectUtil.java
@@ -23,8 +23,8 @@
import com.adyen.checkout.base.ui.util.ThemeUtil;
import com.adyen.checkout.core.code.Lint;
-import com.adyen.checkout.core.exeption.CheckoutException;
-import com.adyen.checkout.core.exeption.NoConstructorException;
+import com.adyen.checkout.core.exception.CheckoutException;
+import com.adyen.checkout.core.exception.NoConstructorException;
import com.adyen.checkout.core.log.LogUtil;
import com.adyen.checkout.core.log.Logger;
diff --git a/sepa-base/src/main/java/com/adyen/checkout/sepa/SepaComponent.java b/sepa-base/src/main/java/com/adyen/checkout/sepa/SepaComponent.java
index baf65d455c..6d545e05f9 100644
--- a/sepa-base/src/main/java/com/adyen/checkout/sepa/SepaComponent.java
+++ b/sepa-base/src/main/java/com/adyen/checkout/sepa/SepaComponent.java
@@ -28,6 +28,8 @@ public class SepaComponent extends BasePaymentComponent PROVIDER = new PaymentComponentProviderImpl<>(SepaComponent.class);
+ private static final String[] PAYMENT_METHOD_TYPES = {PaymentMethodTypes.SEPA};
+
public SepaComponent(@NonNull PaymentMethod paymentMethod, @NonNull SepaConfiguration configuration) {
super(paymentMethod, configuration);
}
@@ -71,8 +73,8 @@ protected SepaOutputData getOutputData() {
@NonNull
@Override
- public String getPaymentMethodType() {
- return PaymentMethodTypes.SEPA;
+ public String[] getSupportedPaymentMethodTypes() {
+ return PAYMENT_METHOD_TYPES;
}
@Override
diff --git a/sepa-base/src/main/java/com/adyen/checkout/sepa/SepaConfiguration.java b/sepa-base/src/main/java/com/adyen/checkout/sepa/SepaConfiguration.java
index 44d89fe448..86166bffa4 100644
--- a/sepa-base/src/main/java/com/adyen/checkout/sepa/SepaConfiguration.java
+++ b/sepa-base/src/main/java/com/adyen/checkout/sepa/SepaConfiguration.java
@@ -13,14 +13,14 @@
import android.os.Parcelable;
import android.support.annotation.NonNull;
-import com.adyen.checkout.base.component.BaseConfiguration;
+import com.adyen.checkout.base.component.Configuration;
import com.adyen.checkout.base.component.BaseConfigurationBuilder;
import com.adyen.checkout.core.api.Environment;
import com.adyen.checkout.core.code.Lint;
import java.util.Locale;
-public class SepaConfiguration extends BaseConfiguration {
+public class SepaConfiguration extends Configuration {
public static final Parcelable.Creator CREATOR = new Parcelable.Creator() {
public SepaConfiguration createFromParcel(@NonNull Parcel in) {
diff --git a/sepa-ui/src/main/java/com/adyen/checkout/sepa/SepaView.java b/sepa-ui/src/main/java/com/adyen/checkout/sepa/SepaView.java
index dcc61ef97b..de2d0365a8 100644
--- a/sepa-ui/src/main/java/com/adyen/checkout/sepa/SepaView.java
+++ b/sepa-ui/src/main/java/com/adyen/checkout/sepa/SepaView.java
@@ -21,32 +21,29 @@
import android.view.View;
import android.widget.LinearLayout;
-import com.adyen.checkout.base.ComponentView;
+import com.adyen.checkout.base.ui.view.AdyenLinearLayout;
import com.adyen.checkout.base.ui.view.AdyenTextInputEditText;
import com.adyen.checkout.core.code.Lint;
-import com.adyen.checkout.core.exeption.CheckoutException;
+import com.adyen.checkout.core.exception.CheckoutException;
import com.adyen.checkout.core.log.LogUtil;
import com.adyen.checkout.core.log.Logger;
import com.adyen.checkout.sepa.ui.R;
-public class SepaView extends LinearLayout implements ComponentView, Observer {
+public class SepaView extends AdyenLinearLayout implements Observer {
private static final String TAG = LogUtil.getTag();
- @SuppressLint(Lint.SYNTHETIC)
- SepaComponent mSepaComponent;
-
@SuppressLint(Lint.SYNTHETIC)
SepaInputData mSepaInputData = new SepaInputData();
@SuppressLint(Lint.SYNTHETIC)
- final TextInputLayout mHolderNameInput;
+ TextInputLayout mHolderNameInput;
@SuppressLint(Lint.SYNTHETIC)
- final TextInputLayout mIbanNumberInput;
+ TextInputLayout mIbanNumberInput;
@SuppressLint(Lint.SYNTHETIC)
- final AdyenTextInputEditText mHolderNameEditText;
+ AdyenTextInputEditText mHolderNameEditText;
@SuppressLint(Lint.SYNTHETIC)
- final AdyenTextInputEditText mIbanNumberEditText;
+ AdyenTextInputEditText mIbanNumberEditText;
public SepaView(@NonNull Context context) {
this(context, null);
@@ -60,15 +57,19 @@ public SepaView(@NonNull Context context, @Nullable AttributeSet attrs) {
@SuppressWarnings("JavadocMethod")
public SepaView(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
+
setOrientation(LinearLayout.VERTICAL);
+ LayoutInflater.from(getContext()).inflate(R.layout.sepa_view, this, true);
+
final int padding = (int) getResources().getDimension(R.dimen.standard_margin);
setPadding(padding, padding, padding, 0);
+ }
- final View root = LayoutInflater.from(context).inflate(R.layout.sepa_view, this, true);
-
- mHolderNameInput = root.findViewById(R.id.textInputLayout_holderName);
- mIbanNumberInput = root.findViewById(R.id.textInputLayout_ibanNumber);
+ @Override
+ public void initView() {
+ mHolderNameInput = findViewById(R.id.textInputLayout_holderName);
+ mIbanNumberInput = findViewById(R.id.textInputLayout_ibanNumber);
mHolderNameEditText = (AdyenTextInputEditText) mHolderNameInput.getEditText();
mIbanNumberEditText = (AdyenTextInputEditText) mIbanNumberInput.getEditText();
@@ -96,7 +97,7 @@ public void onTextChanged(@NonNull Editable editable) {
public void onFocusChange(View v, boolean hasFocus) {
mIbanNumberInput.setErrorEnabled(!hasFocus);
- if (!hasFocus && !mSepaComponent.getOutputData().getIbanNumberField().isValid()) {
+ if (!hasFocus && !getComponent().getOutputData().getIbanNumberField().isValid()) {
mIbanNumberInput.setError(getContext().getString(R.string.checkout_iban_not_valid));
}
}
@@ -109,9 +110,13 @@ public void onChanged(@Nullable SepaOutputData sepaOutputData) {
}
@Override
- public void attach(@NonNull SepaComponent component, @NonNull LifecycleOwner lifecycleOwner) {
- mSepaComponent = component;
- mSepaComponent.observeOutputData(lifecycleOwner, this);
+ public void onComponentAttached() {
+ // nothing to impl
+ }
+
+ @Override
+ public void observeComponentChanges(@NonNull LifecycleOwner lifecycleOwner) {
+ getComponent().observeOutputData(lifecycleOwner, this);
}
@Override
@@ -121,8 +126,6 @@ public boolean isConfirmationRequired() {
@SuppressLint(Lint.SYNTHETIC)
void notifyInputDataChanged() {
- if (mSepaComponent != null) {
- mSepaComponent.inputDataChanged(mSepaInputData);
- }
+ getComponent().inputDataChanged(mSepaInputData);
}
}
diff --git a/sepa-ui/src/main/res/layout/sepa_view.xml b/sepa-ui/src/main/res/layout/sepa_view.xml
index d033a0ddab..ab53d245c2 100644
--- a/sepa-ui/src/main/res/layout/sepa_view.xml
+++ b/sepa-ui/src/main/res/layout/sepa_view.xml
@@ -37,9 +37,4 @@
style="@style/AdyenCheckout.Sepa.AccountNumberInput" />
-
-
\ No newline at end of file
diff --git a/sepa-ui/src/main/res/values/strings.xml b/sepa-ui/src/main/res/values/strings.xml
index e7ac503209..7d28c59b09 100644
--- a/sepa-ui/src/main/res/values/strings.xml
+++ b/sepa-ui/src/main/res/values/strings.xml
@@ -10,6 +10,5 @@
Holder Name
Account Number (IBAN)
- I agree that the amount below will be debited from my bank account.
IBAN is not valid
\ No newline at end of file