Payment gateways
This article provides information for developers who would like to develop a connection to the Shoptet payment gateway.
If you are a Premium client, contact your Account or Onboarding Manager. A new payment gateway must be approved by Shoptet, and the client needs to be familiar with the payment terms in advance.
Implementation concept
The following sections must be implemented to integrate the payment gateway. The next chapters provide the details of each step.
- Administration interface for parameter settings by e-shop operators (access data, connection to e-shop processes)
- Creation of a new payment method in the e-shop
- Handling redirection to the payment gateway after order confirmation
- Receiving the required payment information
- Setting the payment result for the transaction and order
- Redirecting back to the e-shop
- For payments without immediate confirmation of money receipt, it is necessary to monitor the payment progress and set the transaction and order status once the result is determined.
New payment method
Contact our Shoptet Partner Manager (or api@shoptet.cz) to create a record for your payment gateway in Shoptet. In this record, we will register the payment type and your gateway for redirection. It is possible to only create one payment record with one gateway URL for one addon. This record registers the payment gateway as an intermediary or a technical means of implementing the payment.
The gateway URL must contain two placeholders, which are used to pass the e-shop identification (ID or URL) and the one-time transaction code at the time of payment. The following placeholders are available:
#ESHOP_ID#- E-shop number#ESHOP_URL#- E-shop URL, including the protocol (e.g.,https://www.example.com). If you need it in the URL, pass it URL-encoded in a query parameter rather than in the path.#PAYMENT_CODE#- One-time payment transaction code (32 alphanumeric characters)#LANGUAGE#- E-shop language code. Possible values:cs, hu, sk, en, pl, de, vi, ro, bg.
For example: https://pay.to.me/gateway/#LANGUAGE#/#ESHOP_ID#/#PAYMENT_CODE#/
The language of the payment gateway can be set by the #LANGUAGE# value, or by the value of the eshopLanguage attribute in
E-shop info API endpoint.
The second step is to create the payment method. Payment methods are created separately in each e-shop and are issued by the intermediary created in the preceding paragraph. Payment methods are created in the administration interface of the e-shop, and their labels, prices, terms and conditions must be set according to the currency, delivery country, delivery service, or order price. A logo may also need to be set. For more information, please visit Support.
However, the payment method can also be prepared for e-shop operators so that they make the settings look as per needs and save them from painful work. To create it, you must be registered as an intermediary (see the first paragraph). The creation is performed using the POST /api/payment-methods endpoint. You can create several payment methods with your payment type — for example for different currencies or countries — as long as your addon is installed in the e-shop.
Set up the new payment method as inactive so that it does not appear in the e-shop before the operator reviews and confirms it, or modifies the parameters. The payment method should also not be visible before the e-shop operator signs the contract and obtains access to the payment gateway.
Order and payment process
Order - Step 1 - Payment methods
Once an addon is installed in the e-shop and a payment method is created, it will be displayed automatically (if the conditions are met in combination with transport, currency, order amount, etc.).
Order - Thank you page
If the purchaser has selected your payment gateway, an online payment button will appear on the order confirmation page (Thank you page). The user can click on it or will be automatically redirected to your payment gateway after 5 seconds (using the gateway URL you provided).
In the gateway URL, the #ESHOP_ID#, #ESHOP_URL# and #PAYMENT_CODE# placeholders will be replaced with actual values. The payment code serves as the identifier of the payment transaction.
The link to the Thank you page in Shoptet (and in the customer’s confirmation email) contains the Shoptet URL, which in turn redirects to the payment gateway URL.
Payment process
There are two ways to connect a payment gateway: either the payment gateway provider adapts its own API to work with Shoptet directly, or the addon acts as an intermediary (proxy) between Shoptet and the payment gateway API.
In the first step of the payment process, the addon must obtain information about the order being paid and the URL to return back to the e-shop. This is done using the endpoint [GET] /api/payment-status/{paymentCode} - see also Documentation.
For order information, use the Order detail endpoint. Note that the order code may look like a number but is actually a string (it may also contain letters).
If you need detailed information about the e-shop (e.g., email, language), you can use the endpoint E-shop info.
You should assume that purchasers may return to the payment later (e.g., via an email link). The addon must verify whether the order has already been paid (the purchaser has clicked the link again, for some reason), or canceled in the meantime. If the order is already paid or canceled, this is considered an inconsistent situation and should be escalated to the e-shop owner and, if applicable, the purchaser.
The rest of the payment is processed according to the payment gateway’s functionality – e.g., selection of payment method, data entry, etc.
Setting the payment result
The result of the payment should be reflected in two places:
- The result of the payment (Pass, Fail, In progress) - we will set the correct wording of the Thank you page upon returning to our e-shop.
- Order status
Payment status
The payment result is set by calling the endpoint [PATCH] /api/payment-status/{paymentCode} - See also Documentation.
The available payment result statuses are:
- Pass (OK) - Payment was sent and the payment gateway received the funds immediately; the order can be dispatched.
- In progress (PENDING) - Payment was entered without errors, but the gateway has not yet received confirmation from the financial institution. Final result may be known later (from minutes to days) and can still fail. This status does not allow the order to be shipped yet, because it is not certain that the money will be transferred. Some gateways label this status as “Awaiting.”
- Fail (FAILED) - The user aborted the process, the payment agent was unavailable, the user had insufficient funds, or another error occurred. The order is not paid.
Once a payment has been set to OK, its status can no longer be changed — further updates for the same payment code are rejected.
Order status
Order status must be set depending on the payment result. Shoptet e-shops allow configurable order statuses, so each e-shop must define which status corresponds to each payment status.
You can retrieve the list of order statuses defined in the e-shop by calling the E-shop Info endpoint: /api/eshop?include=orderStatuses - See also Documentation or List of order statuses.
The payment gateway addon must be able to set at least the status that corresponds to the payment of the order. It is better, however, to allow the e-shop operator to set up a situation that will be set in case of payment failure, and if it is waiting for the confirmation (the “pending” status).
Order status is set using the endpoint PATCH /api/orders/{code}/status (See also Documentation).
In the event of a successful payment, the form of the payment, corresponding to the payment method chosen by the user for payment, should be indicated (typically card for online payments).
The “payment flag” (i.e., switching to a given status also marks the order as paid), automatic document generation (invoice, delivery note), and email sending are handled within Shoptet’s status definitions and are outside the responsibility of the payment gateway addon.
Setting the OK payment status can also create a proof of payment automatically, if the e-shop has this enabled. To prevent documents from being generated or emails from being sent by the payment status update, use the suppressDocumentGeneration and suppressEmailSending parameters of the payment status endpoint.
Optionally, the addon can send email notifications to the purchaser and/or e-shop about payment progress or irregular statuses.
Optionally, the addon can add information to the order, for example the payment number on the payment gateway side or more payment details (especially for underpaid/overpaid payments). Use the PATCH /api/orders/{code}/notes endpoint, which offers two ways to store the note:
- In one of the additional fields (1–6). The list of the additional fields can be obtained from the endpoint
/api/eshop?include=orderAdditionalFields. Keep in mind that the additional fields are printed on the order document (order printout/PDF), so whatever you store there may be seen by the purchaser. - In
eshopRemark. Append your note to the existing value (read the current value, add the note, and save it).
You can also add a remark to the order history using the Order history remark endpoint.
Unfortunately, the order may change during the payment process, especially if the payment takes a long time. The addon should therefore also verify the following:
- The order is in the expected state (i.e. unpaid)
- The order price has not changed (the e-shop operator may have changed or canceled it in the meantime)
- The payment method (i.e.
paymentMethodGuid) has not changed.
The addon is responsible for resolving any inconsistencies, based on the procedures defined by the payment gateway operator. In all cases, it's good practice to inform the e-shop operator.
Return to the e-shop
Once the order status and payment result are set, the addon calls Shoptet’s return URL.
Shoptet will display the Thank You page based on the payment status:
OK- Shoptet checks if the order is marked as paid. If not, an inconsistency warning is shown.PENDING– The purchaser is informed that the payment was entered correctly and the order will be marked as paid once payment is received. Any attached message will be displayed.FAILED– The purchaser is offered an option to retry the payment or contact the e-shop owner for an alternative method.
The ongoing activity of the addon
Besides initial payment handling, the addon should track ongoing payment changes and update order statuses accordingly. Optionally, it can send email alerts or notifications for payments that remain pending for too long.
The addon may also send links for repeat payment in case of failed attempts.
Addon settings
Addon settings can be placed directly in the Shoptet administration. The client account is usually initialized during addon installation. The identity of the e-shop operator can be verified directly in Shoptet via OAuth.
The addon must provide a GUI with at least the following configuration options:
-
Gateway access data
-
Order statuses to be set for each payment status. At a minimum:
- Payment paid
- Payment in progress (entry passed but there is no confirmation of target bank)
- Payment failed / declined (The payment was unsuccessful, e.g. the card was declined or had insufficient funds.)
You can also set order statuses for other payment statuses, for example insufficient amount paid or overpaid. The list of the e-shop's order statuses can be obtained from the endpoint
/api/eshop?include=orderStatuses. -
Note configuration if the addon uses one of the additional fields for notes
-
Optional but recommended: contact details (e.g., an email address or phone number) where the addon notifies the e-shop operator about non-standard situations, such as payment inconsistencies.