---
title: Sending Payment Data to an External API
description: "The **Advanced options** section on each gateway settings page lets you send order and checkout data to an external URL after a customer places an order. Use this to connect WooCommerce with invoicing tools, CRMs, internal systems, or custom payment workflows. Table…"
url: "https://wpruby.com/knowledgebase/sending-payment-data-to-an-external-api/"
updated: "2026-07-07"
category: WooCommerce Custom Payment Gateway Pro
---

# Sending Payment Data to an External API

The **Advanced options** section on each gateway settings page lets you send order and checkout data to an external URL after a customer places an order. Use this to connect WooCommerce with invoicing tools, CRMs, internal systems, or custom payment workflows.

Table of Contents

 [Toggle](#)

- [What API requests are used for](#What_API_requests_are_used_for)
- [Example use cases](#Example_use_cases)
- [API settings overview](#API_settings_overview)
  - [API requests](#API_requests)
  - [API URL](#API_URL)
  - [Redirect the Customer to the API URL](#Redirect_the_Customer_to_the_API_URL)
  - [Request method](#Request_method)
  - [POST requests data type](#POST_requests_data_type)
- [HTTP Headers](#HTTP_Headers)
- [WooCommerce API Parameters](#WooCommerce_API_Parameters)
- [Extra API Parameters](#Extra_API_Parameters)
- [Custom checkout field API parameters](#Custom_checkout_field_API_parameters)
- [Payload Preview](#Payload_Preview)
- [Send Test Request](#Send_Test_Request)
- [API Logs](#API_Logs)
  - [Filtering logs](#Filtering_logs)
  - [Log details](#Log_details)
  - [Retry failed requests](#Retry_failed_requests)
- [Configuration examples](#Configuration_examples)
  - [Send data as form data](#Send_data_as_form_data)
  - [Send data as JSON](#Send_data_as_JSON)
  - [Add an Authorization header](#Add_an_Authorization_header)
  - [Add an API key as an extra parameter](#Add_an_API_key_as_an_extra_parameter)
- [Important notes](#Important_notes)

## What API requests are used for

[https://github.com/wsenjer/woocommerce-custom-payment-gateway/blob/docs-cursor/docs/api-requests.md#what-api-requests-are-used-for](https://github.com/wsenjer/woocommerce-custom-payment-gateway/blob/docs-cursor/docs/api-requests.md#what-api-requests-are-used-for)

After checkout, the plugin can send a request containing:

- WooCommerce order data (order ID, total, billing details, and more)
- Static values you define (API keys, environment flags)
- Values from custom checkout fields (when **API parameter** is set on each field)

Common uses:

- Send order data to an **invoicing system**
- Create or update a record in a **CRM**
- Notify an **internal webhook** for manual review
- Trigger an **external payment request** on your own platform

## Example use cases

[https://github.com/wsenjer/woocommerce-custom-payment-gateway/blob/docs-cursor/docs/api-requests.md#example-use-cases](https://github.com/wsenjer/woocommerce-custom-payment-gateway/blob/docs-cursor/docs/api-requests.md#example-use-cases)

| Scenario | Typical setup |
| --- | --- |
| Create invoice in external system | POST JSON to invoicing API with order ID, total, and billing email |
| Notify sales team | POST form data to Zapier/Make webhook with order details |
| Register pending payment | POST with order ID and custom field values |
| Redirect to external payment page | Enable API + redirect option (see below) |

---

## API settings overview

[https://github.com/wsenjer/woocommerce-custom-payment-gateway/blob/docs-cursor/docs/api-requests.md#api-settings-overview](https://github.com/wsenjer/woocommerce-custom-payment-gateway/blob/docs-cursor/docs/api-requests.md#api-settings-overview)

All API settings are under **Advanced options** on the gateway settings page.

### API requests

[https://github.com/wsenjer/woocommerce-custom-payment-gateway/blob/docs-cursor/docs/api-requests.md#api-requests](https://github.com/wsenjer/woocommerce-custom-payment-gateway/blob/docs-cursor/docs/api-requests.md#api-requests)

**Checkbox:** Enable the gateway to request an API URL after the checkout process.

Turn this on to activate API functionality for this gateway. When off, no API requests are sent.

### API URL

[https://github.com/wsenjer/woocommerce-custom-payment-gateway/blob/docs-cursor/docs/api-requests.md#api-url](https://github.com/wsenjer/woocommerce-custom-payment-gateway/blob/docs-cursor/docs/api-requests.md#api-url)

The URL that receives the request after the order is placed.

**Example:**

```php
https://api.yourservice.com/orders/create
```

### Redirect the Customer to the API URL

[https://github.com/wsenjer/woocommerce-custom-payment-gateway/blob/docs-cursor/docs/api-requests.md#redirect-the-customer-to-the-api-url](https://github.com/wsenjer/woocommerce-custom-payment-gateway/blob/docs-cursor/docs/api-requests.md#redirect-the-customer-to-the-api-url)

When checked, the customer is redirected to the API URL instead of the normal thank-you page flow.

| Request method | Redirect behavior |
| --- | --- |
| **GET** | Customer is redirected to the API URL with data appended as query parameters |
| **POST** | Customer is sent to an intermediate payment receipt page that auto-submits a form to the API URL |

> JSON POST body mode does not apply when redirect is enabled. Use form-style POST for redirects.

### Request method

[https://github.com/wsenjer/woocommerce-custom-payment-gateway/blob/docs-cursor/docs/api-requests.md#request-method](https://github.com/wsenjer/woocommerce-custom-payment-gateway/blob/docs-cursor/docs/api-requests.md#request-method)

| Option | Description |
| --- | --- |
| **POST** | Sends data in the request body (default) |
| **GET** | Sends data as URL query parameters |

### POST requests data type

[https://github.com/wsenjer/woocommerce-custom-payment-gateway/blob/docs-cursor/docs/api-requests.md#post-requests-data-type](https://github.com/wsenjer/woocommerce-custom-payment-gateway/blob/docs-cursor/docs/api-requests.md#post-requests-data-type)

Applies when **POST** is selected and **Redirect the Customer to the API URL** is **not** checked.

| Option | Description |
| --- | --- |
| **FORM DATA** | Sends `application/x-www-form-urlencoded` data (default) |
| **JSON** | Sends `application/json` body |

---

## HTTP Headers

[https://github.com/wsenjer/woocommerce-custom-payment-gateway/blob/docs-cursor/docs/api-requests.md#http-headers](https://github.com/wsenjer/woocommerce-custom-payment-gateway/blob/docs-cursor/docs/api-requests.md#http-headers)

Add custom HTTP headers for authentication or content type.

| Key | Value example |
| --- | --- |
| `Authorization` | `Bearer your-token-here` |
| `Content-Type` | `application/json` |
| `X-API-Key` | `your-api-key` |

Click **Add Row** to add more headers. Use the trash icon to remove a row.

---

## WooCommerce API Parameters

[https://github.com/wsenjer/woocommerce-custom-payment-gateway/blob/docs-cursor/docs/api-requests.md#woocommerce-api-parameters](https://github.com/wsenjer/woocommerce-custom-payment-gateway/blob/docs-cursor/docs/api-requests.md#woocommerce-api-parameters)

Map WooCommerce order values to custom key names in the API payload.

| Key (you define) | Value (WooCommerce data) |
| --- | --- |
| `order_id` | Order ID |
| `order_total` | Order Total |
| `customer_id` | Customer ID |
| `billing_first_name` | Customer First Name |
| `billing_last_name` | Customer Last Name |
| `billing_postcode` | Customer Postcode |
| `billing_address_1` | Customer Address line 1 |
| `billing_address_2` | Customer Address line 2 |
| `billing_city` | Customer City |
| `billing_state` | Customer State |
| `billing_country` | Customer Country |
| `billing_email` | Customer Email |
| `billing_phone` | Customer Phone |
| `billing_ip_address` | Customer IP Address |
| `return_url` | Order Return URL |

**Example mapping:**

| Key | Value |
| --- | --- |
| `invoice_order_id` | Order ID |
| `amount` | Order Total |
| `customer_email` | Customer Email |

---

## Extra API Parameters

[https://github.com/wsenjer/woocommerce-custom-payment-gateway/blob/docs-cursor/docs/api-requests.md#extra-api-parameters](https://github.com/wsenjer/woocommerce-custom-payment-gateway/blob/docs-cursor/docs/api-requests.md#extra-api-parameters)

Add static key/value pairs sent with every request.

You can use `{order_id}` in values — it is replaced with the real order ID when the order is placed.

**Example:**

| Key | Value |
| --- | --- |
| `api_key` | `your-secret-key` |
| `source` | `woocommerce` |
| `reference` | `order-{order_id}` |

---

## Custom checkout field API parameters

[https://github.com/wsenjer/woocommerce-custom-payment-gateway/blob/docs-cursor/docs/api-requests.md#custom-checkout-field-api-parameters](https://github.com/wsenjer/woocommerce-custom-payment-gateway/blob/docs-cursor/docs/api-requests.md#custom-checkout-field-api-parameters)

For each checkout field in the **Custom Form** builder, set **API parameter** to the key name you want in the API payload.

**Example:**

| Checkout field | API parameter |
| --- | --- |
| Company name | `company_name` |
| Purchase order number | `po_number` |
| Billing contact email | `billing_contact` |

Field values are included automatically when the customer submits the form.

---

## Payload Preview

[https://github.com/wsenjer/woocommerce-custom-payment-gateway/blob/docs-cursor/docs/api-requests.md#payload-preview](https://github.com/wsenjer/woocommerce-custom-payment-gateway/blob/docs-cursor/docs/api-requests.md#payload-preview)

The **Payload Preview** shows the structure of the data that will be sent.

- Placeholder values like `[dynamic:order_id]` appear in the preview.
- **Dynamic order values are filled with real data when a customer places an order.**

Use the preview to confirm key names and structure before going live.

---

## Send Test Request

[https://github.com/wsenjer/woocommerce-custom-payment-gateway/blob/docs-cursor/docs/api-requests.md#send-test-request](https://github.com/wsenjer/woocommerce-custom-payment-gateway/blob/docs-cursor/docs/api-requests.md#send-test-request)

The **API Request Tools** section includes **Send Test Request**.

Use it to verify:

- The API URL is reachable
- Headers are correct
- The request method works
- The payload structure matches what your endpoint expects

Test requests use sample data — not a real order. Check the result message shown after sending.

---

## API Logs

[https://github.com/wsenjer/woocommerce-custom-payment-gateway/blob/docs-cursor/docs/api-requests.md#api-logs](https://github.com/wsenjer/woocommerce-custom-payment-gateway/blob/docs-cursor/docs/api-requests.md#api-logs)

The **API Logs** table records requests sent by the plugin.

| Column | Description |
| --- | --- |
| Status | Success, Failed, Pending, or Retried |
| Gateway | Gateway that sent the request |
| Order | Related order ID |
| Method | GET or POST |
| URL | Request URL |
| Response | Response summary |
| Attempts | Number of attempts |
| Created / Last Attempt | Timestamps |

### Filtering logs

[https://github.com/wsenjer/woocommerce-custom-payment-gateway/blob/docs-cursor/docs/api-requests.md#filtering-logs](https://github.com/wsenjer/woocommerce-custom-payment-gateway/blob/docs-cursor/docs/api-requests.md#filtering-logs)

Filter by status, order ID, or date range using the controls above the table.

### Log details

[https://github.com/wsenjer/woocommerce-custom-payment-gateway/blob/docs-cursor/docs/api-requests.md#log-details](https://github.com/wsenjer/woocommerce-custom-payment-gateway/blob/docs-cursor/docs/api-requests.md#log-details)

Open a log entry to view:

- Error message (if failed)
- Request headers
- Request payload
- Response body
- Attempt history

### Retry failed requests

[https://github.com/wsenjer/woocommerce-custom-payment-gateway/blob/docs-cursor/docs/api-requests.md#retry-failed-requests](https://github.com/wsenjer/woocommerce-custom-payment-gateway/blob/docs-cursor/docs/api-requests.md#retry-failed-requests)

Failed requests can be retried from the log actions. Retries use the **current** gateway API settings and the **current** order data.

> Retries use the current gateway API settings and the current order data.

---

## Configuration examples

[https://github.com/wsenjer/woocommerce-custom-payment-gateway/blob/docs-cursor/docs/api-requests.md#configuration-examples](https://github.com/wsenjer/woocommerce-custom-payment-gateway/blob/docs-cursor/docs/api-requests.md#configuration-examples)

### Send data as form data

[https://github.com/wsenjer/woocommerce-custom-payment-gateway/blob/docs-cursor/docs/api-requests.md#send-data-as-form-data](https://github.com/wsenjer/woocommerce-custom-payment-gateway/blob/docs-cursor/docs/api-requests.md#send-data-as-form-data)

1. Enable **API requests**.
2. Set **API URL**.
3. **Request method:** POST
4. **POST requests data type:** FORM DATA
5. Add **WooCommerce API Parameters** and **Extra API Parameters**.
6. Click **Send Test Request** to verify.

### Send data as JSON

[https://github.com/wsenjer/woocommerce-custom-payment-gateway/blob/docs-cursor/docs/api-requests.md#send-data-as-json](https://github.com/wsenjer/woocommerce-custom-payment-gateway/blob/docs-cursor/docs/api-requests.md#send-data-as-json)

1. Enable **API requests**.
2. Set **API URL**.
3. **Request method:** POST
4. **POST requests data type:** JSON
5. Leave **Redirect the Customer to the API URL** unchecked.
6. Add headers if needed.
7. Save and send a test request.

### Add an Authorization header

[https://github.com/wsenjer/woocommerce-custom-payment-gateway/blob/docs-cursor/docs/api-requests.md#add-an-authorization-header](https://github.com/wsenjer/woocommerce-custom-payment-gateway/blob/docs-cursor/docs/api-requests.md#add-an-authorization-header)

In **HTTP Headers**:

| Key | Value |
| --- | --- |
| `Authorization` | `Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...` |

### Add an API key as an extra parameter

[https://github.com/wsenjer/woocommerce-custom-payment-gateway/blob/docs-cursor/docs/api-requests.md#add-an-api-key-as-an-extra-parameter](https://github.com/wsenjer/woocommerce-custom-payment-gateway/blob/docs-cursor/docs/api-requests.md#add-an-api-key-as-an-extra-parameter)

In **Extra API Parameters**:

| Key | Value |
| --- | --- |
| `api_key` | `sk_live_your_key_here` |

---

## Important notes

[https://github.com/wsenjer/woocommerce-custom-payment-gateway/blob/docs-cursor/docs/api-requests.md#important-notes](https://github.com/wsenjer/woocommerce-custom-payment-gateway/blob/docs-cursor/docs/api-requests.md#important-notes)

- **Dynamic values:** Order totals, billing fields, and custom field values are populated when a real order is placed. The payload preview shows placeholders until then.
- **Test requests:** Use test requests to validate URL, headers, method, and payload — not to create real orders in external systems unless your endpoint is designed for test data.
- **API logs:** Check logs when requests fail. Empty logs usually mean API requests are disabled or no orders have used the gateway yet.
- **Sensitive data:** Card numbers, CVV codes, and similar values are blocked from storage and API payloads. Do not configure fields to collect them. See [Security and Sensitive Payment Data](https://wpruby.com/knowledgebase/security-and-sensitive-payment-data/).
- **Storage option:** If you disable **Store Payment Information in the Database** in global settings, field data may only exist in the API request and not in order meta.
