Skip to content

Commit

Permalink
2.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
adyen-git-manager committed Nov 21, 2018
1 parent e45b127 commit c367280
Show file tree
Hide file tree
Showing 44 changed files with 708 additions and 1,033 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.1.0"
final checkoutVersion = "2.2.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.1.0"
final checkoutVersion = "2.2.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
8 changes: 4 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ ext {
supportLibVersion = "27.1.1"
roomVersion = "1.1.1"
lifecycleVersion = "1.1.1"
playServicesWalletVersion = "15.0.1"
playServicesWalletVersion = "16.0.1"
weChatPayVersion = "5.1.6"
adyenCseVersion = "1.0.5"

Expand All @@ -20,16 +20,16 @@ ext {
"android.arch.persistence.room:runtime:85cb19d9aaa725308470cbb71b3b1a91:MD5",
"android.arch.persistence.room:compiler:c208e3e84a2ab539ad4a0c4dc7b8aee0:MD5",
"com.adyen.cse:adyen-cse:71b934caa76326fdbfaade8a0916737048b5306c3a86faffedc15bf16dfdabc4:SHA-256",
"com.google.android.gms:play-services-wallet:8a1887a18e5dfec1d0c5216327a8651f:MD5",
"com.google.android.gms:play-services-wallet:0b1f46bd3fe205286d44aa8e5aeab5e2:MD5",
"com.android.support:appcompat-v7:5272248a8e29af3b29c195e28a3ad780:MD5",
"com.android.support:recyclerview-v7:619f39f296cbecda5c3ffdd861d78f60:MD5",
"com.android.support:customtabs:5a282babea31b0081fd45887c76b4976:MD5",
"com.android.support:design:481deb2f8b4451e322d52ecdb9224cf4:MD5",
"com.tencent.mm.opensdk:wechat-sdk-android-without-mta:9a15154c07c05eadba8351c110647c1754316e32d8f12f55e24679891b52739c:SHA-256",
]

versionCode = 204
versionName = "2.1.0"
versionCode = 205
versionName = "2.2.0"

testCoverageEnabled = true
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@
* This file is open source and available under the MIT license. See the LICENSE file for more info.
* <p>
* Created by timon on 09/07/2018.
* <p>
* @deprecated Android Pay has been deprecated in favor of Google Pay.
*/
@Deprecated
public final class AndroidPayConfigurationImpl extends JsonObject implements AndroidPayConfiguration {
public static final Parcelable.Creator<AndroidPayConfigurationImpl> CREATOR = new DefaultCreator<>(AndroidPayConfigurationImpl.class);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@
* This file is open source and available under the MIT license. See the LICENSE file for more info.
* <p>
* Created by timon on 04/07/2018.
* <p>
* @deprecated Android Pay has been deprecated in favor of Google Pay.
*/
@Deprecated
@ProvidedBy(AndroidPayConfigurationImpl.class)
public interface AndroidPayConfiguration extends Configuration {
/**
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
ext.releaseArtifactId = "googlewallet"
ext.releaseArtifactId = "googlepay"

apply plugin: "com.android.library"
apply from: "$rootProject.rootDir/checkDependencies.gradle"
apply from: "$rootProject.rootDir/quality.gradle"
//apply from: "$rootProject.rootDir/release.gradle"
apply from: "$rootProject.rootDir/release.gradle"

android {
compileSdkVersion rootProject.compileSdkVersion
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.adyen.checkout.googlewallet">
package="com.adyen.checkout.googlepay">

<application>

<activity
android:theme="@android:style/Theme.Translucent.NoTitleBar"
android:name=".internal.GoogleWalletDetailsActivity" />
android:name=".internal.GooglePayDetailsActivity" />

<meta-data
android:name="com.google.android.gms.wallet.api.enabled"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.adyen.checkout.googlewallet;
package com.adyen.checkout.googlepay;

import android.app.Activity;
import android.app.Application;
Expand All @@ -8,13 +8,11 @@
import com.adyen.checkout.core.CheckoutException;
import com.adyen.checkout.core.PaymentMethodHandler;
import com.adyen.checkout.core.PaymentReference;
import com.adyen.checkout.core.model.AndroidPayConfiguration;
import com.adyen.checkout.core.model.GooglePayConfiguration;
import com.adyen.checkout.core.model.PaymentMethod;
import com.adyen.checkout.core.model.PaymentSession;
import com.adyen.checkout.googlewallet.internal.AndroidPayUtil;
import com.adyen.checkout.googlewallet.internal.GooglePayUtil;
import com.adyen.checkout.googlewallet.internal.GoogleWalletDetailsActivity;
import com.adyen.checkout.googlepay.internal.GooglePayDetailsActivity;
import com.adyen.checkout.googlepay.internal.IsReadyToPayCallable;
import com.adyen.checkout.util.PaymentMethodTypes;

import java.util.concurrent.Callable;
Expand All @@ -26,14 +24,13 @@
* <p>
* Created by timon on 11/06/2018.
*/
public final class GoogleWalletHandler implements PaymentMethodHandler {
public final class GooglePayHandler implements PaymentMethodHandler {
public static final Factory FACTORY = new Factory() {
@Override
public boolean supports(@NonNull Application application, @NonNull PaymentMethod paymentMethod) {
String paymentMethodType = paymentMethod.getType();

return PaymentMethodTypes.ANDROID_PAY.equals(paymentMethodType)
|| PaymentMethodTypes.GOOGLE_PAY.equals(paymentMethodType);
return PaymentMethodTypes.GOOGLE_PAY.equals(paymentMethodType);
}

@Override
Expand All @@ -43,22 +40,12 @@ public boolean isAvailableToShopper(
@NonNull PaymentMethod paymentMethod
) {
try {
String paymentMethodType = paymentMethod.getType();
paymentMethod.getConfiguration(GooglePayConfiguration.class);

if (PaymentMethodTypes.ANDROID_PAY.equals(paymentMethodType)) {
paymentMethod.getConfiguration(AndroidPayConfiguration.class);

return true;
} else if (PaymentMethodTypes.GOOGLE_PAY.equals(paymentMethodType)) {
paymentMethod.getConfiguration(GooglePayConfiguration.class);

return true;
}
return true;
} catch (CheckoutException e) {
// Invalid configuration.
return false;
}

return false;
}
};

Expand All @@ -69,37 +56,33 @@ public boolean isAvailableToShopper(
private final PaymentMethod mPaymentMethod;

/**
* Returns a {@link Callable} that can be executed on a background thread to determine whether the shopper has setup the given payment method
* and is ready to pay.
* Returns a {@link Callable} that can be executed on a background thread to determine whether the shopper has setup Google Pay and is ready to
* pay.
*
* @param application The {@link Application}.
* @param paymentSession The {@link PaymentSession}.
* @param paymentMethod The Google Wallet {@link PaymentMethod}.
* @return A {@link Callable} to be executed on a background thread to determine whether the shopper has setup the given payment method and is
* ready to pay.
* @param paymentMethod The Google Pay {@link PaymentMethod}.
* @return A {@link Callable} that can be executed on a background thread to determine whether the shopper has setup Google Pay and is ready to
* pay.
*/
@NonNull
public static Callable<Boolean> getReadyToPayCallable(
@NonNull Application application,
@NonNull PaymentSession paymentSession,
@NonNull PaymentMethod paymentMethod
) {
if (PaymentMethodTypes.ANDROID_PAY.equals(paymentMethod.getType())) {
return AndroidPayUtil.isReadyToPay(application, paymentSession, paymentMethod);
} else {
return GooglePayUtil.isReadyToPay(application, paymentSession, paymentMethod);
}
return new IsReadyToPayCallable(application, paymentSession, paymentMethod);
}

public GoogleWalletHandler(@NonNull PaymentReference paymentReference, @NonNull PaymentMethod paymentMethod) {
public GooglePayHandler(@NonNull PaymentReference paymentReference, @NonNull PaymentMethod paymentMethod) {
mPaymentReference = paymentReference;
mPaymentMethod = paymentMethod;
}

@Override
public void handlePaymentMethodDetails(@NonNull Activity activity, int requestCode) {
activity.finishActivity(requestCode);
Intent intent = GoogleWalletDetailsActivity.newIntent(activity, mPaymentReference, mPaymentMethod);
Intent intent = GooglePayDetailsActivity.newIntent(activity, mPaymentReference, mPaymentMethod);
activity.startActivityForResult(intent, requestCode);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
package com.adyen.checkout.googlepay.internal;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;

import com.adyen.checkout.core.CheckoutException;
import com.adyen.checkout.core.Observable;
import com.adyen.checkout.core.Observer;
import com.adyen.checkout.core.PaymentHandler;
import com.adyen.checkout.core.PaymentReference;
import com.adyen.checkout.core.PaymentResult;
import com.adyen.checkout.core.handler.ErrorHandler;
import com.adyen.checkout.core.model.GooglePayConfiguration;
import com.adyen.checkout.core.model.GooglePayDetails;
import com.adyen.checkout.core.model.PaymentMethod;
import com.adyen.checkout.core.model.PaymentSession;
import com.adyen.checkout.googlepay.GooglePayHandler;
import com.google.android.gms.common.api.Status;
import com.google.android.gms.tasks.Task;
import com.google.android.gms.wallet.AutoResolveHelper;
import com.google.android.gms.wallet.PaymentData;
import com.google.android.gms.wallet.WalletConstants;

import org.json.JSONException;

/**
* Copyright (c) 2018 Adyen B.V.
* <p>
* This file is open source and available under the MIT license. See the LICENSE file for more info.
* <p>
* Created by timon on 07/06/2018.
*/
public class GooglePayDetailsActivity extends Activity {
private static final String EXTRA_PAYMENT_REFERENCE = "EXTRA_PAYMENT_REFERENCE";

private static final String EXTRA_PAYMENT_METHOD = "EXTRA_PAYMENT_METHOD";

private static final int REQUEST_CODE_GOOGLE_PAY = 1;

private PaymentMethod mPaymentMethod;

private PaymentHandler mPaymentHandler;

@NonNull
public static Intent newIntent(@NonNull Context context, @NonNull PaymentReference paymentReference, @NonNull PaymentMethod paymentMethod) {
Intent intent = new Intent(context, GooglePayDetailsActivity.class);
intent.putExtra(EXTRA_PAYMENT_REFERENCE, paymentReference);
intent.putExtra(EXTRA_PAYMENT_METHOD, paymentMethod);

return intent;
}

@Override
protected void onCreate(@Nullable final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

Intent intent = getIntent();

PaymentReference paymentReference = intent.getParcelableExtra(EXTRA_PAYMENT_REFERENCE);
mPaymentMethod = intent.getParcelableExtra(EXTRA_PAYMENT_METHOD);
mPaymentHandler = paymentReference.getPaymentHandler(this);

final GooglePayConfiguration configuration;
try {
configuration = mPaymentMethod.getConfiguration(GooglePayConfiguration.class);
} catch (CheckoutException e) {
throw new RuntimeException("Invalid Google Pay configuration.");
}

if (savedInstanceState == null) {
final Observable<PaymentSession> paymentSessionObservable = mPaymentHandler.getPaymentSessionObservable();
paymentSessionObservable.observe(this, new Observer<PaymentSession>() {
@Override
public void onChanged(@NonNull PaymentSession paymentSession) {
Task<PaymentData> paymentDataTask = GooglePayUtil
.getPaymentDataTask(GooglePayDetailsActivity.this, paymentSession, configuration);
AutoResolveHelper.resolveTask(paymentDataTask, GooglePayDetailsActivity.this, REQUEST_CODE_GOOGLE_PAY);
paymentSessionObservable.removeObserver(this);
}
});
}
mPaymentHandler.setErrorHandler(this, new ErrorHandler() {
@Override
public void onError(@NonNull CheckoutException error) {
Intent resultData = new Intent();
resultData.putExtra(GooglePayHandler.RESULT_CHECKOUT_EXCEPTION, error);
setResult(GooglePayHandler.RESULT_CODE_ERROR, resultData);
finish();
}
});
mPaymentHandler.getPaymentResultObservable().observe(this, new Observer<PaymentResult>() {
@Override
public void onChanged(@NonNull PaymentResult paymentResult) {
Intent resultData = new Intent();
resultData.putExtra(GooglePayHandler.RESULT_PAYMENT_RESULT, paymentResult);
setResult(GooglePayHandler.RESULT_CODE_OK, resultData);
finish();
}
});
}

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);

if (requestCode == REQUEST_CODE_GOOGLE_PAY) {
if (resultCode == Activity.RESULT_OK) {
try {
String token = GooglePayUtil.getPaymentToken(data);
GooglePayDetails googlePayDetails = new GooglePayDetails.Builder(token).build();
mPaymentHandler.initiatePayment(mPaymentMethod, googlePayDetails);
} catch (JSONException e) {
CheckoutException checkoutException = new CheckoutException.Builder("Could not retrieve token from PaymentData.", e).build();
Intent resultData = new Intent();
resultData.putExtra(GooglePayHandler.RESULT_CHECKOUT_EXCEPTION, checkoutException);
setResult(GooglePayHandler.RESULT_CODE_ERROR, resultData);
finish();
}
} else {
Status status = AutoResolveHelper.getStatusFromIntent(data);
int errorCode = status != null ? status.getStatusCode() : WalletConstants.ERROR_CODE_UNKNOWN;

int result = resultCode == RESULT_CANCELED
? GooglePayHandler.RESULT_CODE_CANCELED
: GooglePayHandler.RESULT_CODE_ERROR;

Intent resultData = new Intent();
resultData.putExtra(GooglePayHandler.RESULT_ERROR_CODE, errorCode);
setResult(result, resultData);
finish();
}
}
}
}
Loading

0 comments on commit c367280

Please sign in to comment.