Run a pre-authorization
A merchant can use pre-authorizations to hold an amount on a customer’s card to capture later. The merchant can run pre-authorizations only if we have enabled the function on their account. If we have not enabled pre-authorizations on the merchant’s account, we run pre-authorization attempts as sales with a status of ‘pending’.
If a merchant needs to capture more than they originally pre-authorized, they can adjust the pre-authorization amount before they capture it. For example:
- A hotel pre-authorizes a one-night stay for a customer at $100.
- The customer decides to have dinner in the hotel for $50. The hotel adjusts the $100 pre-authorization to $150.
- At checkout, the hotel captures $150 from the customer’s account for the one- night stay and dinner.
Integration steps
Step 1. Create a payment.
Step 2. (Optional) Adjust a payment.
Step 3. Capture a 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 your Bearer token, complete the following steps:
- Include your API key in the x-api-key parameter in the header of a POST request.
- 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
Example response
If your request is successful, we return a response that contains your Bearer token, information about its scope, and when it expires.
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.
Errors
If your request is unsuccessful, we return an error. For more information about errors, see Errors.
Step 1. Create a payment
To run a pre-authorization, set both autoCapture and processAsSale to false
in the request body. If both parameters are set to true
, the transaction runs as a sale instead of a pre-authorization.
To run a pre-authorization, send a POST request to our Payments endpoint.
Request parameters
To create the body of your request, use the following parameters:
Example request
Response fields
Important: Save the paymentId
to use when you capture the payment.
If your request is successful, we send a pre-authorization request to the customer’s bank or card company for the specific amount. The response contains the following fields:
Example response
Step 2. (Optional) Adjust a payment
Important: A merchant can capture more than they originally pre-authorized, however each card brand sets different limits to the additional amount that the merchant can capture. If a merchant needs to capture more than they originally pre-authorized, we recommend that they adjust the pre-authorization before they capture it.
To adjust a pre-authorized amount, send a POST request to our Payments endpoint.
Request parameters
To create the body of your request, use the following parameters:
Example request
Response fields
If your request is successful, we adjust the pre-authorization amount and return a response. The response contains the following fields:
Example response
Step 3. Capture a payment
To capture the pre-authorization, send a POST request to our Payments endpoint.
Request parameters
To create the body of your request, use the following parameters:
Example request
Response fields
If your request is successful, we capture the pre-authorization and return a response. The response contains the following fields:
Example response
Test cases
Before you run test cases, read the Payments page in Test Your Integration.
Run a pre-authorization
Send a POST request to the following endpoint:
POST https://api.uat.payroc.com/v1/payments
Note: Set the value for the autoCapture parameter to false
.
Example response
Capture a pre-authorization
Send a POST request to the following endpoint:
POST https://api.uat.payroc.com/v1/payments/{paymentId}/capture
Example response