A Payment Request represents a request for a payment. The Payment Request lifecycle is defined in PaymentRequestState.

A Payment Request is created by the integrator calling Klarna.Payment.initiate().

Example of how to programmatically create and initiate a payment request without the Klarna payment button.

Klarna.on("complete", (paymentRequest) => {
// Authorize the payment with the Payment Token which can be found at paymentRequest.stateContext.paymentToken
}))

function myClickHandler() {
// payment request is patched with data provided in method calls
try {
await Klarna.Payment.initiate({
currency: "USD",
amount: 1000
})
} catch (error) {
console.error("Failed to initiate payment request", error)
}
}
<button onclick="myClickHandler()">Place payment</button>
interface PaymentRequest {
    paymentRequestId: string;
    previousState?:
        | "SUBMITTED"
        | "IN_PROGRESS"
        | "COMPLETED"
        | "EXPIRED"
        | "CANCELED";
    state: "SUBMITTED"
    | "IN_PROGRESS"
    | "COMPLETED"
    | "EXPIRED"
    | "CANCELED";
    stateContext?: PaymentRequestStateContext;
    stateReason?:
        | "PARTNER_CANCELED"
        | "PURCHASE_FLOW_ABORTED"
        | "TECHNICAL_ERROR";
}

Properties

paymentRequestId: string

Unique identifier of this payment request

previousState?:
    | "SUBMITTED"
    | "IN_PROGRESS"
    | "COMPLETED"
    | "EXPIRED"
    | "CANCELED"

Current state of the payment request

state: "SUBMITTED" | "IN_PROGRESS" | "COMPLETED" | "EXPIRED" | "CANCELED"

Current state of the payment request

Context for the current state of the payment request

stateReason?: "PARTNER_CANCELED" | "PURCHASE_FLOW_ABORTED" | "TECHNICAL_ERROR"

Reason why the payment request is in its current state