Solutions to common integration issues and debugging techniques.
BASH
curl -X GET "https://gate.reviopay.com/api/v1/clients/" \
-H "Authorization: Bearer YOUR_API_KEY"
Symptoms:
JSON
{
"__all__": {
"message": "Invalid or expired authentication token",
"code": "invalid_token"
}
}
Common Causes:
BASH
# Wrong
-H "Authorization: your_api_key"
# Correct
-H "Authorization: Bearer your_api_key"
Resolution:
Symptoms:
JSON
{
"__all__": {
"message": "Authorization header is required",
"code": "missing_authorization"
}
}
Resolution:
Ensure every request includes the header:
PYTHON
headers = {
"Authorization": f"Bearer {api_key}",
"Content-Type": "application/json"
}
Symptoms:
JSON
{
"brand_id": {
"message": "Invalid pk \"xxx\" - object does not exist",
"code": "does_not_exist"
}
}
Causes:
Resolution:
xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
Symptoms:
checkout_url is null in responsedirect_post_url is null
Causes:
success_redirect or failure_redirectpurchase.request_client_details is not empty
Resolution:
Include redirect URLs:
JSON
{
"success_redirect": "https://yoursite.com/success",
"failure_redirect": "https://yoursite.com/failure",
...
}
Symptoms:
Diagnosis:
PYTHON
# Check how total is calculated
total = sum(
product['price'] * int(product.get('quantity', '1'))
for product in products
)
Common Issues:
Resolution:
JSON
{
"products": [
{"name": "Item", "price": 5000, "quantity": "2"} // quantity is STRING
],
"total_override": null // Don't set unless intentional
}
Symptoms:
Possible Causes:
Debugging:
BASH
# Check purchase for detailed error
GET /purchases/{id}/
# Response includes:
{
"status": "failed",
"payment_failure_reason": "do_not_honour"
}
Symptoms:
3ds_authentication_failed
Causes:
Resolution:
Symptoms:
pending indefinitely
Diagnosis:
BASH
# Check current status
GET /purchases/{id}/
# Response
{
"status": "pending",
"events": [...], // Check for processing events
"payment_method_details": {...}
}
Causes:
Resolution:
Checklist:
Debug Steps:
BASH
GET /webhooks/
# Check your endpoints are listed
BASH
curl -X POST "https://yoursite.com/webhooks/precium" \
-H "Content-Type: application/json" \
-d '{"test": true}'
Symptoms:
Debug:
PYTHON
import hmac
import hashlib
def debug_signature(payload, received_sig, secret):
calculated = hmac.new(
secret.encode(),
payload.encode(),
hashlib.sha256
).hexdigest()
print(f"Received: {received_sig}")
print(f"Calculated: {calculated}")
print(f"Match: {received_sig == calculated}")
return received_sig == calculated
Common Issues:
PYTHON
# Wrong - parsed JSON
payload = json.dumps(request.json)
# Correct - raw body
payload = request.get_data(as_text=True)
Cause: Webhook retry on non-200 response
Resolution:
PYTHON
# Implement idempotency
processed_events = set()
def handle_webhook(event):
event_id = event.get('id')
if event_id in processed_events:
return # Already processed
processed_events.add(event_id)
# Process event...
Best Practice: Store event IDs in the database:
SQL
CREATE TABLE webhook_events (
event_id VARCHAR(50) PRIMARY KEY,
event_type VARCHAR(50),
processed_at TIMESTAMP DEFAULT NOW()
);
Symptoms:
force_recurring: true set but no token
Causes:
skip_capture
Debug:
BASH
# Check if payment completed
GET /purchases/{id}/
# Verify status is "paid" or "hold"
# List client tokens
GET /clients/{client_id}/recurring_tokens/
Resolution:
For zero-amount tokenization:
JSON
{
"purchase": {
"products": [{"name": "Auth", "price": 0}]
},
"skip_capture": true,
"force_recurring": true
}
Symptoms:
/charge/ endpoint returns error
Error Types:
Debug:
BASH
# Verify token exists
GET /clients/{client_id}/recurring_tokens/{token_id}/
# Check original purchase
GET /purchases/{token_id}/
Causes:
purchase.request_client_details not empty
Resolution:
JSON
{
"success_redirect": "https://...", // Required
"failure_redirect": "https://...", // Required
"purchase": {
"request_client_details": [] // Must be empty
}
}
Symptoms:
Debug Checklist:
MM/YY
Field Requirements:
HTML
<!-- Exact field names required -->
<input name="cardholder_name"> <!-- Latin, max 30 chars -->
<input name="card_number"> <!-- Digits only, max 19 -->
<input name="expires"> <!-- MM/YY format -->
<input name="cvc"> <!-- 3-4 digits -->
<input name="pm" value="visa"> <!-- Payment method -->
Diagnosis:
PYTHON
import time
start = time.time()
response = requests.get(url, headers=headers)
elapsed = time.time() - start
print(f"Response time: {elapsed:.2f}s")
Causes:
Resolution:
Symptoms:
JSON
HTTP 429 Too Many Requests
Headers:
X-RateLimit-Limit: 100
X-RateLimit-Remaining: 0
X-RateLimit-Reset: 1619740860
Resolution:
PYTHON
import time
def api_request_with_backoff(func, max_retries=3):
for attempt in range(max_retries):
response = func()
if response.status_code == 429:
reset_time = int(response.headers.get('X-RateLimit-Reset', 0))
wait = max(reset_time - time.time(), 2 ** attempt)
print(f"Rate limited. Waiting {wait:.0f}s...")
time.sleep(wait)
continue
return response
raise Exception("Rate limit exceeded after retries")
PYTHON
import logging
logging.basicConfig(level=logging.DEBUG)
# Log all requests
import http.client
http.client.HTTPConnection.debuglevel = 1
PYTHON
def debug_response(response):
print(f"Status: {response.status_code}")
print(f"Headers: {dict(response.headers)}")
print(f"Body: {response.text}")
BASH
curl -v -X POST "https://gate.reviopay.com/api/v1/purchases/" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"..."}'
Email: support@precium.com
Include: