Skip to content

Commit

Permalink
Release 1.11.1
Browse files Browse the repository at this point in the history
  • Loading branch information
adyen-git-manager committed Oct 25, 2017
1 parent 4b0ed75 commit 083e292
Show file tree
Hide file tree
Showing 25 changed files with 223 additions and 218 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ This README provides the usage manual for the SDK itself. For the full documenta
To integrate the Adyen SDK into your project, import the **core**, **utils** and **ui** module by adding the following lines to your build.gradle file.

```
compile 'com.adyen.checkout:core:1.10.0'
compile 'com.adyen.checkout:utils:1.10.0'
compile 'com.adyen.checkout:ui:1.10.0'
compile 'com.adyen.checkout:cardscan:1.10.0'
compile 'com.adyen.checkout:core:1.11.0'
compile 'com.adyen.checkout:utils:1.11.0'
compile 'com.adyen.checkout:ui:1.11.0'
compile 'com.adyen.checkout:cardscan:1.11.0'
```

> For implementing Custom integration, only the **core** module is required. However, you might also want to include the **utils** module to use Adyen's utility methods such as Luhn check, credit card type detection, etc.
Expand Down
2 changes: 1 addition & 1 deletion adyen-androidpay/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,6 @@ dependencies {
debugCompile project(path: ':adyen-core', configuration: 'debug')
releaseCompile project(path: ':adyen-core', configuration: 'release')
} else {
compile project(':adyen-core')
provided group: 'com.adyen.checkout', name: 'core', version: "${rootProject.versionName}"
}
}

This file was deleted.

3 changes: 2 additions & 1 deletion adyen-androidpay/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
android:value="true" />

<activity
android:name=".ui.AndroidPayActivity" />
android:name=".ui.AndroidPayActivity"
android:theme="@style/AndroidPayActivity"/>

</application>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ public void process(@NonNull final Context context, @NonNull final PaymentReques
intent.putExtra("amount", paymentRequest.getAmount());
intent.putExtra("publicKey", paymentMethod.getConfiguration().getPublicKey());
intent.putExtra("merchantName", paymentMethod.getConfiguration().getMerchantName());
intent.putExtra("environment", paymentMethod.getConfiguration().getEnvironment());
context.startActivity(intent);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package com.adyen.androidpay.ui;

import android.app.Activity;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
Expand Down Expand Up @@ -33,6 +36,8 @@
import java.util.Locale;
import java.util.Map;

import static com.adyen.core.constants.Constants.PaymentRequest.ADYEN_UI_FINALIZE_INTENT;

public class AndroidPayActivity extends FragmentActivity implements GoogleApiClient.OnConnectionFailedListener,
GoogleApiClient.ConnectionCallbacks {

Expand All @@ -51,6 +56,13 @@ public class AndroidPayActivity extends FragmentActivity implements GoogleApiCli
private String merchantName;
private String currency;

private BroadcastReceiver uiFinalizationIntent = new BroadcastReceiver() {
@Override
public void onReceive(final Context context, final Intent intent) {
finish();
}
};

@SuppressWarnings("unchecked")
@Override
protected void onCreate(Bundle savedInstanceState) {
Expand All @@ -69,12 +81,22 @@ protected void onCreate(Bundle savedInstanceState) {

googleApiClient = getGoogleApiClient();

supportWalletFragment = createWalletFragment(WalletConstants.ENVIRONMENT_TEST,
int environment = WalletConstants.ENVIRONMENT_TEST;

if (intent.hasExtra("environment") && intent.getExtras().getString("environment") != null
&& !intent.getExtras().getString("environment").isEmpty()) {
environment = Integer.parseInt(intent.getExtras().getString("environment"));
}

supportWalletFragment = createWalletFragment(environment,
WalletFragmentStyle.BuyButtonAppearance.ANDROID_PAY_DARK, WalletConstants.THEME_DARK);
// add Wallet fragment to the UI
getSupportFragmentManager().beginTransaction()
.replace(R.id.android_pay_fragment_container, supportWalletFragment)
.commit();

LocalBroadcastManager.getInstance(getApplicationContext()).registerReceiver(uiFinalizationIntent,
new IntentFilter(ADYEN_UI_FINALIZE_INTENT));
}

@Override
Expand Down
28 changes: 19 additions & 9 deletions adyen-androidpay/src/main/res/layout/activity_android_pay.xml
Original file line number Diff line number Diff line change
@@ -1,12 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_height="match_parent">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:weightSum="3"
android:orientation="vertical"
android:gravity="bottom">

<FrameLayout
android:id="@+id/android_pay_fragment_container"
android:layout_width="300dp"
android:layout_height="48dp"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"/>
<LinearLayout
android:background="@android:color/white"
android:layout_weight="1"
android:layout_width="match_parent"
android:layout_height="0dp"
android:gravity="center">

</RelativeLayout>
<FrameLayout
android:id="@+id/android_pay_fragment_container"
android:layout_width="300dp"
android:layout_height="48dp"/>
</LinearLayout>

</LinearLayout>
10 changes: 10 additions & 0 deletions adyen-androidpay/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="AndroidPayActivity" parent="android:Theme.Holo.Light">
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowContentOverlay">@null</item>
<item name="android:backgroundDimEnabled">true</item>
</style>
</resources>
2 changes: 1 addition & 1 deletion adyen-core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,5 @@ dependencies {
compile 'io.reactivex.rxjava2:rxjava:2.1.2'
compile 'io.reactivex.rxjava2:rxandroid:2.0.1'

compile 'com.adyen.cse:adyen-cse:1.0.3'
compile 'com.adyen.cse:adyen-cse:1.0.4'
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ final class DeviceTokenGenerator {

private static final String TAG = DeviceTokenGenerator.class.getSimpleName();

private static final String DEVICE_FINGER_PRINT_VERSION = "1.0";
private static final String DEVICE_FINGER_PRINT_VERSION = "1.1";
private static final String SDK_VERSION = BuildConfig.VERSION_NAME;

private DeviceTokenGenerator() {
Expand All @@ -31,7 +31,7 @@ private DeviceTokenGenerator() {
* Uses device and SDK information to create token.
* @return token
*/
static String getToken(final Context context, final PaymentStateHandler paymentStateHandler) {
static String getToken(final Context context, final PaymentStateHandler paymentStateHandler, boolean isQuickIntegration) {
final JSONObject deviceInfo = new JSONObject();
try {
final String androidId = Settings.Secure.getString(context.getContentResolver(),
Expand All @@ -44,6 +44,8 @@ static String getToken(final Context context, final PaymentStateHandler paymentS
deviceInfo.put("deviceIdentifier", androidId);
deviceInfo.put("locale", StringUtils.getLocale(context));

deviceInfo.put("integration", (isQuickIntegration) ? "quick" : "custom");

} catch (final JSONException jsonException) {
Log.e(TAG, "Token could not be created", jsonException);
paymentStateHandler.setPaymentErrorThrowableAndTriggerError(jsonException);
Expand Down
40 changes: 23 additions & 17 deletions adyen-core/src/main/java/com/adyen/core/PaymentStateHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class PaymentStateHandler implements State.StateChangeListener {
private PaymentRequestResult paymentResult;
private PaymentRequest paymentRequest;

private List<PaymentMethod> filteredPaymentMethodsList;
private List<PaymentMethod> availablePaymentMethods;
private List<PaymentMethod> preferredPaymentMethods;

private PaymentProcessorStateMachine paymentProcessorStateMachine;
Expand All @@ -92,7 +92,7 @@ class PaymentStateHandler implements State.StateChangeListener {
this.merchantPaymentRequestDetailsListener = paymentRequestDetailsListener;

paymentBroadcastReceivers = new PaymentBroadcastReceivers(this, paymentRequest);
filteredPaymentMethodsList = new ArrayList<>();
availablePaymentMethods = new ArrayList<>();
paymentProcessorStateMachine = new PaymentProcessorStateMachine(this);

paymentRequestListeners.add(paymentRequestListener);
Expand Down Expand Up @@ -184,7 +184,7 @@ public void onStateNotChanged(State state) {
private void requestPaymentData() {
Log.d(TAG, "requestPaymentData()");

final String token = DeviceTokenGenerator.getToken(context, this);
final String token = DeviceTokenGenerator.getToken(context, this, sdkHandlesUI());

for (PaymentRequestListener listener : paymentRequestListeners) {
listener.onPaymentDataRequested(paymentRequest, token, paymentBroadcastReceivers.getPaymentDataCallback());
Expand All @@ -210,7 +210,7 @@ private void requestPaymentMethodSelection() {

for (PaymentRequestDetailsListener detailsListener : paymentRequestDetailsListeners) {
detailsListener.onPaymentMethodSelectionRequired(paymentRequest, preferredPaymentMethods,
filteredPaymentMethodsList, paymentBroadcastReceivers.getPaymentMethodCallback());
availablePaymentMethods, paymentBroadcastReceivers.getPaymentMethodCallback());
}

final IntentFilter intentFilter = new IntentFilter(PAYMENT_METHOD_SELECTED_INTENT);
Expand Down Expand Up @@ -256,19 +256,25 @@ private void unregisterBroadcastReceivers() {

private void fetchPaymentMethods() {
if (paymentResponse != null) {
List<PaymentMethod> unfilteredPaymentMethods = paymentResponse.getAvailablePaymentMethods();
this.preferredPaymentMethods = paymentResponse.getPreferredPaymentMethods();
Observable<List<PaymentMethod>> listObservable = ModuleAvailabilityUtil.filterPaymentMethods(context,
unfilteredPaymentMethods);
listObservable.subscribe(new Consumer<List<PaymentMethod>>() {
@Override
public void accept(List<PaymentMethod> filteredPaymentMethods) {
filteredPaymentMethods.removeAll(Collections.singleton(null));
PaymentStateHandler.this.filteredPaymentMethodsList.clear();
PaymentStateHandler.this.filteredPaymentMethodsList.addAll(filteredPaymentMethods);
paymentProcessorStateMachine.onTrigger(PaymentTrigger.PAYMENT_METHODS_AVAILABLE);
}
});

if (merchantPaymentRequestDetailsListener == null) {
List<PaymentMethod> unfilteredPaymentMethods = paymentResponse.getAvailablePaymentMethods();
Observable<List<PaymentMethod>> listObservable = ModuleAvailabilityUtil.filterPaymentMethods(context,
unfilteredPaymentMethods);
listObservable.subscribe(new Consumer<List<PaymentMethod>>() {
@Override
public void accept(List<PaymentMethod> filteredPaymentMethods) {
filteredPaymentMethods.removeAll(Collections.singleton(null));
PaymentStateHandler.this.availablePaymentMethods.clear();
PaymentStateHandler.this.availablePaymentMethods.addAll(filteredPaymentMethods);
paymentProcessorStateMachine.onTrigger(PaymentTrigger.PAYMENT_METHODS_AVAILABLE);
}
});
} else {
this.availablePaymentMethods = paymentResponse.getAvailablePaymentMethods();
paymentProcessorStateMachine.onTrigger(PaymentTrigger.PAYMENT_METHODS_AVAILABLE);
}
}
}

Expand Down Expand Up @@ -503,7 +509,7 @@ public void onSuccess(byte[] response) {

for (PaymentRequestDetailsListener detailsListener : paymentRequestDetailsListeners) {
detailsListener.onPaymentMethodSelectionRequired(paymentRequest, preferredPaymentMethods,
filteredPaymentMethodsList, paymentBroadcastReceivers.getPaymentMethodCallback());
availablePaymentMethods, paymentBroadcastReceivers.getPaymentMethodCallback());
}
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ static PaymentMethod createPaymentMethod(final JSONObject paymentMethodJSON, fin
configuration.merchantId = configurationJson.optString("merchantIdentifier");
configuration.merchantName = configurationJson.optString("merchantName");
configuration.publicKey = configurationJson.optString("publicKey").replaceAll("\\r\\n", "");
configuration.environment = configurationJson.optString("environment");
}

if (paymentMethod.inputDetails != null) {
Expand Down Expand Up @@ -313,6 +314,7 @@ public static final class Configuration implements Serializable {
private String publicKey;
private String cvcOptional;
private String noCVC;
private String environment; //For AndroidPay

private Configuration() { }

Expand All @@ -335,6 +337,10 @@ public String getCvcOptional() {
public String getNoCVC() {
return noCVC;
}

public String getEnvironment() {
return environment;
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,23 @@
import android.util.Log;
import android.widget.ImageView;

import com.adyen.core.internals.TLSSocketFactory;

import java.io.FileNotFoundException;
import java.io.InputStream;
import java.net.URL;
import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException;

import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLSocketFactory;

import io.reactivex.Observable;
import io.reactivex.ObservableEmitter;
import io.reactivex.ObservableOnSubscribe;
import io.reactivex.Observer;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.Disposable;
import io.reactivex.schedulers.Schedulers;
import io.reactivex.android.schedulers.AndroidSchedulers;

/**
* Utility class for downloading images and assigning them to ImageViews.
Expand All @@ -33,6 +40,16 @@ public final class AsyncImageDownloader {
@NonNull private static final LruCache<String, Bitmap> BITMAP_LRU_CACHE
= new LruCache<>(MAX_NUMBER_OF_IMAGES_TO_BE_CACHED);

private static final SSLSocketFactory SSL_SOCKET_FACTORY;

static {
try {
SSL_SOCKET_FACTORY = new TLSSocketFactory();
} catch (KeyManagementException | NoSuchAlgorithmException e) {
throw new RuntimeException(e);
}
}

public interface ImageListener {
void onImage(Bitmap bitmap, String url);
}
Expand Down Expand Up @@ -162,7 +179,7 @@ private static Bitmap retrieveImage(Context context, String url, Bitmap fallback

/**
* This method issues an http request to retrieve the image at the given url.
* If successfull, the image will be saved in the local cache (static variable) and
* If successful, the image will be saved in the local cache (static variable) and
* also in the sharedpreferences.
* @param context Application context
* @param url Url of the icon to be loaded
Expand All @@ -171,10 +188,14 @@ private static Bitmap retrieveImage(Context context, String url, Bitmap fallback
*/
private static Bitmap downloadImage(Context context, String url, Bitmap fallbackImage) {
Bitmap icon = null;
HttpsURLConnection urlConnection = null;
try {
Log.d(TAG, "Downloading image from: " + url);
InputStream in = new java.net.URL(url).openStream();
icon = BitmapFactory.decodeStream(in);
urlConnection = (HttpsURLConnection) new URL(url).openConnection();
urlConnection.setSSLSocketFactory(SSL_SOCKET_FACTORY);
urlConnection.connect();

icon = BitmapFactory.decodeStream(urlConnection.getInputStream());
BITMAP_LRU_CACHE.put(url, icon);
IconStorage.storeIcon(context, icon, url);
} catch (@NonNull final FileNotFoundException fileNotFoundException) {
Expand All @@ -190,6 +211,10 @@ private static Bitmap downloadImage(Context context, String url, Bitmap fallback
} catch (Exception e) {
Log.e("Error", e.getMessage());
e.printStackTrace();
} finally {
if (urlConnection != null) {
urlConnection.disconnect();
}
}
return icon;
}
Expand Down
Loading

0 comments on commit 083e292

Please sign in to comment.