Skip to content

Commit 28ce7f8

Browse files
feat(POM-519): nAPM headless redirect (#336)
1 parent 9db4d75 commit 28ce7f8

14 files changed

Lines changed: 457 additions & 65 deletions

example/src/main/kotlin/com/processout/example/ui/screen/nativeapm/NativeApmFragment.kt

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,9 @@ class NativeApmFragment : BaseFragment<FragmentNativeApmBinding>(
119119
gatewayConfigurationId = uiModel.gatewayConfigurationId
120120
),
121121
cancelButton = CancelButton(),
122-
returnUrl = Constants.RETURN_URL,
122+
redirect = RedirectConfiguration(
123+
returnUrl = Constants.RETURN_URL
124+
),
123125
paymentConfirmation = PaymentConfirmationConfiguration(
124126
confirmButton = Button(),
125127
cancelButton = CancelButton(disabledForSeconds = 3)
@@ -134,11 +136,15 @@ class NativeApmFragment : BaseFragment<FragmentNativeApmBinding>(
134136
customerTokenId = uiModel.customerTokenId
135137
),
136138
cancelButton = CancelButton(),
137-
returnUrl = Constants.RETURN_URL,
139+
redirect = RedirectConfiguration(
140+
returnUrl = Constants.RETURN_URL,
141+
enableHeadlessMode = true
142+
),
138143
paymentConfirmation = PaymentConfirmationConfiguration(
139144
confirmButton = Button(),
140145
cancelButton = CancelButton(disabledForSeconds = 3)
141-
)
146+
),
147+
success = null
142148
)
143149
)
144150
AUTHORIZE_LEGACY -> launcherLegacy.launch(
@@ -155,7 +161,9 @@ class NativeApmFragment : BaseFragment<FragmentNativeApmBinding>(
155161
gatewayConfigurationId = uiModel.gatewayConfigurationId
156162
),
157163
cancelButton = CancelButton(),
158-
returnUrl = Constants.RETURN_URL,
164+
redirect = RedirectConfiguration(
165+
returnUrl = Constants.RETURN_URL
166+
),
159167
paymentConfirmation = PaymentConfirmationConfiguration(
160168
confirmButton = Button(),
161169
cancelButton = CancelButton(disabledForSeconds = 3)
Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,33 @@
11
package com.processout.sdk.api.model.response
22

3+
import android.os.Parcelable
34
import com.squareup.moshi.Json
45
import com.squareup.moshi.JsonClass
6+
import kotlinx.parcelize.Parcelize
57

68
/**
79
* Image resource for light/dark themes.
810
*
911
* @param[lightUrl] URL to image for light theme.
1012
* @param[darkUrl] URL to image for dark theme.
1113
*/
14+
@Parcelize
1215
@JsonClass(generateAdapter = true)
1316
data class POImageResource(
1417
@Json(name = "light_url")
1518
val lightUrl: ResourceUrl,
1619
@Json(name = "dark_url")
1720
val darkUrl: ResourceUrl?
18-
) {
21+
) : Parcelable {
1922

2023
/**
2124
* Image resource URL.
2225
*
2326
* @param[raster] URL to raster image.
2427
*/
28+
@Parcelize
2529
@JsonClass(generateAdapter = true)
2630
data class ResourceUrl(
2731
val raster: String
28-
)
32+
) : Parcelable
2933
}

sdk/src/main/kotlin/com/processout/sdk/api/model/response/napm/v2/PONativeAlternativePaymentAuthorizationResponse.kt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
package com.processout.sdk.api.model.response.napm.v2
22

3+
import android.os.Parcelable
34
import com.processout.sdk.api.model.response.napm.v2.PONativeAlternativePaymentAuthorizationResponse.Invoice
45
import com.squareup.moshi.Json
56
import com.squareup.moshi.JsonClass
7+
import kotlinx.parcelize.Parcelize
68

79
/**
810
* Specifies details of native alternative payment.
@@ -13,25 +15,27 @@ import com.squareup.moshi.JsonClass
1315
* @param[elements] An ordered list of elements that needs to be rendered on the UI during native alternative payment flow.
1416
* @param[redirect] Indicates required redirect.
1517
*/
18+
@Parcelize
1619
data class PONativeAlternativePaymentAuthorizationResponse(
1720
val state: PONativeAlternativePaymentState,
1821
val invoice: Invoice,
1922
val paymentMethod: PONativeAlternativePaymentMethodDetails,
2023
val elements: List<PONativeAlternativePaymentElement>?,
2124
val redirect: PONativeAlternativePaymentRedirect?
22-
) {
25+
) : Parcelable {
2326

2427
/**
2528
* Invoice details.
2629
*
2730
* @param[amount] Invoice amount.
2831
* @param[currency] Invoice currency.
2932
*/
33+
@Parcelize
3034
@JsonClass(generateAdapter = true)
3135
data class Invoice(
3236
val amount: String,
3337
val currency: String
34-
)
38+
) : Parcelable
3539
}
3640

3741
@JsonClass(generateAdapter = true)

sdk/src/main/kotlin/com/processout/sdk/api/model/response/napm/v2/PONativeAlternativePaymentCustomerInstruction.kt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,25 @@
11
package com.processout.sdk.api.model.response.napm.v2
22

3+
import android.os.Parcelable
34
import com.processout.sdk.api.model.response.POBarcode
45
import com.processout.sdk.api.model.response.POImageResource
56
import com.processout.sdk.core.annotation.ProcessOutInternalApi
67
import com.squareup.moshi.Json
78
import com.squareup.moshi.JsonClass
9+
import kotlinx.parcelize.Parcelize
810

911
/**
1012
* Specifies instruction for the customer, providing additional information and/or describing required actions.
1113
*/
12-
sealed class PONativeAlternativePaymentCustomerInstruction {
14+
sealed class PONativeAlternativePaymentCustomerInstruction : Parcelable {
1315

1416
/**
1517
* Customer instruction provided as a markdown text.
1618
*
1719
* @param[label] Optional label.
1820
* @param[value] Markdown text.
1921
*/
22+
@Parcelize
2023
@JsonClass(generateAdapter = true)
2124
data class Message(
2225
val label: String?,
@@ -28,6 +31,7 @@ sealed class PONativeAlternativePaymentCustomerInstruction {
2831
*
2932
* @param[value] Image resource.
3033
*/
34+
@Parcelize
3135
@JsonClass(generateAdapter = true)
3236
data class Image(
3337
val value: POImageResource
@@ -39,6 +43,7 @@ sealed class PONativeAlternativePaymentCustomerInstruction {
3943
* @param[rawSubtype] Raw barcode subtype.
4044
* @param[rawValue] Base64 encoded value.
4145
*/
46+
@Parcelize
4247
@JsonClass(generateAdapter = true)
4348
data class Barcode(
4449
@Json(name = "subtype")
@@ -59,6 +64,7 @@ sealed class PONativeAlternativePaymentCustomerInstruction {
5964
* Placeholder that allows adding additional cases while staying backward compatible.
6065
* __Warning:__ Do not match this case directly, use _when-else_ instead.
6166
*/
67+
@Parcelize
6268
@ProcessOutInternalApi
6369
data object Unknown : PONativeAlternativePaymentCustomerInstruction()
6470
}

sdk/src/main/kotlin/com/processout/sdk/api/model/response/napm/v2/PONativeAlternativePaymentElement.kt

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,31 @@
11
package com.processout.sdk.api.model.response.napm.v2
22

3+
import android.os.Parcelable
34
import com.processout.sdk.api.model.response.napm.v2.PONativeAlternativePaymentElement.Form.Parameter
45
import com.processout.sdk.core.annotation.ProcessOutInternalApi
56
import com.processout.sdk.core.util.findBy
67
import com.squareup.moshi.Json
78
import com.squareup.moshi.JsonClass
9+
import kotlinx.parcelize.IgnoredOnParcel
10+
import kotlinx.parcelize.Parcelize
811

912
/**
1013
* Specifies an element that needs to be rendered on the UI during native alternative payment flow.
1114
*/
12-
sealed class PONativeAlternativePaymentElement {
15+
sealed class PONativeAlternativePaymentElement : Parcelable {
1316

1417
/**
1518
* A form element with the specified [parameterDefinitions].
1619
*/
20+
@Parcelize
1721
data class Form(
1822
val parameterDefinitions: List<Parameter>
1923
) : PONativeAlternativePaymentElement() {
2024

2125
/**
2226
* Payment parameter definition.
2327
*/
24-
sealed class Parameter {
28+
sealed class Parameter : Parcelable {
2529

2630
/** Parameter key. */
2731
abstract val key: String
@@ -41,6 +45,7 @@ sealed class PONativeAlternativePaymentElement {
4145
* @param[minLength] Optional minimum length.
4246
* @param[maxLength] Optional maximum length.
4347
*/
48+
@Parcelize
4449
@JsonClass(generateAdapter = true)
4550
data class Text(
4651
override val key: String,
@@ -60,6 +65,7 @@ sealed class PONativeAlternativePaymentElement {
6065
* @param[required] Indicates whether the parameter is required.
6166
* @param[availableValues] Available values.
6267
*/
68+
@Parcelize
6369
@JsonClass(generateAdapter = true)
6470
data class SingleSelect(
6571
override val key: String,
@@ -80,12 +86,13 @@ sealed class PONativeAlternativePaymentElement {
8086
* @param[label] Value display label.
8187
* @param[preselected] Indicates whether the value should be preselected by default.
8288
*/
89+
@Parcelize
8390
@JsonClass(generateAdapter = true)
8491
data class AvailableValue(
8592
val value: String,
8693
val label: String,
8794
val preselected: Boolean
88-
)
95+
) : Parcelable
8996
}
9097

9198
/**
@@ -95,6 +102,7 @@ sealed class PONativeAlternativePaymentElement {
95102
* @param[label] Parameter display label.
96103
* @param[required] Indicates whether the parameter is required.
97104
*/
105+
@Parcelize
98106
@JsonClass(generateAdapter = true)
99107
data class Bool(
100108
override val key: String,
@@ -111,6 +119,7 @@ sealed class PONativeAlternativePaymentElement {
111119
* @param[minLength] Optional minimum length.
112120
* @param[maxLength] Optional maximum length.
113121
*/
122+
@Parcelize
114123
@JsonClass(generateAdapter = true)
115124
data class Digits(
116125
override val key: String,
@@ -130,6 +139,7 @@ sealed class PONativeAlternativePaymentElement {
130139
* @param[required] Indicates whether the parameter is required.
131140
* @param[dialingCodes] Supported international dialing codes.
132141
*/
142+
@Parcelize
133143
@JsonClass(generateAdapter = true)
134144
data class PhoneNumber(
135145
override val key: String,
@@ -146,12 +156,13 @@ sealed class PONativeAlternativePaymentElement {
146156
* Corresponds to a two-letter ISO 3166-1 alpha-2 country code.
147157
* @param[value] Dialing code value.
148158
*/
159+
@Parcelize
149160
@JsonClass(generateAdapter = true)
150161
data class DialingCode(
151162
@Json(name = "region_code")
152163
val regionCode: String,
153164
val value: String
154-
)
165+
) : Parcelable
155166
}
156167

157168
/**
@@ -161,6 +172,7 @@ sealed class PONativeAlternativePaymentElement {
161172
* @param[label] Parameter display label.
162173
* @param[required] Indicates whether the parameter is required.
163174
*/
175+
@Parcelize
164176
@JsonClass(generateAdapter = true)
165177
data class Email(
166178
override val key: String,
@@ -177,6 +189,7 @@ sealed class PONativeAlternativePaymentElement {
177189
* @param[minLength] Optional minimum length.
178190
* @param[maxLength] Optional maximum length.
179191
*/
192+
@Parcelize
180193
@JsonClass(generateAdapter = true)
181194
data class Card(
182195
override val key: String,
@@ -198,6 +211,7 @@ sealed class PONativeAlternativePaymentElement {
198211
* @param[minLength] Optional minimum length.
199212
* @param[maxLength] Optional maximum length.
200213
*/
214+
@Parcelize
201215
@JsonClass(generateAdapter = true)
202216
data class Otp(
203217
override val key: String,
@@ -238,10 +252,16 @@ sealed class PONativeAlternativePaymentElement {
238252
* Placeholder that allows adding additional cases while staying backward compatible.
239253
* __Warning:__ Do not match this case directly, use _when-else_ instead.
240254
*/
255+
@Parcelize
241256
@ProcessOutInternalApi
242257
data object Unknown : Parameter() {
258+
@IgnoredOnParcel
243259
override val key = String()
260+
261+
@IgnoredOnParcel
244262
override val label = String()
263+
264+
@IgnoredOnParcel
245265
override val required = false
246266
}
247267
}
@@ -250,6 +270,7 @@ sealed class PONativeAlternativePaymentElement {
250270
/**
251271
* Specifies instruction for the customer, providing additional information and/or describing required actions.
252272
*/
273+
@Parcelize
253274
data class CustomerInstruction(
254275
val instruction: PONativeAlternativePaymentCustomerInstruction
255276
) : PONativeAlternativePaymentElement()
@@ -260,6 +281,7 @@ sealed class PONativeAlternativePaymentElement {
260281
* @param[label] Optional group display label.
261282
* @param[instructions] Grouped instructions for the customer that provide additional information and/or describe required actions.
262283
*/
284+
@Parcelize
263285
data class CustomerInstructionGroup(
264286
val label: String?,
265287
val instructions: List<PONativeAlternativePaymentCustomerInstruction>
@@ -269,6 +291,7 @@ sealed class PONativeAlternativePaymentElement {
269291
* Placeholder that allows adding additional cases while staying backward compatible.
270292
* __Warning:__ Do not match this case directly, use _when-else_ instead.
271293
*/
294+
@Parcelize
272295
@ProcessOutInternalApi
273296
data object Unknown : PONativeAlternativePaymentElement()
274297
}
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,21 @@
11
package com.processout.sdk.api.model.response.napm.v2
22

3+
import android.os.Parcelable
34
import com.processout.sdk.api.model.response.POImageResource
45
import com.squareup.moshi.Json
56
import com.squareup.moshi.JsonClass
7+
import kotlinx.parcelize.Parcelize
68

79
/**
810
* Specifies payment method details.
911
*
1012
* @param[displayName] Payment method display name.
1113
* @param[logo] Image resource for light/dark themes.
1214
*/
15+
@Parcelize
1316
@JsonClass(generateAdapter = true)
1417
data class PONativeAlternativePaymentMethodDetails(
1518
@Json(name = "display_name")
1619
val displayName: String,
1720
val logo: POImageResource
18-
)
21+
) : Parcelable
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
11
package com.processout.sdk.api.model.response.napm.v2
22

3+
import android.os.Parcelable
34
import com.squareup.moshi.JsonClass
5+
import kotlinx.parcelize.Parcelize
46

57
/**
68
* Specifies native alternative payment redirect parameters.
79
*
810
* @param[url] Redirect URL.
911
* @param[hint] A hint or description associated with the redirect URL.
1012
*/
13+
@Parcelize
1114
@JsonClass(generateAdapter = true)
1215
data class PONativeAlternativePaymentRedirect(
1316
val url: String,
1417
val hint: String
15-
)
18+
) : Parcelable

0 commit comments

Comments
 (0)