PHP Listener Script for Paypal Webhooks

匿名 (未验证) 提交于 2019-12-03 00:59:01

问题:

I'm having trouble writing a PHP listener script for Paypal notification webhooks. I simply need a script to listen for and request the Paypal json data. I have created one for Stripe successfully, thanks to plenty of online documentation. This is what I have:

<?php require_once('./lib/Stripe.php');     Stripe::setApiKey("my_secret_stripe_key");      $input = @file_get_contents("php://input");     $event_json = json_decode($input);      // then I request the json data from a Stripe event... //     $event_json->type == 'charge.succeeded'     // etc... // ?> 

I just need something similar to handle Paypal event json.

回答1:

PayPal just released a new version, PayPal PHP-SDK 1.4.0; this has a webhook listener.

https://github.com/paypal/PayPal-PHP-SDK/releases/tag/v1.4.0

The file is ValidateWebhookEvent.php

It is in the samples.
PayPal-PHP-SDK/paypal/rest-api-sdk-php/sample/notifications/ValidateWebhookEvent.php

The docs are here
https://github.com/paypal/PayPal-PHP-SDK/wiki/Webhook-Validation



回答2:

I used this tutorial on http://code.tutsplus.com/ which was very helpful. You might also want to take a look at the webhook validation.



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!