Testing Your Integration
Test your integration before going live.
Table of contents
- Test Mode vs Live Mode
- Getting Test Keys
- Making Test Payments
- Testing Webhooks
- Test Scenarios
- Integration Checklist
- Going Live
- Debugging Tips
Test Mode vs Live Mode
Coinskro Pay provides two environments:
| Mode | API Key Prefix | Real Money? | Use For |
|---|---|---|---|
| Test | sk_test_ | No | Development & testing |
| Live | sk_live_ | Yes | Production |
Always use test keys during development. Test payments don’t involve real cryptocurrency.
Getting Test Keys
- Log in to your Dashboard
- Select your integration
- Toggle to Test Mode (top-right switch)
- Copy your Test Secret Key
Making Test Payments
Create a Test Payment
Use your test secret key:
curl -X PUT https://api.coinskro.com/payment/create \
-H "Authorization: Bearer sk_test_xxxxxxxxxxxx" \
-H "Content-Type: application/json" \
-d '{
"amount": 50.00,
"currency": "USDT",
"payment_type": "deposit",
"customer_email": "test@example.com"
}'
Complete the Test Payment
When redirected to the payment page in test mode, you’ll see a “Simulate Payment” button. Click it to simulate:
- ✅ Successful payment - Triggers
payment_completedwebhook - ❌ Failed payment - Triggers
payment_failedwebhook - ⏰ Abandoned payment - Close the page (triggers
payment_abandonedafter timeout)
Testing Webhooks
Local Development
Use ngrok to receive webhooks on your local machine:
# Terminal 1: Start your server
npm start # or python app.py, go run main.go, etc.
# Terminal 2: Start ngrok
ngrok http 3000
Copy the ngrok URL and set it as your webhook URL in the dashboard:
https://abc123.ngrok.io/webhooks/coinskro
Webhook Testing Checklist
Test these scenarios:
- Payment completed - order marked as paid
- Payment failed - user shown error message
- Payment abandoned - order remains pending
- Duplicate webhook - order not processed twice
- Invalid webhook - request rejected gracefully
Manual Webhook Testing
Test your webhook endpoint with curl:
curl -X POST https://yoursite.com/webhooks/coinskro \
-H "Content-Type: application/json" \
-H "X-Signature: YOUR_COMPUTED_SIGNATURE" \
-H "X-Event-Id: test-event-001" \
-d '{
"event_id": "test-event-001",
"payment_id": "550e8400-e29b-41d4-a716-446655440000",
"currency": "USDT",
"amount": 50.00,
"payment_reference": "ORDER_TEST_001",
"payment_status": "completed",
"service_fee": 0.25,
"customer_email": "test@example.com",
"customer_reference": "CUST_TEST_001",
"integration_id": "test-integration-id",
"event_type": "payment_completed",
"timestamp": 1738838100
}'
To compute a valid
X-Signaturefor testing, see Verifying Webhook Signatures.
Test Scenarios
Scenario 1: Successful Payment
- Create a payment
- Redirect to payment URL
- Click “Simulate Successful Payment”
- Verify:
- Webhook received with
payment_completed - Order marked as paid in your database
- Customer redirected to
success_url
- Webhook received with
Scenario 2: Failed Payment
- Create a payment
- Redirect to payment URL
- Click “Simulate Failed Payment”
- Verify:
- Customer redirected to
failure_url - Order remains unpaid
- Customer redirected to
Scenario 3: Abandoned Payment
- Create a payment
- Redirect to payment URL
- Close the browser tab
- Wait 10 minutes (test mode timeout)
- Verify:
- Webhook received with
payment_abandoned - Order remains pending
- Webhook received with
Scenario 4: Duplicate Webhooks
- Complete a test payment
- Manually retry the webhook from dashboard
- Verify:
- Second webhook processed without errors
- Order not fulfilled twice
- No duplicate emails sent
Integration Checklist
Before going live, verify:
Payment Flow
- Payments created successfully
- Customers redirected to payment page
- Success URL receives customer after payment
- Failure URL receives customer on failure
Webhooks
- Webhook endpoint accessible from internet
- Webhook returns 200 OK quickly
payment_completedwebhook fulfills orders- Duplicate webhooks handled (idempotency)
- Webhook errors logged for debugging
Error Handling
- Invalid API key shows proper error
- Invalid amount shows proper error
- Network errors handled gracefully
- User sees friendly error messages
Security
- Secret key stored securely (environment variable)
- Secret key never exposed in frontend code
- HTTPS used for all API calls
- Webhook
X-Signatureverified on every request
Going Live
Once testing is complete:
- Switch to Live Mode in dashboard
- Copy your Live Secret Key
- Update your environment variable:
# Development
COINSKRO_SECRET_KEY=sk_test_xxxxxxxxxxxx
# Production
COINSKRO_SECRET_KEY=sk_live_xxxxxxxxxxxx
- Deploy your application
- Make a small real payment to verify
Double-check you’re using the live key in production. Test payments won’t work with live keys.
Debugging Tips
Payment Not Created
401 Unauthorized: Missing secret key
→ Check Authorization header format: Bearer sk_xxx
403 Integration is not yet approved
→ Wait for your integration to be approved, or use test mode
Webhook Not Received
- Check webhook is activated in dashboard
- Verify URL is publicly accessible
- Check server logs for incoming requests
- Try the webhook test tool in dashboard
Payment Status Not Updating
- Check webhook logs in dashboard
- Verify webhook returns 200 OK
- Check your server logs for errors
- Ensure database updates are working