Skip to main content

Create Transaction from Intent

Once the Cashier has decided to confirm the transaction (in case of purchase/deposit the cash needs to be handed over) the Distributor POS System needs to trigger the creation of a transaction in Zastrpay Backend. For that purpose the following Distributor Backend -> Zastrpay Backend API call must be implemented:

PUT https://host.com/transaction-service/v1/transactions/3fa85f64-5717-4562-b3fc-2c963f66afa6/from-intent
Content-Type: application/json
x-api-key: $apiKey
x-request-id: 62b76d46-5f76-4274-a59a-5654f31020fd
x-triggered-by-shop-id: 5d4d122c-889d-4033-b9c1-58b3a661923a
x-triggered-by-shop-external-reference: Aaa-Bbb-Ccc-123

{
"transactionIntentId": "3fa85f64-5717-4562-b3fc-2c963f66afa6"
}
transactions/{transactionId} in the url/path

The value of transactionIntentId is used also for the {transactionId} in the URL path. In the general case there is a 1:1 relationship between a transaction intent and transaction, so even though it is possible to supply a different transactionId UUID/GUID value (for future extensibility), using the same (= transactionIntentId) value makes it simpler.

x-triggered-by-shop headers

To identify the source of the API call, the following headers are used:

  • x-triggered-by-shop-id - a UUID/GUID generated by Zastrpay upon initial shop registration
  • x-triggered-by-shop-external-reference – An alphanumeric reference (including dot, hyphen and space, up to 48 characters long) which should be unique within all shops of a distributor Exactly one of the above headers be provided.
x-request-id header and retries

x-request-id header value can be a random UUID/GUID value and is used by Zastrpay to check if an API call is a retry or an original/new call. In case the client wants to retry the API call (e.g. because of a timeout, no response received) then the client must use the same x-request-id value as in the original API call. This guarantees that the server will simply return the response for an already processed transaction (whether it was executed successfully or failed), and if not yet processed - process the transaction as new.

Zastrpay Backend will answer with the following response:

201 OK
Location: v1/transactions/{transactionId}

{
"id": "40c7fe9f-3bf9-464a-8d3a-937db20f5dae",
"type": "PassthroughDeposit",
"amount": 100,
"currency": "EUR",
"customerId": "111abc22-33de-4444-5555-111111111111",
"state": "Completed",
"status": "Succeeded",
"createdOn": "2019-01-31T11:50:59Z",
"distributorId": "222abc22-33de-4444-5555-222222222222"
}

See Create Transaction from Intent API Reference for more information.