Skip to main content

Prerequisites

  • Node.js 14+ installed
  • npm or yarn package manager
  • Card2Crypto account with API key

Quick Start

1. Install Dependencies

2. Set Up Environment Variables

Create a .env file in your project root:
Add to .gitignore:

3. Create Basic Server

Creating Payments

Basic Payment Creation

Reusable Payment Helper

Usage:

Handling Return URL

When customer completes payment, they’re redirected to your return URL:

Webhook Integration

Webhooks provide real-time notifications when payment status changes.

Basic Webhook Handler

Complete Example with Database

Here’s a complete example using Prisma ORM:

Install Prisma

Database Schema

Full Integration

Error Handling

Robust Error Handling

Testing

Local Testing with ngrok

Unit Tests

Best Practices

  1. Never expose API keys in frontend code
  2. Always verify webhook signatures
  3. Return 200 OK immediately in webhook handlers
  4. Process webhooks asynchronously
  5. Implement idempotency for critical operations
  6. Log all payment-related events
  7. Use environment variables for secrets
  8. Validate all user input
  9. Handle all payment statuses
  10. Test with real payments before going live

Next Steps

API Reference

Complete API documentation

Webhook Security

Learn about webhook verification

PHP Guide

Integration guide for PHP

Testing Guide

How to test your integration