adyen-magento2
adyen-magento2 copied to clipboard
[PW-1915] Debug payments in local env with proxy like ngrok to receive webhooks
Is your feature request related to a problem? Please describe. I'm always frustrated when i need to debug payments in local env.
Describe the solution you'd like
When I execute a payment in local env i can configure a ngrok
url for webhooks.
Hello @rvitaliy,
Indeed the local processing of the notification webhooks is a situation that we'd like to address. We're considering your report in our internal issue tracker and we'll update you when progress is made.
Thanks.
Update the title with the internal ticket number
Hi @rvitaliy,
We are currently using the following for local env webhook processing:
- In the Adyen customer area, set webhook notifications to use a thirdparty intermediary service, such as https://notification.ninja
- On this thirdparty service, forward incoming notifications to your {magento_url}
- Change the constant variables
WEBHOOK_USERNAME
&WEBHOOK_PASSWORD
according to your Magento 2 configuration. - Run script from terminal
php -S {magento_url} webhookRelay.php
using the PHP built-in server.
const WEBHOOK_USERNAME = “WEBHOOK_USERNAME";
const WEBHOOK_PASSWORD = "WEBHOOK_PASSWORD";
const WEBHOOK_ENDPOINT = “{magento_url}/adyen/process/json";
function addHeaders()
{
header("Access-Control-Allow-Origin: *");
header("Access-Control-Allow-Credentials: true");
header('Access-Control-Allow-Methods: GET, POST, OPTIONS');
header('Access-Control-Allow-Headers: Content-Type, Accept');
}
function sendToMagento($notification)
{
$curl = curl_init(WEBHOOK_ENDPOINT);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-Type: text/plain'));
curl_setopt($curl, CURLOPT_USERPWD, WEBHOOK_USERNAME . ":" . WEBHOOK_PASSWORD);
curl_setopt($curl, CURLOPT_POSTFIELDS, $notification);
curl_exec($curl);
curl_close($curl);
}
function run()
{
addHeaders();
$notificationBody = file_get_contents('php://input');
sendToMagento($notificationBody);
return true;
}
run();
Feel free to drop any feedback related to this script.
Thanks, Jean Adyen
Thank you for replay to this thread after 2 years, i hope that this solution can be useful for someone. Personally i changed the project and i hope never come back to Magento ecosystem 🤞