Skip to content

Commit

Permalink
3.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
adyen-git-manager committed Aug 13, 2019
1 parent dd13d18 commit 916244c
Show file tree
Hide file tree
Showing 74 changed files with 2,686 additions and 141 deletions.
4 changes: 2 additions & 2 deletions 3ds2/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ ext.mavenArtifactDescription = "Adyen Checkout 3DS2 component client for Adyen's

apply plugin: 'com.android.library'

// TODO switch back when we have MD5 file for 3DS2 SDK
//apply from: "../config/gradle/sharedTasks.gradle"
// TODO switch back to use `sharedTasks.gradle` when we have MD5 file for 3DS2 SDK
apply from: "../config/gradle/codeQuality.gradle"
apply from: "../config/gradle/ci.gradle"
apply from: "../config/gradle/runConnectedAndroidTest.gradle"

android {
compileSdkVersion version_compile_sdk
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ 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.1.1"
implementation "com.adyen.checkout:drop-in:3.2.0"
```
For a Credit Card component you should add:
```groovy
implementation "com.adyen.checkout:card-ui:3.1.1"
implementation "com.adyen.checkout:card-ui:3.2.0"
```
For and iDeal component you should add:
```groovy
implementation "com.adyen.checkout:ideal-ui:3.1.1"
implementation "com.adyen.checkout:ideal-ui:3.2.0"
```

## Drop-in
Expand Down
2 changes: 1 addition & 1 deletion RELEASE_NOTES
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<ul>
<li>Bug fixes.</li>
<li>Added support for "Google pay"</li>
</ul>
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@
package com.adyen.checkout.base;

import android.support.annotation.NonNull;
import android.support.annotation.Nullable;

import com.adyen.checkout.base.model.paymentmethods.PaymentMethod;

public interface ComponentAvailableCallback<ConfigurationT extends Configuration> {

void onAvailabilityResult(boolean isAvailable, @NonNull PaymentMethod paymentMethod, @NonNull ConfigurationT config);
void onAvailabilityResult(boolean isAvailable, @NonNull PaymentMethod paymentMethod, @Nullable ConfigurationT config);
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
/**
* The current state of a PaymentComponent.
*/
public final class PaymentComponentState<PaymentMethodDetailsT extends PaymentMethodDetails> {
public class PaymentComponentState<PaymentMethodDetailsT extends PaymentMethodDetails> {

private final PaymentComponentData<PaymentMethodDetailsT> mPaymentComponentData;
private final boolean mIsValid;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ public enum Size {

@Override
public String toString() {
return name().toLowerCase(Locale.US);
return name().toLowerCase(Locale.ROOT);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public abstract class BaseConfiguration implements Configuration {
private final Locale mShopperLocale;
private final Environment mEnvironment;

public BaseConfiguration(@NonNull Locale shopperLocale, @NonNull Environment environment) {
protected BaseConfiguration(@NonNull Locale shopperLocale, @NonNull Environment environment) {
mShopperLocale = shopperLocale;
mEnvironment = environment;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public abstract class BasePaymentComponent<ConfigurationT extends Configuration,
private boolean mIsAnalyticsEnabled = true;

/**
* Constructs a {@link BasePaymentComponent} object.
* Component should not be instantiated directly. Instead use the PROVIDER object.
*
* @param paymentMethod {@link PaymentMethod}
* @param configuration {@link ConfigurationT}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Created by caiof on 4/6/2019.
*/

package com.adyen.checkout.base.model.payments.response;
package com.adyen.checkout.base.model.payments;

import android.os.Parcel;
import android.support.annotation.NonNull;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;

import com.adyen.checkout.base.util.PaymentMethodTypes;
import com.adyen.checkout.core.exeption.ModelSerializationException;
import com.adyen.checkout.core.model.JsonUtils;

Expand All @@ -24,7 +25,7 @@ public final class CardPaymentMethod extends PaymentMethodDetails {
@NonNull
public static final Creator<CardPaymentMethod> CREATOR = new Creator<>(CardPaymentMethod.class);

public static final String PAYMENT_METHOD_TYPE = "scheme";
public static final String PAYMENT_METHOD_TYPE = PaymentMethodTypes.SCHEME;

private static final String ENCRYPTED_CARD_NUMBER = "encryptedCardNumber";
private static final String ENCRYPTED_EXPIRY_MONTH = "encryptedExpiryMonth";
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
/*
* 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/7/2019.
*/

package com.adyen.checkout.base.model.payments.request;

import android.os.Parcel;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;

import com.adyen.checkout.base.util.PaymentMethodTypes;
import com.adyen.checkout.core.exeption.ModelSerializationException;
import com.adyen.checkout.core.model.JsonUtils;

import org.json.JSONException;
import org.json.JSONObject;

@SuppressWarnings("MemberName")
public class GooglePayPaymentMethod extends PaymentMethodDetails {

@NonNull
public static final Creator<GooglePayPaymentMethod> CREATOR = new Creator<>(GooglePayPaymentMethod.class);

public static final String PAYMENT_METHOD_TYPE = PaymentMethodTypes.GOOGLE_PAY;

private static final String PAY_WITH_GOOGLE_TOKEN = "paywithgoogle.token";

@NonNull
public static final Serializer<GooglePayPaymentMethod> SERIALIZER = new Serializer<GooglePayPaymentMethod>() {
@NonNull
@Override
public JSONObject serialize(@NonNull GooglePayPaymentMethod modelObject) {
final JSONObject jsonObject = new JSONObject();
try {
// getting parameters from parent class
jsonObject.putOpt(PaymentMethodDetails.TYPE, modelObject.getType());

jsonObject.putOpt(PAY_WITH_GOOGLE_TOKEN, modelObject.getToken());
} catch (JSONException e) {
throw new ModelSerializationException(GooglePayPaymentMethod.class, e);
}
return jsonObject;
}

@NonNull
@Override
public GooglePayPaymentMethod deserialize(@NonNull JSONObject jsonObject) {
final GooglePayPaymentMethod googlePayPaymentMethod = new GooglePayPaymentMethod();

// getting parameters from parent class
googlePayPaymentMethod.setType(jsonObject.optString(PaymentMethodDetails.TYPE, null));

googlePayPaymentMethod.setToken(jsonObject.optString(PAY_WITH_GOOGLE_TOKEN, null));

return googlePayPaymentMethod;
}
};

private String token;

@Override
public void writeToParcel(@NonNull Parcel dest, int flags) {
JsonUtils.writeToParcel(dest, SERIALIZER.serialize(this));
}

@Nullable
public String getToken() {
return token;
}

public void setToken(@Nullable String token) {
this.token = token;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ static Serializer<? extends PaymentMethodDetails> getChildSerializer(@NonNull St
return OpenBankingPaymentMethod.SERIALIZER;
case EntercashPaymentMethod.PAYMENT_METHOD_TYPE:
return EntercashPaymentMethod.SERIALIZER;
case GooglePayPaymentMethod.PAYMENT_METHOD_TYPE:
return GooglePayPaymentMethod.SERIALIZER;
default:
return GenericPaymentMethod.SERIALIZER;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import android.support.annotation.NonNull;
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.model.JsonUtils;
import com.adyen.checkout.core.model.ModelUtils;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/*
* 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 31/7/2019.
*/

package com.adyen.checkout.base.util;

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.log.LogUtil;
import com.adyen.checkout.core.log.Logger;

import java.math.BigDecimal;
import java.util.Currency;
import java.util.Locale;

public final class AmountFormat {
private static final String TAG = LogUtil.getTag();

/**
* Convert an {@link Amount} to its corresponding {@link BigDecimal} value.
*
* @param amount The {@link Amount} to be converted.
* @return A {@link BigDecimal} representation of the {@link Amount}.
*/
@NonNull
public static BigDecimal toBigDecimal(@NonNull Amount amount) {
return toBigDecimal(amount.getValue(), amount.getCurrency());
}

/**
* Convert a value in minor units with the corresponding currency code to its {@link BigDecimal} representation.
*
* @param value The value in minor units.
* @param currencyCode The currency code of the value.
* @return A {@link BigDecimal} representation.
*/
@NonNull
public static BigDecimal toBigDecimal(long value, @NonNull String currencyCode) {
final int fractionDigits = getFractionDigits(currencyCode);

return BigDecimal.valueOf(value, fractionDigits);
}

private static int getFractionDigits(@NonNull String currencyCode) {
final String normalizedCurrencyCode = currencyCode.replaceAll("[^A-Z]", "").toUpperCase(Locale.ROOT);

try {
final CheckoutCurrency checkoutCurrency = CheckoutCurrency.valueOf(normalizedCurrencyCode);
return checkoutCurrency.getFractionDigits();
} catch (IllegalArgumentException e) {
Logger.e(TAG, normalizedCurrencyCode + " is an unsupported currency. Falling back to information from java.util.Currency.");
}

try {
final Currency currency = Currency.getInstance(normalizedCurrencyCode);
return Math.max(currency.getDefaultFractionDigits(), 0);
} catch (IllegalArgumentException e) {
Logger.e(TAG, "Could not determine fraction digits for " + normalizedCurrencyCode, e);
return 0;
}
}

private AmountFormat() {
throw new NoConstructorException();
}
}
Loading

0 comments on commit 916244c

Please sign in to comment.