API Reference

The NextGen Tech API is organized around REST. Our API has predictable resource-oriented URLs, accepts form-encoded request bodies, returns JSON-encoded responses, and uses standard HTTP response codes, authentication, and verbs.

Base URL https://api.nextgen.tech/v1

Authentication

Authenticate your API requests by including your secret API key in the request header. You can manage your API keys in the Dashboard.

All API requests must be made over HTTPS. Calls made over plain HTTP will fail. API requests without authentication will also fail.

cURL
curl https://api.nextgen.tech/v1/charges \
  -H "Authorization: Bearer sk_test_12345"

Official SDKs

While you can make direct HTTP requests to the NextGen API, we highly recommend using our official Server-side SDKs. They provide strongly-typed requests, automatic retries, and simplified error handling across multiple languages.

JS

Node.js

npm install nextgen-node
PY

Python

pip install nextgen-python
RB

Ruby

gem install nextgen-ruby
PHP

PHP

composer require nextgen-php
const NextGen = require('nextgen-node');
const nextgen = new NextGen('sk_test_12345', {
  apiVersion: '2026-04-17',
  maxNetworkRetries: 3,
});

Errors

NextGen uses conventional HTTP response codes to indicate the success or failure of an API request. In general, codes in the 2xx range indicate success. Codes in the 4xx range indicate an error that failed given the information provided (e.g., a required parameter was omitted, a charge failed, etc.). Codes in the 5xx range indicate an error with NextGen's servers.

HTTP Status Codes

200 - OK
Everything worked as expected.
400 - Bad Request
The request was unacceptable, often due to missing a required parameter.
401 - Unauthorized
No valid API key provided.
404 - Not Found
The requested resource doesn't exist.
500 - Server Error
Something went wrong on NextGen's end. (These are rare.)
Error Response (JSON)
{
  "error": {
    "code": "resource_missing",
    "doc_url": "https://nextgen.tech/docs/errors/resource_missing",
    "message": "No such customer: 'cus_12345'",
    "type": "invalid_request_error"
  }
}

POST

Create a charge

To charge a credit card or other payment source, you create a Charge object. If your API key is in test mode, the supplied payment source (e.g., card) won't actually be charged.

Parameters

amount
Required
Amount intended to be collected by this payment. A positive integer representing how much to charge in the smallest currency unit (e.g., 100 cents to charge $1.00).
currency
Required
Three-letter ISO currency code, in lowercase. Must be a supported currency.
source
Optional
A payment source to be charged. This can be the ID of a card (i.e., credit or debit card), a bank account, or a source object.
Request (Node.js)
const nextgen = require('nextgen')('sk_test_12345');

const charge = await nextgen.charges.create({
  amount: 2000,
  currency: 'usd',
  source: 'tok_visa',
  description: 'My First Test Charge',
});
Response (JSON)
{
  "id": "ch_1J2k3L4m5N6o",
  "object": "charge",
  "amount": 2000,
  "amount_refunded": 0,
  "currency": "usd",
  "description": "My First Test Charge",
  "paid": true,
  "status": "succeeded"
}

Webhooks

NextGen uses webhooks to notify your application when an event happens in your account. Webhooks are particularly useful for asynchronous events like when a customer's bank confirms a payment, a customer disputes a charge, or a recurring billing cycle succeeds.

Verifying Signatures

We include a NextGen-Signature header in every webhook request. You should verify this signature using your webhook endpoint's secret to ensure the event was actually sent by NextGen and not a third party.

Always use the raw request body when verifying signatures. If you are using frameworks like Express, ensure you use the raw body parser for your webhook route.

Webhook Handler (Node.js/Express)
const express = require('express');
const app = express();
const nextgen = require('nextgen-node')('sk_test_12345');

// Match the raw body to verify the signature
app.post('/webhook', express.raw({type: 'application/json'}), (req, res) => {
  const sig = req.headers['nextgen-signature'];
  let event;

  try {
    // Verify and construct the event
    event = nextgen.webhooks.constructEvent(req.body, sig, 'whsec_secret');
  } catch (err) {
    return res.status(400).send(`Webhook Error: ${err.message}`);
  }

  // Handle the event successfully
  if (event.type === 'charge.succeeded') {
    const charge = event.data.object;
    console.log(`Payment for ${charge.amount} succeeded!`);
  }

  // Return a 200 response to acknowledge receipt
  res.json({received: true});
});

POST

Create a customer

Creates a new customer object. You can optionally pass a source parameter to attach a payment source to the customer upon creation, making it easy to charge them later without requiring them to re-enter their card details.

Parameters

email
Optional
Customer's email address. It's displayed in the NextGen Dashboard and can be used to easily search for the customer.
name
Optional
The customer's full name or business name.
description
Optional
An arbitrary string that you can attach to a customer object. It is displayed alongside the customer in the dashboard.
Request (Node.js)
const nextgen = require('nextgen')('sk_test_12345');

const customer = await nextgen.customers.create({
  name: 'Jane Doe',
  email: 'jane.doe@example.com',
  description: 'My First Test Customer',
});
Response (JSON)
{
  "id": "cus_8mNq2Lp5Zk9Xw",
  "object": "customer",
  "balance": 0,
  "created": 1713745200,
  "currency": "usd",
  "description": "My First Test Customer",
  "email": "jane.doe@example.com",
  "name": "Jane Doe"
}

POST

Create a refund

When you create a new refund, you must specify a charge on which to create it. Creating a new refund will refund a charge that has previously been created but not yet refunded. Funds will be refunded to the credit or debit card that was originally charged.

Parameters

charge
Required
The identifier of the charge to refund.
amount
Optional
A positive integer in the smallest currency unit (e.g., 100 cents for $1.00) representing how much of this charge to refund. Can refund up to the remaining unrefunded amount of the charge.
reason
Optional
String indicating the reason for the refund. If set, possible values are duplicate, fraudulent, or requested_by_customer.
Request (Node.js)
const nextgen = require('nextgen')('sk_test_12345');

const refund = await nextgen.refunds.create({
  charge: 'ch_1J2k3L4m5N6o',
  amount: 1000,
  reason: 'requested_by_customer',
});
Response (JSON)
{
  "id": "re_3L9mZ1K0Xp4Qw",
  "object": "refund",
  "amount": 1000,
  "charge": "ch_1J2k3L4m5N6o",
  "created": 1713745800,
  "currency": "usd",
  "reason": "requested_by_customer",
  "status": "succeeded"
}