Skip to main content

External Payments

Onslip 360 supports several kinds of payment methods, including cash, credit cards, foreign currencies and vouchers. In addition to this, developers may integrate external payment systems and handle payments outside of the built-in methods.

This is done by setting up a Payment Method of type external-payment-voucher with the property external-payment-uri pointing to the external payment system's endpoint, to which our servers can send requests to initiate and query transactions. It's an online-only cloud API — not for communicating directly with payment terminals on the local network.

Transaction Requests​

To initiate a transaction, the server sends a POST request with the following payload.

interface ExternalPaymentVoucherRequest {
'service-endpoint-uri': string;
'company-alias': string;
'user-alias': string;
'payment-method': number;
'location'?: number;
'client'?: number;
'voucher-transaction': ExternalPaymentVoucherTransaction;
}

Like webhooks, the request may be authenticated using username/password, a Hawk key signature or a TLS client certificate, to ensure the request originates from a legitimate Onslip 360 account. This is enabled by associating the payment method with an access-token via the access-token-user and access-token fields. Using the already present Hawk access token from the OAuth authorization process is recommended.

The actual transaction is defined by:

namespace ExternalPaymentVoucherTransaction {
type Reason = 'payment' | 'reversal' | 'voucher';
}

interface ExternalPaymentVoucherTransaction {
'reason': ExternalPaymentVoucherTransaction.Reason;
'request-id': string;
'interactive': boolean;
'accounting-currency': string;
'transaction-currency': string;
'exchange-rate'?: number;
'amount': number;
'cashback': number;
'gratuity': number;
'vat-amount': number;
'payment-reference'?: string;
'transaction-reference'?: string;
'tab'?: number;
'order'?: number;
'customer'?: number;
}

The reason defines why the transaction is being sent (payment when used as payment method and reversal when undoing an unwanted transaction; in the future, it may also be voucher when "topping up" the balance1). It's OK to reject a transaction based on the reason in order to limit the scope of the integration.

In any case, the amount will define how the balance should be adjusted, with negative amounts going towards the merchant and positive amounts to the customer: Payments are thus negative for sales and positive for refunds, reversals are positive for sales reversals and negative for refund reversals, and voucher amounts are normally positive but may be negative if a voucher is refunded.

For informational purposes, cashback, gratuity and vat-amount specifies how much of amount is cashback/tips/VAT (using the same sign as amount); tab, order and customer defines the context in which the transaction is taking place; payment-reference is used when finalizing a pre-authorized payment and transaction-reference, finally, may refer to a previous external payment-voucher transaction that is being refunded.

Note that all amounts are specified in the transaction-currency currency. This is most often the same as the currency specified by accounting-currency, but may differ if the Payment Method's currency-code is set. This is something you decide when creating the payment method.

In response to this POST request, you should return:

interface ExternalPaymentVoucherResponse {
'metadata'?: Metadata;
'event-stream-uri'?: string;
}

For synchronous processing, just put the final result in the metadata field (see also Metadata), and that's it:

interface Metadata {
'type': 'external-payment-voucher';
...
'external-payment-voucher'?: ExternalPaymentVoucherMetadata;
'labels'?: number[];
}

namespace ExternalPaymentVoucherMetadata {
type Status = 'approved-online' | 'approved-offline' | 'failed' | 'cancelled';
}

interface ExternalPaymentVoucherMetadata {
'reason': ExternalPaymentVoucherTransaction.Reason;
'request-id': string;
'transaction-id': string;
'transaction-date': DateTime;
'status': ExternalPaymentVoucherMetadata.Status;
'status-code'?: string;
'status-message'?: string;
'exchange-rate': number;
'currency-code': string;
'currency-symbol'?: string;
'amount': number;
'cashback': number;
'gratuity': number;
'vat-amount': number;
'balance'?: number;
'customer'?: number;
}

The integration is allowed to adjust the requested amounts and return updated values in the response metadata (by adding tips, for example). If known, the currently remaining balance of a voucher or customer account may be included as well. currency-code should always be the same as the transaction-currency and exchange-rate should reflect the conversion rate between transaction-currency and accounting-currency (1.0 if they are the same).

However, for interactive transactions, it's better to instead return a Server-sent Event stream URI, from which the cash register will read and process events during the transaction. The client issues a GET request at the beginning of the transaction and DELETE request when the transaction is over (for any reason). The SSE connection is made directly from the cash register to the destination and will not be relayed through any server, nor will it include any credentials except what is included in the URI itself.

namespace ExternalPaymentVoucherEvent {
type Type = 'metadata' | 'cashier-message' | 'cashier-document-uri';
}

interface ExternalPaymentVoucherEvent {
'type': ExternalPaymentVoucherEvent.Type;
'metadata'?: Metadata;
'cashier-message'?: string;
'cashier-document-uri'?: string;
}

cashier-message is a plain-text message that will be displayed to the cashier and cashier-document-uri is an HTTP/HTTPS URI pointing to a document/web page that will be shown inside a sandboxed IFRAME, allowing for forms and other interactive content during the transaction.

note

The document must support clients as old as Chrome 52! This means that you must avoid modern CSS, downcompile your JavaScript and include polyfills for anything these old web runtimes do not natively support.

Also note that the event stream may originate from clients as old as Android 6. This restricts what TLS versions and cipher suites can be used for the stream. The ISRG Root X1 certificate from Let's Encrypt can be assumed to be trusted, though.

An event containing metadata ends the transaction.

Transaction Enquiry​

Finally, your external-payment-uri service should also respond to GET requests with a request_id query parameter, returning the corresponding ExternalPaymentVoucherResponse for a previous request. Respond with 424 Failed Dependency if the response is not available. This is mainly used for crash and error recovery by the cash register.

Footnotes​

  1. Support for selling and topping up external vouchers is currently not implemented, but may be added in a future release. ↩