Use your own software

If you use your own software to manage repeat payments, program your software to run a sale each time the merchant wants to take a payment. Each request should also include the following information:

  • Type of repeat payment
  • Position of the payment in the billing cycle
  • Information about the first payment

You can also use our tokenization service to save the customer’s payment details instead of sending their payment details in each request.

Integration steps

To use your own software for repeat payments, integrate with the following:

Step 1. (Optional) Create a secure token.
Step 2. Create 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 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. (Optional) Create a secure token

To save the customer’s payment details, send a POST request to our Secure Tokens endpoint.

Note: We assign the secure token to the terminal that sent the request. Depending on the merchant’s account settings, other terminals within the merchant’s account can also use the secure token.

Request parameters

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

Request

sourceobjectRequired
Object that contains information about the payment method to tokenize.
secureTokenIdstringOptional>=1 character<=200 characters
Unique identifier that the merchant created for the secure token that represents the customer's payment details. If the merchant doesn't create a secureTokenId, the gateway generates one and returns it in the response.
operatorstringOptional>=1 character<=50 characters
Operator who saved the customer's payment details.
mitAgreementenumOptional
Indicates how the merchant can use the customer's card details, as agreed by the customer: - `unscheduled` - Transactions for a fixed or variable amount that are run at a certain pre-defined event. - `recurring` - Transactions for a fixed amount that are run at regular intervals, for example, monthly. Recurring transactions don't have a fixed duration and run until the customer cancels the agreement. - `installment` - Transactions for a fixed amount that are run at regular intervals, for example, monthly. Installment transactions have a fixed duration.
Allowed values:
customerobjectOptional
Customer contact and address details.
ipAddressobjectOptional
Object that contains information about the IP address of the device that sent the request.
threeDSecureobjectOptional
Object that contains information for an authentication check on the customer's payment details using the 3-D Secure protocol.
customFieldslist of objectsOptional
Array of customField objects.

Example request

POST
/v1/processing-terminals/:processingTerminalId/secure-tokens
1curl -X POST https://api.payroc.com/v1/processing-terminals/ \
2 -H "Idempotency-Key: 8e03978e-40d5-43e8-bc93-6894a57f9324" \
3 -H "Authorization: Bearer <token>" \
4 -H "Content-Type: application/json" \
5 -d '{
6 "source": {
7 "type": "ach",
8 "nameOnAccount": "Shara Hazel Hopper",
9 "accountNumber": "1234567890",
10 "routingNumber": "123456789"
11 }
12}'

Response fields

If your request is successful, we store the customer’s payment details and return a response. The response contains the following fields:

Response

secureTokenIdstringRequired>=0 characters<=200 characters
Unique identifier that the merchant created for the secure token that represents the customer's payment details.
processingTerminalIdstringRequired>=4 characters<=50 characters
Unique identifier that we assigned to the terminal.
sourceobjectRequired
Object that contains information about the payment method that we tokenized.
tokenstringRequired>=12 characters<=19 characters
Token that the merchant can use in future transactions to represent the customer's payment details. The token: - Begins with the six-digit identification number **296753**. - Contains up to 12 digits. - Contains a single check digit that we calculate using the Luhn algorithm.
statusenumRequired
Status of the customer's bank account. The processor performs a security check on the customer's bank account and returns the status of the account. **Note:** Depending on the merchant's account settings, this feature may be unavailable.
mitAgreementenumOptional
Indicates how the merchant can use the customer's card details, as agreed by the customer: - `unscheduled` - Transactions for a fixed or variable amount that are run at a certain pre-defined event. - `recurring` - Transactions for a fixed amount that are run at regular intervals, for example, monthly. Recurring transactions don't have a fixed duration and run until the customer cancels the agreement. - `installment` - Transactions for a fixed amount that are run at regular intervals, for example, monthly. Installment transactions have a fixed duration.
Allowed values:
customerobjectOptional
Customer contact and address details.
customFieldslist of objectsOptional
Array of customField objects.

Example response

Response
1{
2 "secureTokenId": "MREF_abc1de23-f4a5-6789-bcd0-12e345678901fa",
3 "processingTerminalId": "1234001",
4 "source": {
5 "type": "card",
6 "cardholderName": "Sarah Hazel Hopper",
7 "cardNumber": "453985******7062",
8 "expiryDate": "1225"
9 },
10 "token": "296753123456",
11 "status": "notValidated",
12 "mitAgreement": "unscheduled",
13 "customer": {
14 "firstName": "Sarah",
15 "lastName": "Hopper",
16 "dateOfBirth": "1990-07-15",
17 "referenceNumber": "Customer-12",
18 "billingAddress": {
19 "address1": "1 Example Ave.",
20 "city": "Chicago",
21 "state": "Illinois",
22 "country": "US",
23 "postalCode": "60056",
24 "address2": "Example Address Line 2",
25 "address3": "Example Address Line 3"
26 },
27 "shippingAddress": {
28 "recipientName": "Sarah Hopper",
29 "address": {
30 "address1": "1 Example Ave.",
31 "city": "Chicago",
32 "state": "Illinois",
33 "country": "US",
34 "postalCode": "60056",
35 "address2": "Example Address Line 2",
36 "address3": "Example Address Line 3"
37 }
38 },
39 "contactMethods": [
40 {
41 "type": "email",
42 "value": "[email protected]"
43 }
44 ],
45 "notificationLanguage": "en"
46 },
47 "customFields": [
48 {
49 "name": "yourCustomField",
50 "value": "abc123"
51 }
52 ]
53}

Step 2. Create a payment

To take a payment from the customer, send a POST request to the Payments endpoint. In your request, include the standingInstructions object, which contains information about the repeat payment.

Request parameters

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

Request

channelenumRequired
Channel that the merchant used to receive the payment details.
Allowed values:
processingTerminalIdstringRequired>=4 characters<=50 characters
Unique identifier that we assigned to the terminal.
orderobjectRequired
Object that contains information about the payment.
paymentMethodobjectRequired
Object that contains information about the customer's payment details.
operatorstringOptional>=0 characters<=50 characters
Operator who ran the transaction.
customerobjectOptional
Customer contact and address details.
ipAddressobjectOptional
Object that contains information about the IP address of the device that sent the request.
threeDSecureobjectOptional
Object that contains information for an authentication check on the customer's payment details using the 3-D Secure protocol.
credentialOnFileobjectOptional
Object that contains information about saving the customer’s payment details.
offlineProcessingobjectOptional
Object that contains information about the transaction if the merchant ran it when the terminal was offline.
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**.
customFieldslist of objectsOptional
Array of customField objects.

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": "pos",
7 "processingTerminalId": "1234001",
8 "order": {
9 "amount": 4999,
10 "currency": "AED",
11 "orderId": "OrderRef6543"
12 },
13 "paymentMethod": {
14 "type": "card",
15 "cardDetails": {
16 "entryMethod": "raw",
17 "device": {
18 "model": "bbposChp",
19 "serialNumber": "1850010868"
20 },
21 "rawData": "A1B2C3D4E5F67890ABCD1234567890ABCDEF1234567890ABCDEF1234567890ABCDEF"
22 }
23 }
24}'

Response fields

If your request is successful, we create the payment and return a response. The response contains the following fields:

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}

Test cases

Before you run test cases, read the Payments page in Test Your Integration.

Run a card sale

Send a POST request to the following endpoint:

POST https://api.uat.payroc.com/v1/payments

Example response

1{
2 "paymentId": "F1I17KBL0E",
3 "processingTerminalId": "3204001",
4 "order": {
5 "orderId": "Test_001",
6 "dateTime": "2023-05-24T14:44:20.63+01:00",
7 "amount": 4000,
8 "currency": "USD"
9 },
10 "card": {
11 "type": "Visa Credit",
12 "entryMethod": "keyed",
13 "cardNumber": "444433******1111",
14 "expiryDate": "0334",
15 "securityChecks": {
16 "cvvResult": "M",
17 "avsResult": "Y"
18 }
19 },
20 "paymentResult": {
21 "type": "sale",
22 "status": "ready",
23 "approvalCode": "OK14472",
24 "authorizedAmount": 4000,
25 "currency": "USD",
26 "responseCode": "A",
27 "responseMessage": "OK14472"
28 }
29}