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:

  1. A hotel pre-authorizes a one-night stay for a customer at $100.
  2. The customer decides to have dinner in the hotel for $50. The hotel adjusts the $100 pre-authorization to $150.
  3. 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

Authenticate your requests before making API calls. If your request fails, 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:

Request

Example request

POST
/v1/payments
1curl -X POST https://api.payroc.com/v1/payments \
2 -H "Idempotency-Key: 8e03978e-40d5-43e8-bc93-6894a57f9324" \
3 -H "Authorization: Bearer <token>" \
4 -H "Content-Type: application/json" \
5 -d '{
6 "channel": "web",
7 "processingTerminalId": "1234001",
8 "order": {
9 "orderId": "1234567890W",
10 "amount": 4999,
11 "currency": "USD",
12 "description": "Card Transaction (APPLE)"
13 },
14 "paymentMethod": {
15 "type": "digitalWallet",
16 "encryptedData": "7b2262696c6c696e67436f6e74616374223a7b2266616d696c794e616d65223a22222c22676976656e4e616d65223a22222c2270686f6e6574696346616d696c794e616d65223a22222c2270686f6e65746963476976656e4e616d65223a22227d2c227368697070696e67436f6e74616374223a7b22656d61696c41646472657373223a227465737440646f6d61696e2e636f6d222c2266616d696c794e616d65223a22222c22676976656e4e616d65223a22222c2270686f6e6574696346616d696c794e616d65223a22222c2270686f6e65746963476976656e4e616d65223a22227d2c22746f6b656e223a7b227061796d656e7444617461223a7b2264617461223a2259314b37626731573479755568587473335941627a6150756c384d31795057304c724637734e2f70415950456d3871647969716c6257777356792b7732334c666c74344e6932525a684c2f6a52727563356f69496235537437763248543739682b74702f78517838496b6a5631485354594d747156644c6a413977686379774f654f70326575556d306e56386b50726569564273726a596c355931437a30576371495648595134424e737a4b5876675063686a497a6f4d4b456336425650744c7335777654667a434b51574a496a646b62516161306265685958524b422b7941773872537a6a4a476f3758523061467a414b4e70346c6f436e69484e564838373244504e4a77364b30336e544d69724b37725a615566485356754d477544473348366e4d78336c48436e6b517478764551474771754132676c416434424f427943414976483541566671655173534137776a4459702f494c6c66614e64307469467478344d6235566f6952513249387379384548547670307736667861316973613874636f484855614b32353857486474673d3d222c227369676e6174757265223a224d494147435371475349623344514548417143414d494143415145784454414c42676c67686b67425a514d45416745776741594a4b6f5a496876634e415163424141436767444343412b517767674f4c6f414d434151494343466e596f627971394f504e4d416f4743437147534d343942414d434d486f784c6a417342674e5642414d4d4a5546776347786c4945467763477870593246306157397549456c756447566e636d46306157397549454e4249433067527a4d784a6a416b42674e564241734d485546776347786c49454e6c636e52705a6d6c6a59585270623234675158563061473979615852354d524d77455159445651514b44417042634842735a53424a626d4d754d517377435159445651514745774a56557a4165467730794d5441304d6a41784f544d334d444261467730794e6a41304d546b784f544d324e546c614d4749784b44416d42674e5642414d4d4832566a5979317a62584174596e4a76613256794c584e705a32356656554d304c564e42546b5243543167784644415342674e564241734d43326c505579425465584e305a57317a4d524d77455159445651514b44417042634842735a53424a626d4d754d517377435159445651514745774a56557a425a4d424d4742797147534d34394167454743437147534d34394177454841304941424949772f6176446e50646549437851325a74464575593334716b423357797a344c484e53314a6e6d506a505472336f4769576f7768354d4d39334f6a697157777661766f5a4d445263546f656b516d7a7055624570576a676749524d4949434454414d42674e5648524d4241663845416a41414d42384741315564497751594d42614146435079536352506b2b54764a2b62453969687350364b372f53354c4d45554743437347415155464277454242446b774e7a4131426767724267454642516377415959706148523063446f764c32396a633341755958427762475575593239744c32396a633341774e433168634842735a5746705932457a4d4449776767456442674e5648534145676745554d4949424544434341517747435371475349623359325146415443422f6a4342777759494b77594242515548416749776762594d67624e535a5778705957356a5a5342766269423061476c7a49474e6c636e52705a6d6c6a5958526c49474a35494746756553427759584a306553426863334e316257567a4947466a593256776447467559325567623259676447686c4948526f5a5734675958427762476c6a59574a735a53427a644746755a4746795a4342305a584a7463794268626d5167593239755a476c3061573975637942765a6942316332557349474e6c636e52705a6d6c6a5958526c4948427662476c6a65534268626d51675932567964476c6d61574e6864476c7662694277636d466a64476c6a5a53427a644746305a57316c626e527a4c6a4132426767724267454642516343415259716148523063446f764c33643364793568634842735a53356a623230765932567964476c6d61574e68644756686458526f62334a7064486b764d44514741315564487751744d4373774b61416e6f43574749326830644841364c79396a636d77755958427762475575593239744c3246776347786c59576c6a59544d7559334a734d4230474131556444675157424251434a44414c6d753774526a4758704b5a614b5a3543635949635254414f42674e56485138424166384542414d43423441774477594a4b6f5a496876646a5a415964424149464144414b42676771686b6a4f5051514441674e4841444245416942306f624d6b32304a4a517733544a307851644d53416a5a6f6653413436686358424e69566d4d6c2b386f7749676154615155367631433170532b6659415463574b725778517039594961446551344b63363042354b3259457767674c754d49494364614144416745434167684a62532b2f4f706a616c7a414b42676771686b6a4f50515144416a426e4d527377475159445651514444424a42634842735a5342536232393049454e4249433067527a4d784a6a416b42674e564241734d485546776347786c49454e6c636e52705a6d6c6a59585270623234675158563061473979615852354d524d77455159445651514b44417042634842735a53424a626d4d754d517377435159445651514745774a56557a4165467730784e4441314d4459794d7a51324d7a4261467730794f5441314d4459794d7a51324d7a42614d486f784c6a417342674e5642414d4d4a5546776347786c4945467763477870593246306157397549456c756447566e636d46306157397549454e4249433067527a4d784a6a416b42674e564241734d485546776347786c49454e6c636e52705a6d6c6a59585270623234675158563061473979615852354d524d77455159445651514b44417042634842735a53424a626d4d754d517377435159445651514745774a56557a425a4d424d4742797147534d34394167454743437147534d34394177454841304941425041584559515a31325346315270654a594548647569416f752f656536354e34493338533550684d3162565a6c733172694c516c33594e496b353775676a396468664f694d743275325a7776736a6f4b59542f5645576a6766637767665177526759494b77594242515548415145454f6a41344d4459474343734741515546427a41426869706f644852774f69387662324e7a63433568634842735a53356a6232307662324e7a634441304c5746776347786c636d397664474e685a7a4d77485159445652304f4242594546435079536352506b2b54764a2b62453969687350364b372f53354c4d41384741315564457745422f7751464d414d4241663877487759445652306a42426777466f4155753744656f56677a694a716b69706e65767233727239724c4a4b73774e77594456523066424441774c6a41736f4371674b49596d6148523063446f764c324e7962433568634842735a53356a623230765958427762475679623239305932466e4d79356a636d777744675944565230504151482f42415144416745474d42414743697147534962335932514741673445416755414d416f4743437147534d343942414d43413263414d4751434d447250636f4e5246706d78687673317731624b59722f30462b335a4433564e6f6f362b385a7942586b4b33696669593935745a6e356a56515132506e656e432f6749774d693356524347776f7756336246337a4f4475515a2f305866437768625a5a50786e4a7067684a76565068366652755a7935734a6953466842706b50435a4964414141786767474a4d4949426851494241544342686a42364d5334774c4159445651514444435642634842735a5342426348427361574e6864476c766269424a626e526c5a334a6864476c7662694244515341744945637a4d5359774a4159445651514c44423142634842735a5342445a584a3061575a7059324630615739754945463164476876636d6c30655445544d424547413155454367774b51584277624755675357356a4c6a454c4d416b474131554542684d4356564d4343466e596f627971394f504e4d417347435743475341466c41775143416143426b7a415942676b71686b69473977304243514d784377594a4b6f5a496876634e415163424d42774743537147534962334451454a42544550467730794e4445794d5449784e6a51774d5452614d43674743537147534962334451454a4e4445624d426b774377594a59495a4941575544424149426f516f4743437147534d343942414d434d43384743537147534962334451454a4244456942434335615768366c647944637435626844536b62345835494a612b576f746d6d74344a624c74386949754a6b6a414b42676771686b6a4f50515144416752494d45594349514437637561364c6430697a6148716d5371713747303433476770363467484d6b514e523577757a32736137674968414e44643730585a6639432f412b58774e716a75672b76684c39534c4c4966465159746f6745377842534c774141414141414141222c22686561646572223a7b227075626c69634b657948617368223a225542347255754d6b7044627054564b7448636a6452525a496f643465766562754d4f696b7a4156556441593d222c22657068656d6572616c5075626c69634b6579223a224d466b77457759484b6f5a497a6a3043415159494b6f5a497a6a3044415163445167414557556a70324f663878427449432f354335535349544e443554736f75564c423831464547383847504b7243394e394d753365534e72586c32636564757533552f504f53652f616f75384477556a674e6670584d7831673d3d222c227472616e73616374696f6e4964223a2231363431326566383238303362633133356338333165396235663732376432366165623661616130363364633138353861313562323734386666346636333739227d2c2276657273696f6e223a2245435f7631227d2c227061796d656e744d6574686f64223a7b22646973706c61794e616d65223a224d6173746572436172642031343731222c226e6574776f726b223a224d617374657243617264222c2274797065223a226465626974227d2c227472616e73616374696f6e4964656e746966696572223a2231363431326566383238303362633133356338333165396235663732376432366165623661616130363364633138353861313562323734386666346636333739227d7d",
17 "serviceProvider": "apple"
18 },
19 "operator": "Jane"
20}'

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:

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": "J9VULKIKFP",
3 "processingTerminalId": "1234001",
4 "order": {
5 "orderId": "1234567890W",
6 "amount": 4999,
7 "currency": "USD",
8 "dateTime": "2024-07-02T15:30:00Z",
9 "description": "Card Transaction (APPLE)"
10 },
11 "card": {
12 "type": "MasterCard",
13 "entryMethod": "keyed",
14 "cardNumber": "500165******0000",
15 "expiryDate": "0328",
16 "securityChecks": {
17 "avsResult": "U"
18 }
19 },
20 "transactionResult": {
21 "status": "ready",
22 "responseCode": "A",
23 "type": "sale",
24 "approvalCode": "OK3",
25 "authorizedAmount": 4999,
26 "currency": "USD",
27 "responseMessage": "APPROVAL",
28 "processorResponseCode": "00"
29 },
30 "operator": "Jane",
31 "supportedOperations": [
32 "capture",
33 "fullyReverse",
34 "partiallyReverse",
35 "incrementAuthorization",
36 "adjustTip",
37 "setAsPending"
38 ]
39}

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:

Request

adjustmentslist of objectsRequired
Array of polymorphic objects which contain information about adjustments to a payment. The value of the type parameter determines which variant you should use: - `order` - Tip information. - `status` - Status of the transaction. - `customer` - Customer's contact information and shipping address. - `signature` - Customer's signature.
operatorstringOptional0-50 characters
Operator who adjusted the payment.

Example request

POST
/v1/payments/:paymentId/adjust
1curl -X POST https://api.payroc.com/v1/payments/M2MJOG6O2Y/adjust \
2 -H "Idempotency-Key: 8e03978e-40d5-43e8-bc93-6894a57f9324" \
3 -H "Authorization: Bearer <token>" \
4 -H "Content-Type: application/json" \
5 -d '{
6 "adjustments": [
7 {
8 "type": "customer",
9 "shippingAddress": {
10 "recipientName": "Sarah Hopper",
11 "address": {
12 "address1": "1 Example Ave.",
13 "city": "Chicago",
14 "state": "Illinois",
15 "country": "US",
16 "postalCode": "60056",
17 "address2": "Example Address Line 2",
18 "address3": "Example Address Line 3"
19 }
20 }
21 },
22 {
23 "type": "order",
24 "amount": 3999
25 }
26 ]
27}'

Response fields

If your request is successful, we adjust the pre-authorization amount and return a response. The response contains the following fields:

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": "Example payment"
10 },
11 "card": {
12 "type": "MasterCard",
13 "entryMethod": "keyed",
14 "cardNumber": "453985******7062",
15 "expiryDate": "1230",
16 "securityChecks": {
17 "cvvResult": "M",
18 "avsResult": "Y"
19 }
20 },
21 "transactionResult": {
22 "status": "ready",
23 "responseCode": "A",
24 "type": "sale",
25 "approvalCode": "OK6",
26 "authorizedAmount": 4999,
27 "currency": "USD",
28 "responseMessage": "OK6"
29 },
30 "customer": {
31 "firstName": "Sarah",
32 "lastName": "Hopper",
33 "billingAddress": {
34 "address1": "1 Example Ave.",
35 "address2": "Example Address Line 2",
36 "address3": "Example Address Line 3",
37 "city": "Chicago",
38 "state": "Illinois",
39 "country": "US",
40 "postalCode": "60056"
41 },
42 "shippingAddress": {
43 "recipientName": "Sarah Hopper",
44 "address": {
45 "address1": "1 Example Ave.",
46 "address2": "Example Address Line 2",
47 "address3": "Example Address Line 3",
48 "city": "Chicago",
49 "state": "Illinois",
50 "country": "US",
51 "postalCode": "60056"
52 }
53 }
54 },
55 "supportedOperations": [
56 "capture",
57 "fullyReverse",
58 "partiallyReverse",
59 "incrementAuthorization",
60 "adjustTip",
61 "setAsPending"
62 ],
63 "customFields": [
64 {
65 "name": "yourCustomField",
66 "value": "abc123"
67 }
68 ]
69}

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:

Request

Example request

POST
/v1/payments/:paymentId/capture
1curl -X POST https://api.payroc.com/v1/payments/M2MJOG6O2Y/capture \
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 "operator": "Jane",
8 "amount": 4999,
9 "breakdown": {
10 "subtotal": 4999,
11 "dutyAmount": 499,
12 "freightAmount": 500,
13 "items": [
14 {
15 "unitPrice": 4000,
16 "quantity": 1
17 }
18 ]
19 }
20}'

Response fields

If your request is successful, we capture the pre-authorization and return a response. The response contains the following fields:

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 "entryMethod": "keyed",
14 "cardNumber": "453985******7062",
15 "expiryDate": "1230",
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}

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

1{
2 "paymentId": "C7BHY7KWCW",
3 "processingTerminalId": "3204001",
4 "operator": "Davi-Crisostomo-CHP",
5 "order": {
6 "orderId": "1234567890Q1",
7 "dateTime": "2023-06-20T21:03:30.925+01:00",
8 "description": "PreAuth Card Transaction (WEB) - Sale - KEYED (plain_text) with CVV",
9 "amount": 12346,
10 "currency": "USD"
11 },
12 "card": {
13 "type": "Visa Credit",
14 "entryMethod": "keyed",
15 "cardholderName": "Davi",
16 "cardNumber": "444433******1111",
17 "expiryDate": "1223",
18 "securityChecks": {
19 "cvvResult": "M",
20 "avsResult": "Y"
21 }
22 },
23 "transactionResult": {
24 "type": "sale",
25 "status": "pending",
26 "approvalCode": "OK24233",
27 "authorizedAmount": 12346,
28 "currency": "USD",
29 "responseCode": "A",
30 "responseMessage": "OK24233"
31 }
32}

Capture a pre-authorization

Send a POST request to the following endpoint:

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

Example response

1{
2 "paymentId": "C7BHY7KWCW",
3 "processingTerminalId": "3204001",
4 "operator": "Davi-Crisostomo-CHP",
5 "order": {
6 "orderId": "1234567890Q1",
7 "dateTime": "2023-06-20T21:03:31+01:00",
8 "description": "PreAuth Card Transaction (WEB) - Sale - KEYED (plain_text) with CVV",
9 "amount": 6532,
10 "currency": "USD"
11 },
12 "card": {
13 "type": "Visa Credit",
14 "entryMethod": "keyed",
15 "cardholderName": "Davi",
16 "cardNumber": "444433******1111",
17 "expiryDate": "1223",
18 "securityChecks": {
19 "cvvResult": "M",
20 "avsResult": "Y"
21 }
22 },
23 "transactionResult": {
24 "type": "sale",
25 "status": "ready",
26 "approvalCode": "OK24233",
27 "authorizedAmount": 6532,
28 "currency": "USD",
29 "responseCode": "A",
30 "responseMessage": "OK24233"
31 }
32}