Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hide pin #546

Merged
merged 6 commits into from
Nov 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import com.adyen.checkout.components.core.StoredPaymentMethod
import com.adyen.checkout.core.exception.CancellationException
import com.adyen.checkout.core.exception.CheckoutException
import com.adyen.checkout.dropin.dropIn
import com.adyen.checkout.giftcard.giftCard
import com.adyen.checkout.googlepay.GooglePayComponentState
import com.adyen.checkout.googlepay.googlePay
import com.adyen.checkout.sessions.core.CheckoutSession
Expand All @@ -38,6 +39,7 @@ import com.adyenreactnativesdk.configuration.AnalyticsParser
import com.adyenreactnativesdk.configuration.CardConfigurationParser
import com.adyenreactnativesdk.configuration.DropInConfigurationParser
import com.adyenreactnativesdk.configuration.GooglePayConfigurationParser
import com.adyenreactnativesdk.configuration.PartialPaymentParser
import com.adyenreactnativesdk.configuration.RootConfigurationParser
import com.adyenreactnativesdk.configuration.ThreeDSConfigurationParser
import com.adyenreactnativesdk.util.AdyenConstants
Expand Down Expand Up @@ -234,6 +236,10 @@ abstract class BaseModule(context: ReactApplicationContext?) : ReactContextBaseJ
val parser = ThreeDSConfigurationParser(json)
parser.applyConfiguration(this)
}
giftCard {
val parser = PartialPaymentParser(json)
setPinRequired(parser.pinRequired)
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,30 +9,26 @@ import com.facebook.react.bridge.ReadableMap
class AnalyticsParser(config: ReadableMap) {

companion object {
const val ANALYTICS_KEY = "analytics"
const val ANALYTICS_ENABLED_KEY = "enabled"
const val ANALYTICS_VERBOSE_LOGS = "verboseLogs"
const val ROOT_KEY = "analytics"
const val ENABLED_KEY = "enabled"
const val VERBOSE_LOGS_KEY = "verboseLogs"
}

private var config: ReadableMap

init {
if (config.hasKey(ANALYTICS_KEY)) {
this.config = config.getMap(ANALYTICS_KEY)!!
if (config.hasKey(ROOT_KEY)) {
this.config = config.getMap(ROOT_KEY)!!
} else {
this.config = config
}
}

private val analyticsEnabled: Boolean
get() = config.hasKey(ANALYTICS_ENABLED_KEY) && config.getBoolean(
ANALYTICS_ENABLED_KEY
)
get() = if (config.hasKey(ENABLED_KEY)) config.getBoolean(ENABLED_KEY) else true

internal val verboseLogs: Boolean
get() = config.hasKey(ANALYTICS_VERBOSE_LOGS) && config.getBoolean(
ANALYTICS_VERBOSE_LOGS
)
get() = config.hasKey(VERBOSE_LOGS_KEY) && config.getBoolean(VERBOSE_LOGS_KEY)

val analytics: AnalyticsConfiguration
get() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class CardConfigurationParser(config: ReadableMap, private val countryCode: Stri

companion object {
const val TAG = "CardConfigurationParser"
const val CARD_KEY = "card"
const val ROOT_KEY = "card"
const val SHOW_STORE_PAYMENT_FIELD_KEY = "showStorePaymentField"
const val HOLDER_NAME_REQUIRED_KEY = "holderNameRequired"
const val HIDE_CVC_STORED_CARD_KEY = "hideCvcStoredCard"
Expand All @@ -36,8 +36,8 @@ class CardConfigurationParser(config: ReadableMap, private val countryCode: Stri
private var config: ReadableMap

init {
if (config.hasKey(CARD_KEY)) {
this.config = config.getMap(CARD_KEY)!!
if (config.hasKey(ROOT_KEY)) {
this.config = config.getMap(ROOT_KEY)!!
} else {
this.config = config
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class DropInConfigurationParser(config: ReadableMap) {

companion object {
const val TAG = "DropInConfigurationParser"
const val DROPIN_KEY = "dropin"
const val ROOT_KEY = "dropin"
const val SHOW_PRESELECTED_STORED_PAYMENT_METHOD_KEY = "showPreselectedStoredPaymentMethod"
const val SKIP_LIST_WHEN_SINGLE_PAYMENT_METHOD_KEY = "skipListWhenSinglePaymentMethod"
const val SHOW_REMOVE_PAYMENT_METHOD_BUTTON_KEY = "showRemovePaymentMethodButton"
Expand All @@ -22,8 +22,8 @@ class DropInConfigurationParser(config: ReadableMap) {
private var config: ReadableMap

init {
if (config.hasKey(DROPIN_KEY)) {
this.config = config.getMap(DROPIN_KEY)!!
if (config.hasKey(ROOT_KEY)) {
this.config = config.getMap(ROOT_KEY)!!
} else {
this.config = config
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class GooglePayConfigurationParser(config: ReadableMap) {

companion object {
internal const val TAG = "GooglePayConfigParser"
internal const val GOOGLEPAY_KEY = "googlepay"
internal const val ROOT_KEY = "googlepay"
internal const val MERCHANT_ACCOUNT_KEY = "merchantAccount"
internal const val ALLOWED_CARD_NETWORKS_KEY = "allowedCardNetworks"
internal const val ALLOWED_AUTH_METHODS_KEY = "allowedAuthMethods"
Expand All @@ -36,8 +36,8 @@ class GooglePayConfigurationParser(config: ReadableMap) {
private var config: ReadableMap

init {
if (config.hasKey(GOOGLEPAY_KEY)) {
this.config = config.getMap(GOOGLEPAY_KEY)!!
if (config.hasKey(ROOT_KEY)) {
this.config = config.getMap(ROOT_KEY)!!
} else {
this.config = config
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.adyenreactnativesdk.configuration

import com.facebook.react.bridge.ReadableMap

class PartialPaymentParser(config: ReadableMap) {

companion object {
const val ROOT_KEY = "partialPayment"
const val PIN_REQUIRED_KEY = "pinRequired"
}

private var config: ReadableMap

init {
if (config.hasKey(ROOT_KEY)) {
this.config = config.getMap(ROOT_KEY)!!
} else {
this.config = config
}
}

val pinRequired: Boolean
get() = if (config.hasKey(PIN_REQUIRED_KEY))
config.getBoolean(PIN_REQUIRED_KEY)
else true
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,21 @@ import com.facebook.react.bridge.ReadableMap
class ThreeDSConfigurationParser(config: ReadableMap) {
companion object {
const val TAG = "ThreeDSConfigurationParser"
const val THREEDS2_KEY = "threeDS2"
const val THREEDS2_REQUESTOR_APP_URL_KEY = "requestorAppUrl"
const val ROOT_KEY = "threeDS2"
const val REQUESTOR_APP_URL_KEY = "requestorAppUrl"
}

private var config: ReadableMap

init {
if (config.hasKey(THREEDS2_KEY)) {
this.config = config.getMap(THREEDS2_KEY)!!
if (config.hasKey(ROOT_KEY)) {
this.config = config.getMap(ROOT_KEY)!!
} else this.config = config
}

private val requestorAppUrl: String?
get() = if (config.hasKey(THREEDS2_REQUESTOR_APP_URL_KEY)) {
config.getString(THREEDS2_REQUESTOR_APP_URL_KEY)
get() = if (config.hasKey(REQUESTOR_APP_URL_KEY)) {
config.getString(REQUESTOR_APP_URL_KEY)
} else null

fun applyConfiguration(builder: Adyen3DS2Configuration.Builder) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,22 @@ class AnalyticsParserTest {
// GIVEN
val config = WritableMapMock()
val analyticsConfig = WritableMapMock()
config.putMap(AnalyticsParser.ANALYTICS_KEY, analyticsConfig)
config.putMap(AnalyticsParser.ROOT_KEY, analyticsConfig)

// WHEN
val analyticsParser = AnalyticsParser(config)

// THEN
Assert.assertSame(analyticsParser.analytics.level, AnalyticsLevel.NONE)
Assert.assertSame(analyticsParser.analytics.level, AnalyticsLevel.ALL)
Assert.assertFalse(analyticsParser.verboseLogs)
}

@Test
fun testIsEnabled() {
// GIVEN
val config = WritableMapMock()
config.putBoolean(AnalyticsParser.ANALYTICS_ENABLED_KEY, true)
config.putBoolean(AnalyticsParser.ANALYTICS_VERBOSE_LOGS, false)
config.putBoolean(AnalyticsParser.ENABLED_KEY, true)
config.putBoolean(AnalyticsParser.VERBOSE_LOGS_KEY, false)


// WHEN
Expand All @@ -41,8 +41,8 @@ class AnalyticsParserTest {
fun testIsNotEnabled() {
// GIVEN
val config = WritableMapMock()
config.putBoolean(AnalyticsParser.ANALYTICS_ENABLED_KEY, false)
config.putBoolean(AnalyticsParser.ANALYTICS_VERBOSE_LOGS, true)
config.putBoolean(AnalyticsParser.ENABLED_KEY, false)
config.putBoolean(AnalyticsParser.VERBOSE_LOGS_KEY, true)

// WHEN
val analyticsParser = AnalyticsParser(config)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class CardConfigurationParserTest {
// GIVEN
val config = WritableMapMock()
val cardConfig = WritableMapMock()
config.putMap(CardConfigurationParser.CARD_KEY, cardConfig)
config.putMap(CardConfigurationParser.ROOT_KEY, cardConfig)

// WHEN
val sut = CardConfigurationParser(config, countryCode = null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class DropInConfigurationParserTest {
val mockBuilder = mock(DropInConfiguration.Builder::class.java)
val config = WritableMapMock()
val dropinConfig = WritableMapMock()
config.putMap(DropInConfigurationParser.DROPIN_KEY, dropinConfig)
config.putMap(DropInConfigurationParser.ROOT_KEY, dropinConfig)

// WHEN
val sut = DropInConfigurationParser(config)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class GooglePayConfigurationParserTest {
val config = WritableMapMock()
val googleConfig = WritableMapMock()

config.putMap(GooglePayConfigurationParser.GOOGLEPAY_KEY, googleConfig)
config.putMap(GooglePayConfigurationParser.ROOT_KEY, googleConfig)

// WHEN
val sut = GooglePayConfigurationParser(config)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package com.adyenreactnativesdk.configuration

import org.junit.Assert.assertEquals
import org.junit.Test

class PartialPaymentParserTest {

@Test
fun testConfigurationOnEmptySubDictionary() {
// GIVEN
val config = WritableMapMock()
val partialPaymentConfiguration = WritableMapMock()
config.putMap(PartialPaymentParser.ROOT_KEY, partialPaymentConfiguration)

// WHEN
val sut = PartialPaymentParser(config)

// THEN
assertEquals(sut.pinRequired, true)
}

@Test
fun testConfigurationNegativeValue() {
// GIVEN
val config = WritableMapMock()
val partialPaymentConfiguration = WritableMapMock()
partialPaymentConfiguration.putBoolean(PartialPaymentParser.PIN_REQUIRED_KEY, false)
config.putMap(PartialPaymentParser.ROOT_KEY, partialPaymentConfiguration)

// WHEN
val sut = PartialPaymentParser(config)

// THEN
assertEquals(sut.pinRequired, false)
}

@Test
fun testConfigurationPositiveValue() {
// GIVEN
val config = WritableMapMock()
val partialPaymentConfiguration = WritableMapMock()
partialPaymentConfiguration.putBoolean(PartialPaymentParser.PIN_REQUIRED_KEY, true)
config.putMap(PartialPaymentParser.ROOT_KEY, partialPaymentConfiguration)

// WHEN
val sut = PartialPaymentParser(config)

// THEN
assertEquals(sut.pinRequired, true)
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class ThreeDSConfigurationParserTest {
val mockBuilder = mock(Adyen3DS2Configuration.Builder::class.java)
val config = WritableMapMock()
val threedsConfig = WritableMapMock()
config.putMap(ThreeDSConfigurationParser.THREEDS2_KEY, threedsConfig)
config.putMap(ThreeDSConfigurationParser.ROOT_KEY, threedsConfig)

// WHEN
val sut = ThreeDSConfigurationParser(config)
Expand All @@ -31,7 +31,7 @@ class ThreeDSConfigurationParserTest {
val mockBuilder = mock(Adyen3DS2Configuration.Builder::class.java)
val config = WritableMapMock()
config.putString(
ThreeDSConfigurationParser.THREEDS2_REQUESTOR_APP_URL_KEY,
ThreeDSConfigurationParser.REQUESTOR_APP_URL_KEY,
"https://testing.com"
)

Expand Down
22 changes: 14 additions & 8 deletions example/ios/AdyenExample.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
948B9B022A83D269003D15B4 /* DropInTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 948B9B012A83D269003D15B4 /* DropInTest.swift */; };
94FC2FEC2AF28DAE009F6FC1 /* CardConfigurationTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 94FC2FEB2AF28DAE009F6FC1 /* CardConfigurationTests.swift */; };
E773B1092BE3B48900638431 /* DropInConfigurationParserTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = E773B1082BE3B48900638431 /* DropInConfigurationParserTests.swift */; };
E77D207A2CDBB31900FED3F0 /* AnalyticsParserTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = E77D20772CDBB31900FED3F0 /* AnalyticsParserTests.swift */; };
E77D207B2CDBB31900FED3F0 /* RooConfigurationtParserTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = E77D20792CDBB31900FED3F0 /* RooConfigurationtParserTests.swift */; };
E77D207C2CDBB31900FED3F0 /* PartialPaymentConfigurationParserTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = E77D20782CDBB31900FED3F0 /* PartialPaymentConfigurationParserTests.swift */; };
E788D7AD2C77515800FE9BC6 /* ApplePayRecurringConfigurationParserTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = E788D7AC2C77515800FE9BC6 /* ApplePayRecurringConfigurationParserTests.swift */; };
E79C3AD02BE161F100FACBCA /* ThreeDSConfigurationParserTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = E79C3ACF2BE161F100FACBCA /* ThreeDSConfigurationParserTests.swift */; };
F5C555F429F6C9F5008E7AA8 /* AdyenAppearance.swift in Sources */ = {isa = PBXBuildFile; fileRef = F5C555F329F6C9F5008E7AA8 /* AdyenAppearance.swift */; };
Expand Down Expand Up @@ -57,6 +60,9 @@
CF789D357E922939DFD4AED9 /* PrivacyInfo.xcprivacy */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xml; name = PrivacyInfo.xcprivacy; path = AdyenExample/PrivacyInfo.xcprivacy; sourceTree = "<group>"; };
E757C9D727737E6700B62256 /* AdyenExample.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; name = AdyenExample.entitlements; path = AdyenExample/AdyenExample.entitlements; sourceTree = "<group>"; };
E773B1082BE3B48900638431 /* DropInConfigurationParserTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DropInConfigurationParserTests.swift; sourceTree = "<group>"; };
E77D20772CDBB31900FED3F0 /* AnalyticsParserTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AnalyticsParserTests.swift; sourceTree = "<group>"; };
E77D20782CDBB31900FED3F0 /* PartialPaymentConfigurationParserTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PartialPaymentConfigurationParserTests.swift; sourceTree = "<group>"; };
E77D20792CDBB31900FED3F0 /* RooConfigurationtParserTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RooConfigurationtParserTests.swift; sourceTree = "<group>"; };
E788D7AC2C77515800FE9BC6 /* ApplePayRecurringConfigurationParserTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ApplePayRecurringConfigurationParserTests.swift; sourceTree = "<group>"; };
E79C3ACF2BE161F100FACBCA /* ThreeDSConfigurationParserTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ThreeDSConfigurationParserTests.swift; sourceTree = "<group>"; };
ED297162215061F000B7C4FE /* JavaScriptCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = JavaScriptCore.framework; path = System/Library/Frameworks/JavaScriptCore.framework; sourceTree = SDKROOT; };
Expand Down Expand Up @@ -174,6 +180,9 @@
E773B10A2BE3B5B000638431 /* Parsers */ = {
isa = PBXGroup;
children = (
E77D20772CDBB31900FED3F0 /* AnalyticsParserTests.swift */,
E77D20782CDBB31900FED3F0 /* PartialPaymentConfigurationParserTests.swift */,
E77D20792CDBB31900FED3F0 /* RooConfigurationtParserTests.swift */,
E788D7AC2C77515800FE9BC6 /* ApplePayRecurringConfigurationParserTests.swift */,
945936B02AE185B700F3E676 /* ApplePayConfigurationTests.swift */,
E79C3ACF2BE161F100FACBCA /* ThreeDSConfigurationParserTests.swift */,
Expand Down Expand Up @@ -422,6 +431,9 @@
buildActionMask = 2147483647;
files = (
94FC2FEC2AF28DAE009F6FC1 /* CardConfigurationTests.swift in Sources */,
E77D207A2CDBB31900FED3F0 /* AnalyticsParserTests.swift in Sources */,
E77D207B2CDBB31900FED3F0 /* RooConfigurationtParserTests.swift in Sources */,
E77D207C2CDBB31900FED3F0 /* PartialPaymentConfigurationParserTests.swift in Sources */,
E788D7AD2C77515800FE9BC6 /* ApplePayRecurringConfigurationParserTests.swift in Sources */,
945936B12AE185B700F3E676 /* ApplePayConfigurationTests.swift in Sources */,
E773B1092BE3B48900638431 /* DropInConfigurationParserTests.swift in Sources */,
Expand Down Expand Up @@ -630,10 +642,7 @@
"-DFOLLY_CFG_NO_COROUTINES=1",
"-DFOLLY_HAVE_CLOCK_GETTIME=1",
);
OTHER_LDFLAGS = (
"$(inherited)",
" ",
);
OTHER_LDFLAGS = "$(inherited) ";
REACT_NATIVE_PATH = "${PODS_ROOT}/../../node_modules/react-native";
SDKROOT = iphoneos;
SWIFT_VERSION = 5.0;
Expand Down Expand Up @@ -707,10 +716,7 @@
"-DFOLLY_CFG_NO_COROUTINES=1",
"-DFOLLY_HAVE_CLOCK_GETTIME=1",
);
OTHER_LDFLAGS = (
"$(inherited)",
" ",
);
OTHER_LDFLAGS = "$(inherited) ";
REACT_NATIVE_PATH = "${PODS_ROOT}/../../node_modules/react-native";
SDKROOT = iphoneos;
SWIFT_COMPILATION_MODE = wholemodule;
Expand Down
Loading