The SimPay system allows for asynchronous notification of your application about DirectBilling payment status changes ( payments charged to the mobile carrier's bill). These notifications are sent via HTTP POST requests with a body in application/json format.
Unlike Online Payments, DirectBilling notifications use a single consistent structure – the notification simply updates the status for a specific transaction ID.
For the notification to be considered successfully delivered, your IPN server must absolutely return in the body a plain text response with the word OK and an HTTP 200 status code.
Each POST notification contains the following information in its body:
| Field | Type | Description | Example Value |
|---|---|---|---|
id | string | Unique transaction ID in the SimPay system | dc261d4f-31ef-4728-bfd6-97bbe2a5ef0a |
serviceId | string | Your service identifier | e14f8074 |
status | string | Current DirectBilling transaction status | transaction_db_payed |
values | object | Object with amount values | |
values.net | number | Net transaction amount | 11.07 |
values.gross | number | Gross transaction amount | 13.61 |
values.partner | number | Your commission (earnings from the transaction) | 5 |
returns | object | Object with return addresses provided when generating the transaction | |
returns.complete | string | Address the customer should be redirected to after success | https://www.simpay.pl/complete |
returns.failure | string | Address the customer should be redirected to after failure | https://www.simpay.pl/failure |
control | string | Your optional field (sent if it was provided when generating) | order_123 |
number_from | string | Buyer's phone number from which the account was charged | 48123123123 |
provider | integer | GSM operator identifier | 1 |
signature | string | Cryptographic signature (SHA-256 hash) generated from field values | a3116cf... |
In IPN notifications for DirectBilling, you may encounter the following values in the status field:
transaction_db_new– the transaction was successfully created in the system.transaction_db_confirmed– the transaction was confirmed by the operator (e.g., the customer entered the correct PIN), waiting for final funds collection.transaction_db_payed– the transaction was successfully paid (final success).transaction_db_rejected– the transaction was ultimately rejected by the operator (e.g., insufficient funds on the account or an active Premium service block on the customer's number).transaction_db_canceled– the transaction was canceled (e.g., due to PIN entry timeout or cancellation by the user).transaction_db_generate_error– an error occurred during the attempt to generate the transaction directly at the GSM operator.
When you receive an IPN notification, always verify the status field. The expected value for a successfully completed DirectBilling process (based on which you deliver goods or services) is transaction_db_payed.
Below is a dump of a complete notification sent for a successful transaction (transaction_db_payed).
{
"id": "dc261d4f-31ef-4728-bfd6-97bbe2a5ef0a",
"serviceId": "e14f8074",
"status": "transaction_db_payed",
"values": {
"net": 11.07,
"gross": 13.61,
"partner": 5
},
"returns": {
"complete": "https://www.simpay.pl/complete",
"failure": "https://www.simpay.pl/failure"
},
"number_from": "48123123123",
"provider": 1,
"signature": "a3116cf4f1e960223c2cc3088bf387278b6675255209bdeaf96a2f316a2fadc1"
}Verifying the cryptographic signature is an absolute requirement to ensure that the notification actually comes from SimPay.
The signature is generated by concatenating all received parameters (excluding the signature field) in exactly the order they appear in the documentation table. Values are separated by the | separator, and at the very end, your DirectBilling service IPN key (available in the client panel) is appended. If any optional field (e.g., control) was not included in the request – simply skip it.
See signature calculation from the above example
(Assuming the test service key is klucz)
- We create a string, separating values with the
|separator: Our base string will look like this:
dc261d4f-31ef-4728-bfd6-97bbe2a5ef0a|e14f8074|transaction_db_payed|11.07|13.61|5|https://www.simpay.pl/complete|https://www.simpay.pl/failure|48123123123|1(Note: the optional control field is missing from the JSON, so we completely skipped it).
We append our IPN key at the end:
...|kluczWe calculate SHA256 from the above string and encode in hex:
<?php
$signature = hash('sha256', 'dc261d4f-31ef-4728-bfd6-97bbe2a5ef0a|e14f8074|transaction_db_payed|11.07|13.61|5|https://www.simpay.pl/complete|https://www.simpay.pl/failure|48123123123|1|klucz');- The resulting hash (in this case
a3116cf4f1e960223c2cc3088bf387278b6675255209bdeaf96a2f316a2fadc1) should be safely compared with the value sent in thesignaturefield.