Loading...
FinchTrade
Digital asset liquidity provider of your choice

Home OTC liquidity Expand Product features Supported tokens Effective treasury QUICK START Onboarding Limits Trading Settlement White-label Expand About solution Quick start FAQ Integrations Features Supported blockchains For partners Expand Monetise your network Introducing agent White-label OTC desk License-as-a-service Use cases Expand Crypto processing OTC desks Asset manager Crypto exchange Card acquirer About us Expand Our team We are hiring Crypto events Knowledge hub

Glossary

Instant Payment Notification URL

In the world of online transactions, ensuring seamless communication between payment systems and merchants is crucial. This is where IPN (Instant Payment Notification) and Callback URLs come into play. These mechanisms allow for real-time updates on payment status, ensuring that both parties are informed of transaction events. In this article, we will delve into the intricacies of IPN URL and Callback URL, exploring their functionalities, configurations, and security measures.

What is an IPN URL?

An IPN URL, or Instant Payment Notification URL, is a web address that receives notifications from a payment gateway whenever a transaction event occurs. This notification includes details about the transaction, such as payment status, transaction ID, and other relevant data. The IPN URL acts as an IPN listener, capturing these notifications and processing them accordingly.

How Does the IPN Service Work?

When a transaction is initiated, the payment gateway sends a payment notification to the configured IPN URL. This notification is a POST data request containing the entire request body, which includes transaction-related events and transaction notes. The IPN listener page processes this data, updating the merchant's local database or ERP systems as needed.

Configuring Instant Payment Notification

To configure instant payment notification, merchants must set up an IPN listener URL on their server. This involves creating a custom script that can handle incoming notifications and validate the data received. The IPN configuration process typically includes the following steps:

  1. Enable Callback: In the merchant dashboard, enable the callback option to allow the payment gateway to send notifications to your IPN URL.
  2. Add Manual IPN Configs: Specify the IPN URL in the payment gateway settings, ensuring that it points to the correct listener page.
  3. Validate and Calculate: Implement a function to validate the signature payload received, ensuring that the notification is legitimate and secure.

Security Measures for IPN URL

For security reasons, it is essential to secure the IPN URL and the data it processes. Here are some best practices:

  • IPN URL Secure: Use HTTPS to encrypt data transmitted between the payment gateway and your server.
  • Custom Header Signature: Verify the custom header signature to ensure the notification is from a trusted source.
  • HMAC Signature: Calculate the HMAC signature locally to validate the integrity of the entire request body.

Sample PHP Code Function for IPN Listener

Below is a sample PHP code function that demonstrates how to handle IPN notifications:


function handleIPN() {
    $raw_post_data = file_get_contents('php://input');
    $signature = $_SERVER['HTTP_SIGNATURE'];
    
    // Validate signature
    if (!validateSignature($raw_post_data, $signature)) {
        http_response_code(400);
        exit('Invalid signature');
    }
    
    // Process IPN data
    $ipn_data = json_decode($raw_post_data, true);
    if ($ipn_data['notification_type'] === 'payment') {
        // Update local database with transaction details
        updateTransaction($ipn_data);
    }
    
    // Send correct response
    http_response_code(200);
    echo 'IPN received';
}

function validateSignature($data, $signature) {
    $calculated_signature = hash_hmac('sha256', $data, 'your-secret-key');
    return hash_equals($calculated_signature, $signature);
}

Handling Transaction Events and Notifications

When a selected event occurs, such as a successful payment, the IPN listener processes the notification and updates the transaction notes showing the payment status. This information can be used to update ERP or dependent systems, ensuring that all parties are informed of the transaction status.

Managing Callback URL and Retry Count

In some cases, the payment gateway may need to retry sending the notification if the initial attempt fails. Merchants can configure the retry count to specify how many times the gateway should attempt to send the notification. Additionally, merchants can disable callback if they no longer wish to receive notifications.

Conclusion

IPN URL and Callback URL are essential components of a robust payment notification system. By configuring these URLs correctly and implementing security measures, merchants can ensure that they receive accurate and timely updates on transaction events. Whether you're using a one-time IPN service or a custom script, understanding these concepts is key to managing payment notifications effectively.