Event Types
Card2Crypto sends webhooks for these events:Event | Description | When It’s Sent |
---|---|---|
payment.completed | Payment was successful | After Card2Crypto confirms payment and balance is credited |
payment.failed | Payment failed | When Stripe payment fails or is declined |
payment.refunded | Payment was refunded | After admin processes a refund |
Event Payloads
All webhooks follow the same structure with event-specific differences in thepayment.status
field.
Common Structure
payment.completed
Sent when a payment is successfully processed and the seller’s balance is credited.When It’s Triggered
- Customer completes checkout on your white-labeled page
- Stripe successfully processes the payment
- Card2Crypto credits seller’s balance (amount - 15% fee)
- Webhook is sent to your endpoint
Example Payload
How to Handle
payment.failed
Sent when a payment fails or is declined.When It’s Triggered
- Customer attempts checkout
- Stripe declines the payment (insufficient funds, fraud detection, etc.)
- Webhook is sent to your endpoint
Example Payload
How to Handle
payment.refunded
Sent when an admin processes a refund for a completed payment.When It’s Triggered
- Admin approves a refund request in the dashboard
- Card2Crypto processes the refund
- Seller’s balance is debited
- Webhook is sent to your endpoint
Example Payload
How to Handle
Field Reference
payment object
Field | Type | Description |
---|---|---|
id | string | Unique payment identifier (e.g., pay_abc123 ) |
amount | number | Payment amount in USD (e.g., 100.00 = $100.00) |
currency | string | Always "usd" (USD is the only supported currency) |
status | string | Payment status: completed , failed , or refunded |
customer_email | string | Customer’s email address (optional, can be null ) |
customer_name | string | Customer’s name (optional, can be null ) |
metadata | object | Custom data you provided when creating payment |
created_at | string | ISO 8601 timestamp when payment was created |
completed_at | string | null | ISO 8601 timestamp when payment completed (null for failed payments) |
shop object
Field | Type | Description |
---|---|---|
id | string | Your shop ID |
shop_name | string | Your shop name |
Root fields
Field | Type | Description |
---|---|---|
event | string | Event type: payment.completed , payment.failed , or payment.refunded |
timestamp | string | ISO 8601 timestamp when webhook was sent |
Handling Multiple Events
Use a switch statement to handle different event types:Metadata Usage
Themetadata
object contains any custom data you provided when creating the payment. This is useful for linking webhooks to your internal systems.
When Creating Payment
In Webhook
Best Practices
1. Always Check Event Type
Don’t assume all webhooks arepayment.completed
:
2. Handle Missing Fields
Not all fields are guaranteed to be present:3. Use Metadata Wisely
Store identifiers in metadata to link payments to your system:4. Log All Events
Keep records of all webhooks for debugging:Testing Events
Use the “Test Webhook” button in your shop settings to testpayment.completed
events.
For testing other event types in development, you can manually create test payloads: