Recurx Developer Documentation

Welcome to the RecurX developer documentation. Here you'll find comprehensive guides and documentation to help you start working with RecurX as quickly as possible.

Installation

Get started with RecurX by installing our SDK using your preferred package manager:

npm install @recurx/sdk

Quick Start

Initialize the RecurX client with your API key:

import { RecurX } from '@recurx/sdk';

// Initialize the client
const recurx = new Recurx({
  apiKey: 'your_api_key',
  environment: 'sandbox' // or 'production'
});

// Create a payment
async function createPayment() {
  try {
    const payment = await recurx.payments.create({
      amount: 1000, // $10.00
      currency: 'USD',
      description: 'Order #1234',
      customer: {
        email: 'customer@example.com'
      }
    });
    
    console.log(payment);
  } catch (error) {
    console.error(error);
  }
}

Authentication

All requests to the Recurx API require authentication. You can authenticate your requests by including your API key in the Authorization header:

curl -X GET \
  https://api.recurx.io/v1/payments \
  -H "Authorization: Bearer your_api_key"

Security Note

Never expose your API keys in client-side code. Always use a backend service to make authenticated requests to the Recurx API.

Payments

The Payments API allows you to create, retrieve, update, and list payments. A payment represents a charge on a customer's payment method.

Creating a Payment

To create a payment, you need to specify at least the amount and currency:

const payment = await RecurX.payments.create({
  amount: 2000, // $20.00
  currency: 'USD',
  description: 'Premium subscription',
  payment_method: 'pm_card_visa',
  confirm: true
});

Webhooks

Webhooks allow you to receive real-time notifications about events that happen in your RecurX account. For example, you can use webhooks to be notified when a payment is successful or when a subscription is canceled.

To use webhooks, you need to create a webhook endpoint on your server and register it in the RecurX dashboard.