Run a sale

A merchant can use their POS to initiate a sale on their payment device.

Integration steps

To run a sale using Payroc Cloud, integrate with the following:

Step 1. Create a payment instruction.
Step 2. View the status of the payment instruction.
Step 3. View the details of the payment.

Before you begin

Bearer tokens

Use our Identity Service to generate a Bearer token to include in the header of your requests. To generate a Bearer token, complete the following steps:

  1. Include your API key in the x-api-key parameter in the header of a POST request.
  2. Send your request to https://identity.payroc.com/authorize.

Note: You need to generate a new Bearer token before the previous Bearer token expires.

Example request

$curl --location --request POST 'https://identity.payroc.com/authorize' --header 'x-api-key: <api key>'

If your request is successful, we return a response that contains your Bearer token, information about its scope, and when it expires.

Example response

1{
2 "access_token": "eyJhbGc....adQssw5c",
3 "expires_in": 3600,
4 "scope": "service_a service_b",
5 "token_type": "Bearer"
6}

Headers

To create the header of each POST request, you must include the following parameters:

  • Content-Type: Include application/json as the value for this parameter.
  • Authorization: Include your Bearer token in this parameter.
  • Idempotency-Key: Include a UUID v4 to make the request idempotent.
$curl
>-H "Content-Type: application/json"
>-H "Authorization: <Bearer token>"
>-H "Idempotency-Key: <UUID v4>"

Errors

If your request is unsuccessful, we return an error. For more information about errors, see Errors.

Step 1. Create a payment instruction

To send a payment instruction to a device, send a POST request to the Devices endpoint.

Request parameters

To create the body of your request, use the following parameters:

Request

processingTerminalIdstringRequired>=4 characters<=50 characters
Unique identifier that we assigned to the terminal.
orderobjectRequired
Object that contains information about the payment.
operatorstringOptional>=0 characters<=50 characters
Operator who initiated the request.
customerobjectOptional
Customer contact and address details.
ipAddressobjectOptional
Object that contains information about the IP address of the device that sent the request.
credentialOnFileobjectOptional
Object that contains information about saving the customer’s payment details.
customizationOptionsobjectOptional
Object that contains available options to customize certain aspects of an instruction.
autoCapturebooleanOptionalDefaults to true
Indicates if we should automatically capture the payment amount. - `true` - Run a sale and automatically capture the transaction. - `false`- Run a pre-authorization and capture the transaction later. **Note:** If you send `false` and the terminal doesn't support pre-authorization, we set the transaction's status to pending. The merchant must capture the transaction to take payment from the customer.
processAsSalebooleanOptionalDefaults to false
Indicates if we should immediately settle the sale transaction. The merchant cannot adjust the transaction if we immediately settle it. **Note:** If the value for **processAsSale** is `true`, the gateway ignores the value in **autoCapture**.

Example request

POST
/v1/devices/:serialNumber/payment-instructions
1curl -X POST https://api.payroc.com/v1/devices/ \
2 -H "Idempotency-Key: 8e03978e-40d5-43e8-bc93-6894a57f9324" \
3 -H "Authorization: Bearer <token>" \
4 -H "Content-Type: application/json" \
5 -d '{
6 "processingTerminalId": "1234001",
7 "order": {
8 "amount": 2899,
9 "currency": "AED",
10 "orderId": "OrderRef6543"
11 }
12}'

Response fields

If your request is successful, we send the payment instruction to the device.

Note: The response returns a value of inProgress for status and an identifier for the instruction that you can use to check the status of the instruction. To get a link to view the details of the payment, go to Step 2.

The response contains the following fields:

Response

paymentInstructionIdstringRequired>=1 character<=36 characters
Unique identifier that our gateway assigned to the instruction.
errorMessagestringOptional
Description of the error that caused the instruction to fail.
statusenumOptional
Indicates the current status of the instruction. - `canceled` – The instruction was canceled before it was completed. - `completed` – The instruction has completed. Use the link to check the resource. - `failure` – The instruction failed. Check the error message for more information. - `inProgress` – The instruction is currently in progress.
Allowed values:

Example response

Response
1{
2 "paymentInstructionId": "a37439165d134678a9100ebba3b29597",
3 "link": {
4 "rel": "self",
5 "method": "GET",
6 "href": "https://api.payroc.com/v1/payment-instructions/a37439165d134678a9100ebba3b29597"
7 },
8 "status": "inProgress"
9}

Step 2. View the status of a payment instruction

To check for updates to the status or view the details of the payment, send a GET request to the Payment Instructions endpoint.

Before our gateway sends a response, it waits for up to 30 seconds for the status of the instruction to change. We recommend that you keep the session open until the status of the instruction changes or the request times out.

If the status of the instruction doesn’t change, send another GET request. Our gateway waits up to 30 seconds for the status of the instruction to change. Continue to send GET requests until the status changes.

Note: Wait until you receive a response from our gateway before you send another request.

Request parameters

To create the body of your request, use the following parameters:

Path parameters

paymentInstructionIdstringRequired>=1 character<=36 characters
Unique identifier of the payment instruction.

Example request

GET
/v1/payment-instructions/:paymentInstructionId
1curl https://api.payroc.com/v1/payment-instructions/ \
2 -H "Authorization: Bearer <token>"

Response fields

If your request is successful, we return the details of the payment instruction.

To check whether a transaction is approved or declined, follow the HATEOAS link in the response to view the transaction.

If the status of the payment instruction is inProgress, our gateway waits up to a minute for the status to change before it returns a response.

Response

paymentInstructionIdstringRequired>=1 character<=36 characters
Unique identifier that our gateway assigned to the instruction.
errorMessagestringOptional
Description of the error that caused the instruction to fail.
statusenumOptional
Indicates the current status of the instruction. - `canceled` – The instruction was canceled before it was completed. - `completed` – The instruction has completed. Use the link to check the resource. - `failure` – The instruction failed. Check the error message for more information. - `inProgress` – The instruction is currently in progress.
Allowed values:

Example response

Response
1{
2 "paymentInstructionId": "a37439165d134678a9100ebba3b29597",
3 "link": {
4 "rel": "payment",
5 "method": "GET",
6 "href": "https://api.payroc.com/v1/payments/M2MJOG6O2Y"
7 },
8 "status": "completed"
9}

Step 3. View the details of the payment

To check if the processor approved or declined the payment, send a GET request to the Payments endpoint.

Request parameters

To create the body of your request, use the following parameters:

Path parameters

paymentIdstringRequired=10 characters
Unique identifier of the payment that the merchant wants to retrieve.

Example request

GET
/v1/payments/:paymentId
1curl https://api.payroc.com/v1/payments/ \
2 -H "Authorization: Bearer <token>"

Response fields

If your request is successful, we return the details of the payment.

Response

paymentIdstringRequired=10 characters
Unique identifier that our gateway assigned to the transaction.
processingTerminalIdstringRequired>=4 characters<=50 characters
Unique identifier of the terminal that initiated the transaction.
orderobjectRequired
Object that contains information about the payment.
cardobjectRequired
Object that contains information about the card.
transactionResultobjectRequired
Object that contains information about the transaction response details.
operatorstringOptional>=0 characters<=50 characters
Operator who initiated the request.
customerobjectOptional
Customer contact and address details.
refundslist of objectsOptional
Array of refundSummary objects. Each object contains information about refunds linked to the transaction.
supportedOperationslist of enumsOptional
Array of operations that you can perform on the transaction. - `capture` - Capture the payment. - `refund` - Refund the payment. - `fullyReverse` - Fully reverse the transaction. - `partiallyReverse` - Partially reverse the payment. - `incrementAuthorization` - Increase the amount of the authorization. - `adjustTip` - Adjust the tip post-payment. - `addSignature` - Add a signature to the payment. - `setAsReady` - Set the transaction’s status to `ready`. - `setAsPending` - Set the transaction’s status to `pending`. - `setAsDeclined` - Set the transaction’s status to `declined`.
customFieldslist of objectsOptional
Array of customField objects.

Example response

Response
1{
2 "paymentId": "M2MJOG6O2Y",
3 "processingTerminalId": "1234001",
4 "order": {
5 "amount": 4999,
6 "currency": "USD",
7 "orderId": "OrderRef6543",
8 "dateTime": "2024-07-02T15:30:00Z",
9 "description": "Large Pepperoni Pizza"
10 },
11 "card": {
12 "type": "MasterCard",
13 "entryMethod": "keyed",
14 "cardNumber": "453985******7062",
15 "expiryDate": "1225",
16 "securityChecks": {
17 "cvvResult": "M",
18 "avsResult": "Y"
19 }
20 },
21 "transactionResult": {
22 "type": "sale",
23 "status": "ready",
24 "responseCode": "A",
25 "responseMessage": "OK3",
26 "approvalCode": "OK3",
27 "authorizedAmount": 4999,
28 "currency": "USD"
29 },
30 "operator": "Postman",
31 "customer": {
32 "firstName": "Sarah",
33 "lastName": "Hopper",
34 "billingAddress": {
35 "address1": "1 Example Ave.",
36 "city": "Chicago",
37 "state": "Illinois",
38 "country": "US",
39 "postalCode": "60056",
40 "address2": "Example Address Line 2",
41 "address3": "Example Address Line 3"
42 },
43 "shippingAddress": {
44 "recipientName": "Sarah Hopper",
45 "address": {
46 "address1": "1 Example Ave.",
47 "city": "Chicago",
48 "state": "Illinois",
49 "country": "US",
50 "postalCode": "60056",
51 "address2": "Example Address Line 2",
52 "address3": "Example Address Line 3"
53 }
54 }
55 },
56 "supportedOperations": [
57 "capture",
58 "fullyReverse",
59 "partiallyReverse",
60 "incrementAuthorization",
61 "adjustTip",
62 "setAsPending"
63 ],
64 "customFields": [
65 {
66 "name": "yourCustomField",
67 "value": "abc123"
68 }
69 ]
70}

Before you test your integration

To test your integration with a payment device, first complete the following tasks:

  • Get the serial number of the payment device.
  • Connect the payment device to the internet.

Test cases

Create a payment instruction using options that you configured in the gateway

Step 1. Create a payment instruction

Use our gateway to configure the surcharging options, tip options, and tax amounts.

Note: If you’re unsure about how to configure these options, contact your Payroc Integration Engineer.

Send a POST request to the Devices test endpoint:

https://api.uat.payroc.com/v1/devices/{serialNumber}/payment-instructions

Example request

1{
2 "operator": "jbloggs",
3 "processingTerminalId": "1021",
4 "order": {
5 "orderId": "4fd4-99bc",
6 "currency": "USD",
7 "amount": 1000,
8 "orderBreakdown": {
9 "subtotalAmount": 1000
10 }
11 },
12 "customizationOptions": {
13 "entryMethod": "deviceRead"
14 },
15 "autoCapture": true,
16 "processAsSale": false
17}

Step 2. Retrieve the status of the payment instruction

Send a GET request to the Payment Instructions test endpoint:

https://api.uat.payroc.com/v1/payment-instructions/{paymentInstructionId}

If the status of the payment instruction is inProgress, our gateway waits up to a minute for the status to change before it returns a response. Send GET requests until the value for status changes to completed.

Note: If the status of the payment instruction is failed or canceled, contact your Payroc Integration Engineer.

Example response

1{
2 "paymentInstructionId": "3743a9165d134678a9100ebba3b29597",
3 "status": "completed",
4 "link": {
5 "rel": "payment",
6 "method": "GET",
7 "href": "https://api.payroc.com/v1/payments/DD6ZDQU7L2"
8 }
9}

Step 3. Retrieve the status of the payment instruction

Send a GET request to the Payment test endpoint:

https://api.uat.payroc.com/v1/payments/{paymentId}

Use the paymentID that you received in the response from Step 2.

Example response

1{
2 "operator": "XYZ",
3 "terminal": 1021,
4 "order": {
5 "orderId": "4fd4-99bc",
6 "description": "Payment Instruction",
7 "currency": "USD",
8 "totalAmount": 10.00,
9 "orderBreakdown": {
10 "subtotalAmount": 10.00,
11 "surcharge": {
12 "bypass": "true"
13 },
14 "taxes": [
15 {
16 "name": "TAX10",
17 "rate": 10.0
18 }
19 ],
20 "tip": {}
21 }
22 },
23 "customizationOptions": {
24 "entryMethod": "DEVICE_READ"
25 },
26 "customer": {
27 "name": "First Last",
28 "dateOfBirth": "2023-01-01",
29 "referenceNumber": "ABCDEFGH",
30 "billingAddress": {
31 "line1": "billing Addr Line1",
32 "line2": "billing Addr Line2",
33 "city": "billCity",
34 "state": "AZ",
35 "country": "US",
36 "postalCode": 12345
37 },
38 "shippingAddress": {
39 "name": "shipping recipient name",
40 "line1": "shipping Addr Line1",
41 "line2": "shipping Addr Line2",
42 "city": "shipCity",
43 "state": "AZ",
44 "country": "US",
45 "postalCode": "SH12345"
46 },
47 "email": "[email protected]",
48 "phone": "+353891234567",
49 "notificationLanguage": "en"
50 },
51 "autoCapture": true,
52 "processAsSale": false
53}

Create a payment instruction that overrides the values that you configured in the gateway

Step 1. Create a payment instruction

Send a POST request to the Devices test endpoint:

https://api.uat.payroc.com/v1/devices/{serialNumber}/payment-instructions

Example request

1{
2 "operator": "XYZ",
3 "terminal": 1021,
4 "order": {
5 "orderId": "TestPBC-123",
6 "description": "Payment Instruction",
7 "currency": "USD",
8 "totalAmount": 12100,
9 "orderBreakdown": {
10 "subtotalAmount": 12100,
11 "surcharge": {
12 "bypass": "true"
13 },
14 "taxes": [
15 {
16 "name": "TAX10",
17 "rate": 10.0
18 }
19 ],
20 "tip": {
21 "percentage": 10,
22 "type": "PERCENTAGE"
23 }
24 }
25 },
26 "customizationOptions": {
27 "entryMethod": "DEVICE_READ"
28 },
29 "autoCapture": true,
30 "processAsSale": false
31}

Step 2. Retrieve the status of the payment instruction

Send a GET request to the Payment Instructions test endpoint:

https://api.uat.payroc.com/v1/payment-instructions/{paymentInstructionId}

If the status of the payment instruction is inProgress, our gateway waits up to a minute for the status to change before it returns a response. Send GET requests until the value for status changes to completed.

Note: If the status of the payment instruction is failed or canceled, contact your Payroc Integration Engineer.

Example response

1{
2 "paymentInstructionId": "3743a9165d134678a9100ebba3b29597",
3 "status": "completed",
4 "link": {
5 "rel": "payment",
6 "method": "GET",
7 "href": "https://api.payroc.com/v1/payments/DD6ZDQU7L2"
8 }
9}

Step 3. Retrieve the status of the payment instruction

Send a GET request to the Payment test endpoint:

https://api.uat.payroc.com/v1/payments/{paymentId}

Use the paymentID that you received in the response from Step 2.

Example response

1{
2 "paymentId": "DD6ZDQU7L2",
3 "processingTerminalId": "1021",
4 "operator": "Postman",
5 "order": {
6 "orderId": "4fd4-99bc",
7 "dateTime": "2023-07-26T16:42:25.018Z",
8 "description": "Example payment",
9 "amount": 1000,
10 "currency": "USD"
11 },
12 "customer": {
13 "shippingAddress": {}
14 },
15 "card": {
16 "type": "MasterCard",
17 "entryMethod": "keyed",
18 "cardNumber": "500165******0000",
19 "expiryDate": "0328",
20 "securityChecks": {
21 "cvvResult": "M",
22 "avsResult": "Y"
23 }
24 },
25 "transactionResult": {
26 "type": "sale",
27 "status": "ready",
28 "approvalCode": "OK3",
29 "authorizedAmount": 1000,
30 "currency": "USD",
31 "responseCode": "A",
32 "responseMessage": "OK3"
33 }
34}