From 7d8229bf927d3d24865f6fb3e1046f336f683948 Mon Sep 17 00:00:00 2001 From: Scott Antonac Date: Mon, 20 Dec 2021 16:28:32 +1100 Subject: [PATCH 01/16] add ability to change modal theme --- .../com/afterpay/android/view/AfterpayModalTheme.kt | 8 ++++++++ .../afterpay/android/view/AfterpayPriceBreakdown.kt | 10 +++++++++- .../com/example/afterpay/shopping/ShoppingFragment.kt | 2 ++ 3 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 afterpay/src/main/kotlin/com/afterpay/android/view/AfterpayModalTheme.kt diff --git a/afterpay/src/main/kotlin/com/afterpay/android/view/AfterpayModalTheme.kt b/afterpay/src/main/kotlin/com/afterpay/android/view/AfterpayModalTheme.kt new file mode 100644 index 00000000..64b01d35 --- /dev/null +++ b/afterpay/src/main/kotlin/com/afterpay/android/view/AfterpayModalTheme.kt @@ -0,0 +1,8 @@ +package com.afterpay.android.view + +enum class AfterpayModalTheme(val slug: String) { + DEFAULT(""), + DEFAULT_CBT("-cbt"), + WHITE("-theme-white"), + WHITE_CBT("-theme-white-cbt"); +} diff --git a/afterpay/src/main/kotlin/com/afterpay/android/view/AfterpayPriceBreakdown.kt b/afterpay/src/main/kotlin/com/afterpay/android/view/AfterpayPriceBreakdown.kt index d12daedf..0baa5163 100644 --- a/afterpay/src/main/kotlin/com/afterpay/android/view/AfterpayPriceBreakdown.kt +++ b/afterpay/src/main/kotlin/com/afterpay/android/view/AfterpayPriceBreakdown.kt @@ -64,6 +64,10 @@ class AfterpayPriceBreakdown @JvmOverloads constructor( updateText() } + var modalTheme: AfterpayModalTheme = AfterpayModalTheme.DEFAULT + + var modalId: String? = null + private val textView: TextView = TextView(context).apply { setTextColor(context.resolveColorAttr(android.R.attr.textColorPrimary)) setLinkTextColor(context.resolveColorAttr(android.R.attr.textColorSecondary)) @@ -77,8 +81,12 @@ class AfterpayPriceBreakdown @JvmOverloads constructor( // The terms and conditions are tied to the configured locale on the configuration private val infoUrl: String get() { + modalId?.let { + return "https://static.afterpay.com/modal/$modalId.html" + } + val locale = "${Afterpay.locale.language}_${Afterpay.locale.country}" - return "https://static.afterpay.com/modal/$locale.html" + return "https://static.afterpay.com/modal/$locale${modalTheme.slug}.html" } init { diff --git a/example/src/main/kotlin/com/example/afterpay/shopping/ShoppingFragment.kt b/example/src/main/kotlin/com/example/afterpay/shopping/ShoppingFragment.kt index 4893733f..04133265 100644 --- a/example/src/main/kotlin/com/example/afterpay/shopping/ShoppingFragment.kt +++ b/example/src/main/kotlin/com/example/afterpay/shopping/ShoppingFragment.kt @@ -17,6 +17,7 @@ import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.ListAdapter import androidx.recyclerview.widget.RecyclerView import com.afterpay.android.view.AfterpayIntroText +import com.afterpay.android.view.AfterpayModalTheme import com.afterpay.android.view.AfterpayPriceBreakdown import com.example.afterpay.R import com.example.afterpay.data.Product @@ -65,6 +66,7 @@ class ShoppingFragment : Fragment() { val afterpayBreakdown = view.findViewById(R.id.shopping_afterpayPriceBreakdown) afterpayBreakdown.introText = AfterpayIntroText.PAY_IN afterpayBreakdown.showInterestFreeText = false + afterpayBreakdown.modalTheme = AfterpayModalTheme.WHITE_CBT lifecycleScope.launchWhenCreated { viewModel.state.collectLatest { state -> From 5da0e820c621a5ff7e6555f32b1cba7d44bec1d8 Mon Sep 17 00:00:00 2001 From: Scott Antonac Date: Fri, 28 Jan 2022 11:45:52 +1100 Subject: [PATCH 02/16] create class for more info options will later hold a param for info text --- .../android/view/AfterpayPriceBreakdown.kt | 15 ++++++--------- .../afterpay/android/view/MoreInfoOptions.kt | 18 ++++++++++++++++++ .../afterpay/shopping/ShoppingFragment.kt | 5 ++++- 3 files changed, 28 insertions(+), 10 deletions(-) create mode 100644 afterpay/src/main/kotlin/com/afterpay/android/view/MoreInfoOptions.kt diff --git a/afterpay/src/main/kotlin/com/afterpay/android/view/AfterpayPriceBreakdown.kt b/afterpay/src/main/kotlin/com/afterpay/android/view/AfterpayPriceBreakdown.kt index 0baa5163..9d11da21 100644 --- a/afterpay/src/main/kotlin/com/afterpay/android/view/AfterpayPriceBreakdown.kt +++ b/afterpay/src/main/kotlin/com/afterpay/android/view/AfterpayPriceBreakdown.kt @@ -64,9 +64,11 @@ class AfterpayPriceBreakdown @JvmOverloads constructor( updateText() } - var modalTheme: AfterpayModalTheme = AfterpayModalTheme.DEFAULT - - var modalId: String? = null + var moreInfoOptions: MoreInfoOptions = MoreInfoOptions() + set(value) { + field = value + updateText() + } private val textView: TextView = TextView(context).apply { setTextColor(context.resolveColorAttr(android.R.attr.textColorPrimary)) @@ -81,12 +83,7 @@ class AfterpayPriceBreakdown @JvmOverloads constructor( // The terms and conditions are tied to the configured locale on the configuration private val infoUrl: String get() { - modalId?.let { - return "https://static.afterpay.com/modal/$modalId.html" - } - - val locale = "${Afterpay.locale.language}_${Afterpay.locale.country}" - return "https://static.afterpay.com/modal/$locale${modalTheme.slug}.html" + return "https://static.afterpay.com/modal/${moreInfoOptions.modalFile()}" } init { diff --git a/afterpay/src/main/kotlin/com/afterpay/android/view/MoreInfoOptions.kt b/afterpay/src/main/kotlin/com/afterpay/android/view/MoreInfoOptions.kt new file mode 100644 index 00000000..5bb5a0d1 --- /dev/null +++ b/afterpay/src/main/kotlin/com/afterpay/android/view/MoreInfoOptions.kt @@ -0,0 +1,18 @@ +package com.afterpay.android.view + +import com.afterpay.android.Afterpay + +class MoreInfoOptions( + var modalTheme: AfterpayModalTheme = AfterpayModalTheme.DEFAULT, + var modalId: String? = null +) { + + fun modalFile() : String { + modalId?.let { + return "$it.html" + } + + val locale = "${Afterpay.locale.language}_${Afterpay.locale.country}" + return "$locale${modalTheme.slug}.html" + } +} diff --git a/example/src/main/kotlin/com/example/afterpay/shopping/ShoppingFragment.kt b/example/src/main/kotlin/com/example/afterpay/shopping/ShoppingFragment.kt index 04133265..5fb0a169 100644 --- a/example/src/main/kotlin/com/example/afterpay/shopping/ShoppingFragment.kt +++ b/example/src/main/kotlin/com/example/afterpay/shopping/ShoppingFragment.kt @@ -19,6 +19,7 @@ import androidx.recyclerview.widget.RecyclerView import com.afterpay.android.view.AfterpayIntroText import com.afterpay.android.view.AfterpayModalTheme import com.afterpay.android.view.AfterpayPriceBreakdown +import com.afterpay.android.view.MoreInfoOptions import com.example.afterpay.R import com.example.afterpay.data.Product import com.example.afterpay.nav_graph @@ -66,7 +67,9 @@ class ShoppingFragment : Fragment() { val afterpayBreakdown = view.findViewById(R.id.shopping_afterpayPriceBreakdown) afterpayBreakdown.introText = AfterpayIntroText.PAY_IN afterpayBreakdown.showInterestFreeText = false - afterpayBreakdown.modalTheme = AfterpayModalTheme.WHITE_CBT + afterpayBreakdown.moreInfoOptions = MoreInfoOptions( + modalTheme = AfterpayModalTheme.WHITE_CBT + ) lifecycleScope.launchWhenCreated { viewModel.state.collectLatest { state -> From a7a18f2a4749b7b12e6a96c7129af6e96240d04e Mon Sep 17 00:00:00 2001 From: Scott Antonac Date: Fri, 28 Jan 2022 12:12:01 +1100 Subject: [PATCH 03/16] change MoreInfoOptions class name to AfterpayMoreInfoOptions --- .../view/{MoreInfoOptions.kt => AfterpayMoreInfoOptions.kt} | 2 +- .../com/afterpay/android/view/AfterpayPriceBreakdown.kt | 2 +- .../com/example/afterpay/shopping/ShoppingFragment.kt | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) rename afterpay/src/main/kotlin/com/afterpay/android/view/{MoreInfoOptions.kt => AfterpayMoreInfoOptions.kt} (92%) diff --git a/afterpay/src/main/kotlin/com/afterpay/android/view/MoreInfoOptions.kt b/afterpay/src/main/kotlin/com/afterpay/android/view/AfterpayMoreInfoOptions.kt similarity index 92% rename from afterpay/src/main/kotlin/com/afterpay/android/view/MoreInfoOptions.kt rename to afterpay/src/main/kotlin/com/afterpay/android/view/AfterpayMoreInfoOptions.kt index 5bb5a0d1..e53de235 100644 --- a/afterpay/src/main/kotlin/com/afterpay/android/view/MoreInfoOptions.kt +++ b/afterpay/src/main/kotlin/com/afterpay/android/view/AfterpayMoreInfoOptions.kt @@ -2,7 +2,7 @@ package com.afterpay.android.view import com.afterpay.android.Afterpay -class MoreInfoOptions( +class AfterpayMoreInfoOptions( var modalTheme: AfterpayModalTheme = AfterpayModalTheme.DEFAULT, var modalId: String? = null ) { diff --git a/afterpay/src/main/kotlin/com/afterpay/android/view/AfterpayPriceBreakdown.kt b/afterpay/src/main/kotlin/com/afterpay/android/view/AfterpayPriceBreakdown.kt index 9d11da21..c0b4e173 100644 --- a/afterpay/src/main/kotlin/com/afterpay/android/view/AfterpayPriceBreakdown.kt +++ b/afterpay/src/main/kotlin/com/afterpay/android/view/AfterpayPriceBreakdown.kt @@ -64,7 +64,7 @@ class AfterpayPriceBreakdown @JvmOverloads constructor( updateText() } - var moreInfoOptions: MoreInfoOptions = MoreInfoOptions() + var moreInfoOptions: AfterpayMoreInfoOptions = AfterpayMoreInfoOptions() set(value) { field = value updateText() diff --git a/example/src/main/kotlin/com/example/afterpay/shopping/ShoppingFragment.kt b/example/src/main/kotlin/com/example/afterpay/shopping/ShoppingFragment.kt index 5fb0a169..d4c05df6 100644 --- a/example/src/main/kotlin/com/example/afterpay/shopping/ShoppingFragment.kt +++ b/example/src/main/kotlin/com/example/afterpay/shopping/ShoppingFragment.kt @@ -19,7 +19,7 @@ import androidx.recyclerview.widget.RecyclerView import com.afterpay.android.view.AfterpayIntroText import com.afterpay.android.view.AfterpayModalTheme import com.afterpay.android.view.AfterpayPriceBreakdown -import com.afterpay.android.view.MoreInfoOptions +import com.afterpay.android.view.AfterpayMoreInfoOptions import com.example.afterpay.R import com.example.afterpay.data.Product import com.example.afterpay.nav_graph @@ -67,8 +67,8 @@ class ShoppingFragment : Fragment() { val afterpayBreakdown = view.findViewById(R.id.shopping_afterpayPriceBreakdown) afterpayBreakdown.introText = AfterpayIntroText.PAY_IN afterpayBreakdown.showInterestFreeText = false - afterpayBreakdown.moreInfoOptions = MoreInfoOptions( - modalTheme = AfterpayModalTheme.WHITE_CBT + afterpayBreakdown.moreInfoOptions = AfterpayMoreInfoOptions( + modalTheme = AfterpayModalTheme.WHITE ) lifecycleScope.launchWhenCreated { From 003983efe5cbff416397bc10cbf86f2a1ad35e92 Mon Sep 17 00:00:00 2001 From: Scott Antonac Date: Fri, 28 Jan 2022 12:12:29 +1100 Subject: [PATCH 04/16] document moreInfoOptions --- README.md | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 8909bc10..9130d15d 100644 --- a/README.md +++ b/README.md @@ -118,7 +118,7 @@ class ExampleActivity: Activity { ### Launching the Checkout (v2) -Launch the Afterpay checkout v2 flow by starting the intent provided by the SDK for the given options. +Launch the Afterpay checkout v2 flow by starting the intent provided by the SDK for the given options. > When creating a checkout token, `popupOriginUrl` must be set to `https://static.afterpay.com`. The SDK’s example merchant server sets the parameter [here](https://github.com/afterpay/sdk-example-server/blob/master/src/routes/checkout.ts#L28). See the [API reference][express-checkout] for more details! Failing to do so will cause undefined behavior. @@ -199,7 +199,7 @@ class ReceiptFragment : Fragment() { override fun onViewCreated(view: View, savedInstanceState: Bundle?) { // ... - + view.findViewById(R.id.afterpay_widget) .init(token, ::onWidgetExternalLink, ::onWidgetUpdate, ::onWidgetError) } @@ -338,6 +338,22 @@ afterpayBreakdown.introText = AfterpayIntroText.MAKE_TITLE Given the above, the price breakdown text will be rendered `Make 4 interest-free payments of $##.##` +##### More Info Options +Setting `moreInfoOptions` is optional and of type `AfterpayMoreInfoOptions`. This class takes two parameters: +- `modalId`: a `string` that is the filename of a modal hosted on Afterpay static +- `modalTheme`: an enum of type `AfterpayModalTheme` withe the following options: `DEFAULT`, `DEFAULT_CBT`, `WHITE` and `WHITE_CBT`. Please note that not all themes are supported by all locales. + +If both `modalId` and `modalTheme` are set, `modalId` takes precedence. + +```kotlin +val afterpayBreakdown = view.findViewById(R.id.afterpayPriceBreakdown) +afterpayBreakdown.moreInfoOptions = AfterpayMoreInfoOptions( + modalTheme = AfterpayModalTheme.WHITE +) +``` + +Given the above, when clicking the more info "link", the modal that opens will be white in the current locale as set in configuration. + ## Security To limit the possibility of a man-in-the-middle attack during the checkout process, certificate pinning can be configured for the Afterpay portal. Please refer to the Android [Network Security Configuration][network-config] documentation for more information. From c8c0a93fab206298ff1558ae3fda5d2d3b99d38a Mon Sep 17 00:00:00 2001 From: Scott Antonac Date: Fri, 28 Jan 2022 13:57:28 +1100 Subject: [PATCH 05/16] seperate CBT from theme --- README.md | 7 +++++-- .../com/afterpay/android/view/AfterpayModalTheme.kt | 6 ++---- .../android/view/AfterpayMoreInfoOptions.kt | 13 ++++++++----- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 9130d15d..d27bedac 100644 --- a/README.md +++ b/README.md @@ -340,10 +340,13 @@ Given the above, the price breakdown text will be rendered `Make 4 interest-free ##### More Info Options Setting `moreInfoOptions` is optional and of type `AfterpayMoreInfoOptions`. This class takes two parameters: -- `modalId`: a `string` that is the filename of a modal hosted on Afterpay static -- `modalTheme`: an enum of type `AfterpayModalTheme` withe the following options: `DEFAULT`, `DEFAULT_CBT`, `WHITE` and `WHITE_CBT`. Please note that not all themes are supported by all locales. +- `modalId`: a `string` that is the filename of a modal hosted on Afterpay static. +- `modalTheme`: an enum of type `AfterpayModalTheme` withe the following options: `DEFAULT`, `DEFAULT_CBT`, `WHITE` and `WHITE_CBT`. +- `isCBT`: a `boolean` to indicate if the modal should show the CBT details in the modal +**Notes** If both `modalId` and `modalTheme` are set, `modalId` takes precedence. +Not all combinations of Locales and CBT are available. ```kotlin val afterpayBreakdown = view.findViewById(R.id.afterpayPriceBreakdown) diff --git a/afterpay/src/main/kotlin/com/afterpay/android/view/AfterpayModalTheme.kt b/afterpay/src/main/kotlin/com/afterpay/android/view/AfterpayModalTheme.kt index 64b01d35..6df8b617 100644 --- a/afterpay/src/main/kotlin/com/afterpay/android/view/AfterpayModalTheme.kt +++ b/afterpay/src/main/kotlin/com/afterpay/android/view/AfterpayModalTheme.kt @@ -1,8 +1,6 @@ package com.afterpay.android.view enum class AfterpayModalTheme(val slug: String) { - DEFAULT(""), - DEFAULT_CBT("-cbt"), - WHITE("-theme-white"), - WHITE_CBT("-theme-white-cbt"); + MINT(""), + WHITE("-theme-white"); } diff --git a/afterpay/src/main/kotlin/com/afterpay/android/view/AfterpayMoreInfoOptions.kt b/afterpay/src/main/kotlin/com/afterpay/android/view/AfterpayMoreInfoOptions.kt index e53de235..fa97030b 100644 --- a/afterpay/src/main/kotlin/com/afterpay/android/view/AfterpayMoreInfoOptions.kt +++ b/afterpay/src/main/kotlin/com/afterpay/android/view/AfterpayMoreInfoOptions.kt @@ -3,16 +3,19 @@ package com.afterpay.android.view import com.afterpay.android.Afterpay class AfterpayMoreInfoOptions( - var modalTheme: AfterpayModalTheme = AfterpayModalTheme.DEFAULT, - var modalId: String? = null + var modalTheme: AfterpayModalTheme = AfterpayModalTheme.MINT, + var modalId: String? = null, + var isCBT: Boolean = false ) { - - fun modalFile() : String { + internal fun modalFile() : String { modalId?.let { return "$it.html" } val locale = "${Afterpay.locale.language}_${Afterpay.locale.country}" - return "$locale${modalTheme.slug}.html" + val cbt = if(isCBT) "-cbt" else "" + val theme = modalTheme.slug + + return "$locale$theme$cbt.html" } } From 3a5f20046bda446d1bdb315a13992ccdec31c03c Mon Sep 17 00:00:00 2001 From: Scott Antonac Date: Fri, 28 Jan 2022 14:00:25 +1100 Subject: [PATCH 06/16] fix linting issues in AfterpayMoreInfoOptions --- .../com/afterpay/android/view/AfterpayMoreInfoOptions.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/afterpay/src/main/kotlin/com/afterpay/android/view/AfterpayMoreInfoOptions.kt b/afterpay/src/main/kotlin/com/afterpay/android/view/AfterpayMoreInfoOptions.kt index fa97030b..be6f1a31 100644 --- a/afterpay/src/main/kotlin/com/afterpay/android/view/AfterpayMoreInfoOptions.kt +++ b/afterpay/src/main/kotlin/com/afterpay/android/view/AfterpayMoreInfoOptions.kt @@ -7,13 +7,13 @@ class AfterpayMoreInfoOptions( var modalId: String? = null, var isCBT: Boolean = false ) { - internal fun modalFile() : String { + internal fun modalFile(): String { modalId?.let { return "$it.html" } val locale = "${Afterpay.locale.language}_${Afterpay.locale.country}" - val cbt = if(isCBT) "-cbt" else "" + val cbt = if (isCBT) "-cbt" else "" val theme = modalTheme.slug return "$locale$theme$cbt.html" From 66713ee63916f240d67cf020af1511c7b0683eb6 Mon Sep 17 00:00:00 2001 From: Scott Antonac Date: Fri, 28 Jan 2022 15:17:00 +1100 Subject: [PATCH 07/16] fix: move import order for linting --- .../kotlin/com/example/afterpay/shopping/ShoppingFragment.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/example/src/main/kotlin/com/example/afterpay/shopping/ShoppingFragment.kt b/example/src/main/kotlin/com/example/afterpay/shopping/ShoppingFragment.kt index d4c05df6..d329a8c2 100644 --- a/example/src/main/kotlin/com/example/afterpay/shopping/ShoppingFragment.kt +++ b/example/src/main/kotlin/com/example/afterpay/shopping/ShoppingFragment.kt @@ -18,8 +18,8 @@ import androidx.recyclerview.widget.ListAdapter import androidx.recyclerview.widget.RecyclerView import com.afterpay.android.view.AfterpayIntroText import com.afterpay.android.view.AfterpayModalTheme -import com.afterpay.android.view.AfterpayPriceBreakdown import com.afterpay.android.view.AfterpayMoreInfoOptions +import com.afterpay.android.view.AfterpayPriceBreakdown import com.example.afterpay.R import com.example.afterpay.data.Product import com.example.afterpay.nav_graph From 87d4d52b1127abb7b0eb483a6465c9d1f63c1622 Mon Sep 17 00:00:00 2001 From: Scott Antonac Date: Fri, 28 Jan 2022 15:28:44 +1100 Subject: [PATCH 08/16] typo in readme for more info --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d27bedac..9d4d762f 100644 --- a/README.md +++ b/README.md @@ -339,7 +339,7 @@ afterpayBreakdown.introText = AfterpayIntroText.MAKE_TITLE Given the above, the price breakdown text will be rendered `Make 4 interest-free payments of $##.##` ##### More Info Options -Setting `moreInfoOptions` is optional and of type `AfterpayMoreInfoOptions`. This class takes two parameters: +Setting `moreInfoOptions` is optional and of type `AfterpayMoreInfoOptions`. This class takes three parameters: - `modalId`: a `string` that is the filename of a modal hosted on Afterpay static. - `modalTheme`: an enum of type `AfterpayModalTheme` withe the following options: `DEFAULT`, `DEFAULT_CBT`, `WHITE` and `WHITE_CBT`. - `isCBT`: a `boolean` to indicate if the modal should show the CBT details in the modal From f57ee5dd85c04ab61d16d9288d4c2878d5ade12f Mon Sep 17 00:00:00 2001 From: Scott Antonac <76413218+ScottAntonacAP@users.noreply.github.com> Date: Fri, 28 Jan 2022 20:34:54 +1100 Subject: [PATCH 09/16] Fix: typo in README.md Co-authored-by: Luv Gangwani <67246067+luvgangwani92@users.noreply.github.com> --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 9d4d762f..21019b12 100644 --- a/README.md +++ b/README.md @@ -341,7 +341,7 @@ Given the above, the price breakdown text will be rendered `Make 4 interest-free ##### More Info Options Setting `moreInfoOptions` is optional and of type `AfterpayMoreInfoOptions`. This class takes three parameters: - `modalId`: a `string` that is the filename of a modal hosted on Afterpay static. -- `modalTheme`: an enum of type `AfterpayModalTheme` withe the following options: `DEFAULT`, `DEFAULT_CBT`, `WHITE` and `WHITE_CBT`. +- `modalTheme`: an enum of type `AfterpayModalTheme` with the following options: `DEFAULT`, `DEFAULT_CBT`, `WHITE` and `WHITE_CBT`. - `isCBT`: a `boolean` to indicate if the modal should show the CBT details in the modal **Notes** From 8e711819c97b114d3b42dd8fbbacad5db58e2af9 Mon Sep 17 00:00:00 2001 From: Scott Antonac Date: Fri, 28 Jan 2022 20:41:34 +1100 Subject: [PATCH 10/16] fix: documentation for more info options --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 21019b12..8a7f5987 100644 --- a/README.md +++ b/README.md @@ -341,7 +341,7 @@ Given the above, the price breakdown text will be rendered `Make 4 interest-free ##### More Info Options Setting `moreInfoOptions` is optional and of type `AfterpayMoreInfoOptions`. This class takes three parameters: - `modalId`: a `string` that is the filename of a modal hosted on Afterpay static. -- `modalTheme`: an enum of type `AfterpayModalTheme` with the following options: `DEFAULT`, `DEFAULT_CBT`, `WHITE` and `WHITE_CBT`. +- `modalTheme`: an enum of type `AfterpayModalTheme` with the following options: `MINT` (default) and `WHITE`. - `isCBT`: a `boolean` to indicate if the modal should show the CBT details in the modal **Notes** From cbf3ddb97f2e62f6acf4bea0a37e9cef670b13ed Mon Sep 17 00:00:00 2001 From: Scott Antonac Date: Fri, 28 Jan 2022 20:43:15 +1100 Subject: [PATCH 11/16] update documentation: more info notes --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 8a7f5987..cfb76969 100644 --- a/README.md +++ b/README.md @@ -345,7 +345,7 @@ Setting `moreInfoOptions` is optional and of type `AfterpayMoreInfoOptions`. Thi - `isCBT`: a `boolean` to indicate if the modal should show the CBT details in the modal **Notes** -If both `modalId` and `modalTheme` are set, `modalId` takes precedence. +If both `modalId` is set `modalTheme` and `isCBT` are ignored. Not all combinations of Locales and CBT are available. ```kotlin From 3735edab1b5f311539f3748699cf59e92b68c7fc Mon Sep 17 00:00:00 2001 From: Scott Antonac Date: Mon, 31 Jan 2022 10:50:23 +1100 Subject: [PATCH 12/16] Update isCBT param to isCbtEnabled --- README.md | 4 ++-- .../com/afterpay/android/view/AfterpayMoreInfoOptions.kt | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index cfb76969..65156aa8 100644 --- a/README.md +++ b/README.md @@ -342,10 +342,10 @@ Given the above, the price breakdown text will be rendered `Make 4 interest-free Setting `moreInfoOptions` is optional and of type `AfterpayMoreInfoOptions`. This class takes three parameters: - `modalId`: a `string` that is the filename of a modal hosted on Afterpay static. - `modalTheme`: an enum of type `AfterpayModalTheme` with the following options: `MINT` (default) and `WHITE`. -- `isCBT`: a `boolean` to indicate if the modal should show the CBT details in the modal +- `isCbtEnabled`: a `boolean` to indicate if the modal should show the Cross Border Trade details in the modal **Notes** -If both `modalId` is set `modalTheme` and `isCBT` are ignored. +If both `modalId` is set `modalTheme` and `isCbtEnabled` are ignored. Not all combinations of Locales and CBT are available. ```kotlin diff --git a/afterpay/src/main/kotlin/com/afterpay/android/view/AfterpayMoreInfoOptions.kt b/afterpay/src/main/kotlin/com/afterpay/android/view/AfterpayMoreInfoOptions.kt index be6f1a31..4513b977 100644 --- a/afterpay/src/main/kotlin/com/afterpay/android/view/AfterpayMoreInfoOptions.kt +++ b/afterpay/src/main/kotlin/com/afterpay/android/view/AfterpayMoreInfoOptions.kt @@ -5,7 +5,7 @@ import com.afterpay.android.Afterpay class AfterpayMoreInfoOptions( var modalTheme: AfterpayModalTheme = AfterpayModalTheme.MINT, var modalId: String? = null, - var isCBT: Boolean = false + var isCbtEnabled: Boolean = false ) { internal fun modalFile(): String { modalId?.let { @@ -13,7 +13,7 @@ class AfterpayMoreInfoOptions( } val locale = "${Afterpay.locale.language}_${Afterpay.locale.country}" - val cbt = if (isCBT) "-cbt" else "" + val cbt = if (isCbtEnabled) "-cbt" else "" val theme = modalTheme.slug return "$locale$theme$cbt.html" From 8c34ebd0e4eedfdfda590e485caa830eb5b0bd3c Mon Sep 17 00:00:00 2001 From: Scott Antonac Date: Mon, 31 Jan 2022 11:29:44 +1100 Subject: [PATCH 13/16] document AfterpayMoreInfoOptions and reorder params --- .../android/view/AfterpayMoreInfoOptions.kt | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/afterpay/src/main/kotlin/com/afterpay/android/view/AfterpayMoreInfoOptions.kt b/afterpay/src/main/kotlin/com/afterpay/android/view/AfterpayMoreInfoOptions.kt index 4513b977..6682b1cc 100644 --- a/afterpay/src/main/kotlin/com/afterpay/android/view/AfterpayMoreInfoOptions.kt +++ b/afterpay/src/main/kotlin/com/afterpay/android/view/AfterpayMoreInfoOptions.kt @@ -2,9 +2,20 @@ package com.afterpay.android.view import com.afterpay.android.Afterpay +/** + * Setting up options for the more info link in AfterpayPriceBreakdown + * + * **Notes:** + * - If both `modalId` is set, `modalTheme` and `isCbtEnabled` are ignored. + * - Not all combinations of Locales and CBT are available. + * + * @param modalId the filename of a modal hosted on Afterpay static + * @param modalTheme the color theme used when displaying the modal + * @param isCbtEnabled whether to show the Cross Border Trade details in the modal + */ class AfterpayMoreInfoOptions( - var modalTheme: AfterpayModalTheme = AfterpayModalTheme.MINT, var modalId: String? = null, + var modalTheme: AfterpayModalTheme = AfterpayModalTheme.MINT, var isCbtEnabled: Boolean = false ) { internal fun modalFile(): String { From f62b03c645849d2c9fdc6150c06b5c8361b7580d Mon Sep 17 00:00:00 2001 From: Scott Antonac Date: Mon, 31 Jan 2022 13:48:39 +1100 Subject: [PATCH 14/16] create two constructors for AfterpayMoreInfoOptions --- README.md | 5 +- .../android/view/AfterpayMoreInfoOptions.kt | 47 ++++++++++++------- 2 files changed, 35 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index 65156aa8..396fc880 100644 --- a/README.md +++ b/README.md @@ -339,8 +339,11 @@ afterpayBreakdown.introText = AfterpayIntroText.MAKE_TITLE Given the above, the price breakdown text will be rendered `Make 4 interest-free payments of $##.##` ##### More Info Options -Setting `moreInfoOptions` is optional and of type `AfterpayMoreInfoOptions`. This class takes three parameters: +Setting `moreInfoOptions` is optional and of type `AfterpayMoreInfoOptions`. This class has two constructors. +The first takes a single parameter: - `modalId`: a `string` that is the filename of a modal hosted on Afterpay static. + +The second takes two parameters: - `modalTheme`: an enum of type `AfterpayModalTheme` with the following options: `MINT` (default) and `WHITE`. - `isCbtEnabled`: a `boolean` to indicate if the modal should show the Cross Border Trade details in the modal diff --git a/afterpay/src/main/kotlin/com/afterpay/android/view/AfterpayMoreInfoOptions.kt b/afterpay/src/main/kotlin/com/afterpay/android/view/AfterpayMoreInfoOptions.kt index 6682b1cc..56c3ea38 100644 --- a/afterpay/src/main/kotlin/com/afterpay/android/view/AfterpayMoreInfoOptions.kt +++ b/afterpay/src/main/kotlin/com/afterpay/android/view/AfterpayMoreInfoOptions.kt @@ -2,22 +2,37 @@ package com.afterpay.android.view import com.afterpay.android.Afterpay -/** - * Setting up options for the more info link in AfterpayPriceBreakdown - * - * **Notes:** - * - If both `modalId` is set, `modalTheme` and `isCbtEnabled` are ignored. - * - Not all combinations of Locales and CBT are available. - * - * @param modalId the filename of a modal hosted on Afterpay static - * @param modalTheme the color theme used when displaying the modal - * @param isCbtEnabled whether to show the Cross Border Trade details in the modal - */ -class AfterpayMoreInfoOptions( - var modalId: String? = null, - var modalTheme: AfterpayModalTheme = AfterpayModalTheme.MINT, - var isCbtEnabled: Boolean = false -) { +class AfterpayMoreInfoOptions { + private var modalId: String? = null + private var modalTheme: AfterpayModalTheme = AfterpayModalTheme.MINT + private var isCbtEnabled: Boolean = false + + /** + * Set up options for the more info link in AfterpayPriceBreakdown + * + * @param modalId the filename of a modal hosted on Afterpay static + */ + constructor(modalId: String) { + this.modalId = modalId + } + + /** + * Set up options for the more info link in AfterpayPriceBreakdown + * + * **Notes:** + * - Not all combinations of Locales and CBT are available. + * + * @param modalTheme the color theme used when displaying the modal + * @param isCbtEnabled whether to show the Cross Border Trade details in the modal + */ + constructor( + modalTheme: AfterpayModalTheme = AfterpayModalTheme.MINT, + isCbtEnabled: Boolean = false + ) { + this.modalTheme = modalTheme + this.isCbtEnabled = isCbtEnabled + } + internal fun modalFile(): String { modalId?.let { return "$it.html" From 167df01fec207cc3d57a9ae5d34b68154eeeb793 Mon Sep 17 00:00:00 2001 From: Scott Antonac <76413218+ScottAntonacAP@users.noreply.github.com> Date: Mon, 31 Jan 2022 14:47:42 +1100 Subject: [PATCH 15/16] Fix: typo in readme Co-authored-by: Ben Firth --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 396fc880..dc5e42f9 100644 --- a/README.md +++ b/README.md @@ -348,7 +348,7 @@ The second takes two parameters: - `isCbtEnabled`: a `boolean` to indicate if the modal should show the Cross Border Trade details in the modal **Notes** -If both `modalId` is set `modalTheme` and `isCbtEnabled` are ignored. +If `modalId` is set, both `modalTheme` and `isCbtEnabled` are ignored. Not all combinations of Locales and CBT are available. ```kotlin From f37fc22d07bdc38c13c3b5b49991ab6ee9746e77 Mon Sep 17 00:00:00 2001 From: Scott Antonac Date: Mon, 31 Jan 2022 14:57:53 +1100 Subject: [PATCH 16/16] amend notes for more info options --- README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/README.md b/README.md index dc5e42f9..43ded64e 100644 --- a/README.md +++ b/README.md @@ -347,8 +347,7 @@ The second takes two parameters: - `modalTheme`: an enum of type `AfterpayModalTheme` with the following options: `MINT` (default) and `WHITE`. - `isCbtEnabled`: a `boolean` to indicate if the modal should show the Cross Border Trade details in the modal -**Notes** -If `modalId` is set, both `modalTheme` and `isCbtEnabled` are ignored. +**Note** Not all combinations of Locales and CBT are available. ```kotlin