
Webhooks
The Product Expiration Webhooks API provides optional batch notifications when payment products expire. This webhook allows you to track and manage expired payment links, virtual accounts, and QRIS transactions in a single notification, helping you maintain clean product inventory and improve operational efficiency. Alternatively, you can also query the status of specific products (Virtual Accounts, QRIS, or Payment Links) directly through their respective API endpoints for real-time updates.
| Method | Path | Format | Authentication |
|---|---|---|---|
| POST | https://your-webhook-url/callback | json | HMAC SHA512 Signature |
Important: This webhook is completely optional. You can choose not to configure this webhook if you don’t need expiration notifications. Your payment products will still work normally - this webhook only serves as a notification mechanism when products expire.
This webhook sends a POST request to your configured product_expiration_notif_url when payment products (Payment Links, Virtual Accounts, or QRIS transactions) reach their expiration time. Unlike other webhooks, this is a batch notification that can include multiple expired products in a single webhook call.

The product_expiration_notif_url configuration can be accessed from the settings page as shown in the screenshot above.
When payment products expire, Singa Payment Gateway can send a batch webhook notification to your registered callback URL. The request includes security headers for verification.
| Field | Value | Type | Mandatory | Length | Description | Example |
|---|---|---|---|---|---|---|
| Content-Type | application/json | Alphabetic | Mandatory | Specifies JSON format for the request body | application/json | |
| User-Agent | SingaPaymentGateway/1.0 | Alphabetic | Mandatory | Identifies the source of the webhook | SingaPaymentGateway/1.0 | |
| X-Signature | Alphanumeric | Optional* | 128 | HMAC SHA512 signature for request verification (included when signature security is enabled) | 5f4dcc3b5aa765d61d8327deb882cf99… | |
| X-Timestamp | Numeric | Optional* | 10 | Unix timestamp in seconds when the request was sent (included when signature security is enabled) | 1695711945 | |
| Authorization | Bearer <random_token> | Alphanumeric | Optional* | Bearer token with random value (system-generated, not user token) | Bearer a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6 |
* Note: Headers marked as “Optional” are included when you enable signature-based security. See the Security Mechanisms section below to understand the different security options available.
Authorization Note: The access token in the Authorization header is a randomly generated string (not a user access token) because this webhook is triggered by the system’s scheduled expiration checker, not by a user action.
| Field | Type | Mandatory | Length | Description | Example |
|---|---|---|---|---|---|
| status | Numeric | Mandatory | 3 | HTTP Status Code | 200 |
| success | Boolean | Mandatory | 1 | Indicates if the webhook was sent successfully | true |
| event | String | Mandatory | - | Event type identifier (always “product_expiration”) | product_expiration |
| timestamp | String | Mandatory | - | Event timestamp in format “d M Y H:i:s” | 26 Dec 2025 14:00:00 |
| merchant | Object | Mandatory | - | Merchant information | - |
| > id | Numeric | Mandatory | - | Merchant ID | 123 |
| > name | String | Mandatory | - | Merchant name | PT Example Indonesia |
| data | Object | Mandatory | - | Container for expired products | - |
| > payment_links | Array | Mandatory | - | List of expired payment links | [] |
| >> id | Numeric | Mandatory | - | Payment link ID | 456 |
| >> reff_no | String | Mandatory | - | Payment link reference number | PL-20251220-XYZ789 |
| >> title | String | Mandatory | - | Payment link title | Donasi Amal |
| >> status | String | Mandatory | - | Payment link status (should be “expired”) | expired |
| >> expired_at | String | Mandatory | - | Expiration datetime | 2025-12-26 14:00:00 |
| > virtual_accounts | Array | Mandatory | - | List of expired virtual accounts | [] |
| >> id | Numeric | Mandatory | - | Virtual account ID | 789 |
| >> reff_no | String | Mandatory | - | VA reference number | VA-20251226-ABC123 |
| >> virtual_account_number | String | Mandatory | 16 | Virtual account number | 7872955146576837 |
| >> status | String | Mandatory | - | VA status (should be “expired”) | expired |
| >> expired_at | String | Mandatory | - | Expiration datetime | 2025-12-26 14:00:00 |
| > qris_transactions | Array | Mandatory | - | List of expired QRIS transactions | [] |
| >> id | Numeric | Mandatory | - | QRIS transaction ID | 321 |
| >> reff_no | String | Mandatory | - | QRIS reference number | QRIS-20251226-DEF456 |
| >> nmid | String | Mandatory | - | NMID (merchant identifier for QRIS) | ID1234567890123 |
| >> status | String | Mandatory | - | QRIS status (should be “expired”) | expired |
| >> expired_at | String | Mandatory | - | Expiration datetime | 2025-12-26 14:00:00 |
| summary | Object | Mandatory | - | Summary of expiration counts | - |
| > total_expired | Numeric | Mandatory | - | Total count of all expired products | 15 |
| > payment_links_count | Numeric | Mandatory | - | Count of expired payment links | 5 |
| > virtual_accounts_count | Numeric | Mandatory | - | Count of expired virtual accounts | 7 |
| > qris_transactions_count | Numeric | Mandatory | - | Count of expired QRIS transactions | 3 |
Batch Expiration: Here’s an example with multiple product types expired.
{
"status": 200,
"success": true,
"event": "product_expiration",
"timestamp": "26 Dec 2025 14:00:00",
"merchant": {
"id": 123,
"name": "PT Example Indonesia"
},
"data": {
"payment_links": [
{
"id": 456,
"reff_no": "PL-20251220-XYZ789",
"title": "Donasi Amal",
"status": "expired",
"expired_at": "2025-12-26 14:00:00"
},
{
"id": 457,
"reff_no": "PL-20251221-ABC123",
"title": "Pembayaran Tagihan",
"status": "expired",
"expired_at": "2025-12-26 14:00:00"
}
],
"virtual_accounts": [
{
"id": 789,
"reff_no": "VA-20251226-ABC123",
"virtual_account_number": "7872955146576837",
"status": "expired",
"expired_at": "2025-12-26 14:00:00"
},
{
"id": 790,
"reff_no": "VA-20251226-DEF456",
"virtual_account_number": "7872955146576838",
"status": "expired",
"expired_at": "2025-12-26 14:00:00"
},
{
"id": 791,
"reff_no": "VA-20251226-GHI789",
"virtual_account_number": "7872955146576839",
"status": "expired",
"expired_at": "2025-12-26 14:00:00"
}
],
"qris_transactions": [
{
"id": 321,
"reff_no": "QRIS-20251226-DEF456",
"nmid": "ID1234567890123",
"status": "expired",
"expired_at": "2025-12-26 14:00:00"
}
]
},
"summary": {
"total_expired": 6,
"payment_links_count": 2,
"virtual_accounts_count": 3,
"qris_transactions_count": 1
}
}
Single Product Type: You might receive only one type of expired product.
{
"status": 200,
"success": true,
"event": "product_expiration",
"timestamp": "26 Dec 2025 14:00:00",
"merchant": {
"id": 123,
"name": "PT Example Indonesia"
},
"data": {
"payment_links": [],
"virtual_accounts": [
{
"id": 789,
"reff_no": "VA-20251226-ABC123",
"virtual_account_number": "7872955146576837",
"status": "expired",
"expired_at": "2025-12-26 14:00:00"
}
],
"qris_transactions": []
},
"summary": {
"total_expired": 1,
"payment_links_count": 0,
"virtual_accounts_count": 1,
"qris_transactions_count": 0
}
}
To ensure the security and authenticity of webhook requests from Singa Payment Gateway, we provide two recommended security mechanisms. You can choose one or combine both for maximum protection.
Important Note: Signature validation is optional but highly recommended. You can secure your webhook endpoint using either IP whitelisting, signature validation, or both methods together.
This is the simplest security method where you restrict webhook access to only authorized IP addresses from Singa Payment Gateway.
How it works:
Pros:
Cons:
Implementation Example (Nginx):
location /webhook/product-expiration {
# Only allow Singa Payment Gateway IPs
allow 103.xxx.xxx.xxx; # Replace with actual IPs from Singa
allow 103.xxx.xxx.xxx; # Replace with actual IPs from Singa
deny all;
proxy_pass http://your-backend;
}
Implementation Example (PHP):
<?php
// Define allowed IPs (get these from Singa Payment Gateway)
$allowedIPs = [
'103.xxx.xxx.xxx',
'103.xxx.xxx.xxx',
];
$requestIP = $_SERVER['REMOTE_ADDR'];
if (!in_array($requestIP, $allowedIPs)) {
http_response_code(403);
echo json_encode(['status' => 'error', 'message' => 'Access denied']);
exit;
}
// Process webhook...
?>
This method uses cryptographic signatures to verify that:
How it works:
Pros:
Cons:
When to use: Production environments, handling sensitive data, or when maximum security is required.
See the detailed implementation guide in the “How to Validate Signature” section below.
For production environments, we strongly recommend using both IP whitelisting and signature validation together.
Implementation order:
Benefits:
Example Implementation:
<?php
// Layer 1: IP Whitelist
$allowedIPs = ['103.xxx.xxx.xxx', '103.xxx.xxx.xxx'];
$requestIP = $_SERVER['REMOTE_ADDR'];
if (!in_array($requestIP, $allowedIPs)) {
http_response_code(403);
exit;
}
// Layer 2: Signature Validation
$requestBody = file_get_contents('php://input');
$headers = getallheaders();
$clientSecret = 'your-client-secret';
$endpoint = '/webhook/product-expiration';
if (!validateWebhookSignature($requestBody, $headers, $clientSecret, $endpoint)) {
http_response_code(401);
exit;
}
// Both checks passed - process webhook
$payload = json_decode($requestBody, true);
// ... process expiration notification ...
?>
| Recommended Approach | Reason |
|---|---|
| IP Whitelist only | Simple to implement, easy to debug, suitable for testing environments |
| Signature validation only | Higher security, good for testing signature implementation |
| IP Whitelist + Signature ⭐ | Maximum security, industry best practice, recommended for production |
| IP Whitelist + Signature + Timestamp validation | Additional protection against replay attacks for high-security requirements |
To implement IP whitelisting, contact our support team or check your merchant dashboard for the official list of Singa Payment Gateway IP addresses.
Note: We will notify you in advance if our IP addresses change.
The X-Signature header is a security mechanism that ensures the webhook request is authentic and comes from Singa Payment Gateway. This signature is generated using HMAC SHA512 algorithm.
Implementation Note: Product Expiration webhooks use the signature generation method from the GeneratesCallbackSignature trait, which is the standard signature implementation across most webhooks.
Note: While signature validation is optional, we strongly recommend implementing it, especially for production environments, to ensure maximum security and data integrity.
The signature is created using a multi-step process that combines the request method, endpoint, access token, hashed body, and timestamp.
Reference Implementation:
App\Traits\GeneratesCallbackSignatureGeneratesCallbackSignature::generateHeadersCallback() (lines 30-81)GeneratesCallbackSignature::hashNormalizedJson() (lines 90-118)GeneratesCallbackSignature::sortRecursive() (lines 129-143)GeneratesCallbackSignature::extractEndpoint() (lines 154-167)Extract the following headers from the incoming webhook request:
Important: The access token in this webhook is a randomly generated string, not a user access token, since the webhook is triggered by the system’s scheduled job.
Retrieve your Client Secret from the merchant dashboard. This is the same secret used for API authentication and is required as the HMAC key for signature verification.
Important: The Client Secret must be kept secure and never exposed in client-side code or logs.
Extract the endpoint path from your webhook URL. For example:
https://yourdomain.com/webhook/product-expiration?param=value/webhook/product-expiration?param=valueThe endpoint includes the path and any query parameters.
The request body must be normalized before hashing to ensure consistent results:
JSON_UNESCAPED_UNICODE - Don’t escape Unicode charactersJSON_UNESCAPED_SLASHES - Don’t escape forward slashesExample:
Original JSON: {"status":200,"success":true,"event":"product_expiration"}
After sorting: {"event":"product_expiration","status":200,"success":true}
SHA-256 Hash: 5f4dcc3b5aa765d61d8327deb882cf99acd3d28e5cf0e661c02c8e8e6e8e6f9a
Concatenate the following values with colon (:) as separator:
StringToSign = METHOD + ":" + ENDPOINT + ":" + ACCESS_TOKEN + ":" + HASHED_BODY + ":" + TIMESTAMP
Example:
Method: POST
Endpoint: /webhook/product-expiration
Access Token: a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6
Hashed Body: 5f4dcc3b5aa765d61d8327deb882cf99acd3d28e5cf0e661c02c8e8e6e8e6f9a
Timestamp: 1695711945
StringToSign = POST:/webhook/product-expiration:a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6:5f4dcc3b5aa765d61d8327deb882cf99acd3d28e5cf0e661c02c8e8e6e8e6f9a:1695711945
Use your Client Secret as the HMAC key and hash the string to sign:
Calculated Signature = HMAC-SHA512(StringToSign, Client Secret)
Compare the calculated signature with the signature from the X-Signature header using a constant-time comparison to prevent timing attacks.
Important: Use hash_equals() in PHP, crypto.timingSafeEqual() in Node.js, or hmac.compare_digest() in Python for secure comparison.
if (hash_equals($calculatedSignature, $receivedSignature)) {
// Signature is valid - process webhook
} else {
// Signature is invalid - reject request
}
Best Practices
hash_equals(), crypto.timingSafeEqual(), or hmac.compare_digest())client_secret as the HMAC keyCommon Mistakes to Avoid
:, not _ or -)Your webhook endpoint must return an appropriate HTTP response:
When the webhook is processed successfully:
Status Code: 200 OK
{
"status": "success"
}
Invalid Signature (401 Unauthorized):
{
"status": "error",
"message": "Invalid signature"
}
Processing Error (500 Internal Server Error):
{
"status": "error",
"message": "Failed to process webhook"
}
Important: Singa Payment Gateway will retry failed webhooks (non-200 responses) up to 3 times with exponential backoff.
This webhook is completely optional. If you don’t configure a product_expiration_notif_url, no webhooks will be sent for product expirations. Your payment products will still expire normally and change status accordingly - this webhook only serves as a notification mechanism.
When to use this webhook:
When you can skip this webhook:
This webhook is unique - it sends batch notifications containing multiple expired products in a single webhook call:
Example scenarios:
// Scenario 1: Only VAs expired
{
"data": {
"payment_links": [], // Empty
"virtual_accounts": [/* 10 expired VAs */],
"qris_transactions": [] // Empty
},
"summary": {
"total_expired": 10,
"virtual_accounts_count": 10
}
}
// Scenario 2: Mixed expired products
{
"data": {
"payment_links": [/* 3 expired PLs */],
"virtual_accounts": [/* 5 expired VAs */],
"qris_transactions": [/* 2 expired QRIS */]
},
"summary": {
"total_expired": 10,
"payment_links_count": 3,
"virtual_accounts_count": 5,
"qris_transactions_count": 2
}
}
When handling batch notifications, iterate through each product type:
$payload = json_decode($requestBody, true);
// Process expired payment links
foreach ($payload['data']['payment_links'] as $paymentLink) {
$id = $paymentLink['id'];
$reffNo = $paymentLink['reff_no'];
$title = $paymentLink['title'];
// Update your database
updatePaymentLinkStatus($id, 'expired');
// Notify customer
notifyCustomerPaymentLinkExpired($reffNo, $title);
// Log for analytics
logExpiration('payment_link', $id);
}
// Process expired virtual accounts
foreach ($payload['data']['virtual_accounts'] as $va) {
$id = $va['id'];
$vaNumber = $va['virtual_account_number'];
// Update your database
updateVAStatus($id, 'expired');
// Archive VA number
archiveVirtualAccount($vaNumber);
// Log for analytics
logExpiration('virtual_account', $id);
}
// Process expired QRIS transactions
foreach ($payload['data']['qris_transactions'] as $qris) {
$id = $qris['id'];
$nmid = $qris['nmid'];
// Update your database
updateQrisStatus($id, 'expired');
// Log for analytics
logExpiration('qris', $id);
}
// Use summary for quick stats
$totalExpired = $payload['summary']['total_expired'];
if ($totalExpired > 100) {
alertHighExpirationRate($totalExpired);
}
The webhook can contain three types of expired products:
Payment Links (data.payment_links)
Virtual Accounts (data.virtual_accounts)
QRIS Transactions (data.qris_transactions)
Note: The webhook sends minimal data for each expired product to keep the payload size manageable for batch notifications. The following fields are NOT included:
If you need complete product details, use the product’s id or reff_no to query via API.
Important: This webhook uses human-readable timestamp format, not Unix timestamps:
d M Y H:i:s (e.g., “26 Dec 2025 14:00:00”)timestamp (root level)expired_at (for each product)Parsing timestamps:
// PHP
$timestamp = $payload['timestamp']; // "26 Dec 2025 14:00:00"
$date = DateTime::createFromFormat('d M Y H:i:s', $timestamp);
// Or use Carbon (Laravel)
$date = \Carbon\Carbon::createFromFormat('d M Y H:i:s', $timestamp);
# Python
from datetime import datetime
timestamp = payload['timestamp'] # "26 Dec 2025 14:00:00"
date = datetime.strptime(timestamp, '%d %b %Y %H:%M:%S')
// JavaScript
const timestamp = payload.timestamp; // "26 Dec 2025 14:00:00"
const date = new Date(timestamp);
The Authorization header contains a randomly generated token, not a user access token:
// This is NOT a user JWT token - it's a random string
Authorization: Bearer a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6
Why random?
Str::random(32) for each webhookFor signature validation:
Use unique reference numbers to prevent duplicate processing:
// Generate unique webhook identifier
$webhookId = $payload['event'] . '_' . $payload['merchant']['id'] . '_' . strtotime($payload['timestamp']);
// Check if already processed
if (isWebhookProcessed($webhookId)) {
// Already processed, return success without re-processing
return http_response_code(200);
}
// Process webhook
processExpirationBatch($payload);
// Mark as processed
markWebhookProcessed($webhookId);
Use the summary object for quick stats and alerting:
$summary = $payload['summary'];
// Log batch statistics
logExpirationBatch([
'total' => $summary['total_expired'],
'payment_links' => $summary['payment_links_count'],
'vas' => $summary['virtual_accounts_count'],
'qris' => $summary['qris_transactions_count'],
'timestamp' => $payload['timestamp']
]);
// Alert on high expiration rates
if ($summary['total_expired'] > 50) {
sendAlert("High expiration rate: {$summary['total_expired']} products expired");
}
// Track expiration patterns
if ($summary['payment_links_count'] > $summary['total_expired'] * 0.7) {
// More than 70% are payment links
alertTeam("Most expirations are payment links - review link expiration settings");
}
Handle cases where arrays might be empty:
// Check if any products expired
if ($payload['summary']['total_expired'] === 0) {
// No products expired (shouldn't normally happen, but be safe)
return http_response_code(200);
}
// Check each product type before processing
if (!empty($payload['data']['payment_links'])) {
processExpiredPaymentLinks($payload['data']['payment_links']);
}
if (!empty($payload['data']['virtual_accounts'])) {
processExpiredVirtualAccounts($payload['data']['virtual_accounts']);
}
if (!empty($payload['data']['qris_transactions'])) {
processExpiredQrisTransactions($payload['data']['qris_transactions']);
}
When does this webhook fire?
Important: Don’t rely on this webhook for real-time expiration detection. If you need immediate expiration handling, poll product status via API or use individual product webhooks.
1. Automated Product Cleanup:
// Archive expired products to historical table
foreach ($payload['data']['virtual_accounts'] as $va) {
archiveExpiredVA($va['id'], $va['expired_at']);
deleteFromActiveVAs($va['id']);
}
2. Customer Re-engagement:
// Send follow-up for expired payment links
foreach ($payload['data']['payment_links'] as $pl) {
$customer = getCustomerByPaymentLink($pl['reff_no']);
if ($customer) {
sendEmail($customer->email, "Your payment link expired. Here's a new one!");
createNewPaymentLink($customer);
}
}
3. Analytics and Reporting:
// Track expiration patterns
generateExpirationReport([
'date' => $payload['timestamp'],
'total' => $payload['summary']['total_expired'],
'by_type' => [
'payment_links' => $payload['summary']['payment_links_count'],
'virtual_accounts' => $payload['summary']['virtual_accounts_count'],
'qris' => $payload['summary']['qris_transactions_count'],
]
]);
4. Operations Monitoring:
// Alert on unusual patterns
$summary = $payload['summary'];
if ($summary['total_expired'] > historicalAverage() * 2) {
alertOperations("Expiration rate 2x above average - investigate!");
}