Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package com.processout.sdk.api.model.response.napm.v2

import com.processout.sdk.api.model.response.napm.v2.PONativeAlternativePaymentAuthorizationResponse.Invoice
import com.processout.sdk.core.annotation.ProcessOutInternalApi
import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass

/**
Expand All @@ -16,8 +18,8 @@ import com.squareup.moshi.JsonClass
@ProcessOutInternalApi
data class PONativeAlternativePaymentAuthorizationResponse(
val state: PONativeAlternativePaymentState,
// val invoice: Invoice, // TODO(v2): uncomment
// val paymentMethod: PONativeAlternativePaymentMethodDetails, // TODO(v2): uncomment
val invoice: Invoice,
val paymentMethod: PONativeAlternativePaymentMethodDetails,
val elements: List<PONativeAlternativePaymentElement>?,
val redirect: PONativeAlternativePaymentRedirect?
) {
Expand All @@ -38,9 +40,9 @@ data class PONativeAlternativePaymentAuthorizationResponse(
@JsonClass(generateAdapter = true)
internal data class NativeAlternativePaymentAuthorizationResponseBody(
val state: PONativeAlternativePaymentState,
// val invoice: Invoice, // TODO(v2): uncomment
// @Json(name = "payment_method")
// val paymentMethod: PONativeAlternativePaymentMethodDetails, // TODO(v2): uncomment
val invoice: Invoice,
@Json(name = "payment_method")
val paymentMethod: PONativeAlternativePaymentMethodDetails,
val elements: List<NativeAlternativePaymentElement>?,
val redirect: PONativeAlternativePaymentRedirect?
)
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.processout.sdk.api.model.response.napm.v2

import com.processout.sdk.core.annotation.ProcessOutInternalApi
import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass

/**
Expand All @@ -15,16 +16,16 @@ import com.squareup.moshi.JsonClass
@ProcessOutInternalApi
data class PONativeAlternativePaymentTokenizationResponse(
val state: PONativeAlternativePaymentState,
// val paymentMethod: PONativeAlternativePaymentMethodDetails, // TODO(v2): uncomment
val paymentMethod: PONativeAlternativePaymentMethodDetails,
val elements: List<PONativeAlternativePaymentElement>?,
val redirect: PONativeAlternativePaymentRedirect?
)

@JsonClass(generateAdapter = true)
internal data class NativeAlternativePaymentTokenizationResponseBody(
val state: PONativeAlternativePaymentState,
// @Json(name = "payment_method")
// val paymentMethod: PONativeAlternativePaymentMethodDetails, // TODO(v2): uncomment
@Json(name = "payment_method")
val paymentMethod: PONativeAlternativePaymentMethodDetails,
val elements: List<NativeAlternativePaymentElement>?,
val redirect: PONativeAlternativePaymentRedirect?
)
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ internal interface CustomerTokensApi {
@Body request: AssignCustomerTokenRequestWithDeviceData
): Response<CustomerTokenResponse>

@POST("/customers/{customer_id}/tokens/{token_id}/tokenize")
@POST("/customers/{customer_id}/apm-tokens/{token_id}/tokenize")
suspend fun tokenize(
@Path("customer_id") customerId: String,
@Path("token_id") tokenId: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,6 @@ internal interface InvoicesApi {
@Body request: NativeAlternativePaymentRequestBody
): Response<NativeAlternativePaymentAuthorizationResponseBody>

@GET("/invoices/{invoiceId}/apm-payment/{gatewayConfigurationId}")
suspend fun nativeAlternativePayment(
@Path("invoiceId") invoiceId: String,
@Path("gatewayConfigurationId") gatewayConfigurationId: String
): Response<NativeAlternativePaymentAuthorizationResponseBody>

@POST("/invoices/{id}/native-payment")
suspend fun initiatePayment(
@Path("id") invoiceId: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ internal class DefaultCustomerTokensRepository(
private fun NativeAlternativePaymentTokenizationResponseBody.toModel() =
PONativeAlternativePaymentTokenizationResponse(
state = state,
// paymentMethod = paymentMethod, // TODO(v2): uncomment
paymentMethod = paymentMethod,
elements = elements?.map {
when (it) {
is NativeAlternativePaymentElement.Form ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package com.processout.sdk.api.repository
import com.processout.sdk.api.model.request.*
import com.processout.sdk.api.model.request.napm.v2.NativeAlternativePaymentRequestBody
import com.processout.sdk.api.model.request.napm.v2.NativeAlternativePaymentRequestBody.SubmitData
import com.processout.sdk.api.model.request.napm.v2.PONativeAlternativePaymentAuthorizationDetailsRequest
import com.processout.sdk.api.model.request.napm.v2.PONativeAlternativePaymentAuthorizationRequest
import com.processout.sdk.api.model.request.napm.v2.PONativeAlternativePaymentSubmitData.Parameter
import com.processout.sdk.api.model.request.napm.v2.PONativeAlternativePaymentSubmitData.Parameter.Value
Expand Down Expand Up @@ -44,15 +43,6 @@ internal class DefaultInvoicesRepository(
)
}.map { it.toModel() }

override suspend fun nativeAlternativePayment(
request: PONativeAlternativePaymentAuthorizationDetailsRequest
) = apiCall {
api.nativeAlternativePayment(
invoiceId = request.invoiceId,
gatewayConfigurationId = request.gatewayConfigurationId
)
}.map { it.toModel() }

override suspend fun initiatePayment(
request: PONativeAlternativePaymentMethodRequest
) = apiCall {
Expand Down Expand Up @@ -172,8 +162,8 @@ internal class DefaultInvoicesRepository(
private fun NativeAlternativePaymentAuthorizationResponseBody.toModel() =
PONativeAlternativePaymentAuthorizationResponse(
state = state,
// invoice = invoice, // TODO(v2): uncomment
// paymentMethod = paymentMethod, // TODO(v2): uncomment
invoice = invoice,
paymentMethod = paymentMethod,
elements = elements?.map {
when (it) {
is NativeAlternativePaymentElement.Form ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import com.processout.sdk.api.model.request.POCreateInvoiceRequest
import com.processout.sdk.api.model.request.POInvoiceAuthorizationRequest
import com.processout.sdk.api.model.request.POInvoiceRequest
import com.processout.sdk.api.model.request.PONativeAlternativePaymentMethodRequest
import com.processout.sdk.api.model.request.napm.v2.PONativeAlternativePaymentAuthorizationDetailsRequest
import com.processout.sdk.api.model.request.napm.v2.PONativeAlternativePaymentAuthorizationRequest
import com.processout.sdk.api.model.response.*
import com.processout.sdk.api.model.response.napm.v2.PONativeAlternativePaymentAuthorizationResponse
Expand All @@ -22,10 +21,6 @@ internal interface InvoicesRepository {
request: PONativeAlternativePaymentAuthorizationRequest
): ProcessOutResult<PONativeAlternativePaymentAuthorizationResponse>

suspend fun nativeAlternativePayment(
request: PONativeAlternativePaymentAuthorizationDetailsRequest
): ProcessOutResult<PONativeAlternativePaymentAuthorizationResponse>

suspend fun initiatePayment(
request: PONativeAlternativePaymentMethodRequest
): ProcessOutResult<PONativeAlternativePaymentMethod>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import com.processout.sdk.api.model.request.POCreateInvoiceRequest
import com.processout.sdk.api.model.request.POInvoiceAuthorizationRequest
import com.processout.sdk.api.model.request.POInvoiceRequest
import com.processout.sdk.api.model.request.PONativeAlternativePaymentMethodRequest
import com.processout.sdk.api.model.request.napm.v2.PONativeAlternativePaymentAuthorizationDetailsRequest
import com.processout.sdk.api.model.request.napm.v2.PONativeAlternativePaymentAuthorizationRequest
import com.processout.sdk.api.model.response.POInvoice
import com.processout.sdk.api.model.response.PONativeAlternativePaymentMethod
Expand Down Expand Up @@ -170,11 +169,6 @@ internal class DefaultInvoicesService(
): ProcessOutResult<PONativeAlternativePaymentAuthorizationResponse> =
repository.authorizeInvoice(request)

override suspend fun nativeAlternativePayment(
request: PONativeAlternativePaymentAuthorizationDetailsRequest
): ProcessOutResult<PONativeAlternativePaymentAuthorizationResponse> =
repository.nativeAlternativePayment(request)

override suspend fun initiatePayment(
request: PONativeAlternativePaymentMethodRequest
): ProcessOutResult<PONativeAlternativePaymentMethod> =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import com.processout.sdk.api.model.request.POCreateInvoiceRequest
import com.processout.sdk.api.model.request.POInvoiceAuthorizationRequest
import com.processout.sdk.api.model.request.POInvoiceRequest
import com.processout.sdk.api.model.request.PONativeAlternativePaymentMethodRequest
import com.processout.sdk.api.model.request.napm.v2.PONativeAlternativePaymentAuthorizationDetailsRequest
import com.processout.sdk.api.model.request.napm.v2.PONativeAlternativePaymentAuthorizationRequest
import com.processout.sdk.api.model.response.POInvoice
import com.processout.sdk.api.model.response.PONativeAlternativePaymentMethod
Expand Down Expand Up @@ -75,15 +74,6 @@ interface POInvoicesService {
request: PONativeAlternativePaymentAuthorizationRequest
): ProcessOutResult<PONativeAlternativePaymentAuthorizationResponse>

/**
* Fetch native alternative payment details.
*/
/** @suppress */
@ProcessOutInternalApi
suspend fun nativeAlternativePayment(
request: PONativeAlternativePaymentAuthorizationDetailsRequest
): ProcessOutResult<PONativeAlternativePaymentAuthorizationResponse>

/**
* Initiates native alternative payment with the given request.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ data class PONativeAlternativePaymentConfiguration(
@Parcelize
data class Style(
val title: POTextStyle? = null,
val label: POTextStyle? = null,
val label: POTextStyle? = null, // TODO(v2): remove, not used
val field: POFieldStyle? = null,
val codeField: POFieldStyle? = null,
val radioField: PORadioFieldStyle? = null,
Expand All @@ -323,7 +323,7 @@ data class PONativeAlternativePaymentConfiguration(
val dialog: PODialogStyle? = null,
val background: POBackgroundStyle? = null,
val message: POTextStyle? = null,
val errorMessage: POTextStyle? = null,
val errorMessage: POTextStyle? = null, // TODO(v2): remove, not used
val errorMessageBox: POMessageBoxStyle? = null,
val successMessage: POTextStyle? = null,
@DrawableRes
Expand All @@ -346,14 +346,12 @@ data class PONativeAlternativePaymentConfiguration(
* @param[field] Field style.
* @param[codeField] Code field style.
* @param[radioButton] Radio button style. __Deprecated__: not used.
* @param[checkbox] Checkbox style.
* @param[dropdownMenu] Dropdown menu style.
* @param[actionsContainer] Style of action buttons and their container.
* @param[dialog] Dialog style.
* @param[background] Background style.
* @param[message] Message style.
* @param[errorMessage] Error message style.
* @param[errorMessageBox] Error message box style.
* @param[successMessage] Success message style.
* @param[successImageResId] Success image drawable resource ID.
* @param[progressIndicatorColorResId] Color resource ID for progress indicator.
Expand All @@ -368,14 +366,12 @@ data class PONativeAlternativePaymentConfiguration(
field: POFieldStyle? = null,
codeField: POFieldStyle? = null,
radioButton: PORadioButtonStyle? = null,
checkbox: POCheckboxStyle? = null,
dropdownMenu: PODropdownMenuStyle? = null,
actionsContainer: POActionsContainerStyle? = null,
dialog: PODialogStyle? = null,
background: POBackgroundStyle? = null,
message: POTextStyle? = null,
errorMessage: POTextStyle? = null,
errorMessageBox: POMessageBoxStyle? = null,
successMessage: POTextStyle? = null,
@DrawableRes
successImageResId: Int? = null,
Expand All @@ -393,14 +389,14 @@ data class PONativeAlternativePaymentConfiguration(
field = field,
codeField = codeField,
radioField = null,
checkbox = checkbox,
checkbox = null,
dropdownMenu = dropdownMenu,
actionsContainer = actionsContainer,
dialog = dialog,
background = background,
message = message,
errorMessage = errorMessage,
errorMessageBox = errorMessageBox,
errorMessageBox = null,
successMessage = successMessage,
successImageResId = successImageResId,
progressIndicatorColorResId = progressIndicatorColorResId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ import coil.request.ImageRequest
import coil.request.ImageResult
import com.processout.sdk.R
import com.processout.sdk.api.dispatcher.POEventDispatcher
import com.processout.sdk.api.model.request.napm.v2.PONativeAlternativePaymentAuthorizationDetailsRequest
import com.processout.sdk.api.model.request.napm.v2.PONativeAlternativePaymentAuthorizationRequest
import com.processout.sdk.api.model.request.napm.v2.PONativeAlternativePaymentSubmitData
import com.processout.sdk.api.model.request.napm.v2.PONativeAlternativePaymentSubmitData.Parameter.Companion.phoneNumber
import com.processout.sdk.api.model.request.napm.v2.PONativeAlternativePaymentSubmitData.Parameter.Companion.string
import com.processout.sdk.api.model.request.napm.v2.PONativeAlternativePaymentTokenizationRequest
import com.processout.sdk.api.model.response.napm.v2.*
import com.processout.sdk.api.model.response.napm.v2.PONativeAlternativePaymentAuthorizationResponse.Invoice
import com.processout.sdk.api.model.response.napm.v2.PONativeAlternativePaymentElement.CustomerInstruction
import com.processout.sdk.api.model.response.napm.v2.PONativeAlternativePaymentElement.Form
import com.processout.sdk.api.model.response.napm.v2.PONativeAlternativePaymentElement.Form.Parameter
Expand Down Expand Up @@ -157,14 +157,17 @@ internal class NativeAlternativePaymentInteractor(
}

private suspend fun fetchAuthorizationDetails(flow: Authorization) {
val request = PONativeAlternativePaymentAuthorizationDetailsRequest(
val request = PONativeAlternativePaymentAuthorizationRequest(
invoiceId = flow.invoiceId,
gatewayConfigurationId = flow.gatewayConfigurationId
)
invoicesService.nativeAlternativePayment(request)
invoicesService.authorize(request)
.onSuccess { response ->
handlePaymentState(
stateValue = initUserInputStateValue(),
stateValue = initUserInputStateValue(
paymentMethod = response.paymentMethod,
invoice = response.invoice
),
paymentState = response.state,
elements = response.elements
)
Expand All @@ -183,7 +186,10 @@ internal class NativeAlternativePaymentInteractor(
customerTokensService.tokenize(request)
.onSuccess { response ->
handlePaymentState(
stateValue = initUserInputStateValue(),
stateValue = initUserInputStateValue(
paymentMethod = response.paymentMethod,
invoice = null
),
paymentState = response.state,
elements = response.elements
)
Expand Down Expand Up @@ -216,7 +222,12 @@ internal class NativeAlternativePaymentInteractor(
handleFormParameters(stateValue, parameters)
}

private fun initUserInputStateValue() = UserInputStateValue(
private fun initUserInputStateValue(
paymentMethod: PONativeAlternativePaymentMethodDetails,
invoice: Invoice?,
) = UserInputStateValue(
paymentMethod = paymentMethod,
invoice = invoice,
fields = emptyList(),
focusedFieldId = null,
primaryActionId = ActionId.SUBMIT,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ package com.processout.sdk.ui.napm.v2

import android.graphics.Bitmap
import com.processout.sdk.api.model.response.POBarcode.BarcodeType
import com.processout.sdk.api.model.response.napm.v2.PONativeAlternativePaymentAuthorizationResponse.Invoice
import com.processout.sdk.api.model.response.napm.v2.PONativeAlternativePaymentElement.Form.Parameter
import com.processout.sdk.api.model.response.napm.v2.PONativeAlternativePaymentElement.Form.Parameter.*
import com.processout.sdk.api.model.response.napm.v2.PONativeAlternativePaymentMethodDetails
import com.processout.sdk.ui.napm.v2.NativeAlternativePaymentInteractorState.*
import com.processout.sdk.ui.shared.state.FieldValue
import kotlinx.coroutines.flow.MutableStateFlow
Expand Down Expand Up @@ -39,8 +41,8 @@ internal sealed interface NativeAlternativePaymentInteractorState {
//endregion

data class UserInputStateValue(
// val invoice: Invoice, // TODO(v2)
// val gateway: Gateway, // TODO(v2)
val paymentMethod: PONativeAlternativePaymentMethodDetails,
val invoice: Invoice?,
val fields: List<Field>,
val focusedFieldId: String?,
val primaryActionId: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -709,7 +709,6 @@ internal object NativeAlternativePaymentScreen {
@Immutable
data class Style(
val title: POText.Style,
val label: POText.Style,
val field: POField.Style,
val codeField: POField.Style,
val radioField: PORadioField.Style,
Expand All @@ -720,7 +719,6 @@ internal object NativeAlternativePaymentScreen {
val normalBackgroundColor: Color,
val successBackgroundColor: Color,
val message: AndroidTextView.Style,
val errorMessage: POText.Style,
val errorMessageBox: POMessageBox.Style,
val successMessage: POText.Style,
@DrawableRes val successImageResId: Int,
Expand All @@ -736,9 +734,6 @@ internal object NativeAlternativePaymentScreen {
title = custom?.title?.let {
POText.custom(style = it)
} ?: POText.title,
label = custom?.label?.let {
POText.custom(style = it)
} ?: POText.label1,
field = custom?.field?.let {
POField.custom(style = it)
} ?: POField.default2,
Expand Down Expand Up @@ -773,9 +768,6 @@ internal object NativeAlternativePaymentScreen {
controlsTintColor = controlsTintColor ?: colors.text.primary
)
} ?: AndroidTextView.default,
errorMessage = custom?.errorMessage?.let {
POText.custom(style = it)
} ?: POText.errorLabel,
errorMessageBox = custom?.errorMessageBox?.let {
POMessageBox.custom(style = it)
} ?: POMessageBox.error2,
Expand Down
Loading