Midtrans/midtrans-php

Uncaught Exception when notify url accessed directly.

erikdemarco opened this issue · 1 comments

When you do something like this in notify url script:

namespace Midtrans;
require_once dirname(__FILE__) . '/../Midtrans.php';
Config::$isProduction = false;
Config::$serverKey = '<your serverkey>';
$notif = new Notification();

Then this notify url accessed directly or not contained the correct format it will cause error:
"Uncaught Exception: Midtrans API is returning API error. HTTP status code: 404 API response: .... in /midtrans-php/Midtrans/ApiRequestor.php on line 167"

Isn't the correct way of handling this is returning false or returning null to $notif? So developer can easily check wheter the notification returned the correct data.

Hi @erikdemarco thank you for asking. Notification class/function helper, and Expect to accepted HTTP request POST only. Then pass through transaction_id from a POST request to status function. You can also use status to build your own notification handling.

But your feedback is valid, will put this as our backlog and implement it in the next release.

Thank you