It looks like you're using Google Chrome - try our powerful extension! Find out more. Add to Chrome
x
Help Center Getting StartedGateway ConnectionCustom Integration

Custom Payment Integration

ChargeDesk supports integrating any payment platform using our API and custom webhooks. If you use a gateway which is not currently supported by ChargeDesk, or you would like to add custom logic to your billing support workflow, you can use these custom integration tools.

Integrating a custom payment platform with ChargeDesk requires some custom development. There's two key parts to the integration; Importing Data via the API and Processing Changes via Webhooks.

Add Custom Integration as a Gateway

If you do not already have a custom integration added to your account, you will need to add this as a new gateway. You can do this from Setup > Gateways > Add Gateway > Choose "Custom Integration" from the top of the list;

If you would like to route agent actions for an existing gateway to your custom integration (for example to process Stripe cancellation via a custom endpoint), please contact support so we can enable this for your company.

Importing Data via the API

Data can be imported to ChargeDesk using the ChargeDesk API. We recommend importing any data you would like made visible to support agents. At a minimum we recommend import data about any Charges, Customers and Subscriptions for the connected company.

API Authentication

The ChargeDesk API is authenticated using HTTP Basic Authentication. You can pass your secret key in the basic auth username. A password is not required.

Each company you create on ChargeDesk has their own secret key and must have API access enabled. You can turn on API access for your company and find your secret key at https://chargedesk.com/connect/api

Importing Duplicate Data

Charges, Customers, Subscriptions and Products all have unique IDs (transaction_id for Charges, customer_id for Customers, subscription_id for Subscriptions and product_id for Products). When importing data from your system, you may not always know if the relevant resource has already been imported into ChargeDesk.

When this is the case, to save duplicating API calls, you can set duplicate=update on any of the creation endpoints for these resources. If existing data matching the unique ID for the resource already exists, the request will not fail and instead will update the relevant resource with the latest data.

Processing Changes via Webhooks

In order to process changes made by agents via ChargeDesk, you will need to support receiving ChargeDesk webhooks. Custom webhooks can be configured from Setup > Gateways > Configure next to your Custom Integration.

You should set the "Base Path" to be a URL you control which can receive custom ChargeDesk webhooks. Adding "Headers" allows you to add additional information to these webhooks such as authentication headers. Both the Base Path and Headers support replacing any of the fields in the webhook object payload by wrapping the field ID in opening and closing brackets. For example setting a header to Charge: {charge_id} will add the charge ID as a header to any webhook which contains charge information.

Also on this page, you can find sections which allow you to enable individual custom webhook paths. Enabling a webhook path will enable that functionality on your ChargeDesk account.



Webhook Requests

Perform full or partial refunds of paid charges. The following parameters will be sent with a refund request;

refund_amount The amount to being refunded.
action_reason The reason provided by the support agent for the refund (if any).
charge The charge object being refunded.

Example refund payload;

{
    "refund_amount": 12.34,
    "action_reason": "Customer received incorrect product",
    "charge": {
        "amount": "34.00",
        "amount_refunded": "0.00",
        "currency": "USD",
        "payment_method": "Credit",
        "payment_method_brand": "Visa",
        "gateway_id": "",
        "charge_id": "example-Xs84hY5BSt5IttuRSIsQIA8r",
        "customer_id": "cus-example-RLf9f6T6Ok",
        "product_id": "prod-example-uloKnvvT6J",
        "subscription_id": "sub-example-GVajOxJRvZ",
        "transaction_id": "transaction-example-y9Tut8QrPt",
        "customer_name": "Jane Customer",
        "customer_email": "jane@example.com",
        "customer_username": "janecustomer",
        "customer_country": "US",
        "description": "An example charge",
        "last_4_digits": "1234",
        "occurred": 1732181492,
        "object": "charge",
        "amount_with_commas": "34.00",
        "amount_refunded_formatted": "$0.00 USD",
        "amount_symbol": "$",
        "amount_formatted": "$34.00 USD",
        "is_paid": true,
        "status": "paid",
        "status_text": "paid",
        "support_email": "company-example+example-Xs84hY5BSt5IttuRSIsQIA8r@chargedesk.com",
        "support_url": "https:\/\/chargedesk.com\/company-example\/example-Xs84hY5BSt5IttuRSIsQIA8r",
        "manage_url": "https:\/\/chargedesk.com\/manage\/company-example\/charges\/example-Xs84hY5BSt5IttuRSIsQIA8r",
        "invoice_url": "https:\/\/chargedesk.com\/company-example\/example-Xs84hY5BSt5IttuRSIsQIA8r\/invoice",
        "invoice_download_url": "https:\/\/chargedesk.com\/company-example\/example-Xs84hY5BSt5IttuRSIsQIA8r\/invoice\/download",
        "customer_phone": null,
        "methods_supported": [
            "edit",
            "remind",
            "email"
        ],
        "methods_active": [
            "email"
        ],
        "occurred_relative": "moments ago",
        "occurred_formatted": "moments ago",
        "payment_method_describe": "Visa credit card",
        "added_tax": "0.00",
        "invoice_company": null,
        "company": "company-example",
        "metadata": {
            "example_key": "Example charge metadata"
        },
        "logs": [],
        "gateway_url": "",
        "sent_invoice": "",
        "sent_invoice_reminder": "",
        "refunded_at_formatted": "",
        "product_desc": "",
        "name_email": "receipt",
        "email_last_sent": 0,
        "name_send_email": "Send Receipt"
    }
}

Capture or void previously authorized charges. The following parameters will be sent with a capture/void request;

charge The charge object being captured.

Example capture/void payload;

{
    "charge": {
        "amount": "34.00",
        "amount_refunded": "0.00",
        "currency": "USD",
        "payment_method": "Credit",
        "payment_method_brand": "Visa",
        "gateway_id": "",
        "charge_id": "example-r5D8vjzaXNTLwFZA4cM9Cg5b",
        "customer_id": "cus-example-w4g8gwj74L",
        "product_id": "prod-example-29e0Q5snHH",
        "subscription_id": "sub-example-yLqi4fYGM2",
        "transaction_id": "transaction-example-zSwmCNyVsP",
        "customer_name": "Jane Customer",
        "customer_email": "jane@example.com",
        "customer_username": "janecustomer",
        "customer_country": "US",
        "description": "An example charge",
        "last_4_digits": "1234",
        "occurred": 1732181492,
        "object": "charge",
        "amount_with_commas": "34.00",
        "amount_refunded_formatted": "$0.00 USD",
        "amount_symbol": "$",
        "amount_formatted": "$34.00 USD",
        "is_paid": true,
        "status": "paid",
        "status_text": "paid",
        "support_email": "company-example+example-r5D8vjzaXNTLwFZA4cM9Cg5b@chargedesk.com",
        "support_url": "https:\/\/chargedesk.com\/company-example\/example-r5D8vjzaXNTLwFZA4cM9Cg5b",
        "manage_url": "https:\/\/chargedesk.com\/manage\/company-example\/charges\/example-r5D8vjzaXNTLwFZA4cM9Cg5b",
        "invoice_url": "https:\/\/chargedesk.com\/company-example\/example-r5D8vjzaXNTLwFZA4cM9Cg5b\/invoice",
        "invoice_download_url": "https:\/\/chargedesk.com\/company-example\/example-r5D8vjzaXNTLwFZA4cM9Cg5b\/invoice\/download",
        "customer_phone": null,
        "methods_supported": [
            "edit",
            "remind",
            "email"
        ],
        "methods_active": [
            "email"
        ],
        "occurred_relative": "moments ago",
        "occurred_formatted": "moments ago",
        "payment_method_describe": "Visa credit card",
        "added_tax": "0.00",
        "invoice_company": null,
        "company": "company-example",
        "metadata": {
            "example_key": "Example charge metadata"
        },
        "logs": [],
        "gateway_url": "",
        "sent_invoice": "",
        "sent_invoice_reminder": "",
        "refunded_at_formatted": "",
        "product_desc": "",
        "name_email": "receipt",
        "email_last_sent": 0,
        "name_send_email": "Send Receipt"
    }
}

Cancel active subscriptions. The following parameters will be sent with a cancel request;

action Can be 'cancel', 'cancel-immediately', 'cancel-period-end' or 'suspend'.
refund Available if 'action' is 'cancel-immediately'. Can be 'none', 'partial' (perform a pro-rated refund of last transaction), 'full' (perform a full refund of last transaction).
action_reason The reason provided by the support agent for the cancellation (if any).
subscription The subscription object being cancelled.
charge Available if 'refund' is not 'none'. The charge object being refunded.

Example cancel payload;

{
    "action": "cancel-immediately",
    "refund": "partial",
    "action_reason": "Customer is planning on upgrading subscription",
    "subscription": {
        "subscription_id": "sub-example-vkx55s374c",
        "customer_id": "cus-example-RAFiJBiib1",
        "product_id": "prod-example-UR9KyyjODh",
        "amount": "34.00",
        "currency": "USD",
        "gateway_id": "",
        "interval": "month",
        "interval_count": 1,
        "charges": 1,
        "quantity": 2,
        "current_period_start": 1732181492,
        "current_period_end": 1734811235,
        "trial_start": 0,
        "trial_end": 1733391092,
        "ended_at": 0,
        "canceled_at": 0,
        "has_items": 0,
        "billing_cycles_total": 0,
        "billing_cycles_current": 1,
        "trial_period_days": 14,
        "setup_amount": 10,
        "object": "subscription",
        "amount_formatted": "2x $34.00 USD",
        "amount_symbol": "$",
        "status": "active",
        "status_text": "Active",
        "first_seen": 1732181492,
        "methods_supported": [
            "edit"
        ],
        "methods_active": [
            "edit"
        ],
        "readable_interval": "Monthly",
        "product_desc": "",
        "company": "company-example",
        "logs": [],
        "items": [],
        "metadata": {
            "example_key": "Example subscription metadata"
        },
        "manage_url": "https:\/\/chargedesk.com\/manage\/company-example\/subscriptions\/sub-example-vkx55s374c",
        "gateway_url": ""
    },
    "charge": {
        "amount": "34.00",
        "amount_refunded": "0.00",
        "currency": "USD",
        "payment_method": "Credit",
        "payment_method_brand": "Visa",
        "gateway_id": "",
        "charge_id": "example-dcVNtrQoNtyLxadmoPmbIAX2",
        "customer_id": "cus-example-6vsE7EUPfk",
        "product_id": "prod-example-rUPrhAuKv4",
        "subscription_id": "sub-example-xmTY1OCL45",
        "transaction_id": "transaction-example-7q8HbWrTTK",
        "customer_name": "Jane Customer",
        "customer_email": "jane@example.com",
        "customer_username": "janecustomer",
        "customer_country": "US",
        "description": "An example charge",
        "last_4_digits": "1234",
        "occurred": 1732181492,
        "object": "charge",
        "amount_with_commas": "34.00",
        "amount_refunded_formatted": "$0.00 USD",
        "amount_symbol": "$",
        "amount_formatted": "$34.00 USD",
        "is_paid": true,
        "status": "paid",
        "status_text": "paid",
        "support_email": "company-example+example-dcVNtrQoNtyLxadmoPmbIAX2@chargedesk.com",
        "support_url": "https:\/\/chargedesk.com\/company-example\/example-dcVNtrQoNtyLxadmoPmbIAX2",
        "manage_url": "https:\/\/chargedesk.com\/manage\/company-example\/charges\/example-dcVNtrQoNtyLxadmoPmbIAX2",
        "invoice_url": "https:\/\/chargedesk.com\/company-example\/example-dcVNtrQoNtyLxadmoPmbIAX2\/invoice",
        "invoice_download_url": "https:\/\/chargedesk.com\/company-example\/example-dcVNtrQoNtyLxadmoPmbIAX2\/invoice\/download",
        "customer_phone": null,
        "methods_supported": [
            "edit",
            "remind",
            "email"
        ],
        "methods_active": [
            "email"
        ],
        "occurred_relative": "moments ago",
        "occurred_formatted": "moments ago",
        "payment_method_describe": "Visa credit card",
        "added_tax": "0.00",
        "invoice_company": null,
        "company": "company-example",
        "metadata": {
            "example_key": "Example charge metadata"
        },
        "logs": [],
        "gateway_url": "",
        "sent_invoice": "",
        "sent_invoice_reminder": "",
        "refunded_at_formatted": "",
        "product_desc": "",
        "name_email": "receipt",
        "email_last_sent": 0,
        "name_send_email": "Send Receipt"
    }
}

Reactivate suspended or pending cancellation subscriptions. The following parameters will be sent with a reactivate request;

subscription The subscription object being reactivated.

Example reactivate payload;

{
    "subscription": {
        "subscription_id": "sub-example-uqj4QP2rEQ",
        "customer_id": "cus-example-DUPwFBH4NU",
        "product_id": "prod-example-SiW1x4NPH7",
        "amount": "34.00",
        "currency": "USD",
        "gateway_id": "",
        "interval": "month",
        "interval_count": 1,
        "charges": 1,
        "quantity": 2,
        "current_period_start": 1732181492,
        "current_period_end": 1734811235,
        "trial_start": 0,
        "trial_end": 1733391092,
        "ended_at": 0,
        "canceled_at": 0,
        "has_items": 0,
        "billing_cycles_total": 0,
        "billing_cycles_current": 1,
        "trial_period_days": 14,
        "setup_amount": 10,
        "object": "subscription",
        "amount_formatted": "2x $34.00 USD",
        "amount_symbol": "$",
        "status": "active",
        "status_text": "Active",
        "first_seen": 1732181492,
        "methods_supported": [
            "edit"
        ],
        "methods_active": [
            "edit"
        ],
        "readable_interval": "Monthly",
        "product_desc": "",
        "company": "company-example",
        "logs": [],
        "items": [],
        "metadata": {
            "example_key": "Example subscription metadata"
        },
        "manage_url": "https:\/\/chargedesk.com\/manage\/company-example\/subscriptions\/sub-example-uqj4QP2rEQ",
        "gateway_url": ""
    }
}

Edit subscription plans. The following parameters will be sent with a edit plans request;

plans A list of new plans and quantities to be applied on the subscription. Any existing plans should be replaced with this new list.
subscription The subscription object being edited.

Example edit plans payload;

{
    "plans": [
        {
            "product_id": "prod-example-AyL17r5mIC",
            "quantity": 2
        }
    ],
    "subscription": {
        "subscription_id": "sub-example-7bJT0T1dcy",
        "customer_id": "cus-example-1n6qSdbSaW",
        "product_id": "prod-example-o4shHvgUjC",
        "amount": "34.00",
        "currency": "USD",
        "gateway_id": "",
        "interval": "month",
        "interval_count": 1,
        "charges": 1,
        "quantity": 2,
        "current_period_start": 1732181492,
        "current_period_end": 1734811235,
        "trial_start": 0,
        "trial_end": 1733391092,
        "ended_at": 0,
        "canceled_at": 0,
        "has_items": 0,
        "billing_cycles_total": 0,
        "billing_cycles_current": 1,
        "trial_period_days": 14,
        "setup_amount": 10,
        "object": "subscription",
        "amount_formatted": "2x $34.00 USD",
        "amount_symbol": "$",
        "status": "active",
        "status_text": "Active",
        "first_seen": 1732181492,
        "methods_supported": [
            "edit"
        ],
        "methods_active": [
            "edit"
        ],
        "readable_interval": "Monthly",
        "product_desc": "",
        "company": "company-example",
        "logs": [],
        "items": [],
        "metadata": {
            "example_key": "Example subscription metadata"
        },
        "manage_url": "https:\/\/chargedesk.com\/manage\/company-example\/subscriptions\/sub-example-7bJT0T1dcy",
        "gateway_url": ""
    }
}

Request a new payment from a customer. Endpoint must return a 'redirect_url' parameter to a payment page. The following parameters will be sent with a payment request;

charge The charge object for invoice.

Example payment payload;

{
    "charge": {
        "amount": "34.00",
        "amount_refunded": "0.00",
        "currency": "USD",
        "payment_method": "Credit",
        "payment_method_brand": "Visa",
        "gateway_id": "",
        "charge_id": "example-gM7eI914EY5RAgDf82sESg3U",
        "customer_id": "cus-example-fEr84pTO5T",
        "product_id": "prod-example-tR3Xw8FPE6",
        "subscription_id": "sub-example-nvAP7kDqcI",
        "transaction_id": "transaction-example-avLL1b8hPP",
        "customer_name": "Jane Customer",
        "customer_email": "jane@example.com",
        "customer_username": "janecustomer",
        "customer_country": "US",
        "description": "An example charge",
        "last_4_digits": "1234",
        "occurred": 1732181492,
        "object": "charge",
        "amount_with_commas": "34.00",
        "amount_refunded_formatted": "$0.00 USD",
        "amount_symbol": "$",
        "amount_formatted": "$34.00 USD",
        "is_paid": true,
        "status": "paid",
        "status_text": "paid",
        "support_email": "company-example+example-gM7eI914EY5RAgDf82sESg3U@chargedesk.com",
        "support_url": "https:\/\/chargedesk.com\/company-example\/example-gM7eI914EY5RAgDf82sESg3U",
        "manage_url": "https:\/\/chargedesk.com\/manage\/company-example\/charges\/example-gM7eI914EY5RAgDf82sESg3U",
        "invoice_url": "https:\/\/chargedesk.com\/company-example\/example-gM7eI914EY5RAgDf82sESg3U\/invoice",
        "invoice_download_url": "https:\/\/chargedesk.com\/company-example\/example-gM7eI914EY5RAgDf82sESg3U\/invoice\/download",
        "customer_phone": null,
        "methods_supported": [
            "edit",
            "remind",
            "email"
        ],
        "methods_active": [
            "email"
        ],
        "occurred_relative": "moments ago",
        "occurred_formatted": "moments ago",
        "payment_method_describe": "Visa credit card",
        "added_tax": "0.00",
        "invoice_company": null,
        "company": "company-example",
        "metadata": {
            "example_key": "Example charge metadata"
        },
        "logs": [],
        "gateway_url": "",
        "sent_invoice": "",
        "sent_invoice_reminder": "",
        "refunded_at_formatted": "",
        "product_desc": "",
        "name_email": "receipt",
        "email_last_sent": 0,
        "name_send_email": "Send Receipt"
    }
}

Webhook Responses

To acknowledge successful processing of a custom integration webhook, your endpoint must return a 2xx HTTP status code (e.g. 200). If a 2xx status code is not returned, the agent will receive an error message that the action could not be performed. Additionally you can return a JSON payload with an error key which contains a message that can be displayed to the agent. This is an example of an error response;

{
    "error": "Refund amount was greater than amount remaining on charge."
}

As agents are immediately notified of a failure, custom integration webhooks are not retried.

Upon successful action, we recommend that the webhook response contains an object with a list of fields to update corresponding to the action. This allows agents to immediately see, if say a charge was refunded.

{
    "subscription": {
        "status": "cancelled",
    },
    "charge": {
        "status": "partially refunded",
        "amount_refunded" : 11.23
    }
}

You may also pass back an entire charge, customer, subscription or product object with fields matching those on the API documentation for updating their record.

However, response objects are optional. If not provided, ChargeDesk will automatically update corresponding objects with the appropriate data. For example, a charge will show as refunded or a subscription cancelled. However using response objects ensures data consistency between your system and ChargeDesk. As the update object state is shown to agents immediately after performing an action, having this data come directly from your system provides for manual review by the agent and a sanity check if any processing has been performed incorrectly.

Publishing the Integration

ChargeDesk supports converting custom integrations into core integrations available to anyone using ChargeDesk. This allows payment gateways and storefronts to easily integrate with ChargeDesk to leverage our helpdesk integrations and other payment services.

Once you have built your custom integration, please contact support if you would like to publish your integration to all users.