Skip to content

Commit

Permalink
feat(POM-419): Dynamic Checkout lifecycle events (#233)
Browse files Browse the repository at this point in the history
  • Loading branch information
vitalii-vanziak-cko authored Oct 25, 2024
1 parent 7222ad9 commit 85950c8
Show file tree
Hide file tree
Showing 11 changed files with 455 additions and 255 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package com.processout.sdk.api.model.event

import com.processout.sdk.api.model.response.PODynamicCheckoutPaymentMethod
import com.processout.sdk.core.ProcessOutResult

/**
* Defines dynamic checkout lifecycle events.
*/
sealed class PODynamicCheckoutEvent {

/**
* Initial event that is sent prior any other event.
*/
data object WillStart : PODynamicCheckoutEvent()

/**
* Event indicates that initialization is complete.
* Currently waiting for user input.
*/
data object DidStart : PODynamicCheckoutEvent()

/**
* Event is sent when user asked to confirm cancellation, e.g. via dialog.
*/
data object DidRequestCancelConfirmation : PODynamicCheckoutEvent()

/**
* Event is sent when payment method is selected by the user.
*/
data class DidSelectPaymentMethod(
val paymentMethod: PODynamicCheckoutPaymentMethod
) : PODynamicCheckoutEvent()

/**
* Event is sent when certain payment method has failed with retryable error.
* User can provide different payment details or try another payment method.
*/
data class DidFailPayment(
val failure: ProcessOutResult.Failure,
val paymentMethod: PODynamicCheckoutPaymentMethod
) : PODynamicCheckoutEvent()

/**
* Event is sent after payment was confirmed to be captured. This is a final event.
*/
data class DidCompletePayment(
val paymentMethod: PODynamicCheckoutPaymentMethod
) : PODynamicCheckoutEvent()

/**
* Event is sent when unretryable error occurs. This is a final event.
*/
data class DidFail(
val failure: ProcessOutResult.Failure
) : PODynamicCheckoutEvent()
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.processout.sdk.api.model.request

import com.processout.sdk.api.dispatcher.POEventDispatcher
import com.processout.sdk.api.model.response.POCardIssuerInformation
import com.processout.sdk.core.annotation.ProcessOutInternalApi
import java.util.UUID
Expand All @@ -12,5 +13,5 @@ import java.util.UUID
*/
data class POCardTokenizationPreferredSchemeRequest @ProcessOutInternalApi constructor(
val issuerInformation: POCardIssuerInformation,
val uuid: UUID = UUID.randomUUID()
)
override val uuid: UUID = UUID.randomUUID()
) : POEventDispatcher.Request
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.processout.sdk.api.model.request

import com.processout.sdk.api.dispatcher.POEventDispatcher
import com.processout.sdk.api.model.response.PONativeAlternativePaymentMethodParameter
import com.processout.sdk.core.annotation.ProcessOutInternalApi
import java.util.UUID
Expand All @@ -16,5 +17,5 @@ data class PONativeAlternativePaymentMethodDefaultValuesRequest @ProcessOutInter
val gatewayConfigurationId: String,
val invoiceId: String,
val parameters: List<PONativeAlternativePaymentMethodParameter>,
val uuid: UUID = UUID.randomUUID()
)
override val uuid: UUID = UUID.randomUUID()
) : POEventDispatcher.Request
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,8 @@ sealed class PODynamicCheckoutPaymentMethod {
val name: String,
val logo: POImageResource,
@Json(name = "brand_color")
val brandColor: POColor
val brandColor: POColor,
val description: String?
)

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.processout.sdk.api.model.response

import com.processout.sdk.api.dispatcher.POEventDispatcher
import com.processout.sdk.api.model.request.POCardTokenizationPreferredSchemeRequest
import java.util.UUID

Expand All @@ -12,10 +13,10 @@ import java.util.UUID
* @param[preferredScheme] Preferred scheme that will be used by default for card tokenization.
*/
data class POCardTokenizationPreferredSchemeResponse internal constructor(
val uuid: UUID,
override val uuid: UUID,
val issuerInformation: POCardIssuerInformation,
val preferredScheme: String?
)
) : POEventDispatcher.Response

/**
* Creates [POCardTokenizationPreferredSchemeResponse] from [POCardTokenizationPreferredSchemeRequest].
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.processout.sdk.api.model.response

import com.processout.sdk.api.dispatcher.POEventDispatcher
import com.processout.sdk.api.model.request.PONativeAlternativePaymentMethodDefaultValuesRequest
import java.util.UUID

Expand All @@ -11,9 +12,9 @@ import java.util.UUID
* @param[defaultValues] Map where key is [PONativeAlternativePaymentMethodParameter.key] and value is a default value for this parameter.
*/
data class PONativeAlternativePaymentMethodDefaultValuesResponse internal constructor(
val uuid: UUID,
override val uuid: UUID,
val defaultValues: Map<String, String>
)
) : POEventDispatcher.Response

/**
* Creates response with default values from request to use the same UUID.
Expand Down
Loading

0 comments on commit 85950c8

Please sign in to comment.