All Downloads are FREE. Search and download functionalities are using the official Maven repository.

co.saltpay.epos.models.response.ReverseLastPaymentResponse.kt Maven / Gradle / Ivy

There is a newer version: 1.3.2
Show newest version
package co.saltpay.epos.models.response

import kotlinx.serialization.Serializable

/**
 * Subtype of [ResponseModel] which contains possible responses
 * for the [co.saltpay.epos.models.request.ReverseLastPayment] request.
 */
@Serializable
sealed interface ReverseLastPaymentResponse : ResponseModel {

    /**
     * Subtype of [ReverseLastPaymentResponse] sent when the reversal payment
     * request is approved by payment application.
     *
     * @property requestId see [ResponseModel.requestId]
     * @property creationDateEpochTimestamp epoch timestamp in milliseconds of the payment creation
     * @property reversalId id of the reversal payment
     */
    @Serializable
    data class Approved(
        override val requestId: String,
        val creationDateEpochTimestamp: Long,
        val reversalId: String
    ) : ReverseLastPaymentResponse

    /**
     * Subtype of [ReverseLastPaymentResponse] sent when the reversal payment
     * request failed for some [Reason].
     *
     * [creationDateEpochTimestamp] and [reversalId] might be null if the error was local
     * before processing the payment in the backend.
     *
     * @property requestId see [ResponseModel.requestId]
     * @property creationDateEpochTimestamp epoch timestamp in milliseconds of the refund creation
     * @property reversalId id of the reversal
     * @property reason reason for the failure [Reason]
     */
    @Serializable
    data class Failed(
        override val requestId: String,
        val creationDateEpochTimestamp: Long?,
        val reversalId: String?,
        val reason: Reason
    ) : ReverseLastPaymentResponse {
        enum class Reason {

            /**
             * Returned when the [co.saltpay.epos.models.request.ReverseLastPayment] included the
             * [co.saltpay.epos.models.request.ReverseLastPayment.askForManagerPIN] as true and the
             * user failed to input the correct PIN.
             */
            WRONG_MANAGER_PIN,

            /**
             * Some error occurred while processing the reversal
             */
            FAILED,

            /**
             * The payment was canceled by the user
             */
            CANCELLED
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy