k.payment.paynlCheckout
Pay.NL payments.
| Execution Context | Prerequisites | Typical Use |
|---|---|---|
KScript API (k.api.get / k.api.post), server-side <script env="server"> | Configure PaynlSetting (sales location code/secret and token) in site CMS | Create Pay.NL Checkout payments, query transaction status, and handle exchange callbacks |
k.payment.paynlCheckout creates Pay.NL Checkout payment requests.
Quick Start
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 / Property | Description | Returns |
|---|---|---|
paynlCheckout.charge(params) | Create a Pay.NL Checkout payment request | ChargeResponse |
paynlCheckout.checkStatus(requestId) | Check payment status by requestId (triggers order/callback updates on paid/failed) | PaymentStatusResponse |
paynlCheckout.setting / context | Site Pay.NL settings and current request context | PaynlSetting / context |
paynlCheckout.charge()
Create a Pay.NL Checkout payment request.
| Parameter | Type | Required | Description |
|---|---|---|---|
returnUrl | string | Yes | Return URL after successful payment |
exchangeUrl | string | Yes | Server-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) |
expire | number | No | Expiration time in seconds; default 86400 |
statsData | StatsData | No | Statistics extended data |
totalAmount | number | Yes | Order amount |
name | string | Yes | Order name |
description | string | Yes | Order description |
currency | string | Yes | Currency, such as EUR |
order | string | No | Commerce order ID. Updates order payment status when paid |
callbackCodeName | string | No | Callback code name executed after payment completes |
Returns: ChargeResponse
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.
| Parameter | Type | Required | Description |
|---|---|---|---|
requestId | string | Yes | requestId returned by charge() |
Returns: PaymentStatusResponse
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
| Property | Type | Description |
|---|---|---|
extra1 | string | Extended field 1 |
extra2 | string | Extended field 2 |
extra3 | string | Extended field 3 |
PaynlSetting
| Property | Type | Description |
|---|---|---|
paynlUrl | string | Pay.NL API URL |
testMode | boolean | Whether test mode is enabled |
salesLocationCode | string | Sales location code |
salesLocationSecret | string | Sales location secret |
code | string | Config code |
token | string | Token |
TypeScript Definitions
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;
}