Quickstart Guide
This guide will help you integrate SwiftPay into your application and start accepting payments.
1. Get Your API Key
Get Approved
Wait for your business to be approved by our team. You’ll receive an email
notification.
Generate API Key
Navigate to Settings → API Keys in your dashboard and create a new API
key.
Keep your API key secure! Never expose it in client-side code or public
repositories.
2. Create a Checkout Session
Create a checkout session to start accepting payments:
curl -X POST https://api.swiftpay.cx/api/checkout/sessions \
-H "Authorization: Bearer mp_live_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"items": [
{
"name": "Premium Plan",
"price": 29.99,
"quantity": 1
}
],
"customer": {
"email": "[email protected]"
},
"urls": {
"success": "https://yoursite.com/success",
"cancel": "https://yoursite.com/cancel"
}
}'
3. Redirect to Checkout
Redirect your customer to the checkout page:
// Redirect to the checkout page
const checkoutUrl = `https://app.swiftpay.cx/checkout/${session.data.id}`;
window.location.href = checkoutUrl;
4. Handle the Result
After payment, the customer is redirected to your success or cancel URL.
For production applications, always verify the payment status via webhook or
API call instead of relying solely on the redirect.
5. Set Up Webhooks (Recommended)
Configure webhooks to receive real-time payment notifications:
curl -X POST https://api.swiftpay.cx/api/webhooks \
-H "Authorization: Bearer mp_live_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"url": "https://yoursite.com/webhooks/swiftpay",
"events": ["checkout.succeeded", "checkout.failed", "refund.created"]
}'
The response includes a secret that you’ll use to verify webhook signatures.
Next Steps