SWiP POS API
Terms and definitions
POS (point of sale) - a place where a user executes the payment for goods or services.
Merchant - small amd medium enterprises, supplier of goods and/or services that work with the SWiP service.
Integrator - an employee of POS/merchant/third-party who connects the merchant's POS to the SWiP system and provides further support.
SWiP loyalty - a loyalty program provided by SWiP, which is configured by the merchant.
User - a person who makes purchases and pays through the SWiP app.
Payment scenarios - SWiP supports following payment scenarios:
Scenario 1 - the user pays by the SWiP app after SWiP loyalty calculation. Payments can be made via various methods: from bank cards, from e-wallets, from payment system, from national payment system and other methods.
Scenario 2 - the user makes payment in cash or by bank card at the terminal after SWiP loyalty calculation.
Two-stage payments - a payment operation that requires additional confirmation.
Holding - the user makes the payment and the funds are put on hold on their bank card. While the funds are put on hold, you can debit funds or cancel the payment within the specified timeout (the payment cancellation period can be changed in the settings).
Withdraw - funds on hold are debited after confirmation.
Using the API
POS API - a programming interface for accepting online payments executed by the SWiP service. Using the API, you can execute a payment, cancel a payment, make refunds, get statements with all orders that are made by the SWiP service.
Integration schema
SWIP can be delivered as an external loyalty system, as well as as an external loyalty system with the specified payment method. To learn more about these loyalty systems, see below.
SWiP loyalty calculation and payment inside the SWiP app
During the payment process, SWiP loyalty is calculated, if there is a loyalty program for the user. This scenario includes payment inside SWiP app using the following payment methods: from bank cards, from e-wallets, from payment system, from national payment system and other methods.
HTTP protocol
Step 1. The POS system creates an order.
Step 2. The POS system receives the Order object.
Step 3. The SWiP app requests order detailed information.
Step 4. The User receives the Order object with personalized loyalty at the SWiP app.
Step 5. The User confirms payment at the SWiP app.
Step 6. The SWiP server sends a request for order payment.
Step 7. The SWiP server receives order payment confirmation.
Step 8. The SWiP app receives order payment confirmation from the SWiP server.
Step 9. The POS system sends a request to get the information about the current order status.
Step 10. The POS system receives the paid order with applied loyalty.
Step 11. The POS system sends a request to close the order.
SWiP loyalty calculation without payment inside the SWIP app
During the payment process, SWiP loyalty is calculated, if loyalty is provided to the user. This scenario includes payment by cash or card in bank terminal.
HTTP protocol
Step 1. The POS system creates an order.
Step 2. The POS system receives the Order object.
Step 3. The SWiP app requests order detailed information.
Step 4. The User receives the Order object with personalized loyalty at the SWiP app.
Step 5. The User confirms payment via alternative payment method (by cash or card in bank terminal).
Step 6. The POS system sends a request to get the information about the current order status.
Step 7. The POS system receives unpaid order with applied loyalty.
Step 8. The POS accepts payment by cash or card in bank terminal.
Step 9. The POS system sends a request to close the order.
Integration URL
URL of the integration environment https://capi3.weawer.ru.
Order and session identification
The id
and the merchantOrderId
fields act as an order identifier.
Field name | Description |
---|---|
| The identifier in the SWiP system. The POS must not fill it. The POS creates an order when sending an order object (Order). The Order object returns with the specified ID field. This field is used in GET requests. |
| Order ID in the merchant's system. |
The sessionCode
field acts as a session identifier.
Field name | Description |
---|---|
| The session identifier (the text value encrypted in the QR code). If the POS system works in a restaurant mode, then the QR code is received from the server's response to the order creation request. |
Transport and protocol
The API uses HTTPS as a protocol. Messages are represented in the JSON format.
Authentification
Authentification is implemented by a static token. The token must be sent in the header of HTTP requests.
The header in every API request should include:
Field name | Value example | Description |
---|---|---|
Authorization | Bearer 8c6b8b64-6815-6084-0a3e-178401251b68 | Token from the merchant’s marketing engine. |
X-Merchant-ID | ABCD | The value is sent by the SWiP employee after the merchant's onboarding. Four-letter codes are used at the moment. The values can be expanded in the future. |
X-Store-ID | Test storeID | The Store ID that the SWiP employee sends after the merchant's onboarding. The value is taken from the merchant's system: either the real identifier of the store or, if it cannot be received from the POS, the value from the SWiP plugin settings. |
X-Cash-ID | 1231 | POS ID in the merchant's system. |
Api-Version | 3 | API version. |
Integration scenarios
The POS API supports several payment scenarios. They differ depending on the payment method and store’s settings.
Grocery store, bakery, coffee shop, restaurant, supermarket and many others
Example of implementation:
The user makes an order at the POS system.
The POS creates an order and sends parameters in the API request headers (for more information, see the Authentification chapter):
X-Merchant-ID - the identifier of the merchant;
X-Store-ID - the identifier of the store in the merchant's system;
X-Cash-ID - the POS ID in the merchant's system.The user confirms the payment.
The POS closes the order and prints the fiscal receipt.
Vending machine
Example of implementation:
The user selects a product on the vending machine.
The vending machine creates an order and sends parameters in the API request headers (for more information, see the Authentification chapter):
X-Merchant-ID - the identifier of the merchant;
X-Store-ID - the identifier of the vending machine;
X-Cash-ID - the modem IMEI or an empty value.The user confirms the payment and receives the product.
Order object
The Order
object (Order) contains all currently relevant information about the order. The object is generated during creation of an order and sent as a response to some requests.
The order object can contain other fields that the POS is not using yet. They should be ignored.
*- the fields that are filled in by the POS system when creating an order.
The values in the Required column are the following:
true - the field is mandatory when interacting with the service
false - the field is not mandatory when interacting with the service
Parameter | Type | Description | Required |
---|---|---|---|
| string (UUID) | Order ID in the SWiP system. | false |
| string | Order ID in the merchant's system. | true |
| integer | API version which was used for the order payment. | false |
| string | Authorization code from the payment system. | false |
| boolean | Attribute of an alternative payment method. | false |
| double | Order closing amount. Indicated after the order closing. | true |
| string (UUID) | ID of a customer who paid the order. Indicated after the order closing. | false |
| string | Discount card ID in the SWiP system. | false |
| string | Text description of the last error by order payment. | false |
| string | POS or POS group ID (no need to fill, is taken from HTTP request headers). | false |
| string | Cashier name. | true |
| string (UUID) | Cashier ID. For POS systems, that sets this parameter. | true |
| string | Description of the merchant scope. | false |
| double | Merchant's external commission. | false |
| double | Discount provided by a merchant. | false |
| string (UUID) | Merchant ID in the SWiP system. | false |
| string | Merchant name. | false |
| string | Order number in the merchant’s system (printed on a receipt usually). | true |
| string (UUID) | Image ID in the merchant’s profile. | false |
| string | Merchant store ID (no need to fill, is taken from HTTP request headers). | false |
| string | Order number in the acquirer bank. | false |
| OrderStatus | Order status. Possible values:
| false |
| double | Amount paid by the user using the application. Indicated after the payment is confirmed by the bank. | false |
| string | Masked card number. | false |
| PaymentMethod | Payment method. Possible values:
| false |
| PaymentSystem | Payment system. Сurrent values:
If necessary, the list can be expanded. | false |
| object | List of purchases. | false |
| double | Order refund amount. | false |
| string | Unique identifier of the bank transaction that is assigned by the Acquiring Bank when the payment is initialized. | false |
| long | Sale date (milliseconds since 1970.01.01). The creation date does not have to match the date that will be printed on the receipt. | true |
| string | QR code (only in fast food and offline store mode). | true |
| string | Formatted text (80 symbols in width) with bank information about the payment. | false |
| string | Bank terminal number. | false |
| double | Amount after deducting discount. | true |
| double | Initial order amount. | true |
| double | Amount paid by the user using the application, but not confirmed by the POS (paid>=unconfirmed). | false |
Purchases object
The values in the Required column are the following:
true - the field is mandatory when interacting with the service
false - the field is not mandatory when interacting with the service
Parameter | Type | Description | Required |
---|---|---|---|
| string (UUID) | Product ID. | true |
| double | SWiP calculated loyalty for purchase (under development). | false |
| string | Parent product ID. If the order contains products with modifier, than the modifier should have | false |
| string | Product item (product ID) in the merchant’s system. | true |
| string | Description of purchase. | false |
| double | Quantity (pieces, kilograms, liters). | true |
| double | Price. | true |
| double | Amount (price * quantity). | false |
| Unit | Units (LITERS, KILOGRAMS, PIECES). | false |
Example of the ORDER object
{
"apiVersion": 3,
"authorizationCode": "string",
"cash": false,
"closeAmount": 0.0,
"customerId": null,
"discountCard": "string",
"error": "string",
"id": "1374289e-12fd-47e1-b111-0c6ae5568ff1",
"merchantCash": "88",
"merchantCashier": "Cashier name",
"merchantCashierId": "77527945-9a53-4849-a732-bd8736b39144",
"merchantCategory": "Electronics",
"merchantCommission": 0,
"merchantId": "VZLT",
"merchantName": "shop",
"merchantOrderId": "1374289e-12fd-47e1-b111-0c6ae5568ff1",
"merchantOrderNumber": "11",
"merchantProfileImageId": "175bdc4f-9c3d-4465-89e0-a5bce381d381",
"merchantStore": "3",
"orderNumber": "28048058915136358726242016980679",
"orderStatus": "OPEN",
"paid": 0.0,
"pan": "string",
"paymentMethod": "CARD",
"paymentSystem": "AMEX",
"purchases": [
{
"id": "b314fd4e-df92-427b-a2f9-1da10dcefb78",
"discount": 0,
"name": "Sprite 0,33 l",
"parentId": "string",
"productId": null,
"quantity": 0,
"unit": "string",
"price": 50.0,
"amount": 50.0,
}
],
"refunded": 0,
"rrn": "string",
"saleDate": 1540485815026,
"sessionCode": "https://swip.one/?qr=6794742",
"slip": "...very long text...",
"terminalNo": "string",
"total": 50.0,
"totalOriginal": 50.0,
"unconfirmed": 0.0
}
Create an order
To send an order for loyalty calculation and payment execution, you need to create an Order
object. It contains all the necessary payment information.
If necessary, you can always send a single product in the Purchases
object, for example, a service.
The order can be in the OPEN status for 1,5 minutes for POS systems that operate in the fast food or retail mode. For POS systems operating in restaurant mode, the timeout is 10 hours.
If one of the following methods was used (/close
, /reverses
или /refund
), and there is a need to create the same or lightly modified order, then it has to have a new merchantOrderId
, even if for a single product.
Endpoint
POST /orders
Request format
To create an order, you have to send a request with the following parameters:
The values in the Required column are the following:
true - the field is mandatory when interacting with the service
false - the field is not mandatory when interacting with the service
The request body in each API request must include:
Parameter | Type | Description | Required |
---|---|---|---|
| string | QR code text value. | false |
| string | Order ID in the merchant's system. | true |
| string | Merchant order number (printed on a receipt usually). | false |
| string | Cashier ID. For POS systems, that sets this parameter. | false |
| string | Cashier name. | true |
| date | Sale date (milliseconds since 1970.01.01). The creation date does not have to match the date that will be printed on the receipt. | true |
| double | Amount after deducting discount. | true |
| double | Initial order amount. | true |
| list | Purchase list. | true |
| integer | Number of guests | false |
| string | Pos type. Possible values:
| true |
| boolean | Positional discount (influences the | false |
Purchases details
Parameter | Type | Description | Required |
---|---|---|---|
| string | Product ID. | false |
| string | Description of purchase. | true |
| string | Parent product ID. If the order contains products with a modifier, than the modifier should have | false |
| string | Product item (product ID) in the merchant’s system. | false |
| double | Quantity (pieces, kilograms, liters). | true |
| Unit | Units (LITERS, KILOGRAMS, PIECES). | false |
| double | Price. | true |
| double | Amount (price * quantity). | true |
| double | Minimal retail price | false |
*Example of calculation using MRP (minimal retail price)
Here, we are recalculating the final discount.
For example, there are two products that cost $100.
product 1 : $100
product 2 : $100 (mrp $90)
if a 20% discount is applied to this purchase, then the final discount will be $30, which accounts to 15%.
As a result, the system will display 15% on the scoreboard.
Note: The mrp
parameter can be applied only if positionalDiscount: true
Request example
{
"guests": 0, // number of guests
"merchantCashier": "Cashier name", // cashier name
"merchantCashierId": "77527945-9a53-4849-a732-bd8736b39144", // cashier ID
"merchantOrderId": "1374289e-12fd-47e1-b111-0c6ae5568ff1", // order ID in the merchant's system
"merchantOrderNumber": "11", // order number in the merchant's system (printed on a receipt usually)
"posType": "RKEEPER" // origin of order cash
"purchases": [
{
"id": "b314fd4e-df92-427b-a2f9-1da10dcefb78", // product ID in the SWiP system
"name": "Sprite 0,33 l", // item name
"parentId": "string",
"productId": null, // product item (product ID)
"quantity": 0, // quantity (in selected units)
"unit": "string", // units (LITERS, KILOGRAMS, PIECES)
"price": 50.0, // price
"amount": 50.0, // total amount (price * quantity)
}
],
"saleDate": 1540485815026, // sale date (milliseconds since 1970.01.01)
"sessionCode": "https://swip.one/?qr=6794742", // QR code text value
"total": 50.0, // purchase amount with discount
"totalOriginal": 50.0 // purchase amount without discount
}
Response format
The response to the request will contain the same order with the filled fields:
id - SWiP orderId,
sessionCode.
If sessionCode was sent empty, then the field with filled in values will return. It should be printed on the guest receipt or shown on the screen (of the POS system) to the user.
If there is a discount on the entire receipt or on one of the products in the receipt, the DISCOUNT field value in the purchase
object will be greater than zero if POSITION DISCOUNT = true.
Response example
{
"apiVersion": 3, // API version
"authorizationCode": "string", // authorization code from payment system
"cash": false,
"closeAmount": 0.0,
"customerId": null,
"discountCard": "string", // discount card ID in the SWiP system
"error": "string", // text description of the last error by order payment
"id": "1374289e-12fd-47e1-b111-0c6ae5568ff1", // order ID in the SWiP system
"merchantCash": "88", // POS or POS group ID
"merchantCashier": "Cashier name", // cashier name
"merchantCashierId": "77527945-9a53-4849-a732-bd8736b39144", // cashier ID
"merchantCategory": "Electronics", // description of the merchant scope
"merchantCommission": 0, // merchant's external commission
"merchantId": "VZLT", // merchant ID in the SWiP system
"merchantName": "shop", // merchant name
"merchantOrderId": "1374289e-12fd-47e1-b111-0c6ae5568ff1", // order ID in the merchant's system
"merchantOrderNumber": "11", // order number in the merchant's system (printed on a receipt usually)
"merchantProfileImageId": "175bdc4f-9c3d-4465-89e0-a5bce381d381", // image ID in the merchant's profile
"merchantStore": "3", // merchant store ID
"orderNumber": "28048058915136358726242016980679", // order number in the acquirer bank
"orderStatus": "OPEN", // order status
"paid": 0.0,
"pan": "string", // masked card number
"paymentMethod": "CARD", // payment method
"paymentSystem": "AMEX", // payment system
"purchases": [ // list of purchases
{
"id": "b314fd4e-df92-427b-a2f9-1da10dcefb78", // product ID in the SWiP system
"discount": 0,
"name": "Sprite 0,33 l", // item name
"parentId": "string",
"productId": null, // product item (product ID)
"quantity": 0, // quantity (in selected units)
"unit": "string", // units (LITERS, KILOGRAMS, PIECES)
"price": 50.0, // price
"amount": 50.0, // total amount (price * quantity)
}
],
"refunded": 0, // order refund amount
"rrn": "string", // unique identifier of the bank transaction
"saleDate": 1540485815026, // sale date (milliseconds since 1970.01.01)
"sessionCode": "https://swip.one/?qr=6794742", // QR code text value
"slip": "...very long text...", // formatted text with bank information about payment
"terminalNo": "string", // bank terminal number
"total": 50.0, // purchase amount with discount
"totalOriginal": 50.0, // purchase amount without discount
"unconfirmed": 0.0 // amount paid by the user using the application, but not confirmed by POS
}
Get an order
Sends a request to get the information about the current order status by its unique ID.
Endpoint
GET /orders/{id}
Request format
To get the information about the current order status, you have to send a request with the following parameters:
Parameter | Parameter type | Type | Description | Required |
---|---|---|---|---|
| path | string | Unique order ID in the SWiP system. | True |
Response format
The response to the request will contain the Order object with the current status.
Response example
Order status options and how they change
The POS system waits 90 seconds for the payment. If there is no payment during this time, the POS system has to close the order with amount=0.
An order can have the following statuses:
OPEN,
CLOSED.
Payment is determined by the paid field. Let's say that a payment is made for 100 monetary units:
Order creation:
orderStatus=OPEN, totalOriginal=100, total=100, paid=0, unconfirmed=0
Payment:
orderStatus=OPEN, totalOriginal=100, total=100, paid=100, unconfirmed=100
Order closure:
orderStatus=CLOSED, totalOriginal=100, total=100, paid=100, unconfirmed=0
If you close the order with amount=0, the payment will be cancelled:orderStatus=CLOSED, totalOriginal=100, total=100, paid=0, unconfirmed=0
Close an order
Sends a request to close the order.
Order closing method can be requested only once. In the request body, you must pass the order closing amount. If there is an error in the closing process or there is no order closing amount, the money for the order will be refunded.
If after closing the order (the amount can be == 0, or either > 0) the order is used in the creation request (/orders
), do make sure that the NEW merchantOrderId
is specified. In case the old merchantOrderId
is specified, there will be an error.
Endpoint
POST /orders/{id}/actions/close
Request format
To close the order, you have to send a request with the following parameters:
Parameter | Parameter type | Type | Description | Required |
---|---|---|---|---|
| path | string | Unique order ID in the SWiP system. | True |
| body | double | Order closing amount. | True |
| body | List<String> | If there is a tag, the rounding will be applied. | False |
Request example
Response format
The response to the request will contain the Order
object with the current status.
Rounding
Sends a request to round the total cost of the purchase.
If earlier there was a zero amount in the total amount of the order, the order was canceled, and the Customer received a refund of the amount paid. Now, if there is an amount for rounding in the total amount of the order, the "ROUNDED"
tag is used. It should be noted that this approach only works for alternative payment (cash).
At the same time, the difference between TotalCloseAmount
and the ROUNDED
tag should not be more than one, since only pennies can be rounded.
Request example
Cancelation of payments
Refund a payment
Important: Only the order with the CLOSED status can be refunded.
Returns a successfully completed payment by the order’s unique ID. The SWiP loyalty will also be returned. Payment can be refunded in whole or in part. You are allowed to make an infinite number of partial refunds, as long as the total amount of all partial refunds does not exceed the payment amount.
Endpoint
POST /refunds
Request format
To make a refund, you have to send a request with the following parameters:
Parameter | Parameter type | Type | Description | Required |
---|---|---|---|---|
| body | double | Amount to be refunded to the user. | True |
| path | string | Merchant ID in the SWiP system. | True |
| path | string | Order ID in the merchant's system. | True |
Request example
Response format
The response to the request will contain the refund status and its description.
Response example
Reverse a payment
Important: Only the order with the CLOSED status can be cancelled.
This method performs cancellation of a payment for which funds were put on hold and have not yet been captured. If it is already impossible to cancel the payment, an error with code 27 will be returned.
Endpoint
POST /reverses
Request format
To cancel the payment, you have to send a request with the following parameters:
Parameter | Parameter type | Type | Description | Required |
---|---|---|---|---|
| body | double | Amount of the payment cancellation. | False |
| path | string | Merchant ID in the SWiP system. | True |
| path | string | Order ID in the merchant's system. | True |
Request example
Response format
The response to the request will contain the payment cancellation status and its description.
Response example
Cancel an order
This method is necessary in case of a timeout at POS or other reasons to cancel an order.
Cancels the order with the OPEN status.
Endpoint
POST /orders/{id}/actions/close
Request format
To cancel the order, you have to send a request with the following parameters:
Parameter | Parameter type | Type | Description | Required |
---|---|---|---|---|
| path | string | Unique order ID in the SWiP system. | True |
| body | double | Amount which the POS transmits to cancellation. | False |
Request example
The request body is optional. If it is absent, the entire order is cancelled.
Response format
The response to the request will contain the Order object with the current status.
Response example
Calculate Anonymous discount
Sends a request to calculate available discounts for all customers.
In the request body, you must pass the order data with purchases to get available discount amount for this order.
Endpoint
POST /loyalty-calculations
Request format
To close the order, you have to send a request with the following parameters:
Parameter | Parameter type | Type | Description | Required |
---|---|---|---|---|
| path | string | Unique order ID. | True |
| body | List of purchases. |
| |
| body | double | Order total amount. | True |
Request example
Response format
The response to the request will contain the discount calculation result for the current order.
Response example
Response codes
In case an error occurs during the processing of a request, the API will return an error object and a standard HTTP code.
HTTP code | Description | Error code |
---|---|---|
200 | Successful request. |
|
400 | Invalid request because of rule violations regarding the interaction with the API. | unauthorized |
401 | Invalid authorization. | unauthorized |
403 | No permission to access. | forbidden |
404 | Resource with specified ID was not found in the SWiP system. | not_found |
405 | Forbidden or unsupported method is used. | method_not_allowed |
429 | Too many requests sent in a short amount of time. | too_many_request |
500 | Internal server error. | internal_server_error |
Error codes and description
Error code | Description |
---|---|
1 | INTERNAL SERVER ERROR |
2 | AUTHENTICATION ERROR |
4 | ACCESS DENIED |
5 | VALIDATION FAILED |
6 | ILLEGAL STATE |
7 | METHOD NOT SUPPORTED |
8 | DUPLICATE |
9 | NOT FOUND |
10 | UNSUPPORTED MESSAGE |
11 | ORDER FLOW VIOLATION |
13 | OPERATION TIMED OUT |
27 | REVERSE UNAVAILABLE |
28 | ORDER ALREADY EXISTS |
29 | ORDER ALREADY REFUNDED |
30 | ORDER ALREADY CONFIRMED |
31 | ORDER NOT PAID |
32 | EXCESS TOTAL AMOUNT |
Error object
If something is wrong with the request (the HTTP response code other than 200), then HTTP response codes 4xx or 5xx will return a response body in JSON format with a description of the error.
Example of response body in case of error
- 1 Terms and definitions
- 2 Using the API
- 3 Integration schema
- 4 Integration URL
- 5 Order and session identification
- 6 Transport and protocol
- 7 Authentification
- 8 Integration scenarios
- 9 Order object
- 10 Create an order
- 11 Get an order
- 12 Close an order
- 13 Cancelation of payments
- 14 Refund a payment
- 15 Reverse a payment
- 16 Cancel an order
- 17 Calculate Anonymous discount
- 18 Response codes
- 19 Error codes and description
We are always ready to help and answer all your questions via support@swip.one