ChargX Documentation

HTTP API

API documentation

Welcome to ChargX payment gateway API documentation - set of clearly defined methods of communication between clients apps and payment gateway.

Before you start

Before you start, make sure:

  • You have access to your ChargX account and Publishable API Key. If not, follow the Getting Started guide

REST API endpoint

Basic URL: https://api.chargx.io

Headers

The only mandatory header required for all types of requests is x-publishable-api-key which should contain a value of Publishable API Key.

Retrieve pretransact keys

Before doing any payments you need to retrieve the pretransact keys:

Request:

GET https://api.chargx.io/pretransact

Headers:
x-publishable-api-key=pk_256c3fa9....t23f

Response:

{
  "authData": {
    "apiLoginID": "2R.....Vz",
    "clientKey": "743M................n6E3",
  },
  "isProduction": true,
  "cardTokenRequestUrl": "https://api.processor.net/xml/v1/request.api",
  "cardTokenRequestParams": {"securePaymentContainerRequest":{"merchantAuthentication":{"name":"2R.....Vz","clientKey":"743M................n6E3"},"data":{"type":"TOKEN","id":"37296fb7-0a75-5f25-77dc-0760091b89e6","token":{"cardNumber":"#cardNumber#","expirationDate":"#expirationDate#","cardCode":"#cardCode#"}}}},
  "googlePay": {
    "methodData": [
      {
        "supportedMethods": "https://google.com/pay",
        "data": {
          "environment": "PRODUCTION",
          "apiVersion": 2,
          "apiVersionMinor": 0,
          "merchantInfo": {
            "merchantId": "store_01KAty6123213231230732WR8",
            "merchantName": "Your Store Name"
          },
          "allowedPaymentMethods": [
            {
              "type": "CARD",
              "parameters": {
                "allowedAuthMethods": [
                  "PAN_ONLY",
                  "CRYPTOGRAM_3DS"
                ],
                "allowedCardNetworks": [
                  "MASTERCARD",
                  "VISA"
                ]
              },
              "tokenizationSpecification": {
                "type": "PAYMENT_GATEWAY",
                "parameters": {
                  "gateway": "authorizenet",
                  "gatewayMerchantId": "1723296"
                }
              }
            }
          ]
        }
      }
    ]
  },
  "applePay": {
    "paymentRequest": {
      "countryCode": "US",
      "currencyCode": "USD",
      "supportedNetworks": [
        "visa",
        "masterCard",
        "amex",
        "discover"
      ],
      "merchantCapabilities": [
        "supports3DS"
      ],
      "total": {
        "label": "Your Store Name",
        "amount": 0
      }
    }
  }
}

Tokenize card

To exchange credit card details for a token, a tokenization system is used, which substitutes the actual credit card number with a unique, random string of characters called a token for secure online transactions

  • this should be a POST request to cardTokenRequestUrl endpoint and parameters taken from cardTokenRequestParams from Retrieve pretransact keys request.
  • you must replace stubs in cardTokenRequestParams, e.g. #cardNumber#, #expirationDate#, #cardCode# with real card details. The pseudo code looks like the following:
    const cardTokenRequestParamsString = JSON.stringify(pretransactResponse.cardTokenRequestParams)
      .replace("#cardNumber#", testCard.cardNumber)
      .replace("#expirationDate#", testCard.expirationDate)
      .replace("#cardCode#", testCard.cardCode);
    const cardTokenRequestParams = JSON.parse(cardTokenRequestParamsString);

Request:

POST https://api.processor.net/xml/v1/request.api

Headers:
content-type=application/json

Body:
{"securePaymentContainerRequest":{"merchantAuthentication":{"name":"2R.....Vz","clientKey":"743M................n6E3"},"data":{"type":"TOKEN","id":"37296fb7-0a75-5f25-77dc-0760091b89e6","token":{"cardNumber":"#cardNumber#","expirationDate":"#expirationDate#","cardCode":"#cardCode#"}}}},

Response:

Depending on underlying payment processor, the response coulde be one of the following:

{
    "opaqueData": {...},
}

or

{
    "token": "...",
}

Charge credit card

Use this method to authorize and capture a credit card payment.

Request:

POST https://api.chargx.io/transact

Headers:
x-publishable-api-key=pk_256c3fa9....t23f
content-type=application/json

Body:
{
  "currency":"USD",
  "amount":"22",
  "type":"fiat",
  "opaqueData":{...},
  "customer":{
    "name":"SamJohnatan",
    "email":"samj@email.com",
    "phone":"+18731944982"
  },
  "billingAddress":{
    "street":"6Street",
    "unit":"",
    "city":"Orlando",
    "state":"Florida",
    "zipCode":"31-566",
    "countryCode":"USA",
    "phone":"+18731944982"
  },
  "orderId":33,
}

Parameters

FieldTypeRequiredDescription
amountstring✅ YesThe amount to charge, represented as a string or numeric value.
currencystring⚙️ OptionalThe transaction currency. Format: ISO 4217. Default is USD.
typestring✅ YesDefines the transaction type. Use "fiat" for standard currency payments.
opaqueDataobject✅ YesEncrypted or tokenized payment data (e.g. card details or digital wallet tokens).
opaqueData.dataDescriptorstringEither dataDescriptor+dataValue or tokenEncrypted or tokenized payment data
opaqueData.dataValuestringEither dataDescriptor+dataValue or tokenEncrypted or tokenized payment data
opaqueData.tokenstringEither dataDescriptor+dataValue or tokenEncrypted or tokenized payment data
vaultIdstringEither vaultId or opaqueDataAn id of user vault
cvvstring⚙️ OptionalThe card security code. While this is not required, it is strongly recommended.
customerobject⚙️ OptionalCustomer details for the transaction.
customer.namestring✅ YesFull name of the customer.
customer.emailstring✅ YesCustomer email address for receipts or notifications.
customer.phonestring⚙️ OptionalCustomer phone number in international format.
billingAddressobject⚙️ OptionalBilling address associated with the payment method.
billingAddress.streetstring✅ YesStreet name and number.
billingAddress.unitstring⚙️ OptionalApartment, suite, or unit number.
billingAddress.citystring✅ YesCity of the billing address.
billingAddress.statestring✅ YesState or province of the billing address.
billingAddress.zipCodestring✅ YesZIP or postal code.
billingAddress.countryCodestring✅ Yes3-letter ISO country code (e.g. USA).
billingAddress.phonestring⚙️ OptionalPhone number associated with the billing address.
orderIdstring⚙️ OptionalUnique identifier for the related order or invoice from YOUR system

Response:

{
  "message":"Ok",
  "result":{
    "orderId":"order_01K74...WYKJ",
    "orderDisplayId": "79",
  }
}

Credit Card Transaction Declines

Credit card transactions can be declined for various reasons. To determine the cause of a decline, examine the /transact API response:

{
    "message": "Error creating transaction",
    "error": [
        {
            "errorCode": "44",
            "errorText": "This transaction has been declined."
        }
    ]
}

The platform may not provide specific reasons for a particular decline, but some details on declines are included in transaction responses, if available. There are some common decline reasons along with their associated Response Reason Codes:

Response Reason CodeReason
2The issuing bank declined the transaction.
3Approval requires calling the issuing bank.
4The card is reported lost or stolen and should be retained if possible.
27Billing address does not match (AVS failure), declined based on configured rules.
44Security code (CVV/CVC) failed verification.
45Both AVS and security code failed validation, declined based on rules.
65Security code mismatch, declined due to account rules.

Authorize credit card

Use this method to authorize a credit card payment. To actually charge the funds you will need to follow up with a capture transaction.

Request:

POST https://api.chargx.io/card/authorize

Headers:
x-publishable-api-key=pk_256c3fa9....t23f
content-type=application/json

Body:
{
  "currency":"USD",
  "amount":"22",
  "type":"fiat",
  "opaqueData":{...},
  "customer":{
    "name":"SamJohnatan",
    "email":"samj@email.com",
    "phone":"+18731944982"
  },
  "billingAddress":{
    "street":"6Street",
    "unit":"",
    "city":"Orlando",
    "state":"Florida",
    "zipCode":"31-566",
    "countryCode":"USA",
    "phone":"+18731944982"
  },
  "orderId":33,
}

Parameters

FieldTypeRequiredDescription
amountstring✅ YesThe amount to charge, represented as a string or numeric value.
typestring✅ YesDefines the transaction type. Use "fiat" for standard currency payments.
opaqueDataobject✅ YesEncrypted or tokenized payment data (e.g. card details or digital wallet tokens).
customerobject⚙️ OptionalCustomer details for the transaction.
customer.namestring✅ YesFull name of the customer.
customer.emailstring✅ YesCustomer email address for receipts or notifications.
customer.phonestring⚙️ OptionalCustomer phone number in international format.
billingAddressobject⚙️ OptionalBilling address associated with the payment method.
billingAddress.streetstring✅ YesStreet name and number.
billingAddress.unitstring⚙️ OptionalApartment, suite, or unit number.
billingAddress.citystring✅ YesCity of the billing address.
billingAddress.statestring✅ YesState or province of the billing address.
billingAddress.zipCodestring✅ YesZIP or postal code.
billingAddress.countryCodestring✅ Yes3-letter ISO country code (e.g. USA).
billingAddress.phonestring⚙️ OptionalPhone number associated with the billing address.
orderIdstring⚙️ OptionalUnique identifier for the related order or invoice from YOUR system

Response:

{
  "message":"Ok",
  "result":{
    "orderId":"order_01K74...WYKJ",
    "orderDisplayId": "79",
  }
}

Capture a previously authorized amount

Use this method to capture funds reserved with a previous Authorize transaction request.

Request:

POST https://api.chargx.io/transaction/capture

Headers:
x-publishable-api-key=pk_256c3fa9....t23f
content-type=application/json

Body:
{
  "orderId":"order_01K74...WYKJ",
}

Parameters

FieldTypeRequiredDescription
orderIdstring✅ YesThe order(transaction id) to capture

Response:

{
  "message":"Ok",
  "result":{
    "orderId":"order_01K74...WYKJ",
    "orderDisplayId": "79",
  }
}

Refund transaction

To refund a customer for a transaction that was successfully settled through the payment gateway.

Request:

POST https://api.chargx.io/transaction/refund

Headers:
x-publishable-api-key=pk_256c3fa9....t23f
content-type=application/json

Body:
{
  "orderId":"order_01K74...WYKJ",
}

Parameters

FieldTypeRequiredDescription
orderIdstring✅ YesThe order(transaction id) to refund

Response:

{
  "message":"Ok",
}

Void transaction

To cancel an original transaction that is not yet settled. A Void prevents the transaction or the order from being sent for settlement.

Request:

POST https://api.chargx.io/transaction/void

Headers:
x-publishable-api-key=pk_256c3fa9....t23f
content-type=application/json

Body:
{
  "orderId":"order_01K74...WYKJ",
}

Parameters

FieldTypeRequiredDescription
orderIdstring✅ YesThe order(transaction id) to void

Response:

{
  "message":"Ok",
}

Create subscription

Create subscription for recurring payments.

Request:

POST https://api.chargx.io/subscription

Headers:
x-publishable-api-key=pk_256c3fa9....t23f
content-type=application/json

Body:
{
  "variant_id": "premium-monthly-001",
  "opaqueData": {
    "dataDescriptor": "COMMON.ACCEPT.INAPP.PAYMENT",
    "dataValue": "947561b67cc948f38fd241ee1fb3f1e3"
  },
  "customer": {
    "email": "john.doe@example.com",
    "name": "John",
    "lastName": "Doe",
    "phone": "+15550001234"
  },
  "address": {
    "street": "123 Main Street",
    "city": "Los Angeles",
    "zipCode": "90001",
    "countryCode": "US",
    "unit": "Suite 204",
    "state": "CA"
  }
}

Parameters

FieldTypeRequiredDescription
variant_idstringYesIdentifier of the subscription product or plan variant.
opaqueData.dataDescriptorstringYesDescriptor used to identify the payment tokenization method (e.g., "COMMON.ACCEPT.INAPP.PAYMENT").
opaqueData.dataValuestringYesTokenized payment data value returned from the payment processor.
customer.emailstring (email)YesCustomer email address.
customer.namestringYesCustomer first name.
customer.lastNamestringYesCustomer last name.
customer.phonestringNoCustomer phone number.
address.streetstringYesStreet address.
address.citystringYesCity of residence.
address.zipCodestringYesZIP or postal code.
address.countryCodestringYesISO country code.
address.unitstringNoApartment, suite, or unit number.
address.statestringNoState or province (required based on region).

Response:

{
  "id":"subscription_947561b67cc948f38fd241ee1fb3f1e3",
}

Retrieve subscription

Retrieve subscription details of recurring payments.

Request:

GET https://api.chargx.io/subscription/<id>

Headers:
x-publishable-api-key=pk_256c3fa9....t23f
content-type=application/json

**Response:**

```bash
{
  "subscription": {
    "id": "subscription_01HYP3KJX473BY9ZPQH22F2Q8M",
    "name": "Premium Monthly Plan",
    "status": "active",
    "subscription_id": "sub_9f3a7320-cd45-4bbc-b762-b91671df15ad",
    "length": 1,
    "unit": "months",
    "start_date": "2025-02-01T12:00:00.000Z",
    "total_occurrences": 12,
    "trial_occurrences": 1,
    "amount": 19.99,
    "trial_amount": 0.00
  }
}

Delete subscription

Delete subscription of recurring payments.

Request:

DELETE https://api.chargx.io/subscription/<id>

Headers:
x-publishable-api-key=pk_256c3fa9....t23f
content-type=application/json

**Response:**

```bash
{
  "id":"subscription_947561b67cc948f38fd241ee1fb3f1e3",
  "object": "subscription",
  "canceled": true,
}

Create Vault

Store user tokenized credit/debit card into Vault for use in multi-time payments. Use Tokenize card request to tokenize card.

Request:

POST https://api.chargx.io/v1/vault

Headers:
x-publishable-api-key=pk_256c3fa9....t23f
content-type=application/json

Body:
{
  "opaqueData": { "token": "..." }
}

Parameters

FieldTypeRequiredDescription
opaqueDataobject✅ YesEncrypted or tokenized payment data (e.g. card details or digital wallet tokens).
opaqueData.tokenstring✅ YesEncrypted or tokenized payment data

Response:

{
  "message":"Ok",
  "result":{
    "customerVaultId":13788232323,
  }
}

The vaultId can be used in Charge credit card request to charge the customer.

Delete Vault

Delete previously created Vault.

Request:

DELETE https://api.chargx.io/v1/vault?customerVaultId=13788232323

Headers:
x-publishable-api-key=pk_256c3fa9....t23f

Parameters

FieldTypeRequiredDescription
customerVaultIdstring✅ YesExisting Customer Vault identifier

Response:

{
  "message":"Ok",
}

Bank-to-bank

The following endpoints support bank-to-bank payments. Use them in sequence: create a link token → redirect the customer to connect their bank → exchange the public token → create a transaction.

Creates a link_token used to initialize the bank connection flow. Your frontend uses this token with UI lib so the customer can connect their bank account. At least one of custPhoneNumber or custEmail is required.

Request:

POST https://api.chargx.io/v1/bank-to-bank/create_link_token

Headers:
x-publishable-api-key=pk_256c3fa9....t23f
content-type=application/json

Body:
{
  "clientName": "Your App Name",
  "redirectUri": "https://yourapp.com/callback",
  "custEmail": "customer@example.com",
  "custPhoneNumber": "+15551234567",
  "custFirstName": "Jane",
  "custLastName": "Doe",
  "themeColor": "0066CC",
  "themeLogo": "https://yourapp.com/logo.png"
}

Parameters

FieldTypeRequiredDescription
clientNamestring✅ YesYour application or merchant name shown in the bank connection flow.
redirectUristring✅ YesURL where the customer is redirected after completing or abandoning the bank connection. Must be a valid URL.
custPhoneNumberstring⚙️ ConditionalCustomer phone number. At least one of custPhoneNumber or custEmail is required.
custEmailstring⚙️ ConditionalCustomer email address. At least one of custPhoneNumber or custEmail is required.
custFirstNamestring⚙️ OptionalCustomer first name.
custLastNamestring⚙️ OptionalCustomer last name.
themeColorstring⚙️ Optional6-character HEX color code (e.g. 0066CC) for Link UI theming.
themeLogostring⚙️ OptionalURL of your logo for the Link UI.

Response:

{
  "message": "Ok",
  "link_token": "link-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
}

Error response (e.g. validation failure):

{
  "message": "Failed to create link token",
  "error": "Failed to create link token"
}

Exchange public token

After the customer completes the bank connection, it redirects to your redirectUri with a public_token. Exchange that token for a bankToken and optional account details. Use bankToken when calling the transact endpoint.

Request:

POST https://api.chargx.io/v1/bank-to-bank/public_token_exchange

Headers:
x-publishable-api-key=pk_256c3fa9....t23f
content-type=application/json

Body:
{
  "publicToken": "public-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
}

Parameters

FieldTypeRequiredDescription
publicTokenstring✅ YesThe public token returned after the customer completes the bank connection (e.g. from your redirect URI query params).

Response:

{
  "message": "Ok",
  "bankToken": "btok_xxxxxxxxxxxxxxxx",
  "bankName": "Chase",
  "bankAccountLastFour": "1234"
}

Error response:

{
  "message": "Failed to exchange public token",
  "error": "Failed to exchange public token"
}

Bank-to-bank transact

Creates a bank-to-bank transaction using a bankToken obtained from Exchange public token. A store-level discount (5%) is applied to the amount before charging. Optionally pass linkToken from Create link token to associate the payment with a cached customer.

Request:

POST https://api.chargx.io/v1/bank-to-bank/transact

Headers:
x-publishable-api-key=pk_256c3fa9....t23f
content-type=application/json

Body:
{
  "bankToken": "btok_xxxxxxxxxxxxxxxx",
  "amount": 99.99,
  "orderId": "order-123-from-your-system",
  "linkToken": "link-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
}

Parameters

FieldTypeRequiredDescription
bankTokenstring✅ YesBank token from the Exchange public token response.
amountnumber✅ YesTransaction amount (e.g. in store’s default currency). A store-defined discount may be applied before charging.
orderIdstring✅ YesUnique identifier for this order from your system (e.g. your order or invoice id).
linkTokenstring⚙️ OptionalLink token from Create link token. Used to look up the cached customer.

Response:

{
  "message": "Ok",
  "result": {
    "orderId": "order_01K74...WYKJ",
    "orderDisplayId": "79",
    "transactionId": "..."
  }
}

Error response:

{
  "message": "Error creating bank-to-bank transaction: <error detail>",
  "error": "<error detail>"
}