-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #561 from Adyen/develop
Release 4.4.0
- Loading branch information
Showing
253 changed files
with
6,988 additions
and
306 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" /> |
80 changes: 80 additions & 0 deletions
80
bacs/src/main/java/com/adyen/checkout/bacs/BacsDirectDebitComponent.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
bacs/src/main/java/com/adyen/checkout/bacs/BacsDirectDebitComponentState.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
} |
90 changes: 90 additions & 0 deletions
90
bacs/src/main/java/com/adyen/checkout/bacs/BacsDirectDebitConfiguration.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
} | ||
} |
Oops, something went wrong.