Get your first payment working in under 10 minutes.
Before you begin, ensure you have:
Verify your credentials work:
BASH
curl -X GET "https://gate.reviopay.com/api/v1/clients/" \
-H "Authorization: Bearer YOUR_API_KEY"
Expected Response:
JSON
{
"results": [],
"next": null,
"previous": null
}
If you receive a 401 Unauthorized error, check your API key.
Create a payment with minimal parameters:
BASH
curl -X POST "https://gate.reviopay.com/api/v1/purchases/" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"client": {
"email": "customer@example.com"
},
"purchase": {
"currency": "ZAR",
"products": [
{
"name": "Test Product",
"price": 10000
}
]
},
"brand_id": "YOUR_BRAND_ID"
}'
Response:
JSON
{
"id": "pur_abc123...",
"checkout_url": "https://gate.reviopay.com/p/abc123.../",
"status": "created",
"purchase": {
"currency": "ZAR",
"total": 10000,
"products": [...]
}
}
Open the checkout_url in your browser to see the hosted checkout page.
For e-commerce with a redirect back to your site:
BASH
curl -X POST "https://gate.reviopay.com/api/v1/purchases/" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"client": {
"email": "customer@example.com"
},
"purchase": {
"currency": "ZAR",
"products": [
{
"name": "Test Product",
"price": 10000
}
]
},
"brand_id": "YOUR_BRAND_ID",
"success_redirect": "https://yoursite.com/payment/success",
"failure_redirect": "https://yoursite.com/payment/failure",
"cancel_redirect": "https://yoursite.com/payment/cancel"
}'
After payment:
success_redirectfailure_redirectcancel_redirect
checkout_url from the response
Check the purchase status:
BASH
curl -X GET "https://gate.reviopay.com/api/v1/purchases/PURCHASE_ID/" \
-H "Authorization: Bearer YOUR_API_KEY"
Successful Payment Response:
JSON
{
"id": "pur_abc123...",
"status": "paid",
"purchase": {
"total": 10000,
"currency": "ZAR"
},
"payment_method_details": {
"card": {
"brand": "visa",
"last4": "1111"
}
}
}
Don't rely solely on redirects. Set up webhooks for reliable payment notifications.
Via Dashboard:
purchase.paid, purchase.payment_failure
Via API:
BASH
curl -X POST "https://gate.reviopay.com/api/v1/webhooks/" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"url": "https://yoursite.com/webhooks/precium",
"events": ["purchase.paid", "purchase.payment_failure"]
}'
JSX
// Express.js example
app.post('/webhooks/precium', (req, res) => {
const event = req.body;
switch (event.event_type) {
case 'purchase.paid':
// Fulfill order
console.log('Payment received:', event.data.id);
break;
case 'purchase.payment_failure':
// Handle failure
console.log('Payment failed:', event.data.id);
break;
}
res.status(200).send('OK');
});
Use CVC 123 and any future expiry date.
Bearer YOUR_API_KEY
success_redirect and failure_redirect are valid URLs
Now that you've processed your first payment:
PYTHON
import requests
API_KEY = "your_api_key"
BRAND_ID = "your_brand_id"
BASE_URL = "https://gate.reviopay.com/api/v1"
def create_checkout(customer_email, amount_cents, product_name, order_id):
"""Create a checkout and return the redirect URL"""
response = requests.post(
f"{BASE_URL}/purchases/",
headers={
"Authorization": f"Bearer {API_KEY}",
"Content-Type": "application/json"
},
json={
"client": {
"email": customer_email
},
"purchase": {
"currency": "ZAR",
"products": [{
"name": product_name,
"price": amount_cents
}]
},
"brand_id": BRAND_ID,
"reference": order_id,
"success_redirect": f"https://yoursite.com/orders/{order_id}/success",
"failure_redirect": f"https://yoursite.com/orders/{order_id}/failure",
"cancel_redirect": f"https://yoursite.com/orders/{order_id}/cancel"
}
)
data = response.json()
return {
"purchase_id": data["id"],
"checkout_url": data["checkout_url"]
}
# Usage
checkout = create_checkout(
customer_email="customer@example.com",
amount_cents=29900, # R299.00
product_name="Premium Subscription",
order_id="ORD-12345"
)
print(f"Redirect customer to: {checkout['checkout_url']}")