To create a new payment, you will need to send an HTTP POST request to the following endpoint:
POST https://<api-host>/v1/payments
Replace `<api-host>` with the appropriate API host URL, either `https://api-sandbox.trustistecommerce.com` for the sandbox environment or `https://api.trustistecommerce.com` for the production environment.
Headers:
– `Content-Type`: `application/json`
– `Authorization`: Hawk authentication header (generated using your client ID, private key, and other Hawk authentication parameters)
Payload:
The request body should be a JSON object containing the following fields:
– `amount`: The payment amount as a decimal value (e.g., 12.34)
– `reference`: A string containing a unique reference for the payment (e.g., “Order 1234”)
– `returnUrl`: The URL to redirect the user to after the payment is completed (e.g., “https://www.example.com?orderId=1234”)
– `cancelUrl`: The URL to redirect the user to if they cancel out of the payment process
– ‘description’: A human-readable text description for the transaction (optional)
– ‘customerDetails’: A single-line text entry to identify the customer (optional)
– ‘workflow’: An object that provides parameters to determine the course of the payer journey (see Workflow section below)
Workflow #
The workflow object will determine how a payer moves through their payment journey. It is limited to a general mode at the moment.
The two modes available are Default and RemoteOnly, where RemoteOnly forces the payer to carry out the transaction on their mobile device, made possible by scanning a QR code if not already on a mobile. Example workflow section:
{
"mode": "Default"
}
Example request:
POST https://api-sandbox.trustistecommerce.com/v1/payments
Content-Type: application/json
Authorization: Hawk id=”your-client-id”, ts=”1618886397″, nonce=”a_random_nonce”, hash=”generated_request_hash”, ext=”hawk.1.header”, mac=”generated_mac”
{
“amount”: 12.34,
“reference”: “Order_1234”,
“returnUrl”: “https://www.example.com?orderId=1234”
}
Response:
The API will respond with a JSON object containing the following fields:
– `id`: A unique identifier for the created payment
– `payLink`: A URL to redirect the customer to complete the payment
If successful, the response will have a 200 OK status code. In case of an error, the API will return an appropriate error status code and a message describing the issue.