Skip to main content

SDK reference

The complete reference is the KDoc of the published artifacts, generated from the code at every release: your IDE shows it from the javadoc jar Maven Central serves, and each GitHub release attaches the same reference as browsable HTML. This page is the map of the public surface; names are the Kotlin ones.

Packages​

PackageMirrors (web)Holds
eu.purse.checkout@upstreampay/headless-checkoutPurseHeadlessCheckout, PurseCheckoutHooks, PurseCheckoutException; element.rememberPaymentElement, payment.item.*, state.*
eu.purse.partnerui@upstreampay/partner-uiPaymentElementListener, PaymentOutcome, PluginOptions, PurseTheme, CardFormTexts, PluginRegistry, PluginEvent, PartnerUiException, the coordinators, redirect.RedirectAction
eu.purse.coresdk, model, commonenvironment.PurseEnvironment, payment.Partner, Method, MethodKey, error.PurseErrorCode, PurseException, api.PaymentApiException, session.PurseSessionException

Entry points​

fun PurseHeadlessCheckout.Companion.init(
widgetData: String,
lockedEnvironment: PurseEnvironment? = null,
hooks: PurseCheckoutHooks? = null,
options: PluginOptions = PluginOptions(),
disabledMethods: Set<MethodKey> = emptySet(),
): PurseHeadlessCheckout

fun PurseHeadlessCheckout.Companion.restore(
state: CheckoutSavedState,
hooks: PurseCheckoutHooks? = null,
options: PluginOptions = PluginOptions(),
): PurseHeadlessCheckout
ParameterMeaning
widgetDataThe base64 widget.data string of the client session
lockedEnvironmentOverrides the environment the session declares; release builds must pass PurseEnvironment.PRODUCTION
hooksonBeforeValidate, onAfterValidate, onRedirection
optionslocale, cardFormTexts, theme
disabledMethods(partner, method) pairs this build never lists, whatever the session offers; scoped to the instance
stateA CheckoutSavedState from saveState(), or CheckoutSavedState.fromJson()

PurseHeadlessCheckout.VERSION is the SDK version; checkout.instanceId identifies one checkout in Purse's monitoring.

Reactive state (StateFlow)​

PropertyTypeChanges when
sessionStateSessionStateREADY → SUBMITTING → SUBMITTED / ERROR; EXPIRED, TERMINATED
paymentSessionPaymentSessionThe session in force; emits again after setSession
paymentMethodsList<PaymentItem>Primaries and gift cards, each with its live disabled state
paymentTokensList<PaymentToken>Saved cards and saved PayPal accounts
savedSecondaryTokensList<SavedSecondaryToken>Saved gift cards, balances resolving in the background
remainingAmountToPayBigDecimalAfter setPrimary, applySecondary, removeSecondary
amountSplitList<PaymentSplit>The slices submitPayment will send
isPaymentFulfilledBooleanThe split covers the amount and every form in it is valid
itemGenerationsMap<String, Int>Bumped by setSession for items that were rebuilt
pluginEventsSharedFlow<CheckoutPluginEvent>Every partner lifecycle event, keyed by item id
isTornDownBooleanAfter teardown()

Plain properties: session, currency, currentSessionId, primaryMethods, secondaryMethods, appliedSecondaries, options, disabledMethods.

Functions​

GroupFunctions
SplitsetPrimary(method?), clearPrimarySplit(), setPrimaryToken(token), applySecondary(token, amount?), removeSecondary(token) (both for SecondaryToken and SavedSecondaryToken)
Gift cardssecondaryConfig(method), getSecondaryToken(method, pan, cvv?) (suspend), registerSecondary(token, registered, name?), registrationOf(token)
Savingregister(method, registered, name?), registrationOf(method)
Wallet (suspend)editToken(token, name), setTokenFavorite(token), deleteToken(token), deleteAllTokens(); editToken and deleteToken also for SavedSecondaryToken
SubmitsubmitPayment(skipOnBeforeValidate = false) (suspend)
BNPL (suspend)simulateLoan(method, product), simulateLoans(method, product)
SessionsetSession(widgetData) (suspend), saveState(), teardown()
AssetsiconUrl(item), schemeAssets(method)
Extensionhost(item) for a coordinator you drive yourself; PluginRegistry.getPlugin, register*, install(module); SecondaryConfigs.register; CheckoutEventBus.getInstance().subscribe { }

Every suspend function runs its network call on Dispatchers.IO; call them from any dispatcher.

Payment element​

@Composable
fun rememberPaymentElement(
checkout: PurseHeadlessCheckout,
item: PaymentItem,
listener: PaymentElementListener = object : PaymentElementListener {},
klarnaReturnUrl: String? = null,
): PaymentElement

@Composable
fun PaymentElementUi(element: PaymentElement, modifier: Modifier = Modifier)

PaymentElement exposes item, hasUi, selfSubmitting, ready and submit(). PaymentElementListener has onReady(ready), onOutcome(outcome), onRequiresAction() and onPaymentId(id), every member with a default.

sealed class PaymentOutcome {
data class Completed(val result: ValidationResult) // status: PaymentStatus, isSuccess
data object ReturnedFromRedirect // not an outcome: your backend confirms
data object Canceled
data class Failed(val error: PurseException) // error.code: PurseErrorCode
}

Coordinators, for an app that draws a wallet button or drives a native step itself: rememberCardCoordinator(host, listener) and rememberRedirectionCoordinator(listener) (in the SDK), rememberGooglePayCoordinator(listener), rememberPaypalCoordinator(listener) and rememberKlarnaCoordinator(listener) (in their artifacts). Only the card coordinator takes its PluginHost (from checkout.host(item)) at creation; the others receive it later through coordinator.prepare(host).

Types​

TypeNotes
PaymentItem (sealed)PrimaryMethod, SecondaryMethod, PaymentToken, SavedSecondaryToken; id, partner, method, disabled: DisabledState?, isSecondary, minAmount, maxAmount
PrimaryMethodcanBeRegistered, simulable, integrationType, supportedBrands
PaymentTokenisVaultedCard, requiresCvv, label, brand, maskedPan, holderName, favorite, tokenSource
SecondaryToken, SavedSecondaryTokenpan, balance; SecondaryToken adds canBeRegistered, saved ones add balanceResolved, disabled
DisabledState (sealed)code, message, isFiltered, isTechnicallyDisabled, requiresUiClear, isRecoverable, isRecomputable; see Method states
PaymentSplitamount, source
MethodKeypartner + method; id is the item id ("paypal-wallet")
Partner, Method (sealed)Purse, Paypal, Klarna, Illicado, … and Other(wireValue); CreditCard, GooglePay, Wallet, Installments, GiftCard, … and Other(wireValue)
CheckoutSavedStateParcelable snapshot from saveState(); toJson(), fromJson(), submitted, savedAt
LoanProduct, LoanSimulationInput and output of BNPL simulation
ValidationResultstatus: PaymentStatus, globalStatus, isSuccess, redirection, raw
PaymentStatus (enum)SUCCESS, FAILED, ERROR, UNCERTAIN, WAITING, UNKNOWN: the API's global_status
RedirectAction (sealed)Get(url), PostForm, PostHtml; what onRedirection receives
PluginEvent (sealed)Ready, Redirect, InitFailed, ClientError, PartnerError(recoverable), Cancelled, EndOfSession
PurseException (abstract)code: PurseErrorCode, documentationLink; subclasses in Error codes
PurseTheme, CardFormTexts, PluginOptionsPresentation options, see Customization

Extending the SDK​

SecondaryConfig adds a gift card issuer; PartnerUiPlugin plus a PartnerModule add a payment method with its own Compose surface, registered with PluginRegistry.install. Both are documented in the KDoc. Declarations marked @InternalPurseApi are the seams the partner artifacts use and carry no compatibility promise.