Callback & Notifications

Overview

Once the order has been placed and payment has been confirmed, you will be notified by ifthenpay via the usual channels, i.e. by push notification, if you have our app installed and have this option activated, by email, or you can check directly in our backoffice.

If you wish to be notified by callback, you must first ask ifthenpay to activate your callback (webhook).

In simpler terms: The callback URL is like a template. When a payment happens, the template is filled in with real information about that payment, and then the information is sent to your website.

ifthenpay offers free technical support to all customers through the following channels:



« go to index

 

Explanation

The following is an explanation of what a callback is and its purpose.

Callback example URL
http://www.yoursite.com/callback.php?key=[ANTI_PHISHING_KEY]&orderId=[ORDER_ID]&amount=[AMOUNT]&requestId=[REQUEST_ID]&payment_datetime=[PAYMENT_DATETIME]

Constraints


URL Breakdown:

The Square Brackets []:

What Happens During a Callback:

  1. Customer Completes Purchase: When a customer finishes buying something on your website, the payment gateway processes the transaction.
  2. Gateway Sends Request: The payment gateway sends a request to the URL you provided.
  3. Placeholders are Replaced: The gateway replaces the placeholders in the URL with the specific details of the transaction.
  4. Your Server Receives Data: Your server receives the request and processes the data, updating your database, sending emails, or performing other actions.

Why use a callback URL?

Common Use Cases:

Response Codes and Retry Policy

Your URL is not required to return any content. The success of our request is determined solely by the HTTP status code returned: if an HTTP 200 status code is received, ifthenpay considers the call successful. If any other status code is returned (HTTP 400, 500, or others), the call is considered unsuccessful and will be retried automatically.

A maximum of 13 attempts will be made: the first 8 at 5-minute intervals, and the remaining attempts at 1-hour intervals. If, after these 13 attempts, a successful response (HTTP 200) is still not obtained, no further retries will be made.

Additionally, if the failure is identified as permanent, the system will stop retrying after the 3rd attempt.

 

Multibanco


Callback example URL
https://www.yoursite.com/callback.php?key=[ANTI_PHISHING_KEY]&orderId=[ORDER_ID]&amount=[AMOUNT]&requestId=[REQUEST_ID]&entity=[entity]&reference=[REFERENCE]&payment_datetime=[PAYMENT_DATETIME]

The description of the replacements is as follows:



Example of a Callback URL triggered after payment confirmation
https://www.yoursite.com/callback.php?key=my_anti_phishing_key&orderId=order-1234&amount=1234.56&requestId=5Qd8gtWLAEUJ6n0lkS5g&entity=99999&reference=123456789&payment_datetime=28-10-2021 10:55:21
 

MB WAY


Callback example URL
https://www.yoursite.com/callback.php?key=[ANTI_PHISHING_KEY]&orderId=[ORDER_ID]&amount=[AMOUNT]&requestId=[REQUEST_ID]&payment_datetime=[PAYMENT_DATETIME]

The description of the replacements is as follows:



Example of a Callback URL triggered after payment confirmation
https://www.yoursite.com/callback.php?key=your_anti_phishing_key&orderId=1887&amount=33.61&requestId=i2szvoUfPYBMWdSxqO3n&payment_datetime=03-01-2024 15:15:16

Notification URL

In addition to the callback URL, which is only triggered when a payment is successful, you can send the optional notificationUrl parameter when requesting an MB WAY payment to receive the final status of each individual MB WAY request. Unlike the callback, you are also notified when the customer declines the payment or when the request expires.

The notification is sent as a POST request with a JSON body to the notificationUrl you provided. Unlike the callback, each notification is sent only once.


Notification request body (JSON)
{ "RequestId": "9iCipyBZ2crhtL4QH8Yv", "CreatedAt": "13-10-2026 18:13:02", "UpdateAt": "13-10-2026 18:13:15", "Status": "020", "Message": "Declined by user" }

The body contains the following fields:


The request includes the following headers:


Notification request headers
Content-Type: application/json X-Ifthenpay-Event-Id: event_almsywu8w4bdozg2tv17 X-Ifthenpay-Signature: b16d24ac111efd7310af99e8644718341b68b9714c3378c0ce6c97ccde67e73e

What you need to implement
  1. An endpoint at your notificationUrl that accepts POST requests with a JSON body.
  2. Validate the X-Ifthenpay-Signature header before trusting the notification:
    • Concatenate orderId, amount and requestId of the payment, with no separators.
    • Compute an HMAC SHA-256 hash of that string, using your MB WAY Key as the secret.
    • Compare the result with the header value and reject the request if they do not match.
  3. Use the RequestId to find the corresponding order and update it according to the Status.

Signature calculation example
Signed string (orderId + amount + requestId): order_4567811.5536jvlEhUYeknQ8PHKprR Secret (MB WAY Key, test value): AAA-000000 Resulting X-Ifthenpay-Signature: d7d2fd272233f0102e6dd0e50969025481cdfe3abb87cc3f135f74cfb47b2561

Alternatively, you can add the ifthenpay server IP address to your whitelist, so that your notification URL only accepts requests from our servers.

 

Payshop


Callback example URL
https://www.yoursite.com/callback.php?anti_phishing_key=[ANTI_PHISHING_KEY]&order_id=[ORDER_ID]&reference=[REFERENCE]&amount=[AMOUNT]&payment_datetime=[PAYMENT_DATETIME]

The description of the replacements is as follows:



Example of a Callback URL triggered after payment confirmation
https://www.yoursite.com/callback.php?anti_phishing_key=my_anti_phishing_key&order_id=12345&reference=1021600051424&amount=5.00&payment_datetime=28-10-2021 10:55:21
 

Credit Card


Callback example URL
https://www.yoursite.com/callback.php?key=[ANTI_PHISHING_KEY]&id=[ORDER_ID]&amount=[AMOUNT]&payment_datetime=[PAYMENT_DATETIME]&payment_method=[PAYMENT_METHOD]

The description of the replacements is as follows:



Example of a Callback URL triggered after payment confirmation
https://www.yoursite.com/callback.php?key=my_anti_phishing_key&id=1234&amount=21.50&payment_datetime=28-10-2021 10:55:21&payment_method=CCARD
 

Google Pay


Callback example URL
https://www.yoursite.com/callback.php?key=[ANTI_PHISHING_KEY]&id=[ORDER_ID]&amount=[AMOUNT]&payment_datetime=[PAYMENT_DATETIME]&payment_method=[PAYMENT_METHOD]

The description of the replacements is as follows:



Example of a Callback URL triggered after payment confirmation
https://www.yoursite.com/callback.php?key=my_anti_phishing_key&id=1234&amount=21.50&payment_datetime=28-10-2021 10:55:21&payment_method=GOOGLE
 

Apple Pay


Callback example URL
https://www.yoursite.com/callback.php?key=[ANTI_PHISHING_KEY]&id=[ORDER_ID]&amount=[AMOUNT]&payment_datetime=[PAYMENT_DATETIME]&payment_method=[PAYMENT_METHOD]

The description of the replacements is as follows:



Example of a Callback URL triggered after payment confirmation
https://www.yoursite.com/callback.php?key=my_anti_phishing_key&id=1234&amount=21.50&payment_datetime=28-10-2021 10:55:21&payment_method=GOOGLE
 

Direct Debit


Callback example URL
https://www.yoursite.com/callback.php?anti_phishing_key=[ANTI_PHISHING_KEY]&mandate_id=[ORDER_ID]&transaction_id=[REQUEST_ID]&amount=[AMOUNT]&payment_datetime=[PAYMENT_DATETIME]

The description of the replacements is as follows:



Example of a Callback URL triggered after payment confirmation
https://www.yoursite.com/callback.php?anti_phishing_key=my_anti_phishing_key&mandate_id=12345&reference=1021600051424&transaction_id=00065411-98&amount=5.00&payment_datetime=28-10-2021 10:55:21

In addition to the callback URL, which only confirms when a payment is successfully collected, you can also use the notification URL to receive the status of each individual collection attempt as it is processed.

Notification example URL
https://www.yoursite.com/notification.php
(This URL will be called using the GET method, and parameters will be appended when a payment is confirmed or refused.)

The following parameters are included in the direct debit notification URL when a payment is either confirmed or refused:



Example of a Notification URL triggered after payment confirmation
https://www.yoursite.com/notification.php?mandateId=09039807130&transactionId=KL83NVuf0fy8GYkpohVo&amount=0.01¤cy=EUR&collectionDate=2025-04-17&reference=6CCEA46379&status=PROCESSING&code=0000
 

PIX


Callback example URL
https://www.yoursite.com/callback.php?anti_phishing_key=[ANTI_PHISHING_KEY]&order_id=[ORDER_ID]&amount=[AMOUNT]&payment_datetime=[PAYMENT_DATETIME]

The description of the replacements is as follows:



Example of a Callback URL triggered after payment confirmation
https://www.yoursite.com/callback.php?anti_phishing_key=my_anti_phishing_key&order_id=12345&amount=5.00&payment_datetime=28-10-2021 10:55:21
 

PAY BY LINK & PINPAY


Callback example URL
https://www.yoursite.com/callback.php?key=[ANTI_PHISHING_KEY]&id=[ID]&amount=[AMOUNT]&payment_datetime=[PAYMENT_DATETIME]&payment_method=[PAYMENT_METHOD]

The description of the replacements is as follows:



Example of a Callback URL triggered after payment confirmation
https://www.yoursite.com/callback.php?key=my_anti_phishing_key&id=1234&amount=21.50&payment_datetime=28-10-2021 10:55:21&payment_method=CCARD

⬅