Skip to main content
The PayMaya Android SDK uses sealed classes to represent the results of various payment operations. Each operation returns a specific result type that indicates success, cancellation, or failure.

PayMayaCheckoutResult

Sealed class representing the result of a checkout payment operation.

PayMayaCheckoutResult.Success

Returned when the checkout payment completes successfully.
checkoutId
String
required
Checkout identifier for the successful transaction.

PayMayaCheckoutResult.Cancel

Returned when the user cancels the checkout payment.
checkoutId
String?
Checkout identifier if available, or null if the cancellation occurred before a checkout ID was generated.

PayMayaCheckoutResult.Failure

Returned when the checkout payment fails.
checkoutId
String?
Checkout identifier if available, or null if the failure occurred before a checkout ID was generated.
exception
Exception
required
Exception containing detailed information about the failure reason.

SinglePaymentResult

Sealed class representing the result of a single payment operation via PayWithPayMaya.

SinglePaymentResult.Success

Returned when the single payment completes successfully.
paymentId
String
required
Payment identifier for the successful transaction.

SinglePaymentResult.Cancel

Returned when the user cancels the single payment.
paymentId
String?
Payment identifier if available, or null if the cancellation occurred before a payment ID was generated.

SinglePaymentResult.Failure

Returned when the single payment fails.
paymentId
String?
Payment identifier if available, or null if the failure occurred before a payment ID was generated.
exception
Exception
required
Exception containing detailed information about the failure reason.

CreateWalletLinkResult

Sealed class representing the result of creating a wallet link.

CreateWalletLinkResult.Success

Returned when the wallet link is created successfully.
Wallet link identifier for the successfully created link.

CreateWalletLinkResult.Cancel

Returned when the user cancels the wallet link creation.
Wallet link identifier if available, or null if the cancellation occurred before a link ID was generated.

CreateWalletLinkResult.Failure

Returned when the wallet link creation fails.
Wallet link identifier if available, or null if the failure occurred before a link ID was generated.
exception
Exception
required
Exception containing detailed information about the failure reason.

PayMayaVaultResult

Sealed class representing the result of a card tokenization process.

PayMayaVaultResult.Success

Returned when card tokenization completes successfully.
paymentTokenId
String
required
The unique identifier for the payment token.
state
String
required
The state of the payment token.
createdAt
String
required
Timestamp when the token was created.
updatedAt
String
required
Timestamp when the token was last updated.
issuer
String
required
The card issuer (e.g., “VISA”, “MASTERCARD”).

PayMayaVaultResult.Cancel

Returned when the user cancels the card tokenization process. This is an object with no additional properties.

CheckPaymentStatusResult

Sealed class representing the result of checking a payment’s status.

CheckPaymentStatusResult.Success

Returned when the payment status check succeeds.
status
PaymentStatus
required
The current status of the payment. See PaymentStatus for possible values.

CheckPaymentStatusResult.Cancel

Returned when the payment status check is cancelled. This is an object with no additional properties.

CheckPaymentStatusResult.Failure

Returned when the payment status check fails.
exception
Exception
required
Exception containing detailed information about the failure reason.

PaymentStatus

Enum representing the various states a payment can be in.
StatusDescription
PENDING_TOKENToken is pending
PENDING_PAYMENTInitial payment status of the checkout transaction
PAYMENT_EXPIREDPayment transaction not executed and expiration time has been reached
FOR_AUTHENTICATIONPayment transaction is waiting for authentication
AUTHENTICATINGPayment transaction is currently authenticating
AUTH_SUCCESSAuthentication successfully executed (e.g., 3DS authentication for card transactions)
AUTH_FAILEDAuthentication of payment has failed
PAYMENT_PROCESSINGPayment is processing
PAYMENT_SUCCESSPayment is successfully processed
PAYMENT_FAILEDPayment is not successfully processed
VOIDEDSuccessfully processed payment has been reversed (usually before settlement cut-off for card-based payments)
REFUNDEDSuccessfully processed payment has been fully or partially reversed (usually after settlement cut-off for card-based payments)

Example Usage

// Checkout payment
val checkoutResult = payMayaCheckout.startCheckout(checkoutRequest)
when (checkoutResult) {
    is PayMayaCheckoutResult.Success -> {
        Log.d(TAG, "Checkout successful: ${checkoutResult.checkoutId}")
    }
    is PayMayaCheckoutResult.Cancel -> {
        Log.d(TAG, "Checkout cancelled")
    }
    is PayMayaCheckoutResult.Failure -> {
        Log.e(TAG, "Checkout failed", checkoutResult.exception)
    }
}

// Single payment
val paymentResult = payWithPayMaya.startSinglePayment(paymentRequest)
when (paymentResult) {
    is SinglePaymentResult.Success -> {
        Log.d(TAG, "Payment successful: ${paymentResult.paymentId}")
    }
    is SinglePaymentResult.Cancel -> {
        Log.d(TAG, "Payment cancelled")
    }
    is SinglePaymentResult.Failure -> {
        Log.e(TAG, "Payment failed", paymentResult.exception)
    }
}

// Wallet link creation
val linkResult = payWithPayMaya.createWalletLink(walletLinkRequest)
when (linkResult) {
    is CreateWalletLinkResult.Success -> {
        Log.d(TAG, "Wallet link created: ${linkResult.linkId}")
    }
    is CreateWalletLinkResult.Cancel -> {
        Log.d(TAG, "Wallet link creation cancelled")
    }
    is CreateWalletLinkResult.Failure -> {
        Log.e(TAG, "Wallet link creation failed", linkResult.exception)
    }
}

// Card tokenization
val vaultResult = payMayaVault.tokenizeCard()
when (vaultResult) {
    is PayMayaVaultResult.Success -> {
        Log.d(TAG, "Tokenization successful: ${vaultResult.paymentTokenId}")
        Log.d(TAG, "Issuer: ${vaultResult.issuer}")
    }
    is PayMayaVaultResult.Cancel -> {
        Log.d(TAG, "Tokenization cancelled")
    }
}

// Check payment status
val statusResult = payMayaCheckout.checkPaymentStatus(checkoutId)
when (statusResult) {
    is CheckPaymentStatusResult.Success -> {
        when (statusResult.status) {
            PaymentStatus.PAYMENT_SUCCESS -> {
                Log.d(TAG, "Payment was successful")
            }
            PaymentStatus.PAYMENT_FAILED -> {
                Log.d(TAG, "Payment failed")
            }
            else -> {
                Log.d(TAG, "Payment status: ${statusResult.status}")
            }
        }
    }
    is CheckPaymentStatusResult.Cancel -> {
        Log.d(TAG, "Status check cancelled")
    }
    is CheckPaymentStatusResult.Failure -> {
        Log.e(TAG, "Status check failed", statusResult.exception)
    }
}

Build docs developers (and LLMs) love