Prerequisites: Authentication
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 as a secure token. For each repeat payment, you can use the secure token instead of the customer's payment details.
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
Authenticate your requests before making API calls. If your request fails, see Errors.
Step 1. (Optional) Create a secure token
Note: If you have already set up your integration to create a secure token, go to Step 2. Create a payment.
To save the customer’s payment details, send a POST request to our Secure Tokens endpoint.
| Environment | URL |
|---|---|
| Test | https://api.uat.payroc.com/v1/processing-terminals/{processingTerminalId}/secure-tokens |
| Production | https://api.payroc.com/v1/processing-terminals/{processingTerminalId}/secure-tokens |
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:
Schema (request.body)
Request body schema for POST /processing-terminals/{processingTerminalId}/secure-tokens
Example request
Request
POST https://api.payroc.com/v1/processing-terminals/{processingTerminalId}/secure-tokens
Secure Token
curl -X POST https://api.payroc.com/v1/processing-terminals/1234001/secure-tokens \
-H "Idempotency-Key: 8e03978e-40d5-43e8-bc93-6894a57f9324" \
-H "Authorization: Bearer <token>" \
-H "Content-Type: application/json" \
-d '{
"source": {
"type": "card",
"cardDetails": {
"entryMethod": "keyed",
"keyedData": {
"dataFormat": "plainText",
"cardNumber": "4539858876047062",
"cvv": "234",
"expiryDate": "1230"
},
"cardholderName": "Sarah Hazel Hopper"
}
},
"operator": "Jane",
"mitAgreement": "unscheduled",
"customer": {
"firstName": "Sarah",
"lastName": "Hopper",
"dateOfBirth": "1990-07-15",
"referenceNumber": "Customer-12",
"billingAddress": {
"address1": "1 Example Ave.",
"city": "Chicago",
"state": "Illinois",
"country": "US",
"postalCode": "60056",
"address2": "Example Address Line 2",
"address3": "Example Address Line 3"
},
"shippingAddress": {
"recipientName": "Sarah Hopper",
"address": {
"address1": "1 Example Ave.",
"city": "Chicago",
"state": "Illinois",
"country": "US",
"postalCode": "60056",
"address2": "Example Address Line 2",
"address3": "Example Address Line 3"
}
},
"contactMethods": [
{
"type": "email",
"value": "sarah.hopper@example.com"
}
],
"notificationLanguage": "en"
},
"ipAddress": {
"type": "ipv4",
"value": "104.18.24.203"
},
"customFields": [
{
"name": "yourCustomField",
"value": "abc123"
}
]
}'
Secure Token
import requests
url = "https://api.payroc.com/v1/processing-terminals/1234001/secure-tokens"
payload = {
"source": {
"type": "card",
"cardDetails": {
"entryMethod": "keyed",
"keyedData": {
"dataFormat": "plainText",
"cardNumber": "4539858876047062",
"cvv": "234",
"expiryDate": "1230"
},
"cardholderName": "Sarah Hazel Hopper"
}
},
"operator": "Jane",
"mitAgreement": "unscheduled",
"customer": {
"firstName": "Sarah",
"lastName": "Hopper",
"dateOfBirth": "1990-07-15",
"referenceNumber": "Customer-12",
"billingAddress": {
"address1": "1 Example Ave.",
"city": "Chicago",
"state": "Illinois",
"country": "US",
"postalCode": "60056",
"address2": "Example Address Line 2",
"address3": "Example Address Line 3"
},
"shippingAddress": {
"recipientName": "Sarah Hopper",
"address": {
"address1": "1 Example Ave.",
"city": "Chicago",
"state": "Illinois",
"country": "US",
"postalCode": "60056",
"address2": "Example Address Line 2",
"address3": "Example Address Line 3"
}
},
"contactMethods": [
{
"type": "email",
"value": "sarah.hopper@example.com"
}
],
"notificationLanguage": "en"
},
"ipAddress": {
"type": "ipv4",
"value": "104.18.24.203"
},
"customFields": [
{
"name": "yourCustomField",
"value": "abc123"
}
]
}
headers = {
"Idempotency-Key": "8e03978e-40d5-43e8-bc93-6894a57f9324",
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
Secure Token
const url = 'https://api.payroc.com/v1/processing-terminals/1234001/secure-tokens';
const options = {
method: 'POST',
headers: {
'Idempotency-Key': '8e03978e-40d5-43e8-bc93-6894a57f9324',
Authorization: 'Bearer <token>',
'Content-Type': 'application/json'
},
body: '{"source":{"type":"card","cardDetails":{"entryMethod":"keyed","keyedData":{"dataFormat":"plainText","cardNumber":"4539858876047062","cvv":"234","expiryDate":"1230"},"cardholderName":"Sarah Hazel Hopper"}},"operator":"Jane","mitAgreement":"unscheduled","customer":{"firstName":"Sarah","lastName":"Hopper","dateOfBirth":"1990-07-15","referenceNumber":"Customer-12","billingAddress":{"address1":"1 Example Ave.","city":"Chicago","state":"Illinois","country":"US","postalCode":"60056","address2":"Example Address Line 2","address3":"Example Address Line 3"},"shippingAddress":{"recipientName":"Sarah Hopper","address":{"address1":"1 Example Ave.","city":"Chicago","state":"Illinois","country":"US","postalCode":"60056","address2":"Example Address Line 2","address3":"Example Address Line 3"}},"contactMethods":[{"type":"email","value":"sarah.hopper@example.com"}],"notificationLanguage":"en"},"ipAddress":{"type":"ipv4","value":"104.18.24.203"},"customFields":[{"name":"yourCustomField","value":"abc123"}]}'
};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
Secure Token
package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.payroc.com/v1/processing-terminals/1234001/secure-tokens"
payload := strings.NewReader("{\n \"source\": {\n \"type\": \"card\",\n \"cardDetails\": {\n \"entryMethod\": \"keyed\",\n \"keyedData\": {\n \"dataFormat\": \"plainText\",\n \"cardNumber\": \"4539858876047062\",\n \"cvv\": \"234\",\n \"expiryDate\": \"1230\"\n },\n \"cardholderName\": \"Sarah Hazel Hopper\"\n }\n },\n \"operator\": \"Jane\",\n \"mitAgreement\": \"unscheduled\",\n \"customer\": {\n \"firstName\": \"Sarah\",\n \"lastName\": \"Hopper\",\n \"dateOfBirth\": \"1990-07-15\",\n \"referenceNumber\": \"Customer-12\",\n \"billingAddress\": {\n \"address1\": \"1 Example Ave.\",\n \"city\": \"Chicago\",\n \"state\": \"Illinois\",\n \"country\": \"US\",\n \"postalCode\": \"60056\",\n \"address2\": \"Example Address Line 2\",\n \"address3\": \"Example Address Line 3\"\n },\n \"shippingAddress\": {\n \"recipientName\": \"Sarah Hopper\",\n \"address\": {\n \"address1\": \"1 Example Ave.\",\n \"city\": \"Chicago\",\n \"state\": \"Illinois\",\n \"country\": \"US\",\n \"postalCode\": \"60056\",\n \"address2\": \"Example Address Line 2\",\n \"address3\": \"Example Address Line 3\"\n }\n },\n \"contactMethods\": [\n {\n \"type\": \"email\",\n \"value\": \"sarah.hopper@example.com\"\n }\n ],\n \"notificationLanguage\": \"en\"\n },\n \"ipAddress\": {\n \"type\": \"ipv4\",\n \"value\": \"104.18.24.203\"\n },\n \"customFields\": [\n {\n \"name\": \"yourCustomField\",\n \"value\": \"abc123\"\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324")
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
Secure Token
require 'uri'
require 'net/http'
url = URI("https://api.payroc.com/v1/processing-terminals/1234001/secure-tokens")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Idempotency-Key"] = '8e03978e-40d5-43e8-bc93-6894a57f9324'
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"source\": {\n \"type\": \"card\",\n \"cardDetails\": {\n \"entryMethod\": \"keyed\",\n \"keyedData\": {\n \"dataFormat\": \"plainText\",\n \"cardNumber\": \"4539858876047062\",\n \"cvv\": \"234\",\n \"expiryDate\": \"1230\"\n },\n \"cardholderName\": \"Sarah Hazel Hopper\"\n }\n },\n \"operator\": \"Jane\",\n \"mitAgreement\": \"unscheduled\",\n \"customer\": {\n \"firstName\": \"Sarah\",\n \"lastName\": \"Hopper\",\n \"dateOfBirth\": \"1990-07-15\",\n \"referenceNumber\": \"Customer-12\",\n \"billingAddress\": {\n \"address1\": \"1 Example Ave.\",\n \"city\": \"Chicago\",\n \"state\": \"Illinois\",\n \"country\": \"US\",\n \"postalCode\": \"60056\",\n \"address2\": \"Example Address Line 2\",\n \"address3\": \"Example Address Line 3\"\n },\n \"shippingAddress\": {\n \"recipientName\": \"Sarah Hopper\",\n \"address\": {\n \"address1\": \"1 Example Ave.\",\n \"city\": \"Chicago\",\n \"state\": \"Illinois\",\n \"country\": \"US\",\n \"postalCode\": \"60056\",\n \"address2\": \"Example Address Line 2\",\n \"address3\": \"Example Address Line 3\"\n }\n },\n \"contactMethods\": [\n {\n \"type\": \"email\",\n \"value\": \"sarah.hopper@example.com\"\n }\n ],\n \"notificationLanguage\": \"en\"\n },\n \"ipAddress\": {\n \"type\": \"ipv4\",\n \"value\": \"104.18.24.203\"\n },\n \"customFields\": [\n {\n \"name\": \"yourCustomField\",\n \"value\": \"abc123\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body
Secure Token
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;
HttpResponse<String> response = Unirest.post("https://api.payroc.com/v1/processing-terminals/1234001/secure-tokens")
.header("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"source\": {\n \"type\": \"card\",\n \"cardDetails\": {\n \"entryMethod\": \"keyed\",\n \"keyedData\": {\n \"dataFormat\": \"plainText\",\n \"cardNumber\": \"4539858876047062\",\n \"cvv\": \"234\",\n \"expiryDate\": \"1230\"\n },\n \"cardholderName\": \"Sarah Hazel Hopper\"\n }\n },\n \"operator\": \"Jane\",\n \"mitAgreement\": \"unscheduled\",\n \"customer\": {\n \"firstName\": \"Sarah\",\n \"lastName\": \"Hopper\",\n \"dateOfBirth\": \"1990-07-15\",\n \"referenceNumber\": \"Customer-12\",\n \"billingAddress\": {\n \"address1\": \"1 Example Ave.\",\n \"city\": \"Chicago\",\n \"state\": \"Illinois\",\n \"country\": \"US\",\n \"postalCode\": \"60056\",\n \"address2\": \"Example Address Line 2\",\n \"address3\": \"Example Address Line 3\"\n },\n \"shippingAddress\": {\n \"recipientName\": \"Sarah Hopper\",\n \"address\": {\n \"address1\": \"1 Example Ave.\",\n \"city\": \"Chicago\",\n \"state\": \"Illinois\",\n \"country\": \"US\",\n \"postalCode\": \"60056\",\n \"address2\": \"Example Address Line 2\",\n \"address3\": \"Example Address Line 3\"\n }\n },\n \"contactMethods\": [\n {\n \"type\": \"email\",\n \"value\": \"sarah.hopper@example.com\"\n }\n ],\n \"notificationLanguage\": \"en\"\n },\n \"ipAddress\": {\n \"type\": \"ipv4\",\n \"value\": \"104.18.24.203\"\n },\n \"customFields\": [\n {\n \"name\": \"yourCustomField\",\n \"value\": \"abc123\"\n }\n ]\n}")
.asString();
Secure Token
<?php
require_once('vendor/autoload.php');
$client = new \GuzzleHttp\Client();
$response = $client->request('POST', 'https://api.payroc.com/v1/processing-terminals/1234001/secure-tokens', [
'body' => '{
"source": {
"type": "card",
"cardDetails": {
"entryMethod": "keyed",
"keyedData": {
"dataFormat": "plainText",
"cardNumber": "4539858876047062",
"cvv": "234",
"expiryDate": "1230"
},
"cardholderName": "Sarah Hazel Hopper"
}
},
"operator": "Jane",
"mitAgreement": "unscheduled",
"customer": {
"firstName": "Sarah",
"lastName": "Hopper",
"dateOfBirth": "1990-07-15",
"referenceNumber": "Customer-12",
"billingAddress": {
"address1": "1 Example Ave.",
"city": "Chicago",
"state": "Illinois",
"country": "US",
"postalCode": "60056",
"address2": "Example Address Line 2",
"address3": "Example Address Line 3"
},
"shippingAddress": {
"recipientName": "Sarah Hopper",
"address": {
"address1": "1 Example Ave.",
"city": "Chicago",
"state": "Illinois",
"country": "US",
"postalCode": "60056",
"address2": "Example Address Line 2",
"address3": "Example Address Line 3"
}
},
"contactMethods": [
{
"type": "email",
"value": "sarah.hopper@example.com"
}
],
"notificationLanguage": "en"
},
"ipAddress": {
"type": "ipv4",
"value": "104.18.24.203"
},
"customFields": [
{
"name": "yourCustomField",
"value": "abc123"
}
]
}',
'headers' => [
'Authorization' => 'Bearer <token>',
'Content-Type' => 'application/json',
'Idempotency-Key' => '8e03978e-40d5-43e8-bc93-6894a57f9324',
],
]);
echo $response->getBody();
Secure Token
using RestSharp;
var client = new RestClient("https://api.payroc.com/v1/processing-terminals/1234001/secure-tokens");
var request = new RestRequest(Method.POST);
request.AddHeader("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324");
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n \"source\": {\n \"type\": \"card\",\n \"cardDetails\": {\n \"entryMethod\": \"keyed\",\n \"keyedData\": {\n \"dataFormat\": \"plainText\",\n \"cardNumber\": \"4539858876047062\",\n \"cvv\": \"234\",\n \"expiryDate\": \"1230\"\n },\n \"cardholderName\": \"Sarah Hazel Hopper\"\n }\n },\n \"operator\": \"Jane\",\n \"mitAgreement\": \"unscheduled\",\n \"customer\": {\n \"firstName\": \"Sarah\",\n \"lastName\": \"Hopper\",\n \"dateOfBirth\": \"1990-07-15\",\n \"referenceNumber\": \"Customer-12\",\n \"billingAddress\": {\n \"address1\": \"1 Example Ave.\",\n \"city\": \"Chicago\",\n \"state\": \"Illinois\",\n \"country\": \"US\",\n \"postalCode\": \"60056\",\n \"address2\": \"Example Address Line 2\",\n \"address3\": \"Example Address Line 3\"\n },\n \"shippingAddress\": {\n \"recipientName\": \"Sarah Hopper\",\n \"address\": {\n \"address1\": \"1 Example Ave.\",\n \"city\": \"Chicago\",\n \"state\": \"Illinois\",\n \"country\": \"US\",\n \"postalCode\": \"60056\",\n \"address2\": \"Example Address Line 2\",\n \"address3\": \"Example Address Line 3\"\n }\n },\n \"contactMethods\": [\n {\n \"type\": \"email\",\n \"value\": \"sarah.hopper@example.com\"\n }\n ],\n \"notificationLanguage\": \"en\"\n },\n \"ipAddress\": {\n \"type\": \"ipv4\",\n \"value\": \"104.18.24.203\"\n },\n \"customFields\": [\n {\n \"name\": \"yourCustomField\",\n \"value\": \"abc123\"\n }\n ]\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
Secure Token
import Foundation
let headers = [
"Idempotency-Key": "8e03978e-40d5-43e8-bc93-6894a57f9324",
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
]
let parameters = [
"source": [
"type": "card",
"cardDetails": [
"entryMethod": "keyed",
"keyedData": [
"dataFormat": "plainText",
"cardNumber": "4539858876047062",
"cvv": "234",
"expiryDate": "1230"
],
"cardholderName": "Sarah Hazel Hopper"
]
],
"operator": "Jane",
"mitAgreement": "unscheduled",
"customer": [
"firstName": "Sarah",
"lastName": "Hopper",
"dateOfBirth": "1990-07-15",
"referenceNumber": "Customer-12",
"billingAddress": [
"address1": "1 Example Ave.",
"city": "Chicago",
"state": "Illinois",
"country": "US",
"postalCode": "60056",
"address2": "Example Address Line 2",
"address3": "Example Address Line 3"
],
"shippingAddress": [
"recipientName": "Sarah Hopper",
"address": [
"address1": "1 Example Ave.",
"city": "Chicago",
"state": "Illinois",
"country": "US",
"postalCode": "60056",
"address2": "Example Address Line 2",
"address3": "Example Address Line 3"
]
],
"contactMethods": [
[
"type": "email",
"value": "sarah.hopper@example.com"
]
],
"notificationLanguage": "en"
],
"ipAddress": [
"type": "ipv4",
"value": "104.18.24.203"
],
"customFields": [
[
"name": "yourCustomField",
"value": "abc123"
]
]
] as [String : Any]
let postData = JSONSerialization.data(withJSONObject: parameters, options: [])
let request = NSMutableURLRequest(url: NSURL(string: "https://api.payroc.com/v1/processing-terminals/1234001/secure-tokens")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error as Any)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()
Response fields
If your request is successful, we store the customer’s payment details and return a response. The response contains the following fields:
Schema (response.body)
Response body schema for POST /processing-terminals/{processingTerminalId}/secure-tokens
Example response
Response (201)
{
"secureTokenId": "MREF_abc1de23-f4a5-6789-bcd0-12e345678901fa",
"processingTerminalId": "1234001",
"source": {
"type": "card",
"cardNumber": "453985******7062",
"cardholderName": "Sarah Hazel Hopper",
"expiryDate": "1230"
},
"token": "296753123456",
"status": "notValidated",
"mitAgreement": "unscheduled",
"customer": {
"firstName": "Sarah",
"lastName": "Hopper",
"dateOfBirth": "1990-07-15",
"referenceNumber": "Customer-12",
"billingAddress": {
"address1": "1 Example Ave.",
"address2": "Example Address Line 2",
"address3": "Example Address Line 3",
"city": "Chicago",
"state": "Illinois",
"country": "US",
"postalCode": "60056"
},
"shippingAddress": {
"recipientName": "Sarah Hopper",
"address": {
"address1": "1 Example Ave.",
"address2": "Example Address Line 2",
"address3": "Example Address Line 3",
"city": "Chicago",
"state": "Illinois",
"country": "US",
"postalCode": "60056"
}
},
"contactMethods": [
{
"type": "email",
"value": "sarah.hopper@example.com"
}
],
"notificationLanguage": "en"
},
"customFields": [
{
"name": "yourCustomField",
"value": "abc123"
}
]
}
Step 2. Create a payment
You can run repeat payments with card details or with bank details. The endpoint that you use depends on the payment method:
Create a card 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.
| Environment | URL |
|---|---|
| Test | https://api.uat.payroc.com/v1/payments |
| Production | https://api.payroc.com/v1/payments |
Request parameters
To create the body of your request, use the following parameters:
Schema (request.body)
Request body schema for POST /payments
Example request
Request
POST https://api.payroc.com/v1/payments
Card sale with secure token and is the first payment in a series
curl -X POST https://api.payroc.com/v1/payments \
-H "Idempotency-Key: 8e03978e-40d5-43e8-bc93-6894a57f9324" \
-H "Authorization: Bearer <token>" \
-H "Content-Type: application/json" \
-d '{
"channel": "web",
"processingTerminalId": "1234001",
"order": {
"orderId": "OrderRef6543",
"amount": 4999,
"currency": "USD",
"description": "Pizza Doe #1234 - Dinner",
"standingInstructions": {
"sequence": "first",
"processingModel": "recurring"
}
},
"paymentMethod": {
"type": "secureToken",
"token": "296753123456"
},
"operator": "Jane",
"customer": {
"firstName": "Sarah",
"lastName": "Hopper",
"billingAddress": {
"address1": "1 Example Ave.",
"city": "Chicago",
"state": "Illinois",
"country": "US",
"postalCode": "60056",
"address2": "Example Address Line 2",
"address3": "Example Address Line 3"
},
"shippingAddress": {
"recipientName": "Sarah Hopper",
"address": {
"address1": "1 Example Ave.",
"city": "Chicago",
"state": "Illinois",
"country": "US",
"postalCode": "60056",
"address2": "Example Address Line 2",
"address3": "Example Address Line 3"
}
}
},
"credentialOnFile": {
"mitAgreement": "recurring"
},
"customFields": [
{
"name": "yourCustomField",
"value": "abc123"
}
]
}'
Card sale with secure token and is the first payment in a series
import requests
url = "https://api.payroc.com/v1/payments"
payload = {
"channel": "web",
"processingTerminalId": "1234001",
"order": {
"orderId": "OrderRef6543",
"amount": 4999,
"currency": "USD",
"description": "Pizza Doe #1234 - Dinner",
"standingInstructions": {
"sequence": "first",
"processingModel": "recurring"
}
},
"paymentMethod": {
"type": "secureToken",
"token": "296753123456"
},
"operator": "Jane",
"customer": {
"firstName": "Sarah",
"lastName": "Hopper",
"billingAddress": {
"address1": "1 Example Ave.",
"city": "Chicago",
"state": "Illinois",
"country": "US",
"postalCode": "60056",
"address2": "Example Address Line 2",
"address3": "Example Address Line 3"
},
"shippingAddress": {
"recipientName": "Sarah Hopper",
"address": {
"address1": "1 Example Ave.",
"city": "Chicago",
"state": "Illinois",
"country": "US",
"postalCode": "60056",
"address2": "Example Address Line 2",
"address3": "Example Address Line 3"
}
}
},
"credentialOnFile": { "mitAgreement": "recurring" },
"customFields": [
{
"name": "yourCustomField",
"value": "abc123"
}
]
}
headers = {
"Idempotency-Key": "8e03978e-40d5-43e8-bc93-6894a57f9324",
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
Card sale with secure token and is the first payment in a series
const url = 'https://api.payroc.com/v1/payments';
const options = {
method: 'POST',
headers: {
'Idempotency-Key': '8e03978e-40d5-43e8-bc93-6894a57f9324',
Authorization: 'Bearer <token>',
'Content-Type': 'application/json'
},
body: '{"channel":"web","processingTerminalId":"1234001","order":{"orderId":"OrderRef6543","amount":4999,"currency":"USD","description":"Pizza Doe #1234 - Dinner","standingInstructions":{"sequence":"first","processingModel":"recurring"}},"paymentMethod":{"type":"secureToken","token":"296753123456"},"operator":"Jane","customer":{"firstName":"Sarah","lastName":"Hopper","billingAddress":{"address1":"1 Example Ave.","city":"Chicago","state":"Illinois","country":"US","postalCode":"60056","address2":"Example Address Line 2","address3":"Example Address Line 3"},"shippingAddress":{"recipientName":"Sarah Hopper","address":{"address1":"1 Example Ave.","city":"Chicago","state":"Illinois","country":"US","postalCode":"60056","address2":"Example Address Line 2","address3":"Example Address Line 3"}}},"credentialOnFile":{"mitAgreement":"recurring"},"customFields":[{"name":"yourCustomField","value":"abc123"}]}'
};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
Card sale with secure token and is the first payment in a series
package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.payroc.com/v1/payments"
payload := strings.NewReader("{\n \"channel\": \"web\",\n \"processingTerminalId\": \"1234001\",\n \"order\": {\n \"orderId\": \"OrderRef6543\",\n \"amount\": 4999,\n \"currency\": \"USD\",\n \"description\": \"Pizza Doe #1234 - Dinner\",\n \"standingInstructions\": {\n \"sequence\": \"first\",\n \"processingModel\": \"recurring\"\n }\n },\n \"paymentMethod\": {\n \"type\": \"secureToken\",\n \"token\": \"296753123456\"\n },\n \"operator\": \"Jane\",\n \"customer\": {\n \"firstName\": \"Sarah\",\n \"lastName\": \"Hopper\",\n \"billingAddress\": {\n \"address1\": \"1 Example Ave.\",\n \"city\": \"Chicago\",\n \"state\": \"Illinois\",\n \"country\": \"US\",\n \"postalCode\": \"60056\",\n \"address2\": \"Example Address Line 2\",\n \"address3\": \"Example Address Line 3\"\n },\n \"shippingAddress\": {\n \"recipientName\": \"Sarah Hopper\",\n \"address\": {\n \"address1\": \"1 Example Ave.\",\n \"city\": \"Chicago\",\n \"state\": \"Illinois\",\n \"country\": \"US\",\n \"postalCode\": \"60056\",\n \"address2\": \"Example Address Line 2\",\n \"address3\": \"Example Address Line 3\"\n }\n }\n },\n \"credentialOnFile\": {\n \"mitAgreement\": \"recurring\"\n },\n \"customFields\": [\n {\n \"name\": \"yourCustomField\",\n \"value\": \"abc123\"\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324")
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
Card sale with secure token and is the first payment in a series
require 'uri'
require 'net/http'
url = URI("https://api.payroc.com/v1/payments")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Idempotency-Key"] = '8e03978e-40d5-43e8-bc93-6894a57f9324'
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"channel\": \"web\",\n \"processingTerminalId\": \"1234001\",\n \"order\": {\n \"orderId\": \"OrderRef6543\",\n \"amount\": 4999,\n \"currency\": \"USD\",\n \"description\": \"Pizza Doe #1234 - Dinner\",\n \"standingInstructions\": {\n \"sequence\": \"first\",\n \"processingModel\": \"recurring\"\n }\n },\n \"paymentMethod\": {\n \"type\": \"secureToken\",\n \"token\": \"296753123456\"\n },\n \"operator\": \"Jane\",\n \"customer\": {\n \"firstName\": \"Sarah\",\n \"lastName\": \"Hopper\",\n \"billingAddress\": {\n \"address1\": \"1 Example Ave.\",\n \"city\": \"Chicago\",\n \"state\": \"Illinois\",\n \"country\": \"US\",\n \"postalCode\": \"60056\",\n \"address2\": \"Example Address Line 2\",\n \"address3\": \"Example Address Line 3\"\n },\n \"shippingAddress\": {\n \"recipientName\": \"Sarah Hopper\",\n \"address\": {\n \"address1\": \"1 Example Ave.\",\n \"city\": \"Chicago\",\n \"state\": \"Illinois\",\n \"country\": \"US\",\n \"postalCode\": \"60056\",\n \"address2\": \"Example Address Line 2\",\n \"address3\": \"Example Address Line 3\"\n }\n }\n },\n \"credentialOnFile\": {\n \"mitAgreement\": \"recurring\"\n },\n \"customFields\": [\n {\n \"name\": \"yourCustomField\",\n \"value\": \"abc123\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body
Card sale with secure token and is the first payment in a series
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;
HttpResponse<String> response = Unirest.post("https://api.payroc.com/v1/payments")
.header("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"channel\": \"web\",\n \"processingTerminalId\": \"1234001\",\n \"order\": {\n \"orderId\": \"OrderRef6543\",\n \"amount\": 4999,\n \"currency\": \"USD\",\n \"description\": \"Pizza Doe #1234 - Dinner\",\n \"standingInstructions\": {\n \"sequence\": \"first\",\n \"processingModel\": \"recurring\"\n }\n },\n \"paymentMethod\": {\n \"type\": \"secureToken\",\n \"token\": \"296753123456\"\n },\n \"operator\": \"Jane\",\n \"customer\": {\n \"firstName\": \"Sarah\",\n \"lastName\": \"Hopper\",\n \"billingAddress\": {\n \"address1\": \"1 Example Ave.\",\n \"city\": \"Chicago\",\n \"state\": \"Illinois\",\n \"country\": \"US\",\n \"postalCode\": \"60056\",\n \"address2\": \"Example Address Line 2\",\n \"address3\": \"Example Address Line 3\"\n },\n \"shippingAddress\": {\n \"recipientName\": \"Sarah Hopper\",\n \"address\": {\n \"address1\": \"1 Example Ave.\",\n \"city\": \"Chicago\",\n \"state\": \"Illinois\",\n \"country\": \"US\",\n \"postalCode\": \"60056\",\n \"address2\": \"Example Address Line 2\",\n \"address3\": \"Example Address Line 3\"\n }\n }\n },\n \"credentialOnFile\": {\n \"mitAgreement\": \"recurring\"\n },\n \"customFields\": [\n {\n \"name\": \"yourCustomField\",\n \"value\": \"abc123\"\n }\n ]\n}")
.asString();
Card sale with secure token and is the first payment in a series
<?php
require_once('vendor/autoload.php');
$client = new \GuzzleHttp\Client();
$response = $client->request('POST', 'https://api.payroc.com/v1/payments', [
'body' => '{
"channel": "web",
"processingTerminalId": "1234001",
"order": {
"orderId": "OrderRef6543",
"amount": 4999,
"currency": "USD",
"description": "Pizza Doe #1234 - Dinner",
"standingInstructions": {
"sequence": "first",
"processingModel": "recurring"
}
},
"paymentMethod": {
"type": "secureToken",
"token": "296753123456"
},
"operator": "Jane",
"customer": {
"firstName": "Sarah",
"lastName": "Hopper",
"billingAddress": {
"address1": "1 Example Ave.",
"city": "Chicago",
"state": "Illinois",
"country": "US",
"postalCode": "60056",
"address2": "Example Address Line 2",
"address3": "Example Address Line 3"
},
"shippingAddress": {
"recipientName": "Sarah Hopper",
"address": {
"address1": "1 Example Ave.",
"city": "Chicago",
"state": "Illinois",
"country": "US",
"postalCode": "60056",
"address2": "Example Address Line 2",
"address3": "Example Address Line 3"
}
}
},
"credentialOnFile": {
"mitAgreement": "recurring"
},
"customFields": [
{
"name": "yourCustomField",
"value": "abc123"
}
]
}',
'headers' => [
'Authorization' => 'Bearer <token>',
'Content-Type' => 'application/json',
'Idempotency-Key' => '8e03978e-40d5-43e8-bc93-6894a57f9324',
],
]);
echo $response->getBody();
Card sale with secure token and is the first payment in a series
using RestSharp;
var client = new RestClient("https://api.payroc.com/v1/payments");
var request = new RestRequest(Method.POST);
request.AddHeader("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324");
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n \"channel\": \"web\",\n \"processingTerminalId\": \"1234001\",\n \"order\": {\n \"orderId\": \"OrderRef6543\",\n \"amount\": 4999,\n \"currency\": \"USD\",\n \"description\": \"Pizza Doe #1234 - Dinner\",\n \"standingInstructions\": {\n \"sequence\": \"first\",\n \"processingModel\": \"recurring\"\n }\n },\n \"paymentMethod\": {\n \"type\": \"secureToken\",\n \"token\": \"296753123456\"\n },\n \"operator\": \"Jane\",\n \"customer\": {\n \"firstName\": \"Sarah\",\n \"lastName\": \"Hopper\",\n \"billingAddress\": {\n \"address1\": \"1 Example Ave.\",\n \"city\": \"Chicago\",\n \"state\": \"Illinois\",\n \"country\": \"US\",\n \"postalCode\": \"60056\",\n \"address2\": \"Example Address Line 2\",\n \"address3\": \"Example Address Line 3\"\n },\n \"shippingAddress\": {\n \"recipientName\": \"Sarah Hopper\",\n \"address\": {\n \"address1\": \"1 Example Ave.\",\n \"city\": \"Chicago\",\n \"state\": \"Illinois\",\n \"country\": \"US\",\n \"postalCode\": \"60056\",\n \"address2\": \"Example Address Line 2\",\n \"address3\": \"Example Address Line 3\"\n }\n }\n },\n \"credentialOnFile\": {\n \"mitAgreement\": \"recurring\"\n },\n \"customFields\": [\n {\n \"name\": \"yourCustomField\",\n \"value\": \"abc123\"\n }\n ]\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
Card sale with secure token and is the first payment in a series
import Foundation
let headers = [
"Idempotency-Key": "8e03978e-40d5-43e8-bc93-6894a57f9324",
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
]
let parameters = [
"channel": "web",
"processingTerminalId": "1234001",
"order": [
"orderId": "OrderRef6543",
"amount": 4999,
"currency": "USD",
"description": "Pizza Doe #1234 - Dinner",
"standingInstructions": [
"sequence": "first",
"processingModel": "recurring"
]
],
"paymentMethod": [
"type": "secureToken",
"token": "296753123456"
],
"operator": "Jane",
"customer": [
"firstName": "Sarah",
"lastName": "Hopper",
"billingAddress": [
"address1": "1 Example Ave.",
"city": "Chicago",
"state": "Illinois",
"country": "US",
"postalCode": "60056",
"address2": "Example Address Line 2",
"address3": "Example Address Line 3"
],
"shippingAddress": [
"recipientName": "Sarah Hopper",
"address": [
"address1": "1 Example Ave.",
"city": "Chicago",
"state": "Illinois",
"country": "US",
"postalCode": "60056",
"address2": "Example Address Line 2",
"address3": "Example Address Line 3"
]
]
],
"credentialOnFile": ["mitAgreement": "recurring"],
"customFields": [
[
"name": "yourCustomField",
"value": "abc123"
]
]
] as [String : Any]
let postData = JSONSerialization.data(withJSONObject: parameters, options: [])
let request = NSMutableURLRequest(url: NSURL(string: "https://api.payroc.com/v1/payments")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error as Any)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()
Response fields
If your request is successful, we create the payment and return a response. The response contains the following fields:
Schema (response.body)
Response body schema for POST /payments
Example response
Response (201)
{
"paymentId": "M2MJOG6O2Y",
"processingTerminalId": "1234001",
"order": {
"orderId": "OrderRef6543",
"amount": 4999,
"currency": "USD",
"dateTime": "2024-07-02T15:30:00Z",
"description": "Pizza Doe #1234 - Dinner",
"standingInstructions": {
"sequence": "first",
"processingModel": "recurring"
}
},
"card": {
"type": "Visa Credit",
"entryMethod": "keyed",
"cardNumber": "453985******7062",
"expiryDate": "1230",
"cardholderName": "Sarah Hopper",
"secureToken": {
"secureTokenId": "MREF_abc1de23-f4a5-6789-bcd0-12e345678901fa",
"customerName": "Sarah Hopper",
"token": "296753123456",
"status": "notValidated",
"link": {
"rel": "self",
"method": "GET",
"href": "https://api.payroc.com/v1/processing-terminals/1234001/secure-tokens/MREF_abc1de23-f4a5-6789-bcd0-12e345678901fa"
}
},
"securityChecks": {
"avsResult": "Y"
}
},
"transactionResult": {
"status": "ready",
"responseCode": "A",
"type": "sale",
"approvalCode": "OK3",
"authorizedAmount": 4999,
"currency": "USD",
"responseMessage": "OK3",
"cardSchemeReferenceId": "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"
},
"operator": "Jane",
"customer": {
"firstName": "Sarah",
"lastName": "Hopper",
"billingAddress": {
"address1": "1 Example Ave.",
"address2": "Example Address Line 2",
"address3": "Example Address Line 3",
"city": "Chicago",
"state": "Illinois",
"country": "US",
"postalCode": "60056"
},
"shippingAddress": {
"recipientName": "Sarah Hopper",
"address": {
"address1": "1 Example Ave.",
"address2": "Example Address Line 2",
"address3": "Example Address Line 3",
"city": "Chicago",
"state": "Illinois",
"country": "US",
"postalCode": "60056"
}
}
},
"supportedOperations": [
"fullyReverse",
"setAsPending"
],
"customFields": [
{
"name": "yourCustomField",
"value": "abc123"
}
]
}
Create a bank transfer payment
To take a payment from the customer, send a POST request to our Bank Transfer Payments endpoint.
| Environment | URL |
|---|---|
| Test | https://api.uat.payroc.com/v1/bank-transfer-payments |
| Production | https://api.payroc.com/v1/bank-transfer-payments |
Request parameters
If you have a secure token that represents the bank account details, include the secure token in the paymentMethod object.
Schema (request.body)
Request body schema for POST /bank-transfer-payments
Example request
Request
POST https://api.payroc.com/v1/bank-transfer-payments
Bank transfer payment with a secure token
curl -X POST https://api.payroc.com/v1/bank-transfer-payments \
-H "Idempotency-Key: 8e03978e-40d5-43e8-bc93-6894a57f9324" \
-H "Authorization: Bearer <token>" \
-H "Content-Type: application/json" \
-d '{
"processingTerminalId": "1234001",
"order": {
"amount": 4999,
"currency": "USD",
"orderId": "OrderRef6543",
"description": "Pizza Doe"
},
"paymentMethod": {
"type": "secureToken",
"token": "296753123456",
"accountType": "checking",
"secCode": "web"
},
"customer": {
"contactMethods": [
{
"type": "email",
"value": "sarah.hopper@example.com"
}
]
},
"customFields": [
{
"name": "yourCustomField",
"value": "abc123"
}
]
}'
Bank transfer payment with a secure token
import requests
url = "https://api.payroc.com/v1/bank-transfer-payments"
payload = {
"processingTerminalId": "1234001",
"order": {
"amount": 4999,
"currency": "USD",
"orderId": "OrderRef6543",
"description": "Pizza Doe"
},
"paymentMethod": {
"type": "secureToken",
"token": "296753123456",
"accountType": "checking",
"secCode": "web"
},
"customer": { "contactMethods": [
{
"type": "email",
"value": "sarah.hopper@example.com"
}
] },
"customFields": [
{
"name": "yourCustomField",
"value": "abc123"
}
]
}
headers = {
"Idempotency-Key": "8e03978e-40d5-43e8-bc93-6894a57f9324",
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
Bank transfer payment with a secure token
const url = 'https://api.payroc.com/v1/bank-transfer-payments';
const options = {
method: 'POST',
headers: {
'Idempotency-Key': '8e03978e-40d5-43e8-bc93-6894a57f9324',
Authorization: 'Bearer <token>',
'Content-Type': 'application/json'
},
body: '{"processingTerminalId":"1234001","order":{"amount":4999,"currency":"USD","orderId":"OrderRef6543","description":"Pizza Doe"},"paymentMethod":{"type":"secureToken","token":"296753123456","accountType":"checking","secCode":"web"},"customer":{"contactMethods":[{"type":"email","value":"sarah.hopper@example.com"}]},"customFields":[{"name":"yourCustomField","value":"abc123"}]}'
};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
Bank transfer payment with a secure token
package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.payroc.com/v1/bank-transfer-payments"
payload := strings.NewReader("{\n \"processingTerminalId\": \"1234001\",\n \"order\": {\n \"amount\": 4999,\n \"currency\": \"USD\",\n \"orderId\": \"OrderRef6543\",\n \"description\": \"Pizza Doe\"\n },\n \"paymentMethod\": {\n \"type\": \"secureToken\",\n \"token\": \"296753123456\",\n \"accountType\": \"checking\",\n \"secCode\": \"web\"\n },\n \"customer\": {\n \"contactMethods\": [\n {\n \"type\": \"email\",\n \"value\": \"sarah.hopper@example.com\"\n }\n ]\n },\n \"customFields\": [\n {\n \"name\": \"yourCustomField\",\n \"value\": \"abc123\"\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324")
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
Bank transfer payment with a secure token
require 'uri'
require 'net/http'
url = URI("https://api.payroc.com/v1/bank-transfer-payments")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Idempotency-Key"] = '8e03978e-40d5-43e8-bc93-6894a57f9324'
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"processingTerminalId\": \"1234001\",\n \"order\": {\n \"amount\": 4999,\n \"currency\": \"USD\",\n \"orderId\": \"OrderRef6543\",\n \"description\": \"Pizza Doe\"\n },\n \"paymentMethod\": {\n \"type\": \"secureToken\",\n \"token\": \"296753123456\",\n \"accountType\": \"checking\",\n \"secCode\": \"web\"\n },\n \"customer\": {\n \"contactMethods\": [\n {\n \"type\": \"email\",\n \"value\": \"sarah.hopper@example.com\"\n }\n ]\n },\n \"customFields\": [\n {\n \"name\": \"yourCustomField\",\n \"value\": \"abc123\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body
Bank transfer payment with a secure token
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;
HttpResponse<String> response = Unirest.post("https://api.payroc.com/v1/bank-transfer-payments")
.header("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"processingTerminalId\": \"1234001\",\n \"order\": {\n \"amount\": 4999,\n \"currency\": \"USD\",\n \"orderId\": \"OrderRef6543\",\n \"description\": \"Pizza Doe\"\n },\n \"paymentMethod\": {\n \"type\": \"secureToken\",\n \"token\": \"296753123456\",\n \"accountType\": \"checking\",\n \"secCode\": \"web\"\n },\n \"customer\": {\n \"contactMethods\": [\n {\n \"type\": \"email\",\n \"value\": \"sarah.hopper@example.com\"\n }\n ]\n },\n \"customFields\": [\n {\n \"name\": \"yourCustomField\",\n \"value\": \"abc123\"\n }\n ]\n}")
.asString();
Bank transfer payment with a secure token
<?php
require_once('vendor/autoload.php');
$client = new \GuzzleHttp\Client();
$response = $client->request('POST', 'https://api.payroc.com/v1/bank-transfer-payments', [
'body' => '{
"processingTerminalId": "1234001",
"order": {
"amount": 4999,
"currency": "USD",
"orderId": "OrderRef6543",
"description": "Pizza Doe"
},
"paymentMethod": {
"type": "secureToken",
"token": "296753123456",
"accountType": "checking",
"secCode": "web"
},
"customer": {
"contactMethods": [
{
"type": "email",
"value": "sarah.hopper@example.com"
}
]
},
"customFields": [
{
"name": "yourCustomField",
"value": "abc123"
}
]
}',
'headers' => [
'Authorization' => 'Bearer <token>',
'Content-Type' => 'application/json',
'Idempotency-Key' => '8e03978e-40d5-43e8-bc93-6894a57f9324',
],
]);
echo $response->getBody();
Bank transfer payment with a secure token
using RestSharp;
var client = new RestClient("https://api.payroc.com/v1/bank-transfer-payments");
var request = new RestRequest(Method.POST);
request.AddHeader("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324");
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n \"processingTerminalId\": \"1234001\",\n \"order\": {\n \"amount\": 4999,\n \"currency\": \"USD\",\n \"orderId\": \"OrderRef6543\",\n \"description\": \"Pizza Doe\"\n },\n \"paymentMethod\": {\n \"type\": \"secureToken\",\n \"token\": \"296753123456\",\n \"accountType\": \"checking\",\n \"secCode\": \"web\"\n },\n \"customer\": {\n \"contactMethods\": [\n {\n \"type\": \"email\",\n \"value\": \"sarah.hopper@example.com\"\n }\n ]\n },\n \"customFields\": [\n {\n \"name\": \"yourCustomField\",\n \"value\": \"abc123\"\n }\n ]\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
Bank transfer payment with a secure token
import Foundation
let headers = [
"Idempotency-Key": "8e03978e-40d5-43e8-bc93-6894a57f9324",
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
]
let parameters = [
"processingTerminalId": "1234001",
"order": [
"amount": 4999,
"currency": "USD",
"orderId": "OrderRef6543",
"description": "Pizza Doe"
],
"paymentMethod": [
"type": "secureToken",
"token": "296753123456",
"accountType": "checking",
"secCode": "web"
],
"customer": ["contactMethods": [
[
"type": "email",
"value": "sarah.hopper@example.com"
]
]],
"customFields": [
[
"name": "yourCustomField",
"value": "abc123"
]
]
] as [String : Any]
let postData = JSONSerialization.data(withJSONObject: parameters, options: [])
let request = NSMutableURLRequest(url: NSURL(string: "https://api.payroc.com/v1/bank-transfer-payments")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error as Any)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()
Response fields
If your request is successful, we create the payment and return a response. The response contains the following fields:
Schema (response.body)
Response body schema for POST /bank-transfer-payments
Example response
Response (201)
{
"paymentId": "E29U8OU8Q4",
"processingTerminalId": "1234001",
"order": {
"amount": 4999,
"currency": "USD",
"orderId": "OrderRef6543",
"dateTime": "2024-07-02T15:30:00Z",
"description": "Pizza Doe #1234 - Dinner"
},
"bankAccount": {
"type": "ach",
"accountNumber": "******3491",
"nameOnAccount": "Sarah Hazel Hopper",
"routingNumber": "063100277",
"secCode": "web",
"secureToken": {
"secureTokenId": "MREF_abc1de23-f4a5-6789-bcd0-12e345678901fa",
"customerName": "Sarah Hazel Hopper",
"token": "296753123456",
"status": "bankAccountValidated",
"link": {
"rel": "self",
"method": "GET",
"href": "https://api.payroc.com/v1/processing-terminals/1234001/secure-tokens/MREF_abc1de23-f4a5-6789-bcd0-12e345678901fa"
}
}
},
"transactionResult": {
"type": "payment",
"status": "pending",
"responseCode": "P",
"authorizedAmount": 4999,
"currency": "USD",
"responseMessage": "Pending"
},
"customer": {
"contactMethods": [
{
"type": "email",
"value": "sarah.hopper@example.com"
}
]
},
"customFields": [
{
"name": "yourCustomField",
"value": "abc123"
}
]
}
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
{
"paymentId": "F1I17KBL0E",
"processingTerminalId": "3204001",
"order": {
"orderId": "Test_001",
"dateTime": "2023-05-24T14:44:20.63+01:00",
"amount": 4000,
"currency": "USD"
},
"card": {
"type": "Visa Credit",
"entryMethod": "keyed",
"cardNumber": "444433******1111",
"expiryDate": "0334",
"securityChecks": {
"cvvResult": "M",
"avsResult": "Y"
}
},
"paymentResult": {
"type": "sale",
"status": "ready",
"approvalCode": "OK14472",
"authorizedAmount": 4000,
"currency": "USD",
"responseCode": "A",
"responseMessage": "OK14472"
}
}