Skip to main content

Payment service

The payment service provides an implementation for kiosk card terminal payments. When registered, the platform will use your plugin to process card payments.

Registration

export default async context => {
context.service.addService({
type: 'paymentService',
paymentType: 'terminal',
startPayment: async params => {
// params contains: paymentSessionId, orderId, amount, currencyIsoCode, uiCultureCode
// ... handle the payment
return { status: 'ReservationStarted', requestData: params };
},
});
};

Request parameters

The startPayment method receives an object with the following properties:

PropertyTypeDescription
paymentSessionIdstringIdentifier for the payment session
orderIdstringThe order being paid for
amountnumberThe total amount to charge in the smallest currency unit (e.g. 100 for $1.00)
currencyIsoCodestringCurrency code (e.g. "SEK", "NOK")
uiCultureCodestringCulture code for localization (e.g. "en-GB")

Responses

Success

Return a ReservationStarted response when payment has been initiated successfully:

return {
status: 'ReservationStarted',
requestData: {
paymentSessionId: params.paymentSessionId,
orderId: params.orderId,
amount: params.amount,
currencyIsoCode: params.currencyIsoCode,
uiCultureCode: params.uiCultureCode,
},
};

Error

Return an Error response when payment fails:

return {
status: 'Error',
error: {
code: 'kiosk.payment.error.amountdeclined',
message: 'A human-readable error message',
},
};

Payment flow after startPayment

After startPayment returns a ReservationStarted response, the UI transitions to a "user action" screen (e.g. an insert card prompt). The UI remains on this screen until one of the following events is received:

EventSourceOutcome
PaymentSessionAbortedOrderingThe payment session was aborted. The UI displays an error and the customer can retry.
PaymentReservationCompletedPaymentThe payment reservation completed successfully. The UI proceeds to the next step.
PaymentReservationFailedPaymentThe payment reservation failed. The UI displays an error and the customer can retry.

Error codes

CodeDescription
kiosk.payment.error.cancelledbycustomerThe customer cancelled the payment
kiosk.payment.error.amountdeclinedThe amount was declined
kiosk.payment.error.declinedThe card was blocked or declined
kiosk.payment.error.terminalissuesTerminal hardware or connection issues
kiosk.payment.error.uncategorizedAn uncategorized error
kiosk.payment.error.invalidpinInvalid PIN entered
kiosk.payment.error.cardnotallowedCard type not accepted
kiosk.payment.error.invalidcardInvalid or unreadable card