PaySmart API Documentation

Complete reference for integrating PaySmart payment processing into your applications

v2.1 Latest API Version
All systems operational

Getting Started

The PaySmart API is organized around REST. Our API accepts JSON-encoded request bodies, returns JSON-encoded responses, and uses standard HTTP response codes and authentication.

Base URL

https://api.paysmart.com/v2

Quick Example

curl https://api.paysmart.com/v2/payments \\
  -u sk_test_4eC39HqLyjWDarjtT1zdp7dc: \\
  -H "Content-Type: application/json" \\
  -d '{
    "amount": 2000,
    "currency": "usd",
    "payment_method": {
      "type": "card",
      "card": {
        "number": "4242424242424242",
        "exp_month": 12,
        "exp_year": 2025,
        "cvc": "123"
      }
    }
  }'
const paysmart = require('paysmart')('sk_test_...');

const payment = await paysmart.payments.create({
  amount: 2000,
  currency: 'usd',
  payment_method: {
    type: 'card',
    card: {
      number: '4242424242424242',
      exp_month: 12,
      exp_year: 2025,
      cvc: '123'
    }
  }
});
import paysmart
paysmart.api_key = "sk_test_..."

payment = paysmart.Payment.create(
    amount=2000,
    currency='usd',
    payment_method={
        'type': 'card',
        'card': {
            'number': '4242424242424242',
            'exp_month': 12,
            'exp_year': 2025,
            'cvc': '123'
        }
    }
)
 2000,
    'currency' => 'usd',
    'payment_method' => [
        'type' => 'card',
        'card' => [
            'number' => '4242424242424242',
            'exp_month' => 12,
            'exp_year' => 2025,
            'cvc' => '123'
        ]
    ]
]);

Authentication

PaySmart uses API keys to authenticate requests. You can view and manage your API keys in the PaySmart Dashboard.

๐Ÿ”‘ Secret Keys

Used for server-side API calls. Must be kept secret and never exposed in client-side code.

sk_live_51H7... (Live) sk_test_51H7... (Test)

๐Ÿ—๏ธ Publishable Keys

Used for client-side operations. Safe to include in frontend JavaScript code.

pk_live_51H7... (Live) pk_test_51H7... (Test)

Authentication Example

# Using HTTP Basic Auth with secret key as username
curl https://api.paysmart.com/v2/payments \\
  -u sk_test_4eC39HqLyjWDarjtT1zdp7dc: \\
  -H "Content-Type: application/json"

# Or using Authorization header
curl https://api.paysmart.com/v2/payments \\
  -H "Authorization: Bearer sk_test_4eC39HqLyjWDarjtT1zdp7dc" \\
  -H "Content-Type: application/json"

Payments

The Payments API allows you to create, retrieve, update, and list payment transactions.

POST
/v2/payments
Create a payment

Parameters

amount required
integer
Amount in cents (e.g., 2000 = $20.00)
currency required
string
Three-letter ISO currency code (e.g., "usd")
payment_method required
object
Payment method details (card, bank transfer, etc.)
customer
string
Customer ID to associate with this payment
description
string
Description for this payment

Example Request

{
  "amount": 2000,
  "currency": "usd",
  "payment_method": {
    "type": "card",
    "card": {
      "number": "4242424242424242",
      "exp_month": 12,
      "exp_year": 2025,
      "cvc": "123"
    }
  },
  "customer": "cus_1234567890",
  "description": "Payment for order #1234"
}

Example Response

{
  "id": "pay_1234567890",
  "object": "payment",
  "amount": 2000,
  "currency": "usd",
  "status": "succeeded",
  "payment_method": {
    "id": "pm_1234567890",
    "type": "card",
    "card": {
      "brand": "visa",
      "last4": "4242",
      "exp_month": 12,
      "exp_year": 2025
    }
  },
  "customer": "cus_1234567890",
  "description": "Payment for order #1234",
  "created": 1640995200,
  "receipt_url": "https://pay.paysmart.com/receipts/pay_1234567890"
}
GET
/v2/payments/{id}
Retrieve a payment
GET
/v2/payments
List all payments

Customers

Customer objects allow you to perform recurring payments and track multiple payments associated with a single customer.

POST
/v2/customers
Create a customer

Example Request

{
  "email": "customer@example.com",
  "name": "John Doe",
  "phone": "+1234567890",
  "address": {
    "line1": "123 Main St",
    "city": "San Francisco",
    "state": "CA",
    "postal_code": "94111",
    "country": "US"
  }
}

Example Response

{
  "id": "cus_1234567890",
  "object": "customer",
  "email": "customer@example.com",
  "name": "John Doe",
  "phone": "+1234567890",
  "address": {
    "line1": "123 Main St",
    "city": "San Francisco",
    "state": "CA",
    "postal_code": "94111",
    "country": "US"
  },
  "created": 1640995200
}

Webhooks

Webhooks allow PaySmart to notify your application when events happen in your account, such as a successful payment or a failed transaction.

Event Types

payment.succeeded

Occurs when a payment is successfully processed

payment.failed

Occurs when a payment attempt fails

refund.created

Occurs when a refund is created

customer.created

Occurs when a new customer is created

Webhook Endpoint Example

// Express.js webhook handler
app.post('/webhook', express.raw({type: 'application/json'}), (req, res) => {
  const sig = req.headers['paysmart-signature'];
  let event;

  try {
    event = paysmart.webhooks.constructEvent(req.body, sig, endpointSecret);
  } catch (err) {
    console.log('Webhook signature verification failed.', err.message);
    return res.status(400).send('Webhook Error: ${err.message}');
  }

  // Handle the event
  switch (event.type) {
    case 'payment.succeeded':
      const payment = event.data.object;
      console.log('Payment succeeded:', payment.id);
      break;
    case 'payment.failed':
      const failedPayment = event.data.object;
      console.log('Payment failed:', failedPayment.id);
      break;
    default:
      console.log('Unhandled event type ${event.type}');
  }

  res.json({received: true});
});

Error Handling

PaySmart uses conventional HTTP response codes to indicate the success or failure of an API request.

HTTP Status Codes

200
Everything worked as expected
400
Bad Request - Often missing required parameter
401
Unauthorized - No valid API key provided
402
Request Failed - Parameters valid but request failed
404
Not Found - The requested resource doesn't exist
500
Server Error - Something went wrong on our end

Error Response Example

{
  "error": {
    "type": "card_error",
    "code": "card_declined",
    "message": "Your card was declined.",
    "decline_code": "generic_decline"
  }
}

SDKs & Libraries

Official PaySmart libraries are available for popular programming languages and frameworks.

๐Ÿ“œ

JavaScript / Node.js

Official JavaScript library for browser and Node.js

npm install paysmart
๐Ÿ

Python

Official Python library for server-side integration

pip install paysmart
๐Ÿ˜

PHP

Official PHP library with Composer support

composer require paysmart/paysmart-php
โ™ฆ๏ธ

Ruby

Official Ruby gem for Rails and Ruby applications

gem install paysmart
โ˜•

Java

Official Java library for enterprise applications

implementation 'com.paysmart:paysmart-java'
๐Ÿ”ท

.NET

Official .NET library for C# applications

dotnet add package PaySmart.net