Automatic Payment Refunds
Aghanim supports automatic payment refunds when your game server rejects a purchase due to expired promotions, insufficient player requirements, or other business logic. This feature allows your webhook to instruct Aghanim to automatically process refunds without manual intervention, improving player experience and reducing support overhead.
Overview
When a player attempts to purchase an item but your game server determines the purchase should be rejected (for example, a promotion has expired), your item.add webhook can respond with a declined error code. If your team has configured automatic refunds in Aghanim, the payment will be automatically refunded.
This prevents players from being charged for items they cannot receive and eliminates the need for manual refund processing.
Automatic refunds must be configured by the Aghanim team. Please contact our integration team to enable automatic refunds for purchases rejected with code="declined".
How It Works
- Player initiates purchase - A player attempts to buy an item through the game hub
- Payment processed - Aghanim processes the payment through the payment provider
- Webhook sent - Aghanim sends an
item.addwebhook to your game server - Game server validates - Your server checks business rules (promotion validity, player eligibility, etc.)
- Purchase declined - If the purchase should be rejected, your server responds with
code="declined" - Automatic refund - If configured, Aghanim automatically processes the refund through the payment provider
Prerequisites
- Configured
item.addwebhook endpoint - HTTPS endpoint capable of processing webhook requests
- Business logic to validate purchases against current promotions and requirements
Implementation
Standard Success Response
For successful purchases, respond with a 200 status code:
{
"status": "ok"
}
Purchase Rejection
To reject a purchase, respond with a 400 status code:
{
"status": "error",
"code": "declined",
"message": "Purchase rejected: promotion has expired"
}
Error Response Schema
| Key | Type | Description | Required? |
|---|---|---|---|
status | string | Must be "error" for rejected purchases. | Yes |
code | string | Error code indicating the reason for the error. | Yes |
message | string | Human-readable error message. | Yes |
Available Error Codes
Standard Error Codes
not_found: The account/player not foundinvalid_signature: The signature was invalidvalidation_error: The request data was invalidbanned: The account/player is banneddeclined: The request was declined due to business rules or restrictions
Only code="declined" will trigger automatic refunds when this feature is enabled by the Aghanim team. Other error codes will not trigger refunds.
Common Rejection Scenarios
Expired Promotion
{
"status": "error",
"code": "declined",
"message": "Purchase rejected: Black Friday promotion ended at midnight"
}
Insufficient Player Level
{
"status": "error",
"code": "declined",
"message": "Purchase rejected: player must be level 10 or higher"
}
Item No Longer Available
{
"status": "error",
"code": "declined",
"message": "Purchase rejected: item is no longer available"
}
Daily Purchase Limit Exceeded
{
"status": "error",
"code": "declined",
"message": "Purchase rejected: daily purchase limit exceeded"
}
Regional Restrictions
{
"status": "error",
"code": "declined",
"message": "Purchase rejected: item not available in player's region"
}
Need help?
Contact our integration team at integration@aghanim.com