PayTree

Quick Start

Get up and running in 5 minutes

Follow these steps to integrate PayTree into your application and start accepting crypto payments.

1

Get Your API Keys

Sign up for a PayTree account and get your API keys from the merchant dashboard.

Note: Your API key starts with pt_live_ for production and pt_test_ for testing.

2

Install the SDK

Install our official SDK for your platform:

# npm
npm install @paytree/sdk

# yarn  
yarn add @paytree/sdk

# pnpm
pnpm add @paytree/sdk
3

Create a Payment

Create your first payment with just a few lines of code:

import PayTree from '@paytree/sdk';

const paytree = new PayTree('pt_live_your_api_key');

const payment = await paytree.payments.create({
  amount: 100.00,
  currency: 'USD',
  description: 'Order #1234',
  customer_email: 'customer@example.com',
  success_url: 'https://yoursite.com/success',
  cancel_url: 'https://yoursite.com/cancel'
});

// Redirect customer to checkout
window.location.href = payment.checkout_url;
4

Handle Webhooks

Set up webhooks to receive real-time payment notifications. See the for details.

5

Go Live!

Once you've tested your integration, switch to your live API keys and start accepting real payments.

Authentication

Secure your API requests

PayTree uses API keys to authenticate requests. You can view and manage your API keys in the merchant dashboard.

Using the Authorization Header

Include your API key in the Authorization header:

Authorization: Bearer pt_live_your_api_key

Using the X-API-Key Header

Alternatively, use the X-API-Key header:

X-API-Key: pt_live_your_api_key

Security: Never expose your API keys in client-side code. Always make API calls from your server.

Safe Testing

Test your integration safely

PayTree provides a safe testing environment. Your test API key (pt_test_) allows you to simulate payments without processing real transactions.

Test Mode

  • Use pt_test_ API key
  • No real transactions
  • Simulated webhook events
  • Test card numbers available

Live Mode

  • Use pt_live_ API key
  • Real cryptocurrency payments
  • Real webhook notifications
  • Actual settlements

Tip: Use environment variables to switch between test and live API keys without changing code.

Payments

Create and manage payments

The Payments API allows you to create, retrieve, and manage payments. Each payment represents a single transaction from a customer.

Create a Payment

POST/v1/payments

Request Parameters

ParameterTypeRequiredDescription
amountnumberYesPayment amount in decimal format
currencystringYesThree-letter ISO currency code (e.g., USD)
descriptionstringNoPayment description
customer_emailstringNoCustomer email for receipt
success_urlstringYesRedirect URL after successful payment
cancel_urlstringYesRedirect URL if payment is cancelled
metadataobjectNoCustom key-value pairs

Response

{
  "id": "pay_abc123def456",
  "object": "payment",
  "amount": 100.00,
  "currency": "USD",
  "status": "pending",
  "checkout_url": "https://checkout.paytree.cc/pay_abc123def456",
  "description": "Order #1234",
  "customer_email": "customer@example.com",
  "metadata": {},
  "created_at": "2024-01-25T10:30:00Z",
  "expires_at": "2024-01-25T11:30:00Z"
}

Webhooks

Receive real-time payment notifications

Webhooks allow you to receive real-time notifications about payment events. When an event occurs, PayTree sends an HTTP POST request to your configured endpoint.

Webhook Events

payment.created

Payment was created

payment.pending

Awaiting customer payment

payment.completed

Payment completed successfully

payment.failed

Payment failed

payment.expired

Payment expired

refund.created

Refund was initiated

Verifying Webhook Signatures

Always verify webhook signatures to ensure the request came from PayTree. Each webhook includes these headers:

  • X-PayTree-Signature - HMAC-SHA256 signature
  • X-PayTree-Timestamp - Unix timestamp
import crypto from 'crypto';

function verifyWebhook(payload, signature, timestamp) {
  const secret = process.env.PAYTREE_WEBHOOK_SECRET;
  const signedPayload = `${timestamp}.${JSON.stringify(payload)}`;
  
  const expectedSignature = crypto
    .createHmac('sha256', secret)
    .update(signedPayload)
    .digest('hex');
  
  return crypto.timingSafeEqual(
    Buffer.from(signature),
    Buffer.from(expectedSignature)
  );
}

// Express webhook handler
app.post('/webhook', (req, res) => {
  const signature = req.headers['x-paytree-signature'];
  const timestamp = req.headers['x-paytree-timestamp'];
  
  if (!verifyWebhook(req.body, signature, timestamp)) {
    return res.status(401).send('Invalid signature');
  }
  
  const { event, data } = req.body;
  
  switch (event) {
    case 'payment.completed':
      // Handle successful payment
      break;
    case 'payment.failed':
      // Handle failed payment
      break;
  }
  
  res.status(200).send('OK');
});

Important: Always return a 200 status code within 30 seconds. PayTree will retry failed webhooks up to 5 times with exponential backoff.

Crypto Settlement

How payments are settled

PayTree settles all payments in cryptocurrency directly to your wallet. No bank account required.

Settlement Timeline

Payment
Confirmation
Settlement (1-24h)

Supported Cryptocurrencies

USDCUSD Coin

Polygon, Ethereum, BSC

USDTTether

Polygon, Ethereum, Tron

BTCBitcoin

Bitcoin, Lightning

ETHEthereum

Ethereum, Polygon

SOLSolana

Solana

MATICPolygon

Polygon

No KYC Required: Start receiving settlements immediately. Your privacy is our priority.

API Endpoints

Complete endpoint reference

Base URL: https://api.paytree.cc

POST/v1/payments
GET/v1/payments/:id
GET/v1/payments
POST/v1/payments/:id/capture
POST/v1/payments/:id/cancel
POST/v1/refunds
GET/v1/refunds/:id
POST/v1/webhooks
GET/v1/webhooks
DELETE/v1/webhooks/:id

Error Handling

HTTP status codes and error responses

PayTree uses standard HTTP status codes to indicate the success or failure of API requests.

CodeStatusDescription
200OKRequest succeeded
201CreatedResource created successfully
400Bad RequestInvalid request parameters
401UnauthorizedInvalid or missing API key
403ForbiddenInsufficient permissions
404Not FoundResource not found
422UnprocessableValidation error
429Too Many RequestsRate limit exceeded
500Server ErrorInternal server error

Error Response Format

{
  "error": {
    "code": "invalid_request",
    "message": "The amount field is required.",
    "param": "amount",
    "doc_url": "https://paytree.cc/docs#payments"
  }
}

Rate Limits

API usage limits

PayTree applies rate limits to ensure fair usage and maintain API performance.

Standard Limits

  • 100 requests per minute
  • 1,000 requests per hour
  • 60 payment creations per hour

Enterprise Limits

  • 1,000 requests per minute
  • Unlimited requests per hour
  • Custom payment limits

Rate limit headers are included in every response:

  • X-RateLimit-Limit - Maximum requests allowed
  • X-RateLimit-Remaining - Requests remaining
  • X-RateLimit-Reset - Unix timestamp when limit resets

Payment Button

Embed payments in your website

Add a PayTree payment button to your website with just a few lines of code.

import { PayTreeButton } from '@paytree/react';

function CheckoutButton() {
  return (
    <PayTreeButton
      apiKey="pt_live_your_api_key"
      amount={99.99}
      currency="USD"
      description="Premium Plan"
      customerEmail="customer@example.com"
      onSuccess={(payment) => {
        console.log('Payment successful:', payment.id);
        // Redirect or update UI
      }}
      onError={(error) => {
        console.error('Payment failed:', error.message);
      }}
      theme="light"
      buttonText="Pay with Crypto"
    />
  );
}

Button Props

PropTypeDefaultDescription
apiKeystring-Your PayTree API key
amountnumber-Payment amount
currencystring"USD"Currency code
themestring"light""light" or "dark"
buttonTextstring"Pay"Button label

WooCommerce

WordPress plugin integration

Accept crypto payments on your WooCommerce store with our official WordPress plugin.

Installation

  1. Download the PayTree WooCommerce plugin
  2. Go to WordPress Admin → Plugins → Add New → Upload Plugin
  3. Upload the plugin ZIP file and click "Install Now"
  4. Activate the plugin
  5. Go to WooCommerce → Settings → Payments → PayTree
  6. Enter your API key and configure settings

Plugin Features

  • Automatic order status updates via webhooks
  • Support for refunds
  • Customizable checkout appearance
  • Multi-currency support
  • Compatible with WooCommerce Subscriptions
Download Plugin

SDKs & Libraries

Official client libraries

Use our official SDKs to integrate PayTree in your favorite programming language.

JS

Node.js

v2.1.0

npm install @paytree/sdk
PY

Python

v1.8.0

pip install paytree
PHP

PHP

v1.5.0

composer require paytree/sdk
RB

Ruby

Coming Soon

GO

Go

Coming Soon

JV

Java

Coming Soon

Need a different language? Contact us at support@paytree.cc to request a new SDK.

Ready to Start Building?

Get your API keys and start accepting crypto payments today.