Skip to content

k.payment.paynlCheckout ​

Pay.NL payments.

Execution ContextPrerequisitesTypical Use
KScript API (k.api.get / k.api.post), server-side <script env="server">Configure PaynlSetting (sales location code/secret and token) in site CMSCreate Pay.NL Checkout payments, query transaction status, and handle exchange callbacks

k.payment.paynlCheckout creates Pay.NL Checkout payment requests.

Quick Start ​

js
k.api.get(() => {
    const result = k.payment.paynlCheckout.charge({
        name: "T-shirt",
        description: "Order payment",
        totalAmount: 1.5,
        currency: "EUR",
        order: "order-id",
        returnUrl: "/payment/success?orderId=order-id",
        exchangeUrl: "https://example.com/payment/paynl/exchange",
        callbackCodeName: "PaymentCallback"
    })

    k.response.setHeader("Content-Type", "text/html; charset=utf-8")
    k.response.write(result.nextAction.renderHtml)
})

Quick Reference ​

Method / PropertyDescriptionReturns
paynlCheckout.charge(params)Create a Pay.NL Checkout payment requestChargeResponse
paynlCheckout.checkStatus(requestId)Check payment status by requestId (triggers order/callback updates on paid/failed)PaymentStatusResponse
paynlCheckout.setting / contextSite Pay.NL settings and current request contextPaynlSetting / context

paynlCheckout.charge() ​

Create a Pay.NL Checkout payment request.

ParameterTypeRequiredDescription
returnUrlstringYesReturn URL after successful payment
exchangeUrlstringYesServer-to-server URL where Pay.NL exchanges transaction status (must be an absolute http:// or https:// URL; sent verbatim to Pay.NL without automatic domain resolution)
expirenumberNoExpiration time in seconds; default 86400
statsDataStatsDataNoStatistics extended data
totalAmountnumberYesOrder amount
namestringYesOrder name
descriptionstringYesOrder description
currencystringYesCurrency, such as EUR
orderstringNoCommerce order ID. Updates order payment status when paid
callbackCodeNamestringNoCallback code name executed after payment completes

Returns: ChargeResponse

js
k.api.get(() => {
    const result = k.payment.paynlCheckout.charge({
        name: "T-shirt",
        description: "Order payment",
        totalAmount: 1.5,
        currency: "EUR",
        order: "order-id",
        returnUrl: "/payment/success?orderId=order-id",
        exchangeUrl: "https://example.com/payment/paynl/exchange",
        statsData: {
            extra1: "order-id",
            extra2: "",
            extra3: ""
        },
        callbackCodeName: "PaymentCallback"
    })

    k.response.setHeader("Content-Type", "text/html; charset=utf-8")
    k.response.write(result.nextAction.renderHtml)
})

checkStatus() ​

Check payment status.

ParameterTypeRequiredDescription
requestIdstringYesrequestId returned by charge()

Returns: PaymentStatusResponse

js
k.api.get(() => {
    const status = k.payment.paynlCheckout.checkStatus("request-id")
    return { paid: status.paid, failed: status.failed, status: status.status }
})

Callback & Exchange Handling ​

paynlCheckout.charge() automatically routes Pay.NL's returnUrl through Kooboo's built-in /_api/paymentcallback/PaynlCheckout_UpdateOrder?requestid={requestId} endpoint. When the buyer returns, Kooboo queries Pay.NL, invokes PaymentManager.CallBack(...) to update PaymentRequest, marks any linked Commerce order as paid, executes callbackCodeName, and redirects 302 to the returnUrl you supplied.

paynlCheckout.updateOrder(context) is an internal callback handler—do not invoke it directly in KScript to update orders (direct calls bypass PaymentManager.CallBack(...) and throw NullReferenceException if requestid is missing). For your exchangeUrl handler or manual verification, call k.payment.paynlCheckout.checkStatus(requestId) instead (which automatically calls PaymentManager.CallBack(...) on paid or failed results).

Data & Configuration Structures ​

StatsData ​

PropertyTypeDescription
extra1stringExtended field 1
extra2stringExtended field 2
extra3stringExtended field 3

PaynlSetting ​

PropertyTypeDescription
paynlUrlstringPay.NL API URL
testModebooleanWhether test mode is enabled
salesLocationCodestringSales location code
salesLocationSecretstringSales location secret
codestringConfig code
tokenstringToken

TypeScript Definitions ​

ts
interface PaynlCheckout {
    setting: PaynlSetting;
    charge(params: PaynlCheckoutParams): ChargeResponse;
    /** Internal callback handler invoked by /_api/paymentcallback/PaynlCheckout_UpdateOrder; do not call directly in KScript */
    updateOrder(context: any): PaymentCallback;
    checkStatus(requestId: string): PaymentStatusResponse;
}

interface PaynlCheckoutParams extends ChargeParams {
    returnUrl: string;
    exchangeUrl: string;
    expire: number;
    statsData: StatsData;
}

interface StatsData {
    extra1: string;
    extra2: string;
    extra3: string;
}

interface PaynlSetting {
    name: string;
    group: string;
    paynlUrl: string;
    testMode: boolean;
    salesLocationCode: string;
    salesLocationSecret: string;
    code: string;
    token: string;
}