Webhooks PHP
Webhooks/Parse
When webhooks are triggered in the gateway, a notification is sent as a POST request to the specified destination URL. The post body contains two x-www-form-urlencoded parameters:
bt_signaturebt_payload
This payload is signed to ensure that the message originated from Braintree and was not modified in transit. The message is identical to standard API responses and contains a snapshot of the related entity at the time the webhook was triggered.
These parameters should be passed to the Braintree_WebhookNotification::parse. The result will be a WebhookNotification object consisting of:
- A timestamp (in UTC)
- Tip: Notifications may not be delivered sequentially, so be sure to look at the timestamp of the event.
- A kind (directly mapped to triggers)
- A standard Braintree object, depending on the type of notification (e.g. a subscription object for recurring billing webhooks)
- Tip: Save webhook data to your database for reporting purposes or use it to trigger other actions in your app
PHP
if(
isset($_POST["bt_signature"]) &&
isset($_POST["bt_payload"])
) {
$webhookNotification = Braintree_WebhookNotification::parse(
$_POST["bt_signature"], $_POST["bt_payload"]
);
$message =
"[Webhook Received " . $webhookNotification->timestamp->format('Y-m-d H:i:s') . "] "
. "Kind: " . $webhookNotification->kind . " | ";
file_put_contents("/tmp/webhook.log", $message, FILE_APPEND);
}
Notice how we are using file_put_contents to store the result of the received Webhooks to /tmp/webhooks.log.
PHP
$webhookNotification = Braintree_WebhookNotification::parse(
$_POST["bt_signature"], $_POST["bt_payload"]
);
$webhookNotification->kind;
# => "subscription_went_past_due"
$webhookNotification->timestamp;
# => Sun Jan 1 00:00:00 UTC 2012
Exceptions
An exception may be raised while attempting to parse a Webhook signature.
Still Have Questions?
If you can’t find an answer, give us a call at 877.434.2894 or email our Support team.
Webhooks PHP的更多相关文章
- 第四十一章 微服务CICD(3)- jenkins + gitlab + webhooks + publish-over-ssh(1)
一.作用 使用webhooks来实现当git客户端push代码到gitlab后,jenkins会立即去gitlab拉取代码并构建. 二.步骤 1.安装插件 ruby_runtime(Hook插件依赖于 ...
- ASP.NET的新成员ASP.NET WebHooks
(此文章同时发表在本人微信公众号"dotNET每日精华文章",欢迎右边二维码来关注.) 题记:前几天微软除了发布了ASP.NET 5的Beta7之外,还有一个值得关注的东西,就是A ...
- 使用 GitHub / GitLab 的 Webhooks 进行网站自动化部署
老早就想写这个话题了,今天正好有机会研究了一下 git 的自动化部署.最终做到的效果就是,每当有新的 commit push 到 master 分支的时候,就自动在测试/生产服务器上进行 git pu ...
- 微软发布了ASP.NET WebHooks预览版
微软 近期发布了ASP.NET WebHooks的预览版 ,这是一个可用于创建及使用Webhook功能的库.WebHooks支持MVC 5及WebApi 2. Webhook是一种通过HTTP实现用户 ...
- WebHooks
WebHooks ASP.NET 5 Beta 7 版本 在 VS2015 发布的同时,微软也发布了 ASP.NET 5 的路线图(详见ASP.NET 5 Schedule and Roadmap ...
- springboot+cloud 学习(五)统一配置中心 spring cloud config + cloud bus + WebHooks +RibbitMQ
前言 微服务要实现集中管理微服务配置.不同环境不同配置.运行期间也可动态调整.配置修改后可以自动更新的需求,Spring Cloud Config同时满足了以上要求.Spring Cloud Conf ...
- 基于 Webhooks gitlab 自动化构建
基于gitlab webhooks 自动构建流程 1.服务器安装 git 服务 安装成功 配置 PHP 脚本: <?php // 接受头部信息 if (!isset($_GET['youpara ...
- jenkins+gitlab webhooks 实现自动触发打包
说明:实现代码在gitlab上的提交后立马自动进行jenkins的job构建 安装插件: Gitlab Hook Plugin Build Authorization Token Root Plug ...
- Gitlab Webhooks, External Services, and API(二)
一. 使用webhooks webhook 是一个API的概念,并且变得越来越流行.我们能用事件描述的事物越多,webhook的作用范围也就越大.webhook作为 个轻量的事件处理应用,正变得越来越 ...
随机推荐
- SecureCrt设置字符编码
SecureCrt设置字符编码,参考:http://www.2cto.com/os/201412/365535.html
- sql server命令行
http://www.cnblogs.com/bingcaihuang/archive/2011/01/31/1948222.html http://www.cnblogs.com/wontonJ/a ...
- java 流
http://www.iteye.com/magazines/132-Java-NIO http://liyuanning.blog.163.com/blog/static/4573228620101 ...
- swift 属性
属性将值和类,结构,枚举相关联.属性分为计算属性和存储属性.存储属性存储常量或变量作为实例的一部分 ,计算属性计算一个值.存储属性用于类和结构体,计算属性用于类,结构体和枚举. 1:存储属性 存储属性 ...
- delphi7的新生,参与分布式应用开发,调用RESTful API,Json的应用
前言: 1.公司delphi7开发的传统软件还活得好好的,但是大家都知道delphi早已经日落西山了,现在成了后进.追随者.细细算了已经6.7不用了.新的delphixe7呢,没有时间成本去适应和研究 ...
- jQuery 1.9 Ajax代码带注释
/* -----------ajax模块开始 -----------*/ var // Document location ajaxLocParts, ajaxLocation, ajax_nonce ...
- 新找到一个安装Android SDk的方法-记录
此方法需使用国内的镜像,但是国内镜像网速不一定要很快. 迅雷下载工具这个是必须的. 今天注意到SDK目录下有一个temp文件夹,打开看了看发现就是缓存的目录,因此想到直接从镜像站下载相应的包来替换,测 ...
- (非妙味3):浏览器window事件:及浏览各种尺寸介绍
(触发)window.onload; window.onscroll; window.onresize; (兼容)网页可视区尺寸.网页全文尺寸.滚动距离 (实例)广告块高度动态居中.回到顶部 ...
- NuGet 让你都美好的PM
题外话 从前有座山,山上有座庙,庙里有个老和尚.阿阿阿,好多鱼好多余. 什么是Nuget NuGet(发音:New-Get)是一个Visual Studio的扩展.在使用Visual Studio开发 ...
- 最近一段时间开发客户端app的感悟
关于android和cocos2d 凭着对大学时候写html+css的一点点的记忆,我还是认为android的布局xml文件还是参考了html+css,只是他更加臃肿!就想 android平台本身那样 ...