我在为 Paypal 通知网络 Hook 编写 PHP 监听器脚本时遇到问题。我只需要一个脚本来监听和请求 Paypal json 数据。由于大量的在线文档,我已经成功地为 Stripe 创建了一个。这是我的:
<?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... //
?>
我只需要类似的东西来处理 Paypal 事件 json。
最佳答案
PayPal 刚刚发布了一个新版本,PayPal PHP-SDK 1.4.0; 这有一个 webhook 监听器。
https://github.com/paypal/PayPal-PHP-SDK/releases/tag/v1.4.0
文件是ValidateWebhookEvent.php
它在示例中。
Paypal -PHP-SDK/paypal/rest-api-sdk-php/sample/notifications/ValidateWebhookEvent.php
文档在这里
https://github.com/paypal/PayPal-PHP-SDK/wiki/Webhook-Validation
关于用于 Paypal Webhooks 的 PHP 监听器脚本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29700437/