Skip to content

Commit

Permalink
2.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
adyen-git-manager committed Mar 11, 2019
1 parent b4f8106 commit af65ddd
Show file tree
Hide file tree
Showing 38 changed files with 1,502 additions and 43 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ To give you as much flexibility as possible, our Android SDK can be integrated i
Import the quick integration modules by adding these lines to your build.gradle file.

```groovy
final checkoutVersion = "2.3.3"
final checkoutVersion = "2.4.0"
implementation "com.adyen.checkout:ui:${checkoutVersion}"
implementation "com.adyen.checkout:nfc:${checkoutVersion}" // Optional; Integrates NFC card reader in card UI
implementation "com.adyen.checkout:wechatpay:${checkoutVersion}" // Optional; Integrates support for WeChat Pay
Expand Down Expand Up @@ -136,7 +136,7 @@ By default, we use the font that is declared in the theme that is used for check
#### Installation
Import the following modules by adding these line to your `build.gradle` file.
```groovy
final checkoutVersion = "2.3.3"
final checkoutVersion = "2.4.0"
implementation "com.adyen.checkout:core:${checkoutVersion}"
implementation "com.adyen.checkout:core-card:${checkoutVersion}" // Optional; Required for processing card payments.
implementation "com.adyen.checkout:nfc:${checkoutVersion}" // Optional; Enables reading of card information with the device"s NFC chip.
Expand Down
12 changes: 6 additions & 6 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
ext {
compileSdkVersion = 27
targetSdkVersion = 27
compileSdkVersion = 28
targetSdkVersion = 28
minSdkVersion = 16

supportLibVersion = "27.1.1"
Expand Down Expand Up @@ -28,8 +28,8 @@ ext {
"com.tencent.mm.opensdk:wechat-sdk-android-without-mta:9a15154c07c05eadba8351c110647c1754316e32d8f12f55e24679891b52739c:SHA-256",
]

versionCode = 209
versionName = "2.3.3"
versionCode = 210
versionName = "2.4.0"

testCoverageEnabled = true
}
Expand All @@ -40,8 +40,8 @@ buildscript {
jcenter()
}
dependencies {
classpath "com.android.tools.build:gradle:3.2.0"
classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.2"
classpath "com.android.tools.build:gradle:3.3.2"
classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.4"
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
/*
* Copyright (c) 2017 Adyen N.V.
*
* This file is open source and available under the MIT license. See the LICENSE file for more info.
*
* Created by Ran Haveshush on 22/11/2018.
*/

package com.adyen.checkout.base.internal;

import android.support.annotation.NonNull;
import android.util.Base64;

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

import java.nio.charset.Charset;

public final class Base64Coder {

private static final Charset DEFAULT_CHARSET = Api.CHARSET;

public static final int DEFAULT_FLAGS = Base64.DEFAULT;

@NonNull
public static <D extends JsonDecodable> D decode(@NonNull String encodedData, @NonNull Class<D> decodableClass) throws JSONException {
return decode(encodedData, decodableClass, DEFAULT_FLAGS);
}

@NonNull
public static <D extends JsonDecodable> D decode(@NonNull String encodedData, @NonNull Class<D> decodableClass, int flags) throws JSONException {
D decodeable = JsonDecodable.decodeFrom(encodedData, decodableClass, flags);

return decodeable;
}

@NonNull
public static <E extends JsonEncodable> String encode(@NonNull E encodable) throws JSONException {
return encode(encodable, DEFAULT_FLAGS);
}

@NonNull
public static <E extends JsonEncodable> String encode(@NonNull E encodable, int flags) throws JSONException {
return JsonEncodable.encodeFrom(encodable, flags);
}

@NonNull
public static String encodeToString(@NonNull JSONObject jsonObject) {
return encodeToString(jsonObject, DEFAULT_FLAGS);
}

@NonNull
public static String encodeToString(@NonNull JSONObject jsonObject, int flags) {
return encodeToString(jsonObject.toString(), flags);
}

@NonNull
public static String encodeToString(@NonNull String decodedData) {
return encodeToString(decodedData, DEFAULT_FLAGS);
}

@NonNull
public static String encodeToString(@NonNull String decodedData, int flags) {
byte[] decodedBytes = decodedData.getBytes(DEFAULT_CHARSET);

return Base64.encodeToString(decodedBytes, flags);
}

@NonNull
public static JSONObject decodeToJSONObject(@NonNull String encodedData) throws JSONException {
return decodeToJSONObject(encodedData, DEFAULT_FLAGS);
}

@NonNull
public static JSONObject decodeToJSONObject(@NonNull String encodedData, int flags) throws JSONException {
String decodedData = decodeToString(encodedData, flags);

return new JSONObject(decodedData);
}

@NonNull
public static String decodeToString(@NonNull String encodedData) {
return decodeToString(encodedData, DEFAULT_FLAGS);
}

@NonNull
public static String decodeToString(@NonNull String encodedData, int flags) {
byte[] decodedBytes = Base64.decode(encodedData, flags);
String decodedData = new String(decodedBytes, DEFAULT_CHARSET);

return decodedData;
}

private Base64Coder() {
throw new IllegalStateException("No instances.");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* Copyright (c) 2017 Adyen N.V.
*
* This file is open source and available under the MIT license. See the LICENSE file for more info.
*
* Created by Ran Haveshush on 21/11/2018.
*/

package com.adyen.checkout.base.internal;

import android.support.annotation.NonNull;

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

public abstract class JsonDecodable extends JsonObject {

@NonNull
public static <T extends JsonDecodable> T decodeFrom(@NonNull String encodedData, @NonNull Class<T> clazz) throws JSONException {
return decodeFrom(encodedData, clazz, Base64Coder.DEFAULT_FLAGS);
}

@NonNull
public static <T extends JsonDecodable> T decodeFrom(@NonNull String encodedData, @NonNull Class<T> clazz, int flags) throws JSONException {
JSONObject jsonObject = Base64Coder.decodeToJSONObject(encodedData, flags);

return parseFrom(jsonObject, clazz);
}

protected JsonDecodable(@NonNull JSONObject jsonObject) throws JSONException {
super(jsonObject);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* Copyright (c) 2017 Adyen N.V.
*
* This file is open source and available under the MIT license. See the LICENSE file for more info.
*
* Created by Ran Haveshush on 21/11/2018.
*/

package com.adyen.checkout.base.internal;

import android.support.annotation.NonNull;

import org.json.JSONException;

public abstract class JsonEncodable implements JsonSerializable {

@NonNull
static <E extends JsonEncodable> String encodeFrom(@NonNull E encodable) throws JSONException {
return encodeFrom(encodable, Base64Coder.DEFAULT_FLAGS);
}

@NonNull
static <E extends JsonEncodable> String encodeFrom(@NonNull E encodable, int flags) throws JSONException {
return encodable.encode(flags);
}

@NonNull
String encode(int flags) throws JSONException {
return Base64Coder.encodeToString(serialize(), flags);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public static <T extends Enum<T>> T parseEnumValue(@NonNull String enumValue, @N

SerializedName serializedName = field.getAnnotation(SerializedName.class);

if (serializedName != null && enumValue.equals(serializedName.value())) {
if (serializedName != null && enumValue.equalsIgnoreCase(serializedName.value())) {
//noinspection RedundantTypeArguments, type arguments need to be present for compiler
return JsonObject.<T>getEnumValueFromField(field);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
* Copyright (c) 2018 Adyen N.V.
*
* This file is open source and available under the MIT license. See the LICENSE file for more info.
*
* Created by Ran Haveshush on 09/05/2018.
*/

package com.adyen.checkout.core;

import android.os.Parcelable;
import android.support.annotation.NonNull;

import com.adyen.checkout.core.model.Authentication;
import com.adyen.checkout.core.model.InputDetail;
import com.adyen.checkout.core.model.PaymentResultCode;

import java.util.List;

/**
* The {@link AuthenticationDetails} class describes all required parameters for an authentication.
*/
public interface AuthenticationDetails extends Parcelable {
/**
* @return The type of payment method for which authentication details are needed.
*/
@NonNull
String getPaymentMethodType();

/**
* Get authentication data that might be needed for the shopper authentication.
*
* @param authenticationClass The {@link Authentication} {@link Class}.
* @param <T> The {@link Authentication} type.
* @return The parsed {@link Authentication}.
* @throws CheckoutException If the data does not match the provided {@link Authentication} {@link Class}.
*/
@NonNull
<T extends Authentication> T getAuthentication(@NonNull Class<T> authenticationClass) throws CheckoutException;

/**
* @return The {@link List} of authentication {@link InputDetail InputDetails}.
*/
@NonNull
List<InputDetail> getInputDetails();

/**
* @return The payment result code {@link PaymentResultCode}.
*/
@NonNull
PaymentResultCode getResultCode();
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import com.adyen.checkout.core.handler.AdditionalDetailsHandler;
import com.adyen.checkout.core.handler.ErrorHandler;
import com.adyen.checkout.core.handler.RedirectHandler;
import com.adyen.checkout.core.handler.AuthenticationHandler;
import com.adyen.checkout.core.model.PaymentMethod;
import com.adyen.checkout.core.model.PaymentMethodDetails;
import com.adyen.checkout.core.model.PaymentSession;
Expand Down Expand Up @@ -49,6 +50,16 @@ public interface PaymentHandler {
@NonNull
Observable<PaymentResult> getPaymentResultObservable();

/**
* Sets an {@link Activity} scoped {@link AuthenticationHandler} for this {@link PaymentHandler}. Setting this {@link AuthenticationHandler}
* is required for {@link PaymentMethod PaymentMethods} that might require {@link AuthenticationDetails} after calling
* {@link #initiatePayment(PaymentMethod, PaymentMethodDetails)} the first time.
*
* @param activity The current {@link Activity}.
* @param authenticationHandler The {@link AuthenticationHandler} responsible for handling {@link AuthenticationDetails}.
*/
void setAuthenticationHandler(@NonNull Activity activity, @NonNull AuthenticationHandler authenticationHandler);

/**
* Sets an {@link Activity} scoped {@link RedirectHandler} for this {@link PaymentHandler}. Setting this {@link RedirectHandler} is required for
* {@link PaymentMethod PaymentMethods} that require a redirect to an external party to complete the payment.
Expand Down Expand Up @@ -86,6 +97,13 @@ public interface PaymentHandler {
*/
void initiatePayment(@NonNull PaymentMethod paymentMethod, @Nullable PaymentMethodDetails paymentMethodDetails);

/**
* Submits authentication details for a payment that was previously initiated.
*
* @param paymentMethodDetails The {@link PaymentMethodDetails} containing the authentication details needed for the payment.
*/
void submitAuthenticationDetails(@NonNull PaymentMethodDetails paymentMethodDetails);

/**
* Submits additional details for a payment that was previously initiated.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
* Copyright (c) 2018 Adyen N.V.
*
* This file is open source and available under the MIT license. See the LICENSE file for more info.
*
* Created by Ran Haveshush on 16/11/2018.
*/

package com.adyen.checkout.core.handler;

import android.support.annotation.NonNull;

import com.adyen.checkout.core.AuthenticationDetails;

public interface AuthenticationHandler {
/**
* Called when authentication details are required to continue with the payment.
*
* @param authenticationDetails The required authentication details.
*/
void onAuthenticationDetailsRequired(@NonNull AuthenticationDetails authenticationDetails);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* Copyright (c) 2018 Adyen N.V.
*
* This file is open source and available under the MIT license. See the LICENSE file for more info.
*
* Created by Ran Haveshush on 16/11/2018.
*/

package com.adyen.checkout.core.internal;

import android.support.annotation.NonNull;

import com.adyen.checkout.core.AuthenticationDetails;
import com.adyen.checkout.core.handler.AuthenticationHandler;

final class AuthenticationManager extends BaseManager<AuthenticationHandler, AuthenticationDetails> {

AuthenticationManager(@NonNull Listener listener) {
super(listener);
}

@Override
void dispatch(@NonNull AuthenticationHandler handler, @NonNull AuthenticationDetails data) {
handler.onAuthenticationDetailsRequired(data);
}
}
Loading

0 comments on commit af65ddd

Please sign in to comment.