Skip to main content

Payment API Reference

Complete reference for payment-related operations in the Reachu Kotlin SDK.

PaymentRepository

Get Available Payment Methods

suspend fun getAvailableMethods(): List<PaymentMethodDto>

Returns list of payment methods available for the current checkout.

Example:

val methods = sdk.payment.getAvailableMethods()
methods.forEach { method ->
println("Available: ${method.name}")
}

Stripe Payment

Create Payment Intent

suspend fun stripeIntent(
checkoutId: String,
returnEphemeralKey: Boolean = true
): PaymentIntentStripeDto

Creates a Stripe payment intent for the checkout.

Parameters: - checkoutId - The checkout ID

  • returnEphemeralKey - Whether to return ephemeral key (default: true)

Returns:PaymentIntentStripeDto with clientSecret and publishableKey

Example:

val intent = sdk.payment.stripeIntent(
checkoutId = checkout.id,
returnEphemeralKey = true
)

suspend fun stripeLink(
checkoutId: String,
successUrl: String,
paymentMethod: String,
email: String
): InitPaymentStripeDto

Initializes Stripe Link payment.

Klarna Payment

Klarna Native Init

suspend fun klarnaNativeInit(
checkoutId: String,
input: KlarnaNativeInitInputDto
): InitPaymentKlarnaNativeDto

Initializes Klarna native payment session.

Parameters: - checkoutId - The checkout ID

  • input - Klarna initialization input

Returns:InitPaymentKlarnaNativeDto with clientToken and sessionId

Example:

val input = KlarnaNativeInitInputDto(
countryCode = "NO",
currency = "NOK",
returnUrl = "reachu://klarna/callback"
)
val result = sdk.payment.klarnaNativeInit(
checkoutId = checkout.id,
input = input
)

Klarna Native Confirm

suspend fun klarnaNativeConfirm(
checkoutId: String,
input: KlarnaNativeConfirmInputDto
): ConfirmPaymentKlarnaNativeDto

Confirms Klarna native payment with authorization token.

Example:

val input = KlarnaNativeConfirmInputDto(
authorizationToken = authToken,
autoCapture = true
)
val result = sdk.payment.klarnaNativeConfirm(
checkoutId = checkout.id,
input = input
)

Klarna Web Init

suspend fun klarnaInit(
checkoutId: String,
countryCode: String,
href: String,
email: String?
): InitPaymentKlarnaDto

Initializes Klarna web payment (fallback when native is not available).

Vipps Payment

Vipps Init

suspend fun vippsInit(
checkoutId: String,
email: String,
returnUrl: String
): InitPaymentVippsDto

Initializes Vipps payment session.

Example:

val result = sdk.payment.vippsInit(
checkoutId = checkout.id,
email = "customer@example.com",
returnUrl = "reachu://vipps/callback"
)

Data Transfer Objects

KlarnaNativeInitInputDto

data class KlarnaNativeInitInputDto(
val countryCode: String,
val currency: String,
val returnUrl: String,
val locale: String? = null,
val customer: KlarnaNativeCustomerInputDto? = null,
val billingAddress: KlarnaNativeAddressInputDto? = null,
val shippingAddress: KlarnaNativeAddressInputDto? = null,
val autoCapture: Boolean = true
)

KlarnaNativeConfirmInputDto

data class KlarnaNativeConfirmInputDto(
val authorizationToken: String,
val autoCapture: Boolean? = null,
val customer: KlarnaNativeCustomerInputDto? = null,
val billingAddress: KlarnaNativeAddressInputDto? = null,
val shippingAddress: KlarnaNativeAddressInputDto? = null
)

Error Handling

All payment methods throw SdkException on error:

try {
val intent = sdk.payment.stripeIntent(checkoutId)
} catch (e: SdkException) {
when (e) {
is AuthException -> { /* Handle auth error */ }
is ValidationException -> { /* Handle validation error */ }
else -> { /* Handle other errors */ }
}
}

Next Steps