Skip to content
Last updated

IPN Notifications - DirectBilling

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.


Expected Server Response

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.


Notification Structure (JSON)

Each POST notification contains the following information in its body:

FieldTypeDescriptionExample Value
idstringUnique transaction ID in the SimPay systemdc261d4f-31ef-4728-bfd6-97bbe2a5ef0a
serviceIdstringYour service identifiere14f8074
statusstringCurrent DirectBilling transaction statustransaction_db_payed
valuesobjectObject with amount values
values.netnumberNet transaction amount11.07
values.grossnumberGross transaction amount13.61
values.partnernumberYour commission (earnings from the transaction)5
returnsobjectObject with return addresses provided when generating the transaction
returns.completestringAddress the customer should be redirected to after successhttps://www.simpay.pl/complete
returns.failurestringAddress the customer should be redirected to after failurehttps://www.simpay.pl/failure
controlstringYour optional field (sent if it was provided when generating)order_123
number_fromstringBuyer's phone number from which the account was charged48123123123
providerintegerGSM operator identifier1
signaturestringCryptographic signature (SHA-256 hash) generated from field valuesa3116cf...

Available Transaction Statuses

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.
Tip

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.


Example JSON Payload

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"
}

Calculating the Signature

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)

  1. 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).

  1. We append our IPN key at the end: ...|klucz

  2. We 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');
  1. The resulting hash (in this case a3116cf4f1e960223c2cc3088bf387278b6675255209bdeaf96a2f316a2fadc1) should be safely compared with the value sent in the signature field.