Protecting Your API Key
The single most common cause of API key compromise is accidental exposure: committing a key to source control, embedding it in client-side JavaScript, or logging it in plain text. Follow these rules to prevent that.Never expose your key on the client side
Your API Key must only ever exist on your server. It must never appear in:- Browser JavaScript (React, Vue, vanilla JS, etc.)
- Native or hybrid mobile apps (iOS, Android, React Native, Flutter)
- Public or private Git repositories (even in commit history)
- Build artifacts, Docker images, or CI/CD logs
Store keys in environment variables
Never hardcode your API Key as a string literal in source code. Load it from an environment variable at runtime:.env file on disk.
Add
.env to your .gitignore file to ensure it is never committed to version control.Use separate keys for test and production
CertoPay provides distinct keys for each environment. Always:- Use a test key (
sk_test_...) during development and staging - Use a live key (
sk_live_...) only in your production environment - Never mix the two — a test key cannot process real payments, and a live key in a test environment is an unnecessary risk
Rotate keys regularly
Periodic key rotation limits the damage window if a key is ever silently compromised. Rotate your active key by calling:Webhook Verification
CertoPay sends webhook events (such astransaction.paid) to your endpoint when payment status changes. However, webhook payloads alone cannot be trusted as proof of payment — an attacker could POST a forged PAID payload directly to your endpoint.
Always verify by querying the transaction
After receiving any webhook, confirm the actual transaction status by making an authenticated API call:status is PAID or CAPTURED.
Webhook endpoint requirements
- Your webhook endpoint must use HTTPS. CertoPay will not deliver events to plain HTTP endpoints.
- Respond with HTTP
200as quickly as possible — do the heavy processing asynchronously (queue a job, update the DB, etc.) to avoid delivery timeouts. - If your endpoint returns a non-
2xxstatus, CertoPay will attempt redelivery. Ensure your handler is idempotent so duplicate deliveries don’t cause double-fulfillment.
Rate Limits
CertoPay enforces a default limit of 100 requests per minute per API Key to protect service stability. Exceeding this limit returns anHTTP 429 Too Many Requests response.
Implement exponential backoff on 429
When your integration receives a429 response, do not immediately retry — that will only worsen the situation. Instead, wait an exponentially increasing amount of time between retries:
HTTPS Only
All communication with the CertoPay API must use HTTPS. Plain HTTP is not supported and connections will be refused. This applies to:- Every outbound API call from your server to
https://v2.certopaybrasil.com/api - Your inbound webhook endpoint, which must also be served over HTTPS
TLS certificates on your webhook endpoint must be valid and issued by a trusted Certificate Authority. Self-signed certificates will cause webhook delivery failures.