OctaPay

API Documentation

Complete guide to integrate OctaPay into your application

Quick Start

Get started with OctaPay API in minutes. Our RESTful API is designed to be simple, predictable, and easy to use.

Base URL
https://api.ledgepay.com/v1

Authentication

All API requests require authentication using your API key. Include your key in the Authorization header:

Authorization: Bearer YOUR_API_KEY

Keep your API keys secure! Never expose them in client-side code or public repositories.

Create a Payment

Create a new payment session for your customer.

POST /payments

Request Body

{
  "amount": 5000,
  "currency": "EUR",
  "description": "Order #12345",
  "customer": {
    "email": "customer@example.com",
    "name": "John Doe"
  },
  "success_url": "https://yoursite.com/success",
  "cancel_url": "https://yoursite.com/cancel",
  "metadata": {
    "order_id": "12345"
  }
}

Response

{
  "id": "pay_1234567890",
  "status": "pending",
  "amount": 5000,
  "currency": "EUR",
  "checkout_url": "https://checkout.ledgepay.com/pay_1234567890",
  "created_at": "2024-01-15T10:30:00Z"
}

Retrieve a Payment

Get the details of a specific payment.

GET /payments/{payment_id}

Response

{
  "id": "pay_1234567890",
  "status": "succeeded",
  "amount": 5000,
  "currency": "EUR",
  "description": "Order #12345",
  "customer": {
    "email": "customer@example.com",
    "name": "John Doe"
  },
  "metadata": {
    "order_id": "12345"
  },
  "created_at": "2024-01-15T10:30:00Z",
  "completed_at": "2024-01-15T10:32:15Z"
}

List Payments

Retrieve a list of payments with optional filters.

GET /payments?limit=10&status=succeeded

Query Parameters

  • limit - Number of results (default: 10, max: 100)
  • status - Filter by status: pending, succeeded, failed, canceled
  • created_after - ISO 8601 timestamp
  • created_before - ISO 8601 timestamp

Create a Refund

Refund a payment partially or fully.

POST /refunds

Request Body

{
  "payment_id": "pay_1234567890",
  "amount": 2500,
  "reason": "customer_request"
}

Webhooks

Receive real-time notifications about payment events.

Event Types

  • payment.succeeded - Payment completed successfully
  • payment.failed - Payment failed
  • payment.canceled - Payment canceled by customer
  • refund.created - Refund issued
  • refund.succeeded - Refund completed

Webhook Payload Example

{
  "event": "payment.succeeded",
  "timestamp": "2024-01-15T10:32:15Z",
  "data": {
    "id": "pay_1234567890",
    "amount": 5000,
    "currency": "EUR",
    "metadata": {
      "order_id": "12345"
    }
  }
}

Always verify webhook signatures to ensure requests are from OctaPay. Check our security documentation for details.

Error Codes

Common HTTP status codes you may encounter:

Code Description
200 Success
201 Resource created
400 Bad request - Invalid parameters
401 Unauthorized - Invalid API key
404 Not found - Resource doesn't exist
429 Too many requests - Rate limit exceeded
500 Internal server error

Rate Limits

API requests are limited to prevent abuse:

  • Standard: 100 requests per minute
  • Enterprise: 1,000 requests per minute

Rate limit information is included in response headers:

X-RateLimit-Limit: 100
X-RateLimit-Remaining: 95
X-RateLimit-Reset: 1610712000

SDKs & Libraries

Official libraries to integrate OctaPay faster:

JavaScript / Node.js

npm install ledgepay

Python

pip install ledgepay

PHP

composer require ledgepay/ledgepay-php

Ruby

gem install ledgepay

Need Help?

Our developer support team is here to help you integrate successfully.