> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://beta-docs.payabli.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://beta-docs.payabli.com/_mcp/server.

# Authorize and capture transactions

For some businesses, it makes sense to authorize a transaction first and then capture later. When you authorize, you verify that the customer has sufficient funds, and you place a hold on that amount without actually processing the transaction and taking the money. Authorizing a transaction gives merchants time to verify inventory, prepare shipments, or complete services before finalizing the charge. When you capture the transaction, it puts the transaction in a batch for settlement and starts the process of moving the funds from the customer to the merchant account.

Capturing an authorized transaction later also allows merchants to capture part of the authorized amount if the final total ends up being less than expected, avoiding the need for refunds.

This guide covers how to authorize and capture transactions through the API.

> **Note**
>
> You must capture an authorized transaction to complete the transaction and move funds from the customer to merchant account. To authorize and capture a payment in one step, use the [Make a transaction](/developer-guides/money-in-transaction-add) endpoint.

## Considerations

Keep these considerations in mind when working with transactions:

* Authorizing a transaction reserves funds for the merchant but doesn't move them.
* You must capture an authorized transaction to complete it and move the funds.
* You can capture an amount equal to or less than the original authorization.
* Authorized transactions aren't flagged for settlement until they're captured.

> **Warning**
>
> If aren't using a stored payment method provided by an embedded component to run transactions, you must secure cardholder, bank account data, and customer IP address because your PCI scope is expanded.

## Authorize a transaction

Send a POST request to `/api/MoneyIn/authorize` to authorize a payment transaction. This action reserves funds and returns an authorization code. See the [API reference](/api-reference/moneyin/authorize-a-transaction) for this endpoint for full documentation.

This example authorizes a card transaction for \$100, with no service fee, for entrypoint `f743aed24a`. The customer ID is `4440`.

### Request

POST [https://api-sandbox.payabli.com/api/MoneyIn/authorize](https://api-sandbox.payabli.com/api/MoneyIn/authorize)

**`AuthorizeTransaction`**

```curl AuthorizeTransaction
curl -X POST https://api-sandbox.payabli.com/api/MoneyIn/authorize \
     -H "requestToken: <apiKey>" \
     -H "Content-Type: application/json" \
     -d '{
  "paymentDetails": {
    "totalAmount": 100,
    "serviceFee": 0
  },
  "paymentMethod": {
    "cardcvv": "999",
    "cardexp": "02/27",
    "cardHolder": "John Cassian",
    "cardnumber": "4111111111111111",
    "cardzip": "12345",
    "initiator": "payor",
    "method": "card"
  },
  "customerData": {
    "customerId": 4440
  },
  "entryPoint": "f743aed24a",
  "ipaddress": "255.255.255.255"
}'
```

**`AuthorizeTransaction`**

```python AuthorizeTransaction
import requests

url = "https://api-sandbox.payabli.com/api/MoneyIn/authorize"

payload = {
    "paymentDetails": {
        "totalAmount": 100,
        "serviceFee": 0
    },
    "paymentMethod": {
        "cardcvv": "999",
        "cardexp": "02/27",
        "cardHolder": "John Cassian",
        "cardnumber": "4111111111111111",
        "cardzip": "12345",
        "initiator": "payor",
        "method": "card"
    },
    "customerData": { "customerId": 4440 },
    "entryPoint": "f743aed24a",
    "ipaddress": "255.255.255.255"
}
headers = {
    "requestToken": "<apiKey>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

**`AuthorizeTransaction`**

```javascript AuthorizeTransaction
const url = 'https://api-sandbox.payabli.com/api/MoneyIn/authorize';
const options = {
  method: 'POST',
  headers: {requestToken: '<apiKey>', 'Content-Type': 'application/json'},
  body: '{"paymentDetails":{"totalAmount":100,"serviceFee":0},"paymentMethod":{"cardcvv":"999","cardexp":"02/27","cardHolder":"John Cassian","cardnumber":"4111111111111111","cardzip":"12345","initiator":"payor","method":"card"},"customerData":{"customerId":4440},"entryPoint":"f743aed24a","ipaddress":"255.255.255.255"}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

**`AuthorizeTransaction`**

```go AuthorizeTransaction
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api-sandbox.payabli.com/api/MoneyIn/authorize"

	payload := strings.NewReader("{\n  \"paymentDetails\": {\n    \"totalAmount\": 100,\n    \"serviceFee\": 0\n  },\n  \"paymentMethod\": {\n    \"cardcvv\": \"999\",\n    \"cardexp\": \"02/27\",\n    \"cardHolder\": \"John Cassian\",\n    \"cardnumber\": \"4111111111111111\",\n    \"cardzip\": \"12345\",\n    \"initiator\": \"payor\",\n    \"method\": \"card\"\n  },\n  \"customerData\": {\n    \"customerId\": 4440\n  },\n  \"entryPoint\": \"f743aed24a\",\n  \"ipaddress\": \"255.255.255.255\"\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("requestToken", "<apiKey>")
	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))

}
```

**`AuthorizeTransaction`**

```ruby AuthorizeTransaction
require 'uri'
require 'net/http'

url = URI("https://api-sandbox.payabli.com/api/MoneyIn/authorize")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["requestToken"] = '<apiKey>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"paymentDetails\": {\n    \"totalAmount\": 100,\n    \"serviceFee\": 0\n  },\n  \"paymentMethod\": {\n    \"cardcvv\": \"999\",\n    \"cardexp\": \"02/27\",\n    \"cardHolder\": \"John Cassian\",\n    \"cardnumber\": \"4111111111111111\",\n    \"cardzip\": \"12345\",\n    \"initiator\": \"payor\",\n    \"method\": \"card\"\n  },\n  \"customerData\": {\n    \"customerId\": 4440\n  },\n  \"entryPoint\": \"f743aed24a\",\n  \"ipaddress\": \"255.255.255.255\"\n}"

response = http.request(request)
puts response.read_body
```

**`AuthorizeTransaction`**

```java AuthorizeTransaction
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api-sandbox.payabli.com/api/MoneyIn/authorize")
  .header("requestToken", "<apiKey>")
  .header("Content-Type", "application/json")
  .body("{\n  \"paymentDetails\": {\n    \"totalAmount\": 100,\n    \"serviceFee\": 0\n  },\n  \"paymentMethod\": {\n    \"cardcvv\": \"999\",\n    \"cardexp\": \"02/27\",\n    \"cardHolder\": \"John Cassian\",\n    \"cardnumber\": \"4111111111111111\",\n    \"cardzip\": \"12345\",\n    \"initiator\": \"payor\",\n    \"method\": \"card\"\n  },\n  \"customerData\": {\n    \"customerId\": 4440\n  },\n  \"entryPoint\": \"f743aed24a\",\n  \"ipaddress\": \"255.255.255.255\"\n}")
  .asString();
```

**`AuthorizeTransaction`**

```php AuthorizeTransaction
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api-sandbox.payabli.com/api/MoneyIn/authorize', [
  'body' => '{
  "paymentDetails": {
    "totalAmount": 100,
    "serviceFee": 0
  },
  "paymentMethod": {
    "cardcvv": "999",
    "cardexp": "02/27",
    "cardHolder": "John Cassian",
    "cardnumber": "4111111111111111",
    "cardzip": "12345",
    "initiator": "payor",
    "method": "card"
  },
  "customerData": {
    "customerId": 4440
  },
  "entryPoint": "f743aed24a",
  "ipaddress": "255.255.255.255"
}',
  'headers' => [
    'Content-Type' => 'application/json',
    'requestToken' => '<apiKey>',
  ],
]);

echo $response->getBody();
```

**`AuthorizeTransaction`**

```csharp AuthorizeTransaction
using RestSharp;

var client = new RestClient("https://api-sandbox.payabli.com/api/MoneyIn/authorize");
var request = new RestRequest(Method.POST);
request.AddHeader("requestToken", "<apiKey>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"paymentDetails\": {\n    \"totalAmount\": 100,\n    \"serviceFee\": 0\n  },\n  \"paymentMethod\": {\n    \"cardcvv\": \"999\",\n    \"cardexp\": \"02/27\",\n    \"cardHolder\": \"John Cassian\",\n    \"cardnumber\": \"4111111111111111\",\n    \"cardzip\": \"12345\",\n    \"initiator\": \"payor\",\n    \"method\": \"card\"\n  },\n  \"customerData\": {\n    \"customerId\": 4440\n  },\n  \"entryPoint\": \"f743aed24a\",\n  \"ipaddress\": \"255.255.255.255\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

**`AuthorizeTransaction`**

```swift AuthorizeTransaction
import Foundation

let headers = [
  "requestToken": "<apiKey>",
  "Content-Type": "application/json"
]
let parameters = [
  "paymentDetails": [
    "totalAmount": 100,
    "serviceFee": 0
  ],
  "paymentMethod": [
    "cardcvv": "999",
    "cardexp": "02/27",
    "cardHolder": "John Cassian",
    "cardnumber": "4111111111111111",
    "cardzip": "12345",
    "initiator": "payor",
    "method": "card"
  ],
  "customerData": ["customerId": 4440],
  "entryPoint": "f743aed24a",
  "ipaddress": "255.255.255.255"
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api-sandbox.payabli.com/api/MoneyIn/authorize")! 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()
```

A successful request returns a 200 response with a JSON body containing a referenceId which you'll need for the capture operation.

### Response (200)

```json
{
  "isSuccess": true,
  "pageIdentifier": null,
  "responseData": {
    "authCode": "123456",
    "avsResponseText": "No address or ZIP match only",
    "customerId": 4440,
    "cvvResponseText": "CVV2/CVC2 no match",
    "methodReferenceId": null,
    "referenceId": "10-7d9cd67d-2d5d-4cd7-a1b7-72b8b201ec13",
    "resultCode": 1,
    "resultText": "Authorized"
  },
  "responseText": "Success"
}
```

> **Check**
>
> After authorizing a transaction, you can capture the transaction to complete it and move the funds from the customer to the merchant account.

## Capture a transaction

To complete an authorized transaction and start the settlement process, send a GET request to /api/MoneyIn/capture. See the [API reference](/api-reference/moneyin/capture-an-authorized-transaction) for full documentation.

Each example captures a card transaction for the transaction 10-7d9cd67d-2d5d-4cd7-a1b7-72b8b201ec13.

#### Full capture example

This example captures the full authorized amount of \$100.00. Sending `0` as the amount captures the full authorized amount.

### Request

GET [https://api-sandbox.payabli.com/api/MoneyIn/capture/\{transId}/\{amount}](https://api-sandbox.payabli.com/api/MoneyIn/capture/\{transId}/\{amount})

**`FullCapture`**

```curl FullCapture
curl https://api-sandbox.payabli.com/api/MoneyIn/capture/10-7d9cd67d-2d5d-4cd7-a1b7-72b8b201ec13/0 \
     -H "requestToken: <apiKey>"
```

**`FullCapture`**

```python FullCapture
import requests

url = "https://api-sandbox.payabli.com/api/MoneyIn/capture/10-7d9cd67d-2d5d-4cd7-a1b7-72b8b201ec13/0"

headers = {"requestToken": "<apiKey>"}

response = requests.get(url, headers=headers)

print(response.json())
```

**`FullCapture`**

```javascript FullCapture
const url = 'https://api-sandbox.payabli.com/api/MoneyIn/capture/10-7d9cd67d-2d5d-4cd7-a1b7-72b8b201ec13/0';
const options = {method: 'GET', headers: {requestToken: '<apiKey>'}};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

**`FullCapture`**

```go FullCapture
package main

import (
	"fmt"
	"net/http"
	"io"
)

func main() {

	url := "https://api-sandbox.payabli.com/api/MoneyIn/capture/10-7d9cd67d-2d5d-4cd7-a1b7-72b8b201ec13/0"

	req, _ := http.NewRequest("GET", url, nil)

	req.Header.Add("requestToken", "<apiKey>")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

**`FullCapture`**

```ruby FullCapture
require 'uri'
require 'net/http'

url = URI("https://api-sandbox.payabli.com/api/MoneyIn/capture/10-7d9cd67d-2d5d-4cd7-a1b7-72b8b201ec13/0")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Get.new(url)
request["requestToken"] = '<apiKey>'

response = http.request(request)
puts response.read_body
```

**`FullCapture`**

```java FullCapture
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.get("https://api-sandbox.payabli.com/api/MoneyIn/capture/10-7d9cd67d-2d5d-4cd7-a1b7-72b8b201ec13/0")
  .header("requestToken", "<apiKey>")
  .asString();
```

**`FullCapture`**

```php FullCapture
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('GET', 'https://api-sandbox.payabli.com/api/MoneyIn/capture/10-7d9cd67d-2d5d-4cd7-a1b7-72b8b201ec13/0', [
  'headers' => [
    'requestToken' => '<apiKey>',
  ],
]);

echo $response->getBody();
```

**`FullCapture`**

```csharp FullCapture
using RestSharp;

var client = new RestClient("https://api-sandbox.payabli.com/api/MoneyIn/capture/10-7d9cd67d-2d5d-4cd7-a1b7-72b8b201ec13/0");
var request = new RestRequest(Method.GET);
request.AddHeader("requestToken", "<apiKey>");
IRestResponse response = client.Execute(request);
```

**`FullCapture`**

```swift FullCapture
import Foundation

let headers = ["requestToken": "<apiKey>"]

let request = NSMutableURLRequest(url: NSURL(string: "https://api-sandbox.payabli.com/api/MoneyIn/capture/10-7d9cd67d-2d5d-4cd7-a1b7-72b8b201ec13/0")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "GET"
request.allHTTPHeaderFields = headers

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()
```

#### Partial capture example

This example campuses \$99.86 of the authorized amount. The remaining \$0.14 is released back to the customer.

### Request

GET [https://api-sandbox.payabli.com/api/MoneyIn/capture/\{transId}/\{amount}](https://api-sandbox.payabli.com/api/MoneyIn/capture/\{transId}/\{amount})

**`PartialCapture`**

```curl PartialCapture
curl https://api-sandbox.payabli.com/api/MoneyIn/capture/10-7d9cd67d-2d5d-4cd7-a1b7-72b8b201ec13/99.86 \
     -H "requestToken: <apiKey>"
```

**`PartialCapture`**

```python PartialCapture
import requests

url = "https://api-sandbox.payabli.com/api/MoneyIn/capture/10-7d9cd67d-2d5d-4cd7-a1b7-72b8b201ec13/99.86"

headers = {"requestToken": "<apiKey>"}

response = requests.get(url, headers=headers)

print(response.json())
```

**`PartialCapture`**

```javascript PartialCapture
const url = 'https://api-sandbox.payabli.com/api/MoneyIn/capture/10-7d9cd67d-2d5d-4cd7-a1b7-72b8b201ec13/99.86';
const options = {method: 'GET', headers: {requestToken: '<apiKey>'}};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

**`PartialCapture`**

```go PartialCapture
package main

import (
	"fmt"
	"net/http"
	"io"
)

func main() {

	url := "https://api-sandbox.payabli.com/api/MoneyIn/capture/10-7d9cd67d-2d5d-4cd7-a1b7-72b8b201ec13/99.86"

	req, _ := http.NewRequest("GET", url, nil)

	req.Header.Add("requestToken", "<apiKey>")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

**`PartialCapture`**

```ruby PartialCapture
require 'uri'
require 'net/http'

url = URI("https://api-sandbox.payabli.com/api/MoneyIn/capture/10-7d9cd67d-2d5d-4cd7-a1b7-72b8b201ec13/99.86")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Get.new(url)
request["requestToken"] = '<apiKey>'

response = http.request(request)
puts response.read_body
```

**`PartialCapture`**

```java PartialCapture
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.get("https://api-sandbox.payabli.com/api/MoneyIn/capture/10-7d9cd67d-2d5d-4cd7-a1b7-72b8b201ec13/99.86")
  .header("requestToken", "<apiKey>")
  .asString();
```

**`PartialCapture`**

```php PartialCapture
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('GET', 'https://api-sandbox.payabli.com/api/MoneyIn/capture/10-7d9cd67d-2d5d-4cd7-a1b7-72b8b201ec13/99.86', [
  'headers' => [
    'requestToken' => '<apiKey>',
  ],
]);

echo $response->getBody();
```

**`PartialCapture`**

```csharp PartialCapture
using RestSharp;

var client = new RestClient("https://api-sandbox.payabli.com/api/MoneyIn/capture/10-7d9cd67d-2d5d-4cd7-a1b7-72b8b201ec13/99.86");
var request = new RestRequest(Method.GET);
request.AddHeader("requestToken", "<apiKey>");
IRestResponse response = client.Execute(request);
```

**`PartialCapture`**

```swift PartialCapture
import Foundation

let headers = ["requestToken": "<apiKey>"]

let request = NSMutableURLRequest(url: NSURL(string: "https://api-sandbox.payabli.com/api/MoneyIn/capture/10-7d9cd67d-2d5d-4cd7-a1b7-72b8b201ec13/99.86")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "GET"
request.allHTTPHeaderFields = headers

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()
```

A successful capture request returns a 200 response with a JSON body containing the transaction details.

### Response (200)

```json
{
  "isSuccess": true,
  "responseData": {
    "AuthCode": "123456",
    "CustomerId": null,
    "ReferenceId": "10-7d9cd67d-2d5d-4cd7-a1b7-72b8b201ec13",
    "ResultCode": 1,
    "ResultText": "SUCCESS"
  },
  "responseText": "Success"
}
```