Quick Start
Get up and running in 5 minutes
Follow these steps to integrate PayTree into your application and start accepting crypto payments.
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.
Install the SDK
Install our official SDK for your platform:
# npm
npm install @paytree/sdk
# yarn
yarn add @paytree/sdk
# pnpm
pnpm add @paytree/sdkCreate 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;Handle Webhooks
Set up webhooks to receive real-time payment notifications. See the for details.
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_keyUsing the X-API-Key Header
Alternatively, use the X-API-Key header:
X-API-Key: pt_live_your_api_keySecurity: 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
| Parameter | Type | Required | Description |
|---|---|---|---|
amount | number | Yes | Payment amount in decimal format |
currency | string | Yes | Three-letter ISO currency code (e.g., USD) |
description | string | No | Payment description |
customer_email | string | No | Customer email for receipt |
success_url | string | Yes | Redirect URL after successful payment |
cancel_url | string | Yes | Redirect URL if payment is cancelled |
metadata | object | No | Custom 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.createdPayment was created
payment.pendingAwaiting customer payment
payment.completedPayment completed successfully
payment.failedPayment failed
payment.expiredPayment expired
refund.createdRefund 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 signatureX-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
Supported Cryptocurrencies
Polygon, Ethereum, BSC
Polygon, Ethereum, Tron
Bitcoin, Lightning
Ethereum, Polygon
Solana
Polygon
No KYC Required: Start receiving settlements immediately. Your privacy is our priority.
API Endpoints
Complete endpoint reference
Base URL: https://api.paytree.cc
/v1/payments/v1/payments/:id/v1/payments/v1/payments/:id/capture/v1/payments/:id/cancel/v1/refunds/v1/refunds/:id/v1/webhooks/v1/webhooks/v1/webhooks/:idError Handling
HTTP status codes and error responses
PayTree uses standard HTTP status codes to indicate the success or failure of API requests.
| Code | Status | Description |
|---|---|---|
| 200 | OK | Request succeeded |
| 201 | Created | Resource created successfully |
| 400 | Bad Request | Invalid request parameters |
| 401 | Unauthorized | Invalid or missing API key |
| 403 | Forbidden | Insufficient permissions |
| 404 | Not Found | Resource not found |
| 422 | Unprocessable | Validation error |
| 429 | Too Many Requests | Rate limit exceeded |
| 500 | Server Error | Internal 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 allowedX-RateLimit-Remaining- Requests remainingX-RateLimit-Reset- Unix timestamp when limit resets
WooCommerce
WordPress plugin integration
Accept crypto payments on your WooCommerce store with our official WordPress plugin.
Installation
- Download the PayTree WooCommerce plugin
- Go to WordPress Admin → Plugins → Add New → Upload Plugin
- Upload the plugin ZIP file and click "Install Now"
- Activate the plugin
- Go to WooCommerce → Settings → Payments → PayTree
- 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
SDKs & Libraries
Official client libraries
Use our official SDKs to integrate PayTree in your favorite programming language.
Node.js
v2.1.0
npm install @paytree/sdkPython
v1.8.0
pip install paytreePHP
v1.5.0
composer require paytree/sdkRuby
Coming Soon
Go
Coming Soon
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.