Run a sale

An AI skill is available for this guide, get it on the Skills Marketplace (GitHub).

After you configure a device for Payroc Cloud, program your POS to send a payment instruction to the payment device. Your POS then checks the status of the instruction until the payment finishes, and views the details of the payment.

How it works

  1. Your POS submits a payment instruction to the device. Our gateway sends the instruction to the device and returns a paymentInstructionId with a status of inProgress.
  2. The cardholder completes the payment on the device. Your POS checks the status of the payment instruction. Our gateway waits up to a minute for the status to change before it responds. If the status is still inProgress, your POS sends another request and keeps checking until the status changes.
  3. When the payment finishes, your POS uses the link in the response to view the details of the payment and to check whether the processor approved it or declined it.

You can also cancel the payment instruction while its status is inProgress.

Before you begin

Authenticate your requests before making API calls. If your request fails, see Errors.

Step 1. Submit a payment instruction

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

EnvironmentURL
Testhttps://api.uat.payroc.com/v1/devices/{serialNumber}/payment-instructions
Productionhttps://api.payroc.com/v1/devices/{serialNumber}/payment-instructions

Request parameters

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

Request

processingTerminalIdstringRequired4-50 characters
Unique identifier that we assigned to the terminal.
orderobjectRequired
Object that contains information about the payment.
operatorstringOptional0-50 characters
Operator who initiated the request.
customerobjectOptional
Object that contains the customer's contact details and address information. Contains parameters required for [Level 2, Level 3, and CEDP transactions](https://docs.payroc.com/knowledge/card-payments/enhanced-data).
ipAddressobjectOptional
Object that contains 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/1850010868/payment-instructions \
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 "orderId": "OrderRef6543",
9 "amount": 4999,
10 "currency": "USD"
11 },
12 "operator": "Jane",
13 "customizationOptions": {
14 "entryMethod": "deviceRead"
15 },
16 "autoCapture": true
17}'

Response fields

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

Note: The response returns a value of inProgress for the status field 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.

Response

statusenumRequired
Indicates the current status of the instruction. - `canceled` – The instruction was canceled before it was completed. - `completed` – The instruction has completed. Use the link object to check the resource. - `failure` – The instruction failed. Check the errorMessage field for more information. - `inProgress` – The instruction is currently in progress.
paymentInstructionIdstringRequired1-36 characters
Unique identifier that we assigned to the payment instruction.
errorMessagestringOptional
Description of the error that caused the instruction to fail. **Note:** We return this field only if the status is `failure`.

Response parameters

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

Step 2. View the status of a payment instruction

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

EnvironmentURL
Testhttps://api.uat.payroc.com/v1/payment-instructions/{paymentInstructionId}
Productionhttps://api.payroc.com/v1/payment-instructions/{paymentInstructionId}

Before our gateway sends a response, it waits for up to a minute 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 a minute 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 your request, use the following parameters:

Path parameters

paymentInstructionIdstringRequired1-36 characters
Unique identifier that we assigned to the payment instruction.

Example request

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

Response fields

If your request is successful, we return the details of the payment instruction, including HATEOAS links to check the details of the payment. Use the HATEOAS links to get the paymentId, which you need in Step 3.

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

statusenumRequired
Indicates the current status of the instruction. - `canceled` – The instruction was canceled before it was completed. - `completed` – The instruction has completed. Use the link object to check the resource. - `failure` – The instruction failed. Check the errorMessage field for more information. - `inProgress` – The instruction is currently in progress.
paymentInstructionIdstringRequired1-36 characters
Unique identifier that we assigned to the payment instruction.
errorMessagestringOptional
Description of the error that caused the instruction to fail. **Note:** We return this field only if the status is `failure`.

Example response

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

Step 3. View the details of the payment

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

EnvironmentURL
Testhttps://api.uat.payroc.com/v1/payments/{paymentId}
Productionhttps://api.payroc.com/v1/payments/{paymentId}

Request parameters

To create 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/M2MJOG6O2Y \
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.
processingTerminalIdstringRequired4-50 characters
Unique identifier of the terminal that initiated the transaction.
orderobjectRequired
Object that contains information about the payment.
cardobjectRequired
Object that contains the details of the payment card.
transactionResultobjectRequired
Object that contains information about the transaction response details.
operatorstringOptional0-50 characters
Operator who initiated the request.
customerobjectOptional
Object that contains the customer's contact details and address information.
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`.
customFieldslist of objectsOptional
Array of customField objects.

Example response

Response
1{
2 "paymentId": "M2MJOG6O2Y",
3 "processingTerminalId": "1234001",
4 "order": {
5 "orderId": "OrderRef6543",
6 "amount": 4999,
7 "currency": "USD",
8 "dateTime": "2024-07-02T15:30:00Z",
9 "description": "Large Pepperoni Pizza"
10 },
11 "card": {
12 "type": "MasterCard",
13 "cardNumber": "453985******7062",
14 "expiryDate": "1230",
15 "entryMethod": "keyed",
16 "securityChecks": {
17 "cvvResult": "M",
18 "avsResult": "Y"
19 }
20 },
21 "transactionResult": {
22 "status": "ready",
23 "responseCode": "A",
24 "type": "sale",
25 "approvalCode": "OK3",
26 "authorizedAmount": 4999,
27 "currency": "USD",
28 "responseMessage": "OK3"
29 },
30 "operator": "Jane",
31 "customer": {
32 "firstName": "Sarah",
33 "lastName": "Hopper",
34 "billingAddress": {
35 "address1": "1 Example Ave.",
36 "address2": "Example Address Line 2",
37 "address3": "Example Address Line 3",
38 "city": "Chicago",
39 "state": "Illinois",
40 "country": "US",
41 "postalCode": "60056"
42 },
43 "shippingAddress": {
44 "recipientName": "Sarah Hopper",
45 "address": {
46 "address1": "1 Example Ave.",
47 "address2": "Example Address Line 2",
48 "address3": "Example Address Line 3",
49 "city": "Chicago",
50 "state": "Illinois",
51 "country": "US",
52 "postalCode": "60056"
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}

(Optional) Cancel a payment instruction

To cancel a payment instruction, send a DELETE request to the Payment Instructions endpoint.

EnvironmentURL
Testhttps://api.uat.payroc.com/v1/payment-instructions/{paymentInstructionId}
Productionhttps://api.payroc.com/v1/payment-instructions/{paymentInstructionId}

Note: You can cancel a payment instruction only if its status is inProgress.

Request parameters

To create your request, use the following parameters:

Path parameters

paymentInstructionIdstringRequired1-36 characters
Unique identifier that we assigned to the payment instruction.

Example request

Path parameters

paymentInstructionIdstringRequired1-36 characters
Unique identifier that we assigned to the payment instruction.

Response

Response

If your request is successful, we cancel the payment instruction.