diff --git a/.editorconfig b/.editorconfig
index e855d433..4c697b24 100644
--- a/.editorconfig
+++ b/.editorconfig
@@ -8,6 +8,10 @@ indent_size = 4
insert_final_newline = true
trim_trailing_whitespace = true
+[*.{kt,kts}]
+ij_kotlin_allow_trailing_comma=true
+ij_kotlin_allow_trailing_comma_on_call_site=true
+
[*.md]
trim_trailing_whitespace = false
diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml
index 583be083..6bb491d3 100644
--- a/.github/workflows/build-and-test.yml
+++ b/.github/workflows/build-and-test.yml
@@ -12,12 +12,13 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Clone Repository
- uses: actions/checkout@v2
+ uses: actions/checkout@v3
- name: Set up JDK 11
- uses: actions/setup-java@v1
+ uses: actions/setup-java@v2
with:
- java-version: '11'
+ java-version: 11
+ distribution: 'zulu'
- name: Lint
run: ./gradlew afterpay:lintDebug afterpay:ktlint
@@ -30,12 +31,13 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Clone Repository
- uses: actions/checkout@v2
+ uses: actions/checkout@v3
- name: Set up JDK 11
- uses: actions/setup-java@v1
+ uses: actions/setup-java@v2
with:
- java-version: '11'
+ java-version: 11
+ distribution: 'zulu'
- name: Build and Lint
run: ./gradlew example:buildDebug example:lintDebug example:ktlint
diff --git a/.github/workflows/release-snapshot.yml b/.github/workflows/release-snapshot.yml
index c64c56d3..bec75030 100644
--- a/.github/workflows/release-snapshot.yml
+++ b/.github/workflows/release-snapshot.yml
@@ -9,12 +9,13 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Clone Repository
- uses: actions/checkout@v2
+ uses: actions/checkout@v3
- name: Set up JDK 11
- uses: actions/setup-java@v1
+ uses: actions/setup-java@v2
with:
- java-version: '11'
+ java-version: 11
+ distribution: 'zulu'
- name: Clean repository before building SDK
run: ./gradlew clean
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 330bea41..a9f59809 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -9,12 +9,13 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Clone Repository
- uses: actions/checkout@v2
+ uses: actions/checkout@v3
- name: Set up JDK 11
- uses: actions/setup-java@v1
+ uses: actions/setup-java@v2
with:
- java-version: '11'
+ java-version: 11
+ distribution: 'zulu'
- name: Remove SNAPSHOT from version
run: sed -i 's/-SNAPSHOT//g' gradle.properties
diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml
index 4e2fe53d..7829f3cf 100644
--- a/.idea/codeStyles/Project.xml
+++ b/.idea/codeStyles/Project.xml
@@ -6,15 +6,6 @@
-
diff --git a/afterpay/consumer-rules.pro b/afterpay/consumer-rules.pro
index 68cf0603..4641d8ca 100644
--- a/afterpay/consumer-rules.pro
+++ b/afterpay/consumer-rules.pro
@@ -1,5 +1,4 @@
-keepattributes *Annotation*, InnerClasses
--dontnote kotlinx.serialization.AnnotationsKt # core serialization annotations
# kotlinx-serialization-json specific. Add this if you have java.lang.NoClassDefFoundError kotlinx.serialization.json.JsonObjectSerializer
-keepclassmembers class kotlinx.serialization.json.** {
diff --git a/afterpay/src/main/kotlin/com/afterpay/android/Afterpay.kt b/afterpay/src/main/kotlin/com/afterpay/android/Afterpay.kt
index ac6293af..6c862efa 100644
--- a/afterpay/src/main/kotlin/com/afterpay/android/Afterpay.kt
+++ b/afterpay/src/main/kotlin/com/afterpay/android/Afterpay.kt
@@ -15,6 +15,7 @@ import com.afterpay.android.internal.getCancellationStatusExtraV3
import com.afterpay.android.internal.getOrderTokenExtra
import com.afterpay.android.internal.getRegionLanguage
import com.afterpay.android.internal.getResultDataExtra
+import com.afterpay.android.internal.putCheckoutShouldLoadRedirectUrls
import com.afterpay.android.internal.putCheckoutUrlExtra
import com.afterpay.android.internal.putCheckoutV2OptionsExtra
import com.afterpay.android.internal.putCheckoutV3OptionsExtra
@@ -75,10 +76,11 @@ object Afterpay {
* Afterpay checkout.
*/
@JvmStatic
- fun createCheckoutIntent(context: Context, checkoutUrl: String): Intent {
+ fun createCheckoutIntent(context: Context, checkoutUrl: String, loadRedirectUrls: Boolean = false): Intent {
val url = if (enabled) { checkoutUrl } else { "LANGUAGE_NOT_SUPPORTED" }
return Intent(context, AfterpayCheckoutActivity::class.java)
.putCheckoutUrlExtra(url)
+ .putCheckoutShouldLoadRedirectUrls(loadRedirectUrls)
}
/**
@@ -89,7 +91,7 @@ object Afterpay {
@JvmStatic
fun createCheckoutV2Intent(
context: Context,
- options: AfterpayCheckoutV2Options = AfterpayCheckoutV2Options()
+ options: AfterpayCheckoutV2Options = AfterpayCheckoutV2Options(),
): Intent = Intent(context, AfterpayCheckoutV2Activity::class.java)
.putCheckoutV2OptionsExtra(options)
@@ -125,14 +127,14 @@ object Afterpay {
maximumAmount: String,
currencyCode: String,
locale: Locale,
- environment: AfterpayEnvironment
+ environment: AfterpayEnvironment,
) {
configuration = Configuration(
minimumAmount = minimumAmount?.toBigDecimal(),
maximumAmount = maximumAmount.toBigDecimal(),
currency = Currency.getInstance(currencyCode),
locale = locale.clone() as Locale,
- environment = environment
+ environment = environment,
).also { validateConfiguration(it) }
}
@@ -192,7 +194,7 @@ object Afterpay {
orderTotal: OrderTotal,
items: Array = arrayOf(),
buyNow: Boolean,
- configuration: CheckoutV3Configuration? = checkoutV3Configuration
+ configuration: CheckoutV3Configuration? = checkoutV3Configuration,
): Intent {
requireNotNull(configuration) {
"`configuration` must be set via `setCheckoutV3Configuration` or passed into this function"
@@ -207,7 +209,7 @@ object Afterpay {
buyNow = buyNow,
checkoutPayload = Json.encodeToString(checkoutRequest),
checkoutUrl = configuration.v3CheckoutUrl,
- confirmUrl = configuration.v3CheckoutConfirmationUrl
+ confirmUrl = configuration.v3CheckoutConfirmationUrl,
)
return Intent(context, AfterpayCheckoutV3Activity::class.java)
@@ -221,7 +223,7 @@ object Afterpay {
fun updateMerchantReferenceV3(
merchantReference: String,
tokens: CheckoutV3Tokens,
- configuration: CheckoutV3Configuration? = checkoutV3Configuration
+ configuration: CheckoutV3Configuration? = checkoutV3Configuration,
): Result {
requireNotNull(configuration) {
"`configuration` must be set via `setCheckoutV3Configuration` or passed into this function"
@@ -231,13 +233,13 @@ object Afterpay {
merchantReference,
token = tokens.token,
ppaConfirmToken = tokens.ppaConfirmToken,
- singleUseCardToken = tokens.singleUseCardToken
+ singleUseCardToken = tokens.singleUseCardToken,
)
return ApiV3.requestUnit(
configuration.v3CheckoutUrl,
ApiV3.HttpVerb.PUT,
- payload
+ payload,
)
}
@@ -256,7 +258,7 @@ object Afterpay {
updateMerchantReferenceV3(merchantReference, tokens, configuration)
.fold(
onSuccess = { null },
- onFailure = { throw it }
+ onFailure = { throw it },
)
}
}
@@ -266,7 +268,7 @@ object Afterpay {
*/
@JvmSynthetic
fun fetchMerchantConfigurationV3(
- configuration: CheckoutV3Configuration? = checkoutV3Configuration
+ configuration: CheckoutV3Configuration? = checkoutV3Configuration,
): Result {
requireNotNull(configuration) {
"`configuration` must be set via `setCheckoutV3Configuration` or passed into this function"
@@ -279,7 +281,7 @@ object Afterpay {
maximumAmount = it.maximumAmount.amount,
currency = Currency.getInstance(configuration.region.currencyCode),
locale = configuration.region.locale,
- environment = configuration.environment
+ environment = configuration.environment,
)
}
}
@@ -291,7 +293,7 @@ object Afterpay {
@JvmStatic
@JvmOverloads
fun fetchMerchantConfigurationV3Async(
- configuration: CheckoutV3Configuration? = checkoutV3Configuration
+ configuration: CheckoutV3Configuration? = checkoutV3Configuration,
): CompletableFuture {
requireNotNull(configuration) {
"`configuration` must be set via `setCheckoutV3Configuration` or passed into this function"
@@ -305,13 +307,13 @@ object Afterpay {
maximumAmount = it.maximumAmount.amount,
currency = Currency.getInstance(configuration.region.currencyCode),
locale = configuration.region.locale,
- environment = configuration.environment
+ environment = configuration.environment,
)
}
result.fold(
onSuccess = { it },
- onFailure = { throw it }
+ onFailure = { throw it },
)
}
}
diff --git a/afterpay/src/main/kotlin/com/afterpay/android/AfterpayCheckoutV2Handler.kt b/afterpay/src/main/kotlin/com/afterpay/android/AfterpayCheckoutV2Handler.kt
index 0df2d135..cada9685 100644
--- a/afterpay/src/main/kotlin/com/afterpay/android/AfterpayCheckoutV2Handler.kt
+++ b/afterpay/src/main/kotlin/com/afterpay/android/AfterpayCheckoutV2Handler.kt
@@ -10,11 +10,11 @@ interface AfterpayCheckoutV2Handler {
fun shippingAddressDidChange(
address: ShippingAddress,
- onProvideShippingOptions: (ShippingOptionsResult) -> Unit
+ onProvideShippingOptions: (ShippingOptionsResult) -> Unit,
)
fun shippingOptionDidChange(
shippingOption: ShippingOption,
- onProvideShippingOption: (ShippingOptionUpdateResult?) -> Unit
+ onProvideShippingOption: (ShippingOptionUpdateResult?) -> Unit,
)
}
diff --git a/afterpay/src/main/kotlin/com/afterpay/android/AfterpayCheckoutV2Options.kt b/afterpay/src/main/kotlin/com/afterpay/android/AfterpayCheckoutV2Options.kt
index f41e6a8a..8b9ac3de 100644
--- a/afterpay/src/main/kotlin/com/afterpay/android/AfterpayCheckoutV2Options.kt
+++ b/afterpay/src/main/kotlin/com/afterpay/android/AfterpayCheckoutV2Options.kt
@@ -7,13 +7,13 @@ data class AfterpayCheckoutV2Options(
val pickup: Boolean? = null,
val buyNow: Boolean? = null,
val shippingOptionRequired: Boolean? = null,
- val enableSingleShippingOptionUpdate: Boolean? = null
+ val enableSingleShippingOptionUpdate: Boolean? = null,
) : Parcelable {
constructor(parcel: Parcel) : this(
parcel.readValue(Boolean::class.java.classLoader) as? Boolean,
parcel.readValue(Boolean::class.java.classLoader) as? Boolean,
parcel.readValue(Boolean::class.java.classLoader) as? Boolean,
- parcel.readValue(Boolean::class.java.classLoader) as? Boolean
+ parcel.readValue(Boolean::class.java.classLoader) as? Boolean,
)
override fun writeToParcel(parcel: Parcel, flags: Int) {
diff --git a/afterpay/src/main/kotlin/com/afterpay/android/AfterpayEnvironment.kt b/afterpay/src/main/kotlin/com/afterpay/android/AfterpayEnvironment.kt
index 3d667e1b..a660cbc5 100644
--- a/afterpay/src/main/kotlin/com/afterpay/android/AfterpayEnvironment.kt
+++ b/afterpay/src/main/kotlin/com/afterpay/android/AfterpayEnvironment.kt
@@ -5,5 +5,5 @@ import java.util.Locale
enum class AfterpayEnvironment {
SANDBOX, PRODUCTION;
- override fun toString(): String = name.toLowerCase(Locale.ROOT)
+ override fun toString(): String = name.lowercase(Locale.ROOT)
}
diff --git a/afterpay/src/main/kotlin/com/afterpay/android/CancellationStatus.kt b/afterpay/src/main/kotlin/com/afterpay/android/CancellationStatus.kt
index f893f1e7..11f08229 100644
--- a/afterpay/src/main/kotlin/com/afterpay/android/CancellationStatus.kt
+++ b/afterpay/src/main/kotlin/com/afterpay/android/CancellationStatus.kt
@@ -12,5 +12,5 @@ enum class CancellationStatus {
enum class CancellationStatusV3 {
USER_INITIATED,
CONFIGURATION_ERROR,
- REQUEST_ERROR
+ REQUEST_ERROR,
}
diff --git a/afterpay/src/main/kotlin/com/afterpay/android/internal/AfterpayCheckoutCompletion.kt b/afterpay/src/main/kotlin/com/afterpay/android/internal/AfterpayCheckoutCompletion.kt
index 8e1e6018..59aae95e 100644
--- a/afterpay/src/main/kotlin/com/afterpay/android/internal/AfterpayCheckoutCompletion.kt
+++ b/afterpay/src/main/kotlin/com/afterpay/android/internal/AfterpayCheckoutCompletion.kt
@@ -5,13 +5,13 @@ import kotlinx.serialization.Serializable
@Serializable
internal data class AfterpayCheckoutCompletion(
val status: Status,
- val orderToken: String
+ val orderToken: String,
) {
@Suppress("UNUSED_PARAMETER")
@Serializable
internal enum class Status(statusString: String) {
SUCCESS("SUCCESS"),
- CANCELLED("CANCELLED")
+ CANCELLED("CANCELLED"),
}
}
diff --git a/afterpay/src/main/kotlin/com/afterpay/android/internal/AfterpayCheckoutMessage.kt b/afterpay/src/main/kotlin/com/afterpay/android/internal/AfterpayCheckoutMessage.kt
index f0eefab0..7b13f84b 100644
--- a/afterpay/src/main/kotlin/com/afterpay/android/internal/AfterpayCheckoutMessage.kt
+++ b/afterpay/src/main/kotlin/com/afterpay/android/internal/AfterpayCheckoutMessage.kt
@@ -24,7 +24,7 @@ internal sealed class AfterpayCheckoutMessage {
fun fromShippingOptionsResult(
result: ShippingOptionsResult,
- meta: AfterpayCheckoutMessageMeta
+ meta: AfterpayCheckoutMessageMeta,
): AfterpayCheckoutMessage = when (result) {
is ShippingOptionsErrorResult -> CheckoutErrorMessage(meta, result.error.name)
is ShippingOptionsSuccessResult -> ShippingOptionsMessage(meta, result.shippingOptions)
@@ -32,12 +32,12 @@ internal sealed class AfterpayCheckoutMessage {
fun fromShippingOptionUpdateResult(
result: ShippingOptionUpdateResult?,
- meta: AfterpayCheckoutMessageMeta
+ meta: AfterpayCheckoutMessageMeta,
): AfterpayCheckoutMessage = when (result) {
is ShippingOptionUpdateErrorResult -> CheckoutErrorMessage(meta, result.error.name)
is ShippingOptionUpdateSuccessResult -> ShippingOptionUpdateMessage(
meta,
- result.shippingOptionUpdate
+ result.shippingOptionUpdate,
)
null -> EmptyPayloadMessage(meta)
}
@@ -48,13 +48,13 @@ internal sealed class AfterpayCheckoutMessage {
@SerialName("onMessage")
internal data class CheckoutLogMessage(
override val meta: AfterpayCheckoutMessageMeta,
- val payload: CheckoutLog
+ val payload: CheckoutLog,
) : AfterpayCheckoutMessage() {
@Serializable
internal data class CheckoutLog(
val severity: String,
- val message: String
+ val message: String,
)
}
@@ -62,39 +62,39 @@ internal data class CheckoutLogMessage(
@SerialName("onError")
internal data class CheckoutErrorMessage(
override val meta: AfterpayCheckoutMessageMeta,
- val error: String
+ val error: String,
) : AfterpayCheckoutMessage()
@Serializable
@SerialName("onShippingAddressChange")
internal data class ShippingAddressMessage(
override val meta: AfterpayCheckoutMessageMeta,
- val payload: ShippingAddress
+ val payload: ShippingAddress,
) : AfterpayCheckoutMessage()
@Serializable
@SerialName("onShippingOptionChange")
internal data class ShippingOptionMessage(
override val meta: AfterpayCheckoutMessageMeta,
- val payload: ShippingOption
+ val payload: ShippingOption,
) : AfterpayCheckoutMessage()
@Serializable
@SerialName("onShippingOptionUpdateChange")
internal data class ShippingOptionUpdateMessage(
override val meta: AfterpayCheckoutMessageMeta,
- val payload: ShippingOptionUpdate?
+ val payload: ShippingOptionUpdate?,
) : AfterpayCheckoutMessage()
@Serializable
@SerialName("onShippingOptionsChange")
internal data class ShippingOptionsMessage(
override val meta: AfterpayCheckoutMessageMeta,
- val payload: List
+ val payload: List,
) : AfterpayCheckoutMessage()
@Serializable
@SerialName("onEmptyPayload")
internal data class EmptyPayloadMessage(
- override val meta: AfterpayCheckoutMessageMeta
+ override val meta: AfterpayCheckoutMessageMeta,
) : AfterpayCheckoutMessage()
diff --git a/afterpay/src/main/kotlin/com/afterpay/android/internal/AfterpayCheckoutV2.kt b/afterpay/src/main/kotlin/com/afterpay/android/internal/AfterpayCheckoutV2.kt
index b70a5bda..8af592b8 100644
--- a/afterpay/src/main/kotlin/com/afterpay/android/internal/AfterpayCheckoutV2.kt
+++ b/afterpay/src/main/kotlin/com/afterpay/android/internal/AfterpayCheckoutV2.kt
@@ -21,7 +21,7 @@ internal data class AfterpayCheckoutV2(
constructor(
token: String,
configuration: Configuration,
- options: AfterpayCheckoutV2Options
+ options: AfterpayCheckoutV2Options,
) : this(
token = token,
locale = configuration.locale.toString(),
@@ -31,6 +31,6 @@ internal data class AfterpayCheckoutV2(
buyNow = options.buyNow,
shippingOptionRequired = options.shippingOptionRequired,
checkoutRedesignForced = options.enableSingleShippingOptionUpdate,
- consumerLocale = Afterpay.language.toString()
+ consumerLocale = Afterpay.language.toString(),
)
}
diff --git a/afterpay/src/main/kotlin/com/afterpay/android/internal/AfterpayDrawable.kt b/afterpay/src/main/kotlin/com/afterpay/android/internal/AfterpayDrawable.kt
index 7ae7d2b2..0597b40b 100644
--- a/afterpay/src/main/kotlin/com/afterpay/android/internal/AfterpayDrawable.kt
+++ b/afterpay/src/main/kotlin/com/afterpay/android/internal/AfterpayDrawable.kt
@@ -66,7 +66,8 @@ internal enum class AfterpayDrawable(
buttonCheckoutForeground = R.drawable.clearpay_button_checkout_fg_es,
buttonPayNowForeground = R.drawable.clearpay_button_pay_now_fg_es,
buttonPlaceOrderForeground = R.drawable.clearpay_button_place_order_fg_es,
- );
+ ),
+ ;
companion object {
fun forLocale(): AfterpayDrawable {
diff --git a/afterpay/src/main/kotlin/com/afterpay/android/internal/AfterpayInstalment.kt b/afterpay/src/main/kotlin/com/afterpay/android/internal/AfterpayInstalment.kt
index 5cd00eac..0c9ead9c 100644
--- a/afterpay/src/main/kotlin/com/afterpay/android/internal/AfterpayInstalment.kt
+++ b/afterpay/src/main/kotlin/com/afterpay/android/internal/AfterpayInstalment.kt
@@ -10,12 +10,12 @@ import java.util.Locale
internal sealed class AfterpayInstalment {
data class Available(
- val instalmentAmount: String
+ val instalmentAmount: String,
) : AfterpayInstalment()
data class NotAvailable(
val minimumAmount: String?,
- val maximumAmount: String
+ val maximumAmount: String,
) : AfterpayInstalment()
object NoConfiguration : AfterpayInstalment()
@@ -84,7 +84,7 @@ internal sealed class AfterpayInstalment {
return NotAvailable(
minimumAmount = configuration.minimumAmount?.let(currencyFormatterNoDecimals::format),
- maximumAmount = currencyFormatterNoDecimals.format(configuration.maximumAmount)
+ maximumAmount = currencyFormatterNoDecimals.format(configuration.maximumAmount),
)
}
diff --git a/afterpay/src/main/kotlin/com/afterpay/android/internal/AfterpayString.kt b/afterpay/src/main/kotlin/com/afterpay/android/internal/AfterpayString.kt
index 46f89b60..cb0f0da4 100644
--- a/afterpay/src/main/kotlin/com/afterpay/android/internal/AfterpayString.kt
+++ b/afterpay/src/main/kotlin/com/afterpay/android/internal/AfterpayString.kt
@@ -53,7 +53,7 @@ internal enum class AfterpayString(
val priceBreakdownWith: String,
val priceBreakdownInterestFree: String,
val priceBreakdownLinkLearnMore: String,
- val priceBreakdownLinkMoreInfo: String
+ val priceBreakdownLinkMoreInfo: String,
) {
EN(
breakdownLimit = "available for orders between %1\$s – %2\$s",
@@ -80,7 +80,7 @@ internal enum class AfterpayString(
priceBreakdownWith = "with ",
priceBreakdownInterestFree = "interest-free ",
priceBreakdownLinkLearnMore = "Learn More",
- priceBreakdownLinkMoreInfo = "More Info"
+ priceBreakdownLinkMoreInfo = "More Info",
),
FR_CA(
breakdownLimit = "disponible pour les montants entre %1\$s – %2\$s",
@@ -189,7 +189,8 @@ internal enum class AfterpayString(
priceBreakdownInterestFree = "sin coste ",
priceBreakdownLinkLearnMore = "Saber más",
priceBreakdownLinkMoreInfo = "Más infos",
- );
+ ),
+ ;
companion object {
fun forLocale(): AfterpayString {
diff --git a/afterpay/src/main/kotlin/com/afterpay/android/internal/ApiV3.kt b/afterpay/src/main/kotlin/com/afterpay/android/internal/ApiV3.kt
index 04947e66..9561fcb9 100644
--- a/afterpay/src/main/kotlin/com/afterpay/android/internal/ApiV3.kt
+++ b/afterpay/src/main/kotlin/com/afterpay/android/internal/ApiV3.kt
@@ -129,6 +129,6 @@ internal object ApiV3 {
val errorCode: String,
val errorId: String,
val message: String,
- val httpStatusCode: Int
+ val httpStatusCode: Int,
)
}
diff --git a/afterpay/src/main/kotlin/com/afterpay/android/internal/Brand.kt b/afterpay/src/main/kotlin/com/afterpay/android/internal/Brand.kt
index c62440fb..3b956eeb 100644
--- a/afterpay/src/main/kotlin/com/afterpay/android/internal/Brand.kt
+++ b/afterpay/src/main/kotlin/com/afterpay/android/internal/Brand.kt
@@ -38,7 +38,8 @@ internal enum class Brand(
description = R.string.clearpay_service_name_description,
badgeForeground = R.drawable.clearpay_badge_fg,
lockup = R.drawable.clearpay_lockup,
- );
+ ),
+ ;
companion object {
diff --git a/afterpay/src/main/kotlin/com/afterpay/android/internal/CheckoutV3.kt b/afterpay/src/main/kotlin/com/afterpay/android/internal/CheckoutV3.kt
index ba79d293..a8189d4d 100644
--- a/afterpay/src/main/kotlin/com/afterpay/android/internal/CheckoutV3.kt
+++ b/afterpay/src/main/kotlin/com/afterpay/android/internal/CheckoutV3.kt
@@ -17,7 +17,7 @@ internal object CheckoutV3 {
val merchantReference: String,
val token: String,
val singleUseCardToken: String,
- val ppaConfirmToken: String
+ val ppaConfirmToken: String,
)
@Serializable
@@ -25,7 +25,7 @@ internal object CheckoutV3 {
val token: String,
val confirmMustBeCalledBefore: String?,
val redirectCheckoutUrl: String,
- val singleUseCardToken: String
+ val singleUseCardToken: String,
)
@Serializable
@@ -41,7 +41,7 @@ internal object CheckoutV3 {
val consumer: Consumer,
val merchant: Merchant,
val shipping: Contact?,
- val billing: Contact?
+ val billing: Contact?,
) {
companion object {
@JvmStatic
@@ -49,7 +49,7 @@ internal object CheckoutV3 {
consumer: CheckoutV3Consumer,
orderTotal: OrderTotal,
items: Array,
- configuration: CheckoutV3Configuration
+ configuration: CheckoutV3Configuration,
): Request {
val currency = Currency.getInstance(configuration.region.currencyCode)
@@ -58,7 +58,7 @@ internal object CheckoutV3 {
shopDirectoryMerchantId = configuration.shopDirectoryMerchantId,
amount = Money(
orderTotal.total,
- currency
+ currency,
),
shippingAmount = Money(orderTotal.shipping, currency),
taxAmount = Money(orderTotal.tax, currency),
@@ -67,14 +67,14 @@ internal object CheckoutV3 {
email = consumer.email,
givenNames = consumer.givenNames,
surname = consumer.surname,
- phoneNumber = consumer.phoneNumber
+ phoneNumber = consumer.phoneNumber,
),
merchant = Merchant(
redirectConfirmUrl = "https://static.afterpay.com",
- redirectCancelUrl = "https://static.afterpay.com"
+ redirectCancelUrl = "https://static.afterpay.com",
),
shipping = Contact.create(consumer.shippingInformation),
- billing = Contact.create(consumer.billingInformation)
+ billing = Contact.create(consumer.billingInformation),
)
}
}
@@ -89,7 +89,7 @@ internal object CheckoutV3 {
val pageUrl: String?,
val imageUrl: String?,
val categories: List>?,
- val estimatedShipmentDate: String?
+ val estimatedShipmentDate: String?,
) {
companion object {
@JvmStatic
@@ -103,7 +103,7 @@ internal object CheckoutV3 {
pageUrl = item.pageUrl.toString(),
imageUrl = item.imageUrl.toString(),
categories = item.categories,
- estimatedShipmentDate = item.estimatedShipmentDate
+ estimatedShipmentDate = item.estimatedShipmentDate,
)
}
}
@@ -112,7 +112,7 @@ internal object CheckoutV3 {
@Serializable
data class Merchant(
val redirectConfirmUrl: String,
- val redirectCancelUrl: String
+ val redirectCancelUrl: String,
)
@Serializable
@@ -120,7 +120,7 @@ internal object CheckoutV3 {
val email: String,
val givenNames: String?,
val surname: String?,
- val phoneNumber: String?
+ val phoneNumber: String?,
)
@Serializable
@@ -133,7 +133,7 @@ internal object CheckoutV3 {
val region: String?,
val postcode: String?,
val countryCode: String,
- val phoneNumber: String?
+ val phoneNumber: String?,
) {
companion object {
@JvmStatic
@@ -148,7 +148,7 @@ internal object CheckoutV3 {
region = contact.region,
postcode = contact.postcode,
countryCode = contact.countryCode,
- phoneNumber = contact.phoneNumber
+ phoneNumber = contact.phoneNumber,
)
}
}
@@ -160,13 +160,13 @@ internal object CheckoutV3 {
data class Response(
val paymentDetails: PaymentDetails,
val cardValidUntil: String?,
- val authToken: String
+ val authToken: String,
)
@Serializable
data class PaymentDetails(
val virtualCard: VirtualCard.Card? = null,
- val virtualCardToken: VirtualCard.TokenizedCard? = null
+ val virtualCardToken: VirtualCard.TokenizedCard? = null,
)
}
}
diff --git a/afterpay/src/main/kotlin/com/afterpay/android/internal/CheckoutV3ViewModel.kt b/afterpay/src/main/kotlin/com/afterpay/android/internal/CheckoutV3ViewModel.kt
index 1f1a3113..282ff869 100644
--- a/afterpay/src/main/kotlin/com/afterpay/android/internal/CheckoutV3ViewModel.kt
+++ b/afterpay/src/main/kotlin/com/afterpay/android/internal/CheckoutV3ViewModel.kt
@@ -29,7 +29,7 @@ class CheckoutV3ViewModel(private var options: AfterpayCheckoutV3Options) : View
options = options.copy(
redirectUrl = url,
singleUseCardToken = response.singleUseCardToken,
- token = response.token
+ token = response.token,
)
url
}
@@ -42,21 +42,21 @@ class CheckoutV3ViewModel(private var options: AfterpayCheckoutV3Options) : View
val tokens = CheckoutV3Tokens(
token = requireNotNull(options.token),
singleUseCardToken = requireNotNull(options.singleUseCardToken),
- ppaConfirmToken = ppaConfirmToken
+ ppaConfirmToken = ppaConfirmToken,
)
val response = withContext(Dispatchers.IO) {
ApiV3.request(
confirmationUrl,
ApiV3.HttpVerb.POST,
- tokens
+ tokens,
)
}.getOrThrow()
CheckoutV3Data(
cardDetails = response.paymentDetails.virtualCard ?: response.paymentDetails.virtualCardToken!!,
cardValidUntilInternal = response.cardValidUntil,
- tokens = tokens
+ tokens = tokens,
)
}
}
diff --git a/afterpay/src/main/kotlin/com/afterpay/android/internal/Intent.kt b/afterpay/src/main/kotlin/com/afterpay/android/internal/Intent.kt
index 24f66cf7..28b316ae 100644
--- a/afterpay/src/main/kotlin/com/afterpay/android/internal/Intent.kt
+++ b/afterpay/src/main/kotlin/com/afterpay/android/internal/Intent.kt
@@ -19,6 +19,7 @@ private object AfterpayIntent {
const val CANCELLATION_STATUS = "AFTERPAY_CANCELLATION_STATUS"
const val CANCELLATION_ERROR = "AFTERPAY_CANCELLATION_ERROR"
const val RESULT_DATA_V3 = "AFTERPAY_RESULT_DATA_V3"
+ const val SHOULD_LOAD_REDIRECT_URLS = "AFTERPAY_SHOULD_LOAD_REDIRECT_URLS"
}
internal fun Intent.putCheckoutUrlExtra(url: String): Intent =
@@ -27,6 +28,12 @@ internal fun Intent.putCheckoutUrlExtra(url: String): Intent =
internal fun Intent.getCheckoutUrlExtra(): String? =
getStringExtra(AfterpayIntent.CHECKOUT_URL)
+internal fun Intent.putCheckoutShouldLoadRedirectUrls(bool: Boolean): Intent =
+ putExtra(AfterpayIntent.SHOULD_LOAD_REDIRECT_URLS, bool)
+
+internal fun Intent.getCheckoutShouldLoadRedirectUrls(): Boolean =
+ getBooleanExtra(AfterpayIntent.SHOULD_LOAD_REDIRECT_URLS, false)
+
internal fun Intent.putCheckoutV2OptionsExtra(options: AfterpayCheckoutV2Options): Intent =
putExtra(AfterpayIntent.CHECKOUT_OPTIONS, options)
diff --git a/afterpay/src/main/kotlin/com/afterpay/android/internal/Locales.kt b/afterpay/src/main/kotlin/com/afterpay/android/internal/Locales.kt
index b10a5bd2..19effbb2 100644
--- a/afterpay/src/main/kotlin/com/afterpay/android/internal/Locales.kt
+++ b/afterpay/src/main/kotlin/com/afterpay/android/internal/Locales.kt
@@ -33,7 +33,7 @@ internal object Locales {
EN_US,
IT_IT,
FR_FR,
- ES_ES
+ ES_ES,
)
}
diff --git a/afterpay/src/main/kotlin/com/afterpay/android/internal/Resources.kt b/afterpay/src/main/kotlin/com/afterpay/android/internal/Resources.kt
index 1a39739d..f8ef1e10 100644
--- a/afterpay/src/main/kotlin/com/afterpay/android/internal/Resources.kt
+++ b/afterpay/src/main/kotlin/com/afterpay/android/internal/Resources.kt
@@ -18,7 +18,7 @@ internal val Float.dp: Float
get() = TypedValue.applyDimension(
TypedValue.COMPLEX_UNIT_DIP,
this,
- Resources.getSystem().displayMetrics
+ Resources.getSystem().displayMetrics,
)
internal val Int.dp: Int
@@ -40,7 +40,7 @@ internal fun Context.color(@ColorRes colorResId: Int): Int {
internal fun Context.coloredDrawable(
@DrawableRes drawableResId: Int,
- @ColorRes colorResId: Int
+ @ColorRes colorResId: Int,
): Drawable = ContextCompat.getDrawable(this, drawableResId).let {
checkNotNull(it) { "Drawable resource not found" }
val wrappedDrawable = DrawableCompat.wrap(it)
@@ -50,9 +50,9 @@ internal fun Context.coloredDrawable(
internal fun Context.rippleDrawable(
@ColorRes rippleColorResId: Int,
- drawable: Drawable
+ drawable: Drawable,
): Drawable = RippleDrawable(
ColorStateList.valueOf(color(rippleColorResId)),
drawable,
- null
+ null,
)
diff --git a/afterpay/src/main/kotlin/com/afterpay/android/internal/Serializers.kt b/afterpay/src/main/kotlin/com/afterpay/android/internal/Serializers.kt
index d1287b1c..f99f35d6 100644
--- a/afterpay/src/main/kotlin/com/afterpay/android/internal/Serializers.kt
+++ b/afterpay/src/main/kotlin/com/afterpay/android/internal/Serializers.kt
@@ -19,7 +19,7 @@ internal object MoneyBigDecimalSerializer : KSerializer {
override val descriptor = PrimitiveSerialDescriptor(
serialName = "BigDecimal",
- kind = PrimitiveKind.STRING
+ kind = PrimitiveKind.STRING,
)
override fun deserialize(decoder: Decoder) = decoder.decodeString().toBigDecimal()
@@ -27,7 +27,7 @@ internal object MoneyBigDecimalSerializer : KSerializer {
// Round to two decimals, as per ISO-4217, using banker's rounding
override fun serialize(encoder: Encoder, value: BigDecimal) {
return encoder.encodeString(
- value.setScale(2, RoundingMode.HALF_EVEN).toPlainString()
+ value.setScale(2, RoundingMode.HALF_EVEN).toPlainString(),
)
}
}
@@ -36,7 +36,7 @@ internal object CurrencySerializer : KSerializer {
override val descriptor = PrimitiveSerialDescriptor(
serialName = "Currency",
- kind = PrimitiveKind.STRING
+ kind = PrimitiveKind.STRING,
)
override fun deserialize(decoder: Decoder): Currency =
diff --git a/afterpay/src/main/kotlin/com/afterpay/android/model/AfterpayRegion.kt b/afterpay/src/main/kotlin/com/afterpay/android/model/AfterpayRegion.kt
index 250ab841..c5ea8f0e 100644
--- a/afterpay/src/main/kotlin/com/afterpay/android/model/AfterpayRegion.kt
+++ b/afterpay/src/main/kotlin/com/afterpay/android/model/AfterpayRegion.kt
@@ -5,5 +5,5 @@ import java.util.Locale
enum class AfterpayRegion(val locale: Locale, val currencyCode: String) {
US(Locales.EN_US, "USD"),
- CA(Locales.EN_CA, "CAD")
+ CA(Locales.EN_CA, "CAD"),
}
diff --git a/afterpay/src/main/kotlin/com/afterpay/android/model/CheckoutV3Configuration.kt b/afterpay/src/main/kotlin/com/afterpay/android/model/CheckoutV3Configuration.kt
index 961187ad..eeeb3c86 100644
--- a/afterpay/src/main/kotlin/com/afterpay/android/model/CheckoutV3Configuration.kt
+++ b/afterpay/src/main/kotlin/com/afterpay/android/model/CheckoutV3Configuration.kt
@@ -7,7 +7,7 @@ import java.net.URL
data class CheckoutV3Configuration(
val shopDirectoryMerchantId: String,
val region: AfterpayRegion,
- val environment: AfterpayEnvironment
+ val environment: AfterpayEnvironment,
) {
internal val shopDirectoryId: String
get() = when (region) {
diff --git a/afterpay/src/main/kotlin/com/afterpay/android/model/CheckoutV3Consumer.kt b/afterpay/src/main/kotlin/com/afterpay/android/model/CheckoutV3Consumer.kt
index 444f33ca..0b605694 100644
--- a/afterpay/src/main/kotlin/com/afterpay/android/model/CheckoutV3Consumer.kt
+++ b/afterpay/src/main/kotlin/com/afterpay/android/model/CheckoutV3Consumer.kt
@@ -3,14 +3,19 @@ package com.afterpay.android.model
interface CheckoutV3Consumer {
/** The consumer’s email address. Limited to 128 characters. **/
val email: String
+
/** The consumer’s first name and any middle names. Limited to 128 characters. **/
val givenNames: String?
+
/** The consumer’s last name. Limited to 128 characters. **/
val surname: String?
+
/** The consumer’s phone number. Limited to 32 characters. **/
val phoneNumber: String?
+
/** The consumer's shipping information. **/
val shippingInformation: CheckoutV3Contact?
+
/** The consumer's billing information. **/
val billingInformation: CheckoutV3Contact?
}
diff --git a/afterpay/src/main/kotlin/com/afterpay/android/model/CheckoutV3Contact.kt b/afterpay/src/main/kotlin/com/afterpay/android/model/CheckoutV3Contact.kt
index 5f8681fb..388dfb73 100644
--- a/afterpay/src/main/kotlin/com/afterpay/android/model/CheckoutV3Contact.kt
+++ b/afterpay/src/main/kotlin/com/afterpay/android/model/CheckoutV3Contact.kt
@@ -3,22 +3,30 @@ package com.afterpay.android.model
interface CheckoutV3Contact {
/** Full name of contact. Limited to 255 characters */
var name: String
+
/** First line of the address. Limited to 128 characters */
var line1: String
+
/** Second line of the address. Limited to 128 characters. */
var line2: String?
+
/** Australian suburb, U.S. city, New Zealand town or city, U.K. Postal town.
* Maximum length is 128 characters.
*/
var area1: String?
+
/** New Zealand suburb, U.K. village or local area. Maximum length is 128 characters. */
var area2: String?
+
/** U.S. state, Australian state, U.K. county, New Zealand region. Maximum length is 128 characters. */
var region: String?
+
/** The zip code or equivalent. Maximum length is 128 characters. */
var postcode: String?
+
/** The two-character ISO 3166-1 country code. */
var countryCode: String
+
/** The phone number, in E.123 format. Maximum length is 32 characters. */
var phoneNumber: String?
}
diff --git a/afterpay/src/main/kotlin/com/afterpay/android/model/CheckoutV3Data.kt b/afterpay/src/main/kotlin/com/afterpay/android/model/CheckoutV3Data.kt
index 6bca1eb9..1baa376b 100644
--- a/afterpay/src/main/kotlin/com/afterpay/android/model/CheckoutV3Data.kt
+++ b/afterpay/src/main/kotlin/com/afterpay/android/model/CheckoutV3Data.kt
@@ -16,12 +16,12 @@ data class CheckoutV3Data(
/** The time before which an authorization needs to be made on the virtual card. */
internal val cardValidUntilInternal: String?,
/** The collection of tokens required to update the merchant reference or cancel the virtual card */
- val tokens: CheckoutV3Tokens
+ val tokens: CheckoutV3Tokens,
) : Parcelable {
constructor(parcel: Parcel) : this(
cardDetails = parcel.readString()?.let { Json.decodeFromString(it) } ?: throw IllegalArgumentException("Missing Serialized value for `cardDetails`"),
cardValidUntilInternal = parcel.readString(),
- tokens = parcel.readString()?.let { Json.decodeFromString(it) } ?: throw IllegalArgumentException("Missing Serialized value `tokens`")
+ tokens = parcel.readString()?.let { Json.decodeFromString(it) } ?: throw IllegalArgumentException("Missing Serialized value `tokens`"),
)
override fun writeToParcel(parcel: Parcel, flags: Int) {
diff --git a/afterpay/src/main/kotlin/com/afterpay/android/model/CheckoutV3Item.kt b/afterpay/src/main/kotlin/com/afterpay/android/model/CheckoutV3Item.kt
index 3ed732bf..bf608ef9 100644
--- a/afterpay/src/main/kotlin/com/afterpay/android/model/CheckoutV3Item.kt
+++ b/afterpay/src/main/kotlin/com/afterpay/android/model/CheckoutV3Item.kt
@@ -6,22 +6,29 @@ import java.net.URL
interface CheckoutV3Item {
/** Product name. Limited to 255 characters. */
val name: String
+
/** The quantity of the item, stored as a signed 32-bit integer. */
val quantity: UInt
+
/** The unit price of the individual item. Must be a positive value. */
val price: BigDecimal
+
/** Product SKU. Limited to 128 characters. */
val sku: String?
+
/** The canonical URL for the item's Product Detail Page. Limited to 2048 characters. */
val pageUrl: URL?
+
/** A URL for a web-optimised photo of the item, suitable for use directly as the src attribute of an img tag.
* Limited to 2048 characters.
*/
val imageUrl: URL?
+
/** An array of arrays to accommodate multiple categories that might apply to the item.
* Each array contains comma separated strings with the left-most category being the top level category.
*/
val categories: List>?
+
/** The estimated date when the order will be shipped. YYYY-MM or YYYY-MM-DD format. */
val estimatedShipmentDate: String?
}
diff --git a/afterpay/src/main/kotlin/com/afterpay/android/model/CheckoutV3Tokens.kt b/afterpay/src/main/kotlin/com/afterpay/android/model/CheckoutV3Tokens.kt
index 0a4ddf17..f4b74051 100644
--- a/afterpay/src/main/kotlin/com/afterpay/android/model/CheckoutV3Tokens.kt
+++ b/afterpay/src/main/kotlin/com/afterpay/android/model/CheckoutV3Tokens.kt
@@ -6,5 +6,5 @@ import kotlinx.serialization.Serializable
data class CheckoutV3Tokens(
val token: String,
val singleUseCardToken: String,
- val ppaConfirmToken: String
+ val ppaConfirmToken: String,
)
diff --git a/afterpay/src/main/kotlin/com/afterpay/android/model/Configuration.kt b/afterpay/src/main/kotlin/com/afterpay/android/model/Configuration.kt
index ba316a0b..dc3fd13a 100644
--- a/afterpay/src/main/kotlin/com/afterpay/android/model/Configuration.kt
+++ b/afterpay/src/main/kotlin/com/afterpay/android/model/Configuration.kt
@@ -10,5 +10,5 @@ data class Configuration(
val maximumAmount: BigDecimal,
val currency: Currency,
val locale: Locale,
- val environment: AfterpayEnvironment
+ val environment: AfterpayEnvironment,
)
diff --git a/afterpay/src/main/kotlin/com/afterpay/android/model/Consumer.kt b/afterpay/src/main/kotlin/com/afterpay/android/model/Consumer.kt
index 9f8bd5a6..b3a8fad0 100644
--- a/afterpay/src/main/kotlin/com/afterpay/android/model/Consumer.kt
+++ b/afterpay/src/main/kotlin/com/afterpay/android/model/Consumer.kt
@@ -9,5 +9,5 @@ data class Consumer(
override var surname: String? = null,
override var phoneNumber: String? = null,
override var shippingInformation: CheckoutV3Contact? = null,
- override var billingInformation: CheckoutV3Contact? = null
+ override var billingInformation: CheckoutV3Contact? = null,
) : CheckoutV3Consumer
diff --git a/afterpay/src/main/kotlin/com/afterpay/android/model/MerchantConfigurationV3.kt b/afterpay/src/main/kotlin/com/afterpay/android/model/MerchantConfigurationV3.kt
index 53308d17..b0fd7ed4 100644
--- a/afterpay/src/main/kotlin/com/afterpay/android/model/MerchantConfigurationV3.kt
+++ b/afterpay/src/main/kotlin/com/afterpay/android/model/MerchantConfigurationV3.kt
@@ -5,5 +5,5 @@ import kotlinx.serialization.Serializable
@Serializable
data class MerchantConfigurationV3(
val minimumAmount: Money,
- val maximumAmount: Money
+ val maximumAmount: Money,
)
diff --git a/afterpay/src/main/kotlin/com/afterpay/android/model/Money.kt b/afterpay/src/main/kotlin/com/afterpay/android/model/Money.kt
index 5dff91de..1b793c5e 100644
--- a/afterpay/src/main/kotlin/com/afterpay/android/model/Money.kt
+++ b/afterpay/src/main/kotlin/com/afterpay/android/model/Money.kt
@@ -9,5 +9,5 @@ import java.util.Currency
@Serializable
data class Money(
@Serializable(with = MoneyBigDecimalSerializer::class) val amount: BigDecimal,
- @Serializable(with = CurrencySerializer::class) val currency: Currency
+ @Serializable(with = CurrencySerializer::class) val currency: Currency,
)
diff --git a/afterpay/src/main/kotlin/com/afterpay/android/model/OrderTotal.kt b/afterpay/src/main/kotlin/com/afterpay/android/model/OrderTotal.kt
index fe264d88..27704647 100644
--- a/afterpay/src/main/kotlin/com/afterpay/android/model/OrderTotal.kt
+++ b/afterpay/src/main/kotlin/com/afterpay/android/model/OrderTotal.kt
@@ -13,5 +13,5 @@ data class OrderTotal(
/** The shipping amount, included for fraud detection purposes. */
val shipping: BigDecimal,
/** The tax amount, included for fraud detection purposes. */
- val tax: BigDecimal
+ val tax: BigDecimal,
)
diff --git a/afterpay/src/main/kotlin/com/afterpay/android/model/ShippingAddress.kt b/afterpay/src/main/kotlin/com/afterpay/android/model/ShippingAddress.kt
index 216f3762..0b54be71 100644
--- a/afterpay/src/main/kotlin/com/afterpay/android/model/ShippingAddress.kt
+++ b/afterpay/src/main/kotlin/com/afterpay/android/model/ShippingAddress.kt
@@ -11,5 +11,5 @@ data class ShippingAddress(
val postcode: String?,
val phoneNumber: String? = null,
val state: String? = null,
- val suburb: String? = null
+ val suburb: String? = null,
)
diff --git a/afterpay/src/main/kotlin/com/afterpay/android/model/ShippingOption.kt b/afterpay/src/main/kotlin/com/afterpay/android/model/ShippingOption.kt
index 5476fcd4..7f07f333 100644
--- a/afterpay/src/main/kotlin/com/afterpay/android/model/ShippingOption.kt
+++ b/afterpay/src/main/kotlin/com/afterpay/android/model/ShippingOption.kt
@@ -9,5 +9,5 @@ data class ShippingOption(
val description: String,
var shippingAmount: Money,
var orderAmount: Money,
- var taxAmount: Money?
+ var taxAmount: Money?,
)
diff --git a/afterpay/src/main/kotlin/com/afterpay/android/model/ShippingOptionUpdate.kt b/afterpay/src/main/kotlin/com/afterpay/android/model/ShippingOptionUpdate.kt
index 2f988e0e..57378c24 100644
--- a/afterpay/src/main/kotlin/com/afterpay/android/model/ShippingOptionUpdate.kt
+++ b/afterpay/src/main/kotlin/com/afterpay/android/model/ShippingOptionUpdate.kt
@@ -7,5 +7,5 @@ data class ShippingOptionUpdate(
val id: String,
var shippingAmount: Money,
var orderAmount: Money,
- var taxAmount: Money?
+ var taxAmount: Money?,
)
diff --git a/afterpay/src/main/kotlin/com/afterpay/android/model/ShippingOptionUpdateResult.kt b/afterpay/src/main/kotlin/com/afterpay/android/model/ShippingOptionUpdateResult.kt
index cf7b044b..67aa1fa8 100644
--- a/afterpay/src/main/kotlin/com/afterpay/android/model/ShippingOptionUpdateResult.kt
+++ b/afterpay/src/main/kotlin/com/afterpay/android/model/ShippingOptionUpdateResult.kt
@@ -3,14 +3,14 @@ package com.afterpay.android.model
sealed class ShippingOptionUpdateResult
data class ShippingOptionUpdateSuccessResult(
- val shippingOptionUpdate: ShippingOptionUpdate
+ val shippingOptionUpdate: ShippingOptionUpdate,
) : ShippingOptionUpdateResult()
data class ShippingOptionUpdateErrorResult(
- val error: ShippingOptionUpdateError
+ val error: ShippingOptionUpdateError,
) : ShippingOptionUpdateResult()
enum class ShippingOptionUpdateError {
SERVICE_UNAVAILABLE,
- BAD_RESPONSE
+ BAD_RESPONSE,
}
diff --git a/afterpay/src/main/kotlin/com/afterpay/android/model/ShippingOptionsResult.kt b/afterpay/src/main/kotlin/com/afterpay/android/model/ShippingOptionsResult.kt
index 4e7e0877..3e50bb33 100644
--- a/afterpay/src/main/kotlin/com/afterpay/android/model/ShippingOptionsResult.kt
+++ b/afterpay/src/main/kotlin/com/afterpay/android/model/ShippingOptionsResult.kt
@@ -3,16 +3,16 @@ package com.afterpay.android.model
sealed class ShippingOptionsResult
data class ShippingOptionsSuccessResult(
- val shippingOptions: List
+ val shippingOptions: List,
) : ShippingOptionsResult()
data class ShippingOptionsErrorResult(
- val error: ShippingOptionsError
+ val error: ShippingOptionsError,
) : ShippingOptionsResult()
enum class ShippingOptionsError {
SHIPPING_ADDRESS_UNRECOGNIZED,
SHIPPING_ADDRESS_UNSUPPORTED,
SERVICE_UNAVAILABLE,
- BAD_RESPONSE
+ BAD_RESPONSE,
}
diff --git a/afterpay/src/main/kotlin/com/afterpay/android/model/VirtualCard.kt b/afterpay/src/main/kotlin/com/afterpay/android/model/VirtualCard.kt
index 75c68346..ca59da46 100644
--- a/afterpay/src/main/kotlin/com/afterpay/android/model/VirtualCard.kt
+++ b/afterpay/src/main/kotlin/com/afterpay/android/model/VirtualCard.kt
@@ -13,7 +13,7 @@ sealed class VirtualCard {
val cvc: String,
private val expiry: String,
@Transient var expiryYear: Int = -1,
- @Transient var expiryMonth: Int = -1
+ @Transient var expiryMonth: Int = -1,
) : VirtualCard() {
init {
val components = expiry.split("-").map { it.toInt() }
@@ -28,7 +28,7 @@ sealed class VirtualCard {
val cardToken: String?,
private val expiry: String,
@Transient var expiryYear: Int = -1,
- @Transient var expiryMonth: Int = -1
+ @Transient var expiryMonth: Int = -1,
) : VirtualCard() {
init {
val components = expiry.split("-").map { it.toInt() }
diff --git a/afterpay/src/main/kotlin/com/afterpay/android/view/AfterpayBadge.kt b/afterpay/src/main/kotlin/com/afterpay/android/view/AfterpayBadge.kt
index b504315d..824f25f4 100644
--- a/afterpay/src/main/kotlin/com/afterpay/android/view/AfterpayBadge.kt
+++ b/afterpay/src/main/kotlin/com/afterpay/android/view/AfterpayBadge.kt
@@ -14,7 +14,7 @@ private const val MIN_WIDTH: Int = 64
class AfterpayBadge @JvmOverloads constructor(
context: Context,
- attrs: AttributeSet? = null
+ attrs: AttributeSet? = null,
) : AppCompatImageView(context, attrs) {
var colorScheme: AfterpayColorScheme = AfterpayColorScheme.DEFAULT
@@ -35,8 +35,8 @@ class AfterpayBadge @JvmOverloads constructor(
colorScheme = AfterpayColorScheme.values()[
attributes.getInteger(
R.styleable.Afterpay_afterpayColorScheme,
- AfterpayColorScheme.DEFAULT.ordinal
- )
+ AfterpayColorScheme.DEFAULT.ordinal,
+ ),
]
}
}
@@ -45,13 +45,13 @@ class AfterpayBadge @JvmOverloads constructor(
setImageDrawable(
context.coloredDrawable(
drawableResId = Afterpay.brand.badgeForeground,
- colorResId = colorScheme.foregroundColorResId
- )
+ colorResId = colorScheme.foregroundColorResId,
+ ),
)
background = context.coloredDrawable(
R.drawable.afterpay_badge_bg,
- colorScheme.backgroundColorResId
+ colorScheme.backgroundColorResId,
)
invalidate()
diff --git a/afterpay/src/main/kotlin/com/afterpay/android/view/AfterpayCheckoutActivity.kt b/afterpay/src/main/kotlin/com/afterpay/android/view/AfterpayCheckoutActivity.kt
index 5e3af4b7..2fe23ade 100644
--- a/afterpay/src/main/kotlin/com/afterpay/android/view/AfterpayCheckoutActivity.kt
+++ b/afterpay/src/main/kotlin/com/afterpay/android/view/AfterpayCheckoutActivity.kt
@@ -3,6 +3,7 @@ package com.afterpay.android.view
import android.annotation.SuppressLint
import android.app.Activity
import android.content.Intent
+import android.graphics.Bitmap
import android.net.Uri
import android.os.Bundle
import android.os.Message
@@ -12,11 +13,13 @@ import android.webkit.WebResourceError
import android.webkit.WebResourceRequest
import android.webkit.WebView
import android.webkit.WebViewClient
+import androidx.activity.OnBackPressedCallback
import androidx.appcompat.app.AlertDialog
import androidx.appcompat.app.AppCompatActivity
import com.afterpay.android.Afterpay
import com.afterpay.android.CancellationStatus
import com.afterpay.android.R
+import com.afterpay.android.internal.getCheckoutShouldLoadRedirectUrls
import com.afterpay.android.internal.getCheckoutUrlExtra
import com.afterpay.android.internal.putCancellationStatusExtra
import com.afterpay.android.internal.putOrderTokenExtra
@@ -32,7 +35,7 @@ internal class AfterpayCheckoutActivity : AppCompatActivity() {
"portal.clearpay.co.uk",
"portal.sandbox.clearpay.co.uk",
"checkout.clearpay.com",
- "checkout.sandbox.clearpay.com"
+ "checkout.sandbox.clearpay.com",
)
}
@@ -52,11 +55,19 @@ internal class AfterpayCheckoutActivity : AppCompatActivity() {
settings.setDomStorageEnabled(true)
webViewClient = AfterpayWebViewClient(
receivedError = ::handleError,
- completed = ::finish
+ completed = ::finish,
+ shouldLoadRedirectUrls = intent.getCheckoutShouldLoadRedirectUrls(),
)
webChromeClient = AfterpayWebChromeClient(openExternalLink = ::open)
}
+ val onBackPressedCallback: OnBackPressedCallback = object : OnBackPressedCallback(true) {
+ override fun handleOnBackPressed() {
+ finish(CancellationStatus.USER_INITIATED)
+ }
+ }
+ onBackPressedDispatcher.addCallback(this, onBackPressedCallback)
+
loadCheckoutUrl()
}
@@ -71,10 +82,6 @@ internal class AfterpayCheckoutActivity : AppCompatActivity() {
super.onDestroy()
}
- override fun onBackPressed() {
- finish(CancellationStatus.USER_INITIATED)
- }
-
private fun loadCheckoutUrl() {
val checkoutUrl = intent.getCheckoutUrlExtra()
?: return finish(CancellationStatus.NO_CHECKOUT_URL)
@@ -104,8 +111,8 @@ internal class AfterpayCheckoutActivity : AppCompatActivity() {
.setMessage(
String.format(
Afterpay.strings.loadErrorMessage,
- resources.getString(Afterpay.brand.title)
- )
+ resources.getString(Afterpay.brand.title),
+ ),
)
.setPositiveButton(Afterpay.strings.loadErrorRetry) { dialog, _ ->
loadCheckoutUrl()
@@ -140,7 +147,8 @@ internal class AfterpayCheckoutActivity : AppCompatActivity() {
private class AfterpayWebViewClient(
private val receivedError: () -> Unit,
- private val completed: (CheckoutStatus) -> Unit
+ private val completed: (CheckoutStatus) -> Unit,
+ private val shouldLoadRedirectUrls: Boolean,
) : WebViewClient() {
override fun shouldOverrideUrlLoading(view: WebView?, request: WebResourceRequest?): Boolean {
val url = request?.url ?: return false
@@ -148,6 +156,10 @@ private class AfterpayWebViewClient(
return when {
status != null -> {
+ if (shouldLoadRedirectUrls) {
+ return false
+ }
+
completed(status)
true
}
@@ -156,10 +168,29 @@ private class AfterpayWebViewClient(
}
}
+ override fun onPageStarted(view: WebView?, url: String?, favicon: Bitmap?) {
+ super.onPageStarted(view, url, favicon)
+
+ if (url.equals("about:blank")) {
+ return
+ }
+
+ val uri = Uri.parse(url)
+ val status = CheckoutStatus.fromUrl(uri)
+
+ when {
+ status != null -> {
+ completed(status)
+ }
+
+ else -> {}
+ }
+ }
+
override fun onReceivedError(
view: WebView?,
request: WebResourceRequest?,
- error: WebResourceError?
+ error: WebResourceError?,
) {
if (request?.isForMainFrame == true) {
receivedError()
@@ -168,7 +199,7 @@ private class AfterpayWebViewClient(
}
private class AfterpayWebChromeClient(
- private val openExternalLink: (Uri) -> Unit
+ private val openExternalLink: (Uri) -> Unit,
) : WebChromeClient() {
companion object {
const val URL_KEY = "url"
@@ -178,7 +209,7 @@ private class AfterpayWebChromeClient(
view: WebView?,
isDialog: Boolean,
isUserGesture: Boolean,
- resultMsg: Message?
+ resultMsg: Message?,
): Boolean {
val hrefMessage = view?.handler?.obtainMessage()
view?.requestFocusNodeHref(hrefMessage)
@@ -195,10 +226,15 @@ private sealed class CheckoutStatus {
object Cancelled : CheckoutStatus()
companion object {
- fun fromUrl(url: Uri): CheckoutStatus? = when (url.getQueryParameter("status")) {
- "SUCCESS" -> url.getQueryParameter("orderToken")?.let(::Success)
- "CANCELLED" -> Cancelled
- else -> null
+ fun fromUrl(url: Uri): CheckoutStatus? {
+ return when (url.getQueryParameter("status")) {
+ "SUCCESS" -> {
+ val token = url.getQueryParameter("orderToken") ?: url.getQueryParameter("token")
+ token?.let(::Success)
+ }
+ "CANCELLED" -> Cancelled
+ else -> null
+ }
}
}
}
diff --git a/afterpay/src/main/kotlin/com/afterpay/android/view/AfterpayCheckoutV2Activity.kt b/afterpay/src/main/kotlin/com/afterpay/android/view/AfterpayCheckoutV2Activity.kt
index 17128fe2..3a2ea2a5 100644
--- a/afterpay/src/main/kotlin/com/afterpay/android/view/AfterpayCheckoutV2Activity.kt
+++ b/afterpay/src/main/kotlin/com/afterpay/android/view/AfterpayCheckoutV2Activity.kt
@@ -21,6 +21,7 @@ import android.webkit.WebView.VISIBLE
import android.webkit.WebView.WebViewTransport
import android.webkit.WebViewClient
import android.widget.FrameLayout
+import androidx.activity.OnBackPressedCallback
import androidx.appcompat.app.AlertDialog
import androidx.appcompat.app.AppCompatActivity
import com.afterpay.android.Afterpay
@@ -56,6 +57,13 @@ internal class AfterpayCheckoutV2Activity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
+ val onBackPressedCallback: OnBackPressedCallback = object : OnBackPressedCallback(true) {
+ override fun handleOnBackPressed() {
+ finish(CancellationStatus.USER_INITIATED)
+ }
+ }
+ onBackPressedDispatcher.addCallback(this, onBackPressedCallback)
+
bootstrapUrl = getString(R.string.afterpay_url_checkout_express)
setContentView(R.layout.activity_express_web_checkout)
@@ -84,14 +92,14 @@ internal class AfterpayCheckoutV2Activity : AppCompatActivity() {
onOpenWebView = { checkoutWebView = it },
onPageFinished = { frameLayout.removeView(loadingWebView) },
receivedError = ::handleCheckoutError,
- openExternalLink = ::open
+ openExternalLink = ::open,
)
val javascriptInterface = BootstrapJavascriptInterface(
activity = activity,
webView = this,
complete = ::finish,
- cancel = ::finish
+ cancel = ::finish,
)
addJavascriptInterface(javascriptInterface, "Android")
@@ -115,10 +123,6 @@ internal class AfterpayCheckoutV2Activity : AppCompatActivity() {
super.onDestroy()
}
- override fun onBackPressed() {
- finish(CancellationStatus.USER_INITIATED)
- }
-
private fun loadCheckoutToken() {
if (!Afterpay.enabled) {
return finish(LANGUAGE_NOT_SUPPORTED)
@@ -152,8 +156,8 @@ internal class AfterpayCheckoutV2Activity : AppCompatActivity() {
.setMessage(
String.format(
Afterpay.strings.loadErrorMessage,
- resources.getString(Afterpay.brand.title)
- )
+ resources.getString(Afterpay.brand.title),
+ ),
)
.setPositiveButton(Afterpay.strings.loadErrorRetry) { dialog, _ ->
retryAction()
@@ -197,7 +201,7 @@ internal class AfterpayCheckoutV2Activity : AppCompatActivity() {
private class BootstrapWebViewClient(
private val onPageFinished: () -> Unit,
- private val receivedError: () -> Unit
+ private val receivedError: () -> Unit,
) : WebViewClient() {
override fun onPageFinished(view: WebView?, url: String?) {
onPageFinished()
@@ -206,7 +210,7 @@ private class BootstrapWebViewClient(
override fun onReceivedError(
view: WebView?,
request: WebResourceRequest?,
- error: WebResourceError?
+ error: WebResourceError?,
) {
if (request?.isForMainFrame == true) {
receivedError()
@@ -220,7 +224,7 @@ private class BootstrapWebChromeClient(
private val onOpenWebView: (WebView) -> Unit,
private val onPageFinished: () -> Unit,
private val receivedError: () -> Unit,
- private val openExternalLink: (Uri) -> Unit
+ private val openExternalLink: (Uri) -> Unit,
) : WebChromeClient() {
companion object {
const val URL_KEY = "url"
@@ -231,7 +235,7 @@ private class BootstrapWebChromeClient(
view: WebView?,
isDialog: Boolean,
isUserGesture: Boolean,
- resultMsg: Message?
+ resultMsg: Message?,
): Boolean {
val webView = WebView(context)
webView.setAfterpayUserAgentString()
@@ -249,7 +253,7 @@ private class BootstrapWebChromeClient(
override fun onReceivedError(
view: WebView?,
request: WebResourceRequest?,
- error: WebResourceError?
+ error: WebResourceError?,
) {
if (request?.isForMainFrame == true) {
receivedError()
@@ -262,7 +266,7 @@ private class BootstrapWebChromeClient(
view: WebView?,
isDialog: Boolean,
isUserGesture: Boolean,
- resultMsg: Message?
+ resultMsg: Message?,
): Boolean {
val hrefMessage = view?.handler?.obtainMessage()
view?.requestFocusNodeHref(hrefMessage)
@@ -290,7 +294,7 @@ private class BootstrapJavascriptInterface(
private val activity: Activity,
private val webView: WebView,
private val complete: (AfterpayCheckoutCompletion) -> Unit,
- private val cancel: (CancellationStatus) -> Unit
+ private val cancel: (CancellationStatus) -> Unit,
) {
private val json = Json { ignoreUnknownKeys = true }
@@ -306,7 +310,7 @@ private class BootstrapJavascriptInterface(
when (message) {
is CheckoutLogMessage -> Log.d(
javaClass.simpleName,
- message.payload.run { "${severity.replaceFirstChar { it.uppercase(Locale.ROOT) }}: $message" }
+ message.payload.run { "${severity.replaceFirstChar { it.uppercase(Locale.ROOT) }}: $message" },
)
is ShippingAddressMessage -> handler.shippingAddressDidChange(message.payload) {
diff --git a/afterpay/src/main/kotlin/com/afterpay/android/view/AfterpayCheckoutV3Activity.kt b/afterpay/src/main/kotlin/com/afterpay/android/view/AfterpayCheckoutV3Activity.kt
index 6ac0dee7..ac0a7a26 100644
--- a/afterpay/src/main/kotlin/com/afterpay/android/view/AfterpayCheckoutV3Activity.kt
+++ b/afterpay/src/main/kotlin/com/afterpay/android/view/AfterpayCheckoutV3Activity.kt
@@ -48,7 +48,7 @@ internal class AfterpayCheckoutV3Activity : AppCompatActivity() {
settings.setSupportMultipleWindows(true)
webViewClient = AfterpayWebViewClientV3(
receivedError = ::handleError,
- received = ::received
+ received = ::received,
)
webChromeClient = AfterpayWebChromeClientV3(openExternalLink = ::open)
val htmlData = Base64.encodeToString(Html.loading.toByteArray(), Base64.NO_PADDING)
@@ -145,7 +145,7 @@ internal class AfterpayCheckoutV3Activity : AppCompatActivity() {
private class AfterpayWebViewClientV3(
private val receivedError: () -> Unit,
- private val received: (CheckoutStatusV3) -> Unit
+ private val received: (CheckoutStatusV3) -> Unit,
) : WebViewClient() {
override fun shouldOverrideUrlLoading(view: WebView?, request: WebResourceRequest?): Boolean {
val url = request?.url ?: return false
@@ -164,7 +164,7 @@ private class AfterpayWebViewClientV3(
override fun onReceivedError(
view: WebView?,
request: WebResourceRequest?,
- error: WebResourceError?
+ error: WebResourceError?,
) {
if (request?.isForMainFrame == true) {
receivedError()
@@ -174,14 +174,14 @@ private class AfterpayWebViewClientV3(
private class AfterpayWebChromeClientV3(
private val openExternalLink: (Uri) -> Unit,
- private val URL_KEY: String = "url"
+ private val URL_KEY: String = "url",
) : WebChromeClient() {
override fun onCreateWindow(
view: WebView?,
isDialog: Boolean,
isUserGesture: Boolean,
- resultMsg: Message?
+ resultMsg: Message?,
): Boolean {
val hrefMessage = view?.handler?.obtainMessage()
view?.requestFocusNodeHref(hrefMessage)
diff --git a/afterpay/src/main/kotlin/com/afterpay/android/view/AfterpayColorScheme.kt b/afterpay/src/main/kotlin/com/afterpay/android/view/AfterpayColorScheme.kt
index 92d1d91f..26d2a8f7 100644
--- a/afterpay/src/main/kotlin/com/afterpay/android/view/AfterpayColorScheme.kt
+++ b/afterpay/src/main/kotlin/com/afterpay/android/view/AfterpayColorScheme.kt
@@ -5,24 +5,25 @@ import com.afterpay.android.R
enum class AfterpayColorScheme(
@ColorRes val foregroundColorResId: Int,
- @ColorRes val backgroundColorResId: Int
+ @ColorRes val backgroundColorResId: Int,
) {
BLACK_ON_MINT(
foregroundColorResId = R.color.afterpay_black,
- backgroundColorResId = R.color.afterpay_mint
+ backgroundColorResId = R.color.afterpay_mint,
),
MINT_ON_BLACK(
foregroundColorResId = R.color.afterpay_mint,
- backgroundColorResId = R.color.afterpay_black
+ backgroundColorResId = R.color.afterpay_black,
),
WHITE_ON_BLACK(
foregroundColorResId = R.color.afterpay_white,
- backgroundColorResId = R.color.afterpay_black
+ backgroundColorResId = R.color.afterpay_black,
),
BLACK_ON_WHITE(
foregroundColorResId = R.color.afterpay_black,
- backgroundColorResId = R.color.afterpay_white
- );
+ backgroundColorResId = R.color.afterpay_white,
+ ),
+ ;
internal companion object {
diff --git a/afterpay/src/main/kotlin/com/afterpay/android/view/AfterpayIntroText.kt b/afterpay/src/main/kotlin/com/afterpay/android/view/AfterpayIntroText.kt
index 5ca6e3af..34ec90e5 100644
--- a/afterpay/src/main/kotlin/com/afterpay/android/view/AfterpayIntroText.kt
+++ b/afterpay/src/main/kotlin/com/afterpay/android/view/AfterpayIntroText.kt
@@ -14,7 +14,8 @@ enum class AfterpayIntroText(val id: Int) {
OR_TITLE(8),
OR(9),
PAY_IN_TITLE(10),
- PAY_IN(11);
+ PAY_IN(11),
+ ;
internal companion object {
diff --git a/afterpay/src/main/kotlin/com/afterpay/android/view/AfterpayLockup.kt b/afterpay/src/main/kotlin/com/afterpay/android/view/AfterpayLockup.kt
index 46be6ee0..57897b35 100644
--- a/afterpay/src/main/kotlin/com/afterpay/android/view/AfterpayLockup.kt
+++ b/afterpay/src/main/kotlin/com/afterpay/android/view/AfterpayLockup.kt
@@ -15,7 +15,7 @@ private const val MIN_WIDTH: Int = 64
class AfterpayLockup @JvmOverloads constructor(
context: Context,
- attrs: AttributeSet? = null
+ attrs: AttributeSet? = null,
) : AppCompatImageView(context, attrs) {
var colorScheme: AfterpayColorScheme = AfterpayColorScheme.DEFAULT
@@ -36,8 +36,8 @@ class AfterpayLockup @JvmOverloads constructor(
colorScheme = AfterpayColorScheme.values()[
attributes.getInteger(
R.styleable.Afterpay_afterpayColorScheme,
- AfterpayColorScheme.DEFAULT.ordinal
- )
+ AfterpayColorScheme.DEFAULT.ordinal,
+ ),
]
}
}
@@ -52,8 +52,8 @@ class AfterpayLockup @JvmOverloads constructor(
setImageDrawable(
context.coloredDrawable(
drawableResId = Afterpay.brand.lockup,
- colorResId = colorScheme.foregroundColorResId
- )
+ colorResId = colorScheme.foregroundColorResId,
+ ),
)
invalidate()
diff --git a/afterpay/src/main/kotlin/com/afterpay/android/view/AfterpayLogoType.kt b/afterpay/src/main/kotlin/com/afterpay/android/view/AfterpayLogoType.kt
index 63874bd4..794d13da 100644
--- a/afterpay/src/main/kotlin/com/afterpay/android/view/AfterpayLogoType.kt
+++ b/afterpay/src/main/kotlin/com/afterpay/android/view/AfterpayLogoType.kt
@@ -2,7 +2,8 @@ package com.afterpay.android.view
enum class AfterpayLogoType(val fontHeightMultiplier: Double) {
BADGE(2.5),
- LOCKUP(1.0);
+ LOCKUP(1.0),
+ ;
internal companion object {
diff --git a/afterpay/src/main/kotlin/com/afterpay/android/view/AfterpayModalLinkStyle.kt b/afterpay/src/main/kotlin/com/afterpay/android/view/AfterpayModalLinkStyle.kt
index a0f93354..4aa9496c 100644
--- a/afterpay/src/main/kotlin/com/afterpay/android/view/AfterpayModalLinkStyle.kt
+++ b/afterpay/src/main/kotlin/com/afterpay/android/view/AfterpayModalLinkStyle.kt
@@ -3,36 +3,34 @@ package com.afterpay.android.view
import com.afterpay.android.Afterpay
import com.afterpay.android.R
-sealed class AfterpayModalLinkStyle(val config: ModalLinkConfig) {
- constructor(string: String, config: ModalLinkConfig) : this(config)
-
+sealed class AfterpayModalLinkStyle(internal val config: ModalLinkConfig) {
object CircledInfoIcon : AfterpayModalLinkStyle(
ModalLinkConfig(
text = "\u24D8",
- underlined = false
- )
+ underlined = false,
+ ),
)
object MoreInfoText : AfterpayModalLinkStyle(
ModalLinkConfig(
- text = Afterpay.strings.priceBreakdownLinkMoreInfo
- )
+ text = Afterpay.strings.priceBreakdownLinkMoreInfo,
+ ),
)
object LearnMoreText : AfterpayModalLinkStyle(
ModalLinkConfig(
- text = Afterpay.strings.priceBreakdownLinkLearnMore
- )
+ text = Afterpay.strings.priceBreakdownLinkLearnMore,
+ ),
)
object CircledQuestionIcon : AfterpayModalLinkStyle(
ModalLinkConfig(
image = R.drawable.icon_circled_question,
- imageRenderingMode = AfterpayImageRenderingMode.TEMPLATE
- )
+ imageRenderingMode = AfterpayImageRenderingMode.TEMPLATE,
+ ),
)
object CircledLogo : AfterpayModalLinkStyle(
ModalLinkConfig(
image = R.drawable.afterpay_logo_small,
- imageRenderingMode = AfterpayImageRenderingMode.ORIGINAL
- )
+ imageRenderingMode = AfterpayImageRenderingMode.ORIGINAL,
+ ),
)
object Custom : AfterpayModalLinkStyle(ModalLinkConfig()) {
public fun setContent(content: CharSequence) {
@@ -50,7 +48,7 @@ sealed class AfterpayModalLinkStyle(val config: ModalLinkConfig) {
internal enum class AfterpayImageRenderingMode {
ORIGINAL,
- TEMPLATE
+ TEMPLATE,
}
internal data class ModalLinkConfig(
@@ -58,5 +56,5 @@ internal data class ModalLinkConfig(
val image: Int? = null,
val imageRenderingMode: AfterpayImageRenderingMode? = null,
var customContent: CharSequence? = null,
- val underlined: Boolean = true
+ val underlined: Boolean = true,
)
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 784104a3..371d0743 100644
--- a/afterpay/src/main/kotlin/com/afterpay/android/view/AfterpayModalTheme.kt
+++ b/afterpay/src/main/kotlin/com/afterpay/android/view/AfterpayModalTheme.kt
@@ -2,7 +2,8 @@ package com.afterpay.android.view
enum class AfterpayModalTheme(val slug: String) {
MINT(""),
- WHITE("-theme-white");
+ WHITE("-theme-white"),
+ ;
internal companion object {
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 daaa5bfb..c6e9d362 100644
--- a/afterpay/src/main/kotlin/com/afterpay/android/view/AfterpayMoreInfoOptions.kt
+++ b/afterpay/src/main/kotlin/com/afterpay/android/view/AfterpayMoreInfoOptions.kt
@@ -16,7 +16,7 @@ class AfterpayMoreInfoOptions {
*/
constructor(
modalId: String,
- modalLinkStyle: AfterpayModalLinkStyle = AfterpayModalLinkStyle.DEFAULT
+ modalLinkStyle: AfterpayModalLinkStyle = AfterpayModalLinkStyle.DEFAULT,
) {
this.modalId = modalId
this.modalLinkStyle = modalLinkStyle
@@ -34,7 +34,7 @@ class AfterpayMoreInfoOptions {
constructor(
modalTheme: AfterpayModalTheme = AfterpayModalTheme.MINT,
isCbtEnabled: Boolean = false,
- modalLinkStyle: AfterpayModalLinkStyle = AfterpayModalLinkStyle.DEFAULT
+ modalLinkStyle: AfterpayModalLinkStyle = AfterpayModalLinkStyle.DEFAULT,
) {
this.modalTheme = modalTheme
this.isCbtEnabled = isCbtEnabled
diff --git a/afterpay/src/main/kotlin/com/afterpay/android/view/AfterpayPaymentButton.kt b/afterpay/src/main/kotlin/com/afterpay/android/view/AfterpayPaymentButton.kt
index 735b04f0..aa25cbd4 100644
--- a/afterpay/src/main/kotlin/com/afterpay/android/view/AfterpayPaymentButton.kt
+++ b/afterpay/src/main/kotlin/com/afterpay/android/view/AfterpayPaymentButton.kt
@@ -25,7 +25,7 @@ private const val PADDING: Int = 0
class AfterpayPaymentButton @JvmOverloads constructor(
context: Context,
- attrs: AttributeSet? = null
+ attrs: AttributeSet? = null,
) : AppCompatImageButton(context, attrs) {
var buttonText: ButtonText = ButtonText.DEFAULT
@@ -57,7 +57,7 @@ class AfterpayPaymentButton @JvmOverloads constructor(
init {
contentDescription = String.format(
Afterpay.strings.paymentButtonContentDescription,
- resources.getString(Afterpay.brand.description)
+ resources.getString(Afterpay.brand.description),
)
scaleType = FIT_CENTER
adjustViewBounds = true
@@ -67,15 +67,15 @@ class AfterpayPaymentButton @JvmOverloads constructor(
buttonText = ButtonText.values()[
attributes.getInteger(
R.styleable.Afterpay_afterpayButtonText,
- ButtonText.DEFAULT.ordinal
- )
+ ButtonText.DEFAULT.ordinal,
+ ),
]
colorScheme = values()[
attributes.getInteger(
R.styleable.Afterpay_afterpayColorScheme,
- AfterpayColorScheme.DEFAULT.ordinal
- )
+ AfterpayColorScheme.DEFAULT.ordinal,
+ ),
]
}
@@ -92,8 +92,8 @@ class AfterpayPaymentButton @JvmOverloads constructor(
setImageDrawable(
context.coloredDrawable(
drawableResId = buttonText.drawableResId,
- colorResId = colorScheme.foregroundColorResId
- )
+ colorResId = colorScheme.foregroundColorResId,
+ ),
)
val rippleColorResId = when (colorScheme) {
@@ -105,8 +105,8 @@ class AfterpayPaymentButton @JvmOverloads constructor(
rippleColorResId = rippleColorResId,
drawable = context.coloredDrawable(
drawableResId = R.drawable.afterpay_button_bg,
- colorResId = colorScheme.backgroundColorResId
- )
+ colorResId = colorScheme.backgroundColorResId,
+ ),
)
invalidate()
@@ -118,7 +118,8 @@ class AfterpayPaymentButton @JvmOverloads constructor(
PAY_NOW(drawableResId = Afterpay.drawables.buttonPayNowForeground),
BUY_NOW(drawableResId = Afterpay.drawables.buttonBuyNowForeground),
CHECKOUT(drawableResId = Afterpay.drawables.buttonCheckoutForeground),
- PLACE_ORDER(drawableResId = Afterpay.drawables.buttonPlaceOrderForeground);
+ PLACE_ORDER(drawableResId = Afterpay.drawables.buttonPlaceOrderForeground),
+ ;
companion object {
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 30319e41..a8c612cd 100644
--- a/afterpay/src/main/kotlin/com/afterpay/android/view/AfterpayPriceBreakdown.kt
+++ b/afterpay/src/main/kotlin/com/afterpay/android/view/AfterpayPriceBreakdown.kt
@@ -31,12 +31,12 @@ import java.util.Observer
class AfterpayPriceBreakdown @JvmOverloads constructor(
context: Context,
- attrs: AttributeSet? = null
+ attrs: AttributeSet? = null,
) : FrameLayout(context, attrs) {
private data class Content(
val text: String,
- val description: String
+ val description: String,
)
var totalAmount: BigDecimal = BigDecimal.ZERO
@@ -108,8 +108,8 @@ class AfterpayPriceBreakdown @JvmOverloads constructor(
colorScheme = AfterpayColorScheme.values()[
attributes.getInteger(
R.styleable.Afterpay_afterpayColorScheme,
- AfterpayColorScheme.DEFAULT.ordinal
- )
+ AfterpayColorScheme.DEFAULT.ordinal,
+ ),
]
}
@@ -147,7 +147,7 @@ class AfterpayPriceBreakdown @JvmOverloads constructor(
append(
context.getString(Afterpay.brand.title),
CenteredImageSpan(drawable),
- Spannable.SPAN_INCLUSIVE_EXCLUSIVE
+ Spannable.SPAN_INCLUSIVE_EXCLUSIVE,
)
append(" ")
append(content.text)
@@ -157,7 +157,7 @@ class AfterpayPriceBreakdown @JvmOverloads constructor(
append(
context.getString(Afterpay.brand.title),
CenteredImageSpan(drawable),
- Spannable.SPAN_INCLUSIVE_EXCLUSIVE
+ Spannable.SPAN_INCLUSIVE_EXCLUSIVE,
)
}
@@ -168,14 +168,14 @@ class AfterpayPriceBreakdown @JvmOverloads constructor(
append(
linkStyle.customContent,
AfterpayInfoSpan(infoUrl, false),
- Spannable.SPAN_INCLUSIVE_EXCLUSIVE
+ Spannable.SPAN_INCLUSIVE_EXCLUSIVE,
)
} else if (linkStyle.text != null) {
append(" ")
append(
linkStyle.text,
AfterpayInfoSpan(infoUrl, linkStyle.underlined),
- Spannable.SPAN_INCLUSIVE_EXCLUSIVE
+ Spannable.SPAN_INCLUSIVE_EXCLUSIVE,
)
} else if (linkStyle.image != null && linkStyle.imageRenderingMode != null) {
append(" ")
@@ -185,12 +185,12 @@ class AfterpayPriceBreakdown @JvmOverloads constructor(
context.theme.resolveAttribute(
android.R.attr.textColorSecondary,
typedValue,
- true
+ true,
)
context.coloredDrawable(
drawableResId = linkStyle.image,
- colorResId = typedValue.resourceId
+ colorResId = typedValue.resourceId,
)
} else {
ResourcesCompat.getDrawable(resources, linkStyle.image, null)
@@ -208,14 +208,14 @@ class AfterpayPriceBreakdown @JvmOverloads constructor(
append(
accessibleLinkString,
CenteredImageSpan(imageDrawable),
- Spannable.SPAN_INCLUSIVE_EXCLUSIVE
+ Spannable.SPAN_INCLUSIVE_EXCLUSIVE,
)
setSpan(
AfterpayInfoSpan(infoUrl),
this.length - accessibleLinkString.length,
this.length,
- Spannable.SPAN_INCLUSIVE_EXCLUSIVE
+ Spannable.SPAN_INCLUSIVE_EXCLUSIVE,
)
}
}
@@ -228,21 +228,21 @@ class AfterpayPriceBreakdown @JvmOverloads constructor(
val drawable = if (logoType === AfterpayLogoType.LOCKUP) {
context.coloredDrawable(
drawableResId = Afterpay.brand.lockup,
- colorResId = colorScheme.foregroundColorResId
+ colorResId = colorScheme.foregroundColorResId,
)
} else {
LayerDrawable(
arrayOf(
context.coloredDrawable(
drawableResId = R.drawable.afterpay_badge_bg,
- colorResId = colorScheme.backgroundColorResId
+ colorResId = colorScheme.backgroundColorResId,
),
context.coloredDrawable(
drawableResId = Afterpay.brand.badgeForeground,
- colorResId = colorScheme.foregroundColorResId
- )
- )
+ colorResId = colorScheme.foregroundColorResId,
+ ),
+ ),
)
}
@@ -284,7 +284,7 @@ class AfterpayPriceBreakdown @JvmOverloads constructor(
numberOfInstalments.toString(),
interestFreeText,
afterpay.instalmentAmount,
- withText
+ withText,
).trim(),
description = String.format(
Afterpay.strings.priceBreakdownAvailableDescription,
@@ -293,46 +293,47 @@ class AfterpayPriceBreakdown @JvmOverloads constructor(
interestFreeText,
afterpay.instalmentAmount,
withText,
- resources.getString(Afterpay.brand.description)
- ).trim()
+ resources.getString(Afterpay.brand.description),
+ ).trim(),
)
}
is AfterpayInstalment.NotAvailable ->
- if (afterpay.minimumAmount != null)
+ if (afterpay.minimumAmount != null) {
Content(
text = String.format(
Afterpay.strings.breakdownLimit,
afterpay.minimumAmount,
- afterpay.maximumAmount
+ afterpay.maximumAmount,
),
description = String.format(
Afterpay.strings.breakdownLimitDescription,
resources.getString(Afterpay.brand.description),
afterpay.minimumAmount,
- afterpay.maximumAmount
- )
+ afterpay.maximumAmount,
+ ),
)
- else
+ } else {
Content(
text = String.format(
Afterpay.strings.breakdownLimit,
"1",
- afterpay.maximumAmount
+ afterpay.maximumAmount,
),
description = String.format(
Afterpay.strings.breakdownLimitDescription,
resources.getString(Afterpay.brand.description),
"1",
- afterpay.maximumAmount
- )
+ afterpay.maximumAmount,
+ ),
)
+ }
AfterpayInstalment.NoConfiguration ->
Content(
text = Afterpay.strings.noConfiguration,
description = String.format(
Afterpay.strings.noConfigurationDescription,
- resources.getString(Afterpay.brand.description)
- )
+ resources.getString(Afterpay.brand.description),
+ ),
)
}
}
@@ -346,7 +347,7 @@ private class CenteredImageSpan(drawable: Drawable) : ImageSpan(drawable) {
text: CharSequence,
start: Int,
end: Int,
- fontMetricsInt: Paint.FontMetricsInt?
+ fontMetricsInt: Paint.FontMetricsInt?,
): Int {
val drawable = drawable
val bounds = drawable.bounds
@@ -373,7 +374,7 @@ private class CenteredImageSpan(drawable: Drawable) : ImageSpan(drawable) {
top: Int,
y: Int,
bottom: Int,
- paint: Paint
+ paint: Paint,
) {
val drawable = drawable
canvas.save()
diff --git a/afterpay/src/main/kotlin/com/afterpay/android/view/AfterpayWidgetView.kt b/afterpay/src/main/kotlin/com/afterpay/android/view/AfterpayWidgetView.kt
index cd998f60..b9bbb569 100644
--- a/afterpay/src/main/kotlin/com/afterpay/android/view/AfterpayWidgetView.kt
+++ b/afterpay/src/main/kotlin/com/afterpay/android/view/AfterpayWidgetView.kt
@@ -32,7 +32,7 @@ import java.math.BigDecimal
class AfterpayWidgetView @JvmOverloads constructor(
context: Context,
attrs: AttributeSet? = null,
- defStyleAttr: Int = 0
+ defStyleAttr: Int = 0,
) : WebView(context, attrs, defStyleAttr) {
private val configuration: Configuration
@@ -62,7 +62,7 @@ class AfterpayWidgetView @JvmOverloads constructor(
onUpdate: (dueToday: Money, checksum: String?) -> Unit,
onError: (error: String) -> Unit,
showLogo: Boolean = true,
- showHeading: Boolean = true
+ showHeading: Boolean = true,
) {
if (!Afterpay.enabled) {
visibility = View.GONE
@@ -97,7 +97,7 @@ class AfterpayWidgetView @JvmOverloads constructor(
onUpdate: (dueToday: Money, checksum: String?) -> Unit,
onError: (error: String) -> Unit,
showLogo: Boolean = true,
- showHeading: Boolean = true
+ showHeading: Boolean = true,
) {
if (!Afterpay.enabled) {
visibility = View.GONE
@@ -119,7 +119,7 @@ class AfterpayWidgetView @JvmOverloads constructor(
private fun configureWebView(
onExternalRequest: (Uri) -> Unit,
onError: (String) -> Unit,
- onPageFinished: () -> Unit
+ onPageFinished: () -> Unit,
) {
setAfterpayUserAgentString()
@SuppressLint("SetJavaScriptEnabled")
@@ -135,14 +135,14 @@ class AfterpayWidgetView @JvmOverloads constructor(
webView: WebView?,
isDialog: Boolean,
isUserGesture: Boolean,
- resultMsg: Message?
+ resultMsg: Message?,
): Boolean {
val message = webView?.handler?.obtainMessage()
webView?.requestFocusNodeHref(message)
message?.data?.getString("url")?.let { onExternalRequest(Uri.parse(it)) }
return false
}
- }
+ },
)
super.setWebViewClient(
@@ -157,7 +157,7 @@ class AfterpayWidgetView @JvmOverloads constructor(
override fun onReceivedError(
webView: WebView?,
request: WebResourceRequest?,
- error: WebResourceError?
+ error: WebResourceError?,
) {
checkNotNull(webView) { "A WebView was expected but not received" }
if (request?.isForMainFrame == true) {
@@ -169,14 +169,14 @@ class AfterpayWidgetView @JvmOverloads constructor(
webView: WebView?,
errorCode: Int,
description: String?,
- failingUrl: String?
+ failingUrl: String?,
) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
checkNotNull(webView) { "A WebView was expected but not received" }
onError(description.orDefaultError())
}
}
- }
+ },
)
val widgetScriptUrl = context.resources.getString(R.string.afterpay_url_widget)
@@ -202,12 +202,12 @@ class AfterpayWidgetView @JvmOverloads constructor(
token: String?,
totalCost: String?,
showLogo: Boolean,
- showHeading: Boolean
+ showHeading: Boolean,
) {
val style = "{ \"logo\": $showLogo, \"heading\": $showHeading }"
evaluateJavascript(
"createAfterpayWidget($token, $totalCost, \"${configuration.locale}\", $style);",
- null
+ null,
)
}
@@ -225,7 +225,7 @@ class AfterpayWidgetView @JvmOverloads constructor(
evaluateJavascript(
"updateAmount(${totalCost.toAmount()});",
- null
+ null,
)
}
@@ -263,7 +263,7 @@ class AfterpayWidgetView @JvmOverloads constructor(
val isValid: Boolean,
val amountDueToday: Money? = null,
val paymentScheduleChecksum: String? = null,
- val error: Error? = null
+ val error: Error? = null,
) {
@Serializable
@@ -271,7 +271,7 @@ class AfterpayWidgetView @JvmOverloads constructor(
val errorCode: String? = null,
val errorId: String? = null,
val message: String? = null,
- val httpStatusCode: Int? = null
+ val httpStatusCode: Int? = null,
)
}
}
diff --git a/afterpay/src/test/kotlin/com/afterpay/android/AfterpayInstalmentLocaleTest.kt b/afterpay/src/test/kotlin/com/afterpay/android/AfterpayInstalmentLocaleTest.kt
index d8fbd89b..7fc76935 100644
--- a/afterpay/src/test/kotlin/com/afterpay/android/AfterpayInstalmentLocaleTest.kt
+++ b/afterpay/src/test/kotlin/com/afterpay/android/AfterpayInstalmentLocaleTest.kt
@@ -241,7 +241,7 @@ class AfterpayInstalmentLocaleTest {
val gbp: AfterpayInstalment.Available,
val nzd: AfterpayInstalment.Available,
val usd: AfterpayInstalment.Available,
- val eur: AfterpayInstalment.Available
+ val eur: AfterpayInstalment.Available,
)
private data class AllUnavailableInstallments(
@@ -250,7 +250,7 @@ class AfterpayInstalmentLocaleTest {
val gbp: AfterpayInstalment.NotAvailable,
val nzd: AfterpayInstalment.NotAvailable,
val usd: AfterpayInstalment.NotAvailable,
- val eur: AfterpayInstalment.NotAvailable
+ val eur: AfterpayInstalment.NotAvailable,
)
private fun createAllAvailableInstalments(amount: BigDecimal, locale: Locale): AllAvailableInstallments {
@@ -260,7 +260,7 @@ class AfterpayInstalmentLocaleTest {
gbp = availableInstalment(amount, poundSterling, locale),
nzd = availableInstalment(amount, newZealandDollar, locale),
usd = availableInstalment(amount, unitedStatesDollar, locale),
- eur = availableInstalment(amount, euro, locale)
+ eur = availableInstalment(amount, euro, locale),
)
}
@@ -271,21 +271,21 @@ class AfterpayInstalmentLocaleTest {
gbp = unavailableInstalment(amount, poundSterling, locale),
nzd = unavailableInstalment(amount, newZealandDollar, locale),
usd = unavailableInstalment(amount, unitedStatesDollar, locale),
- eur = unavailableInstalment(amount, euro, locale)
+ eur = unavailableInstalment(amount, euro, locale),
)
}
private fun availableInstalment(
amount: BigDecimal,
currency: Currency,
- locale: Locale
+ locale: Locale,
): AfterpayInstalment.Available {
val configuration = Configuration(
50.toBigDecimal(),
1000.toBigDecimal(),
currency,
locale,
- AfterpayEnvironment.SANDBOX
+ AfterpayEnvironment.SANDBOX,
)
return AfterpayInstalment.of(amount, configuration, locale) as AfterpayInstalment.Available
}
@@ -293,14 +293,14 @@ class AfterpayInstalmentLocaleTest {
private fun unavailableInstalment(
amount: BigDecimal,
currency: Currency,
- locale: Locale
+ locale: Locale,
): AfterpayInstalment.NotAvailable {
val configuration = Configuration(
10.toBigDecimal(),
20.toBigDecimal(),
currency,
locale,
- AfterpayEnvironment.SANDBOX
+ AfterpayEnvironment.SANDBOX,
)
return AfterpayInstalment.of(amount, configuration, locale) as AfterpayInstalment.NotAvailable
}
diff --git a/afterpay/src/test/kotlin/com/afterpay/android/AfterpayInstalmentPriceTest.kt b/afterpay/src/test/kotlin/com/afterpay/android/AfterpayInstalmentPriceTest.kt
index 4fa5cc3e..0aa0ad1e 100644
--- a/afterpay/src/test/kotlin/com/afterpay/android/AfterpayInstalmentPriceTest.kt
+++ b/afterpay/src/test/kotlin/com/afterpay/android/AfterpayInstalmentPriceTest.kt
@@ -22,14 +22,14 @@ class AfterpayInstalmentPriceTest {
40.04 to "$10.01",
40.009 to "$10.00",
40.019 to "$10.00",
- 40.3934567 to "$10.10"
+ 40.3934567 to "$10.10",
)
private val priceCasesInt = mapOf(
40 to "$10.00",
41 to "$10.25",
100 to "$25.00",
- 103 to "$25.75"
+ 103 to "$25.75",
)
@Test
@@ -38,7 +38,7 @@ class AfterpayInstalmentPriceTest {
val instalments = availableInstalment(
amount.toBigDecimal(),
Currency.getInstance("AUD"),
- Locales.EN_AU
+ Locales.EN_AU,
)
Assert.assertEquals(instalmentAmount, instalments.instalmentAmount)
}
@@ -50,7 +50,7 @@ class AfterpayInstalmentPriceTest {
val instalments = availableInstalment(
amount.toBigDecimal(),
Currency.getInstance("AUD"),
- Locales.EN_AU
+ Locales.EN_AU,
)
Assert.assertEquals(instalmentAmount, instalments.instalmentAmount)
}
@@ -69,7 +69,7 @@ class AfterpayInstalmentPriceTest {
val instalments = availableInstalment(
oneHundredAndTwentyOne,
Currency.getInstance("AUD"),
- Locales.EN_AU
+ Locales.EN_AU,
)
Assert.assertEquals("$30.25", instalments.instalmentAmount)
@@ -78,14 +78,14 @@ class AfterpayInstalmentPriceTest {
private fun availableInstalment(
amount: BigDecimal,
currency: Currency,
- locale: Locale
+ locale: Locale,
): AfterpayInstalment.Available {
val configuration = Configuration(
2.toBigDecimal(),
1000.toBigDecimal(),
currency,
locale,
- AfterpayEnvironment.SANDBOX
+ AfterpayEnvironment.SANDBOX,
)
return AfterpayInstalment.of(amount, configuration, locale) as AfterpayInstalment.Available
}
diff --git a/afterpay/src/test/kotlin/com/afterpay/android/AfterpayTest.kt b/afterpay/src/test/kotlin/com/afterpay/android/AfterpayTest.kt
index 2c0d7a93..40ab0ed3 100644
--- a/afterpay/src/test/kotlin/com/afterpay/android/AfterpayTest.kt
+++ b/afterpay/src/test/kotlin/com/afterpay/android/AfterpayTest.kt
@@ -15,7 +15,7 @@ class AfterpayTest {
maximumAmount = "100.00",
currencyCode = "AUD",
locale = Locale.US,
- environment = environment
+ environment = environment,
)
}
@@ -26,7 +26,7 @@ class AfterpayTest {
maximumAmount = "100.00",
currencyCode = "AUD",
locale = Locale.US,
- environment = environment
+ environment = environment,
)
}
@@ -38,7 +38,7 @@ class AfterpayTest {
maximumAmount = "100.00",
currencyCode = "foo",
locale = Locale.US,
- environment = environment
+ environment = environment,
)
}
}
@@ -51,7 +51,7 @@ class AfterpayTest {
maximumAmount = "100.00",
currencyCode = "AUD",
locale = Locale.US,
- environment = environment
+ environment = environment,
)
}
}
@@ -64,7 +64,7 @@ class AfterpayTest {
maximumAmount = "foo",
currencyCode = "AUD",
locale = Locale.US,
- environment = environment
+ environment = environment,
)
}
}
@@ -77,7 +77,7 @@ class AfterpayTest {
maximumAmount = "100.00",
currencyCode = "AUD",
locale = Locale.US,
- environment = environment
+ environment = environment,
)
}
}
@@ -90,7 +90,7 @@ class AfterpayTest {
maximumAmount = "100.00",
currencyCode = "AUD",
locale = Locale.US,
- environment = environment
+ environment = environment,
)
}
}
@@ -103,7 +103,7 @@ class AfterpayTest {
maximumAmount = "-2.00",
currencyCode = "AUD",
locale = Locale.US,
- environment = environment
+ environment = environment,
)
}
}
@@ -116,7 +116,7 @@ class AfterpayTest {
maximumAmount = "100.00",
currencyCode = "AUD",
locale = Locale.JAPAN,
- environment = environment
+ environment = environment,
)
}
}
diff --git a/build.gradle b/build.gradle
index 6bd589bf..79411740 100644
--- a/build.gradle
+++ b/build.gradle
@@ -1,35 +1,36 @@
buildscript {
ext.versions = [
'compile_sdk' : 31,
+ 'example_compile_sdk' : 33,
'min_sdk' : 24,
'java' : '1.8',
'build_tools' : '30.0.3',
- 'android_gradle_plugin' : '7.0.4',
- 'kotlin' : '1.6.0',
- 'kotlinx_coroutines' : '1.5.1',
- 'kotlinx_serialization' : '1.3.1',
+ 'android_gradle_plugin' : '7.3.1',
+ 'kotlin' : '1.7.20',
+ 'kotlinx_coroutines' : '1.6.4',
+ 'kotlinx_serialization' : '1.4.1',
'maven_publish_plugin' : '0.17.0',
- 'androidx_activity' : '1.4.0',
- 'androidx_constraint_layout': '2.1.2',
- 'androidx_fragment' : '1.4.0',
- 'androidx_lifecycle' : '2.4.0',
- 'androidx_navigation' : '2.3.5',
+ 'androidx_activity' : '1.6.0',
+ 'androidx_constraint_layout': '2.1.4',
+ 'androidx_fragment' : '1.5.3',
+ 'androidx_lifecycle' : '2.5.1',
+ 'androidx_navigation' : '2.5.2',
'androidx_recycler_view' : '1.2.1',
- 'android_three_ten' : '1.3.1',
- 'app_compat' : '1.4.0',
- 'core_ktx' : '1.7.0',
- 'material_design_components': '1.4.0',
- 'moshi' : '1.13.0',
- 'okhttp' : '4.9.1',
+ 'android_three_ten' : '1.4.2',
+ 'app_compat' : '1.5.1',
+ 'core_ktx' : '1.9.0',
+ 'material_design_components': '1.7.0',
+ 'moshi' : '1.14.0',
+ 'okhttp' : '5.0.0-alpha.10',
'retrofit' : '2.9.0',
'junit' : '4.13.2',
- 'androidx_test_orchestrator': '1.4.0',
+ 'androidx_test_orchestrator': '1.4.1',
'androidx_test_core' : '1.4.0',
'androidx_test_junit' : '1.1.3',
'androidx_test_runner' : '1.4.0',
'espresso' : '3.4.0',
'uiautomator' : '2.2.0',
- 'ktlint' : '0.43.2'
+ 'ktlint' : '0.47.1'
]
repositories {
@@ -65,14 +66,14 @@ subprojects {
task ktlint(type: JavaExec, group: "verification") {
description = "Check Kotlin code style."
classpath = configurations.ktlint
- main = "com.pinterest.ktlint.Main"
+ mainClass = "com.pinterest.ktlint.Main"
args "src/**/*.kt"
}
task ktlintFormat(type: JavaExec, group: "formatting") {
description = "Fix Kotlin code style deviations."
classpath = configurations.ktlint
- main = "com.pinterest.ktlint.Main"
+ mainClass = "com.pinterest.ktlint.Main"
args "-F", "src/**/*.kt"
}
}
diff --git a/docs/Gemfile.lock b/docs/Gemfile.lock
index 7b01b259..9c735591 100644
--- a/docs/Gemfile.lock
+++ b/docs/Gemfile.lock
@@ -1,20 +1,20 @@
GEM
remote: https://rubygems.org/
specs:
- activesupport (6.0.5.1)
+ activesupport (6.0.6)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 0.7, < 2)
minitest (~> 5.1)
tzinfo (~> 1.1)
zeitwerk (~> 2.2, >= 2.2.2)
- addressable (2.8.0)
- public_suffix (>= 2.0.2, < 5.0)
+ addressable (2.8.1)
+ public_suffix (>= 2.0.2, < 6.0)
coffee-script (2.4.1)
coffee-script-source
execjs
coffee-script-source (1.11.1)
colorator (1.1.0)
- commonmarker (0.23.5)
+ commonmarker (0.23.6)
concurrent-ruby (1.1.10)
dnsruby (1.61.9)
simpleidn (~> 0.1)
@@ -25,10 +25,10 @@ GEM
ffi (>= 1.15.0)
eventmachine (1.2.7)
execjs (2.8.1)
- faraday (2.5.2)
+ faraday (2.6.0)
faraday-net_http (>= 2.0, < 3.1)
ruby2_keywords (>= 0.0.4)
- faraday-net_http (3.0.0)
+ faraday-net_http (3.0.1)
ffi (1.15.5)
forwardable-extended (2.6.0)
gemoji (3.0.1)
@@ -83,7 +83,7 @@ GEM
octokit (~> 4.0)
public_suffix (>= 3.0, < 5.0)
typhoeus (~> 1.3)
- html-pipeline (2.14.2)
+ html-pipeline (2.14.3)
activesupport (>= 2)
nokogiri (>= 1.4)
http_parser.rb (0.8.0)
@@ -211,8 +211,8 @@ GEM
jekyll (>= 3.5, < 5.0)
jekyll-feed (~> 0.9)
jekyll-seo-tag (~> 2.1)
- minitest (5.16.2)
- nokogiri (1.13.8)
+ minitest (5.16.3)
+ nokogiri (1.13.9)
mini_portile2 (~> 2.8.0)
racc (~> 1.4)
octokit (4.25.1)
@@ -222,7 +222,7 @@ GEM
forwardable-extended (~> 2.6)
public_suffix (4.0.7)
racc (1.6.0)
- rb-fsevent (0.11.1)
+ rb-fsevent (0.11.2)
rb-inotify (0.10.1)
ffi (~> 1.0)
rexml (3.2.5)
@@ -251,7 +251,7 @@ GEM
unf_ext
unf_ext (0.0.8.2)
unicode-display_width (1.8.0)
- zeitwerk (2.6.0)
+ zeitwerk (2.6.1)
PLATFORMS
ruby
diff --git a/docs/getting-started/checkout-v1.md b/docs/getting-started/checkout-v1.md
index 2d0517ad..535303d8 100644
--- a/docs/getting-started/checkout-v1.md
+++ b/docs/getting-started/checkout-v1.md
@@ -28,6 +28,13 @@ class ExampleActivity: Activity {
val afterpayCheckoutButton = findViewById