Skip to content

Commit

Permalink
Merge pull request #561 from Adyen/develop
Browse files Browse the repository at this point in the history
Release 4.4.0
  • Loading branch information
ozgur00 authored Dec 20, 2021
2 parents 69f69aa + d4a7f9f commit 157cbfd
Show file tree
Hide file tree
Showing 253 changed files with 6,988 additions and 306 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/check_pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ name: Check PR
# Every PR should be checked for static analysis
on:
pull_request:
branches: [ develop ]
branches-ignore:
- 'master'
types: [ opened, synchronize, reopened ]

jobs:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,8 @@ class Adyen3DS2ComponentProvider : ActionComponentProvider<Adyen3DS2Component, A
override fun canHandleAction(action: Action): Boolean {
return supportedActionTypes.contains(action.type)
}

override fun providesDetails(): Boolean {
return true
}
}
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ If you are upgrading from 3.x.x to a current release, check out our [migration g
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:4.3.0"
implementation "com.adyen.checkout:drop-in:4.4.0"
```
For a Credit Card component you should add:
```groovy
implementation "com.adyen.checkout:card:4.3.0"
implementation "com.adyen.checkout:card:4.4.0"
```

### Client Key
Expand Down
23 changes: 5 additions & 18 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,11 @@
[//]: # ( # Deprecated)
[//]: # ( - Configurations public constructor are deprecated, please use each Configuration's builder to make a Configuration object)

## WARNING
Make sure you explicitly set your LIVE environment on release builds when initializing Drop-in; `DropInConfiguration` is now initialized with `Environment.TEST` by default instead of `Environment.EUROPE`.

## Deprecated
- `saveState` and `restoreState` methods in action components. We rely on `SavedStateHandle` in all components and providers so these methods can be safely removed now.
- `requiresConfiguration` method in action component providers. All components require configurations therefore this method will always return true.

## Added
- Card component shows a more specific error message when the user enters a card belonging to an unsupported brand.
- `DropInConfiguration.Builder.setSkipListWhenSinglePaymentMethod` to allow skipping payment methods screen when single payment method exists. This only applies to payment methods that require a component (user input). Redirect payment methods, SDK payment methods, and so on will not be skipped.
- Provide `fundingSource` when present in payment methods response.
- Support for installments in card component.
- `Environment.LIVE`, identical to the `Environment.EUROPE`.

## Changed
- Update 3DS2 SDK to version `2.2.5`.
- BACS Direct Debit Component.

## Fixed
- Use `ApplicationInfo.FLAG_DEBUGGABLE` instead of `BuildConfig.DEBUG` to figure out whether it's a debug or release build.
- `NoClassDefFoundError` crash with Card component, if 3DS2 is not included in the project.
- Handle Google Pay cancellation and failure callbacks on initialisation.
- Google Pay Environment being set incorrectly to `WalletConstants.ENVIRONMENT_PRODUCTION`.

## Deprecated
- `DropInServiceResult.Action(actionJSON: String)` is deprecated in favor of `DropInServiceResult.Action(action: com.adyen.checkout.components.model.payments.response.Action)`. Use `com.adyen.checkout.components.model.payments.response.Action.SERIALIZER` to serialize your JSON response string.
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,8 @@ class AwaitComponentProvider : ActionComponentProvider<AwaitComponent, AwaitConf
}

override fun requiresView(action: Action): Boolean = true

override fun providesDetails(): Boolean {
return true
}
}
60 changes: 60 additions & 0 deletions bacs/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/*
* Copyright (c) 2021 Adyen N.V.
*
* This file is open source and available under the MIT license. See the LICENSE file for more info.
*
* Created by ozgur on 1/11/2021.
*/

plugins {
id 'com.android.library'
id 'kotlin-android'
}

// Maven artifact
ext.mavenArtifactId = "bacs"
ext.mavenArtifactName = "Adyen BACS Direct Debit component"
ext.mavenArtifactDescription = "Adyen checkout BACS Direct Debit component client for Adyen's Checkout API."

apply from: "${rootDir}/config/gradle/sharedTasks.gradle"

android {
compileSdkVersion compile_sdk_version

defaultConfig {
minSdkVersion min_sdk_version
targetSdkVersion target_sdk_version
versionCode version_code
versionName version_name

testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
consumerProguardFiles "consumer-rules.pro"
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

kotlinOptions {
jvmTarget = JavaVersion.VERSION_1_8.toString()
}

buildFeatures {
viewBinding true
}
}

dependencies {
// Checkout
api project(':components-core')
api project(':ui-core')

// Dependencies
implementation "com.google.android.material:material:$material_version"

//Tests
testImplementation "junit:junit:$junit_version"
androidTestImplementation "androidx.test.ext:junit:$test_ext_version"
androidTestImplementation "androidx.test.espresso:espresso-core:$espresso_version"
}
Empty file added bacs/consumer-rules.pro
Empty file.
21 changes: 21 additions & 0 deletions bacs/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
11 changes: 11 additions & 0 deletions bacs/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (c) 2021 Adyen N.V.
~
~ This file is open source and available under the MIT license. See the LICENSE file for more info.
~
~ Created by ozgur on 1/11/2021.
-->

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.adyen.checkout.bacs" />
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
/*
* Copyright (c) 2021 Adyen N.V.
*
* This file is open source and available under the MIT license. See the LICENSE file for more info.
*
* Created by ozgur on 2/11/2021.
*/

package com.adyen.checkout.bacs

import androidx.lifecycle.SavedStateHandle
import com.adyen.checkout.components.PaymentComponentProvider
import com.adyen.checkout.components.base.BasePaymentComponent
import com.adyen.checkout.components.base.GenericPaymentComponentProvider
import com.adyen.checkout.components.base.GenericPaymentMethodDelegate
import com.adyen.checkout.components.model.payments.request.BacsDirectDebitPaymentMethod
import com.adyen.checkout.components.model.payments.request.PaymentComponentData
import com.adyen.checkout.components.util.PaymentMethodTypes

private val PAYMENT_METHOD_TYPES = arrayOf(PaymentMethodTypes.BACS)

class BacsDirectDebitComponent(
savedStateHandle: SavedStateHandle,
paymentMethodDelegate: GenericPaymentMethodDelegate,
configuration: BacsDirectDebitConfiguration
) :
BasePaymentComponent<BacsDirectDebitConfiguration, BacsDirectDebitInputData, BacsDirectDebitOutputData,
BacsDirectDebitComponentState>(savedStateHandle, paymentMethodDelegate, configuration) {

override fun getSupportedPaymentMethodTypes() = PAYMENT_METHOD_TYPES

override fun onInputDataChanged(inputData: BacsDirectDebitInputData): BacsDirectDebitOutputData {
return BacsDirectDebitOutputData(
holderNameState = BacsDirectDebitValidationUtils.validateHolderName(inputData.holderName),
bankAccountNumberState = BacsDirectDebitValidationUtils.validateBankAccountNumber(inputData.bankAccountNumber),
sortCodeState = BacsDirectDebitValidationUtils.validateSortCode(inputData.sortCode),
shopperEmailState = BacsDirectDebitValidationUtils.validateShopperEmail(inputData.shopperEmail),
isAmountConsentChecked = inputData.isAmountConsentChecked,
isAccountConsentChecked = inputData.isAccountConsentChecked
)
}

override fun createComponentState(): BacsDirectDebitComponentState {
val paymentComponentData = PaymentComponentData<BacsDirectDebitPaymentMethod>()
val bacsDirectDebitPaymentMethod = BacsDirectDebitPaymentMethod().apply {
type = BacsDirectDebitPaymentMethod.PAYMENT_METHOD_TYPE
holderName = outputData?.holderNameState?.value
bankAccountNumber = outputData?.bankAccountNumberState?.value
bankLocationId = outputData?.sortCodeState?.value
}

paymentComponentData.apply {
shopperEmail = outputData?.shopperEmailState?.value
paymentMethod = bacsDirectDebitPaymentMethod
}

return BacsDirectDebitComponentState(
paymentComponentData = paymentComponentData,
isInputValid = outputData?.isValid ?: false,
isReady = true,
mode = mLatestInputData?.mode ?: BacsDirectDebitMode.INPUT
)
}

fun setInputMode() {
mLatestInputData?.mode = BacsDirectDebitMode.INPUT
notifyStateChanged()
}

fun setConfirmationMode() {
mLatestInputData?.mode = BacsDirectDebitMode.CONFIRMATION
notifyStateChanged()
}

companion object {
@JvmStatic
val PROVIDER: PaymentComponentProvider<BacsDirectDebitComponent, BacsDirectDebitConfiguration> =
GenericPaymentComponentProvider(BacsDirectDebitComponent::class.java)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* Copyright (c) 2021 Adyen N.V.
*
* This file is open source and available under the MIT license. See the LICENSE file for more info.
*
* Created by ozgur on 19/11/2021.
*/

package com.adyen.checkout.bacs

import com.adyen.checkout.components.PaymentComponentState
import com.adyen.checkout.components.model.payments.request.BacsDirectDebitPaymentMethod
import com.adyen.checkout.components.model.payments.request.PaymentComponentData

class BacsDirectDebitComponentState(
paymentComponentData: PaymentComponentData<BacsDirectDebitPaymentMethod>,
isInputValid: Boolean,
isReady: Boolean,
val mode: BacsDirectDebitMode = BacsDirectDebitMode.INPUT
) : PaymentComponentState<BacsDirectDebitPaymentMethod>(paymentComponentData, isInputValid, isReady) {
override fun isValid(): Boolean {
return super.isValid() && mode == BacsDirectDebitMode.CONFIRMATION
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
/*
* Copyright (c) 2021 Adyen N.V.
*
* This file is open source and available under the MIT license. See the LICENSE file for more info.
*
* Created by ozgur on 2/11/2021.
*/

package com.adyen.checkout.bacs

import android.content.Context
import android.os.Parcel
import android.os.Parcelable
import com.adyen.checkout.components.base.BaseConfigurationBuilder
import com.adyen.checkout.components.base.Configuration
import com.adyen.checkout.components.model.payments.Amount
import com.adyen.checkout.components.util.CheckoutCurrency
import com.adyen.checkout.core.api.Environment
import com.adyen.checkout.core.exception.CheckoutException
import com.adyen.checkout.core.model.JsonUtils
import java.util.*

class BacsDirectDebitConfiguration : Configuration {

val amount: Amount

companion object {
@JvmField
val CREATOR: Parcelable.Creator<BacsDirectDebitConfiguration?> = object : Parcelable.Creator<BacsDirectDebitConfiguration?> {
override fun createFromParcel(source: Parcel?): BacsDirectDebitConfiguration? {
if (source == null) return null
return BacsDirectDebitConfiguration(source)
}

override fun newArray(size: Int): Array<BacsDirectDebitConfiguration?> {
return arrayOfNulls(size)
}
}
}

internal constructor(builder: Builder) : super(builder.builderShopperLocale, builder.builderEnvironment, builder.builderClientKey) {
this.amount = builder.amount
}

internal constructor(parcel: Parcel) : super(parcel) {
amount = Amount.CREATOR.createFromParcel(parcel)
}

override fun writeToParcel(parcel: Parcel, flags: Int) {
super.writeToParcel(parcel, flags)
JsonUtils.writeToParcel(parcel, Amount.SERIALIZER.serialize(amount))
}

class Builder : BaseConfigurationBuilder<BacsDirectDebitConfiguration> {

internal var amount: Amount = Amount.EMPTY
private set

constructor(context: Context, clientKey: String) : super(context, clientKey)

/**
* Builder with required parameters.
*
* @param shopperLocale The Locale of the shopper.
* @param environment The [Environment] to be used for network calls to Adyen.
* @param clientKey Your Client Key used for network calls from the SDK to Adyen.
*/
constructor(shopperLocale: Locale, environment: Environment, clientKey: String) : super(shopperLocale, environment, clientKey)

override fun setShopperLocale(builderShopperLocale: Locale): Builder {
return super.setShopperLocale(builderShopperLocale) as Builder
}

override fun setEnvironment(builderEnvironment: Environment): Builder {
return super.setEnvironment(builderEnvironment) as Builder
}

override fun buildInternal(): BacsDirectDebitConfiguration {
return BacsDirectDebitConfiguration(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
}
}
}
Loading

0 comments on commit 157cbfd

Please sign in to comment.