Usage
TOTP verification of a loyalty card upon purchase with Koshelek Pay
Processing loyalty cards with Koshelek TOTP Module
The diagram below describes data flow when a customer presents loyalty card with TOTP-enabled barcode at the checkout:
Pre-conditions
The scenario will properly execute when the following pre-conditions are met:
- There is a Koshelek TOTP Module deployed on your cash desk server.
- The Koshelek TOTP Module is configured (refer to Setup and Configuration).
- The Passcode Verify library is initialized on your cash desk server (refer to Setup and Configuration).
- Your cash desk software is updated to process Koshelek TOTP Module responses returned on the
barcodeVerify()
calls. - The Koshelek Pay server has all services configured to communicate with your environment.
Main flow
Info
For library methods mentioned in subsequent flow, please refer to Passcode Verify library methods below in this document.
- Customer selects your loyalty card in the Koshelek app.
- The Koshelek app requests data required for TOTP barcode generation.
- The Koshelek app renders the TOTP barcode on the screen.
- Checkout operator scans the TOTP barcode value.
- Cash desk software processes the TOTP barcode value.
- Cash desk software communicates the
fullBarcode
value to cash desk server, which uses it as an input parameter for making abarcodeVerify()
call to Koshelek TOTP Module deployed on the server. - Koshelek TOTP Module parses
fullBarcode
value to extract expected parts: prefix, loyalty card number, card session ID (cardSession
), and TOTP password. - Koshelek TOTP Module takes the extracted parameters and validates:
- If TOTP password is valid.
- If bonus points operations are available for loyalty card.
- If Koshelek Pay is available for loyalty card.
- Koshelek TOTP Module responds to cash desk software. The response contains:
- Response code:
resultCode
=CARDSESSION_AVAILABLE
- TOTP password validation result:
totpCodeValid
=true
- Loyalty card number:
cardNumber
- Koshelek Pay payment session ID:
cardSession
- Full barcode value:
fullBarcode
- Response code:
- Cash desk software processes successful result and caches
cardSession
value. - Checkout operator suggests payment with Koshelek Pay.
- Customer confirms payment with Koshelek Pay.
- Cash desk software builds a payment initialization request for methods POST
/availability-info/task
, POST/checkout
, POST/refund
and puts the request in temporary storage. - Cash desk software communicates the saved request body in JSON to cash desk server, which uses it as a
requestData
input parameter in thegetToken()
call to Koshelek TOTP Module deployed on the server. - Koshelek TOTP Module receives the
getToken()
request with therequestData
as an input parameter. - Koshelek TOTP Module generates
token
. - Koshelek TOTP Module returns the
token
value as output parameter to cash desk server. - Cash desk software puts token in
header
for all subsequent Koshelek Pay API requests: POST/availability-info
, POST/checkout
, POST/refund
. - Koshelek Pay API server receives requests with the
token
in header. - Koshelek Pay API server validates
token
and processes requests as per current scenario. - Koshelek Pay API server returns a successful response to cash desk server and generates an invoice to display in the Koshelek app.
- The further flow for cash desk goes according to the Koshelek Pay transaction processing flow (refer to Usage Scenarios).
Alternative flows
There are several branches that extend main flow, as described below.
Main flow, Step 7: TOTP barcode lacks prefix part, or prefix differs from expected (indicates that the loyalty card source is not Koshelek App)
- Koshelek TOTP Module sends the following response to cash desk software:
- Result code:
resultCode
=ANOTHER_INSTANCE
- Unsuccessful validation result:
totpCodeValid
=false
- Loyalty card number missing:
cardNumber
=null
- Koshelek Pay session missing:
cardSession
=null
- Full barcode value:
fullBarcode
- Result code:
- Cash desk software processes response.
- Further payment scenario is performed as if the card source is not the Koshelek App (without loyalty bonus operations and without Koshelek Pay as payment option.
Main flow, Step 7: loyalty card is valid, but TOTP barcode lacks cardSession
(indicates unavailability of Koshelek Pay payments for card)
- Koshelek TOTP Module validates TOTP password. Result: password is valid.
- Koshelek TOTP Module sends the following response to cash desk software:
- Result code:
resultCode
=CARDSESSION_NOT_AVAILABLE
- Successful validation result:
totpCodeValid
=true
- Loyalty card number:
cardNumber
- Koshelek Pay session missing:
cardSession
=null
- Full barcode value:
fullBarcode
- Result code:
- Cash desk software processes response.
- Further payment scenario is performed with loyalty bonus operations but without Koshelek Pay as payment option.
Main flow, Step 7: loyalty card is invalid (error with bonus operations, no further actions with card are possible)
- Koshelek TOTP Module validates TOTP password. Result: password is invalid.
- Koshelek TOTP Module sends the following response to cash desk software:
- Result code:
resultCode
=VALIDATION_FAILED
- Unsuccessful validation result:
totpCodeValid
=false
- Loyalty card number:
cardNumber
- Koshelek Pay session missing:
cardSession
=null
- Full barcode value:
fullBarcode
- Result code:
- Cash desk software processes response.
- Cash desk software outputs error in UI.
- Checkout operator notifies customer that operations with presented card are not possible.
Main flow, Step 8: loyalty card is invalid (error with bonus operations, no further actions with card are possible)
The flow is identical to previous one.
Main flow, Step 21: Koshelek Pay API server found token to be invalid (no further actions with card are possible)
- Koshelek Pay API server founds that
token
received in headers of POST/availability-info/task
, POST/checkout
, POST/refund
is not valid. - Koshelek Pay API server returns error to cash desk software.
- Cash desk software displays error in UI.
- Checkout operator notifies customer that operations with presented card are not possible.
Passcode Verify library methods
Info
Method names may vary slightly, depending on particular library format being used.
init()
Initialize library.
Input parameters
Parameter | Type | Mandatory | Description |
---|---|---|---|
algorythm |
String | Yes | Encryption algorithm being used:HMACSHA256 HMACSHA1 |
passLength |
Int | Yes | One-time password length. Max. value: 10 . |
prefix |
String | Yes | Barcode prefix. Default value = CM . |
key |
String | Yes | Partner’s private key (HEX string) required to build a password. |
interval |
Int | Yes | Password validity interval (in seconds). |
cardSessionLength |
Int | Yes | cardSession parameter length. |
delimeter |
String | Yes | Delimiter for barcode parts. |
Output parameters
None.
barcodeVerify()
Verify barcode value.
Input parameters
Parameter | Type | Mandatory | Description |
---|---|---|---|
fullBarcode |
String | Yes | Barcode value. |
Output parameters
Parameter | Type | Mandatory | Description |
---|---|---|---|
resultCode |
String | Yes | Depending on scenario, either of the following values may return:CARDSESSION_AVAILABLE ANOTHER_INSTANCE CARDSESSION_NOT_AVAILABLE VALIDATION_FAILED |
totpCodeValid |
Boolean | See Description → |
|
cardNumber |
String | See Description → |
|
cardSession |
String | See Description → |
|
fullBarcode |
String | Yes | Barcode value obtained by library from cash desk barcode scanner. |
getToken()
Obtain a token.
Input parameters
Parameter | Type | Mandatory | Description |
---|---|---|---|
requestData |
String | Yes | A string containing JSON response body for POST /checkout . |
Output parameters
Parameter | Type | Mandatory | Description |
---|---|---|---|
token |
String | Yes | A token to be used in request header in POST /checkout . |