vendor/braintree/braintree_php/lib/Braintree/WebhookNotificationGateway.php
(开头部分) 2KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
<?php
namespace Braintree;
/**
* Braintree WebhookNotificationGateway
* Manages Webhooks
*/
class WebhookNotificationGateway
{
// phpcs:ignore PEAR.Commenting.FunctionComment.Missing
public function __construct($gateway)
{
$this->config = $gateway->config;
$this->config->assertHasAccessTokenOrKeys();
}
/**
* Parses a webhook from the Braintree API
*
* @param string $signature used to verify before parsing
* @param mixed $payload to be parsed
*
* @throws Exception\InvalidSignature
*
* @return WebhookNotification object
*/
public function parse($signature, $payload)
{
if (is_null($signature)) {
throw new Exception\InvalidSignature("signature cannot be null");
}
if (is_null($payload)) {
throw new Exception\InvalidSignature("payload cannot be null");
}
if (preg_match("/[^A-Za-z0-9+=\/\n]/", $payload) === 1) {
throw new Exception\InvalidSignature("payload contains illegal characters");
}
self::_validateSignature($signature, $payload);
$xml = base64_decode($payload);
$attributes = Xml::buildArrayFromXml($xml);
return WebhookNotification::factory($attributes['notification']);
}
/*
* Verify a webhook challenge
*
* @param object $challenge to be verified
*
* @throws Exception\InvalidChallenge
*
* @return string
*/
public function verify($challenge)
{
if (!preg_match('/^[a-f0-9]{20,32}$/', $challenge)) {
后面还有 38 行代码,购买后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明
AI 解读
登录后可用,每次 10 积分,解读结果公开显示在下面。
还没有人解读过这个文件。
