Pepay SDK
Welcome to the official Pepay SDK Documentation! This guide explains how to install, configure, and integrate the Pepay SDK into your Node.js/TypeScript applications for seamless cryptocurrency payment processing.
1. Introduction
Overview
The Pepay SDK is a TypeScript/Node.js library that integrates seamlessly with the Pepay API. It enables merchants and developers to create invoices, manage payments, and set up webhooks for real-time notifications—while supporting features like multi-chain transactions, non-custodial wallets, and time-bound invoices.
Who Should Use This SDK?
Developers building AI agent frameworks or merchant apps needing a crypto payment gateway.
Teams seeking an easy-to-use integration that handles invoice creation, listing, and management via the Pepay platform.
2. Installation
NPM/Yarn
Requirements
Node.js v14+
TypeScript (optional but recommended)
A valid Pepay API key (generated in the Pepay dashboard)
3. Quick Start
Key Steps
Install the SDK
Import
PepaySDK
into your applicationInstantiate the SDK with your API key
Create and manage invoices as needed
4. Core Concepts
Invoices
Purpose: Request and collect crypto payments from customers.
Attributes: Each invoice has a unique ID, amount in USD, description, and expiration time.
Payment URLs: A secure link is generated for customers to complete their payment in various cryptocurrencies.
Authentication
API Key: All requests to the Pepay API must include a valid key.
Key Rotation: API keys can be regenerated in the Pepay dashboard. They should be kept confidential and secured.
Idempotency
Usage: Employ a unique idempotency key for each write operation (e.g., UUIDv4).
Benefit: Prevents duplicate invoice creation and ensures reliable retries in case of network issues.
5. API Reference
5.1 createInvoice()
createInvoice()
Creates a new invoice for a specified USD amount.
Parameters
amount_usd: number
– Invoice amount in USDdescription: string
– Optional description of the invoicecustomer_id: string
– Optional customer identifiermetadata: object
– Optional additional dataexpires_in: number
– Optional custom expiration duration (in milliseconds)
Returns
Promise<Invoice>
– The created invoice object
5.2 listInvoices()
listInvoices()
Retrieves a paginated list of invoices based on specified criteria.
Parameters
page: number
– Page number for paginationstatus: string
– Invoice status filter (paid
,unpaid
,expired
, orall
)
Returns
Promise<Invoice[]>
– Array of invoices matching the filter
5.3 getCustomerInvoices()
getCustomerInvoices()
Lists all invoices associated with a specific customer.
Parameters
customer_id: string
– Unique identifier for the customer
Returns
Promise<Invoice[]>
– Array of invoices for the given customer
5.4 getInvoiceTotals()
getInvoiceTotals()
Retrieves a summary of total amounts and invoice counts for your Pepay account.
Returns
Promise<Totals>
– An object with aggregated invoice data
6. Webhook Integration
Overview
Pepay sends webhook events to notify your application about invoice status changes in real-time (e.g., when an invoice is paid, expires, or is partially paid). Handling these events ensures your system stays in sync with the latest payment state.
6.1 Setting Up Webhooks
Configure your webhook URL in the Pepay dashboard.
Store your webhook secret securely—used for verifying request signatures.
Implement an endpoint in your application that can parse raw JSON bodies.
6.2 Webhook Events
invoice.paid
invoice.expired
invoice.partial_payment
invoice.overpaid
6.3 Sample Webhook Handler
7. Error Handling
All errors from the SDK are thrown as PepayError
, which contains a code
and a descriptive message
.
Common Error Codes
INVALID_AMOUNT_FORMAT
INVALID_AMOUNT_RANGE
IDEMPOTENCY_KEY_MISSING
INVOICE_CREATE_FAILED
8. Best Practices
Idempotency: Use a unique key (e.g., UUIDv4) for each write operation to handle retries safely.
Error Handling: Always catch and log
PepayError
to provide clear feedback in production.Webhook Integration: Ensure real-time updates by subscribing to invoice events.
Amount Validation: Keep invoice amounts within
0.01–1,000,000.00 USD
.Expiration Times: Configure durations that match your business needs, using the
expires_in
parameter.
9. Support & Resources
API & Docs: https://docs.pepay.io
Status Page: https://status.pepay.io
Support Email: support@peperuney.pizza
10. Changelog & Versioning
v1.0.0: Initial release, featuring invoice creation, listing, and webhook handling
v1.1.0: Added partial payment functionality and improved logging
Stay updated by watching the GitHub releases.
© 2025 Pepay. All rights reserved.
Last updated