Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Freek Van der Herten:
Handling Stripe webhooks in a Laravel application
Oct 09, 2017 @ 15:33:06

Freek Van der Herten has a new post to his site showing you how to handle Stripe callbacks when integrating its webhook functionality into your application. True to form, he also created a Laravel package to make it even easier.

In the project I’m currently working on I had to integrate Stripe webhooks. Stripe has great documentation on how to handle webhooks, but it still took a fair amount of time to get the integration just right. My solution for handling webhooks is pretty generic and reusable by others. I decided to extract it to a package called laravel-stripe-webhooks, so nobody has to code this stuff up again. In this blogpost I’d like to share how the package works.

He then goes on to talk about the request validation that happens on the webhook callback and how the information can be reworked if something goes wrong. He then talks about the handling of valid requests either using a custom job or using events to trigger when a "source.chargable" event is fired.

tagged: stripe laravel package webhook tutorial event job

Link: https://murze.be/2017/10/handling-stripe-webhooks-laravel-application/

Laravel News:
Testing Laravel Middleware with HTTP Tests
Sep 28, 2017 @ 17:10:05

On the Laravel News site today there's a tutorial posted showing you how to test your middleware with HTTP tests and how they can help in more practical testing of your application.

In this post, I’d like to demonstrate a practical example of testing a middleware using HTTP tests. Testing at the HTTP level can make your tests more resilient to change and more readable.

On a recent episode of Full Stack Radio (#72) with Adam Wathan and Taylor Otwell, it was refreshing to hear them find a lot of practical value in HTTP testing. I have found HTTP tests to be easier to write and maintain, but did feel like I was Doing Testing Wrong™ somehow or that I was cheating by not mocking and isolating everything. If you haven’t listened to this episode yet, give it a listen, it’s full of good, practical testing advice.

He starts by laying out the example middleware he wanted to test, one for validating and securing webhooks coming back from the Mailgun service to handle incoming email. The code for the middleware is included, defining the handle, buildSignature and verify methods. He then uses the artisan command to make a test and provides the code to test and ensure that the middleware forbids requests that aren't POST.

tagged: laravel http testing middleware mailgun webhook post tutorial

Link: https://laravel-news.com/testing-laravel-middleware

Laravel News:
Inbound Email in Laravel
Aug 15, 2017 @ 16:39:02

The Laravel News site has posted a tutorial showing you how to handle inbound email using the framework and Mailgun's inbound routing feature (essentially webhooks)

I recently needed the ability to receive emails and process attachments on those emails. I love Mailgun for the sending of transactional email, so when I needed to process incoming mail I started digging into Mailgun closer and realized their powerful inbound routing email features!

Come along and learn how you can set up a webhook to process inbound email and secure it within your Laravel applications. We will even use Laravel Valet (or ngrok directly) to test it out locally!

They start by talking about inbound routing: what it is and how it works using a request back from the Mailgun service. They briefly walk you through the setup of a Mailgun account and your DNS to use it for mail service. Next they create a new Laravel project, configure it for email with Mailgun and create the hook the webhook from Mailgun will reach back out to. They use Valet to share it via ngrok and configure the Mailgun account with the resulting URL. The post finishes up showing how to secure the webook via validation middleware and how to test it. They also share a few tips you can potentially use in the controller like using jobs for response handling and working with files.

tagged: tutorial inbound email laravel mailgun webhook callback

Link: https://laravel-news.com/laravel-inbound-email

BitExpert Blog:
Mattermost Webhooks and PHP
Jul 19, 2017 @ 15:49:26

On the BitExpert blog Stephan Hochdörfer shares his experience working with Mattermost webhooks and interfacing them with backend PHP scripts. Mattermost is an Open Source Slack clone.

In a recent attempt to automate a few things even more, I was looking for a way to post messages to our [Mattermost](http://mattermost.org/) instance via the [Incoming Webhook](https://docs.mattermost.com/developer/webhooks-incoming.html) feature of Mattermost. I did a quick search on [Packagist](https://packagist.org/search/?q=mattermost) for Mattermost client libraries and as it turns out there a quite a few. I picked the [thibaud-dauce/mattermost-php](https://packagist.org/packages/thibaud-dauce/mattermost-php) package simply because it was the first match.

He then walks through the installation of the package and how it works, using Guzzle, to send messages to the Mattermost service. The incoming request is just a JSON-formatted data set, so it's easily parsed in plain PHP. The output, however, needs to be in a format Mattermost understands. That's where the package comes in, providing a "send" method that allows for the customized text and optional attachment to be sent to the Mattermost server.

tagged: mattermost package webhook messaging message tutorial

Link: https://blog.bitexpert.de/blog/mattermost-webhooks-and-php/

Full Stack Radio:
62: Timezones, Webhook Security, and UI Decisions
Apr 12, 2017 @ 18:06:25

The Full Stack Radio podcast, with host Adam Wathan, has posted their latest episode with guest David Hemphill - Episode #62: Timezones, Webhook Security, and UI Decisions.

In this episode, David talks about adding timezone support to Crondog, and Adam wrestles with some decisions about dealing with failed webhooks in KiteTail.

We also talk a lot about different strategies for securing webhooks, and what we're looking forward to at MicroConf.

You can listen to this latest episode either using the in-page audio player or by downloading the mp3 directly. If you enjoy the show, be sure to subscribe to their feed and follow them on Twitter to get the latest announcements when new shows are released.

tagged: fullstackradio podcast ep62 davidhemphill adamwathan timezone webhook security ui

Link: http://www.fullstackradio.com/62

Christoph Rumpel:
Build a PHP chatbot in 10 minutes
Aug 15, 2016 @ 14:45:23

Christoph Rumpel has written up a tutorial showing you how to build a PHP chatbot in 10 minutes by hooking a PHP 7 based script in, via webhooks, to a Facebook Messenger application.

The chatbot topic is huge right now. Finally there is something quite new again and nobody knows what's happening next. This is the perfect time to start experimenting with chatbots and to build your own one right now. Give me 10 minutes of your time and I will give you your first chatbot!

He then walks you through the full process if setting up the Facebook Messenger application, a page to host it from and using the Chatbot boilerplate code to connect the application back to the Facebook platform. This includes both the code needed and screenshots along the way of what you can expect to see during setup. The result is a bot that can respond with, at first, a static string then is modified to show simple exchange rate data.

tagged: chatbot facebook tutorial boilerplate code example application webhook

Link: http://christoph-rumpel.com/2016/08/build-a-php-chatbot-in-10-minutes/

AWS PHP Development:
Testing Webhooks Locally for Amazon SNS
Apr 08, 2014 @ 16:33:07

In a previous post the AWS for PHP blog showed how to set up webhooks for handling the callbacks from their SNS messaging service. In this next part of the series they continue the process, showing how you can test these hooks locally without needing to actually send the messages. This eliminates the need to deploy to a public-facing server just to test the hooks every time you need an update.

In a recent post, I talked about Receiving Amazon SNS Messages in PHP. I showed you how to use the SNS Message and MessageValidator classes in the AWS SDK for PHP to handle incoming SNS messages. The PHP code for the webhook is easy to write, but can be difficult to test properly, since it must be deployed to a server in order to be accessible to Amazon SNS. I'll show you how you can actually test your code locally with the help of a few simple tools.

Using PHP's own built-in webserver and a tool called ngrok to tunnel from the public internet to a local server. He includes the commands to set up the PHP script directory, the code to intercept the POSTed data from the request, validate it and send the subscription confirmation request. He helps you create an SNS "topic" through the management console and walks you through a sample test request while tailing the logs.

tagged: aws amazon sns webhook testing local server ngrok tutorial

Link: http://blogs.aws.amazon.com/php/post/Tx2CO24DVG9CAK0/Testing-Webhooks-Locally-for-Amazon-SNS

AWS PHP Development:
Receiving Amazon SNS Messages in PHP
Apr 01, 2014 @ 15:53:14

The Amazon Web Services PHP Development blog has a new post from Jeremy Lindblom showing you how you can receive inbound SNS messages via a webhook on your application.

Amazon Simple Notification Service (Amazon SNS) is a fast, fully-managed, push messaging service. Amazon SNS can deliver messages to email, mobile devices, Amazon SQS queues, and HTTP/HTTPS endpoints. [...] Though you can certainly subscribe your email address to receive SNS messages from service events like these, your inbox would fill up rather quickly. There is great power, however, in being able to subscribe an HTTP/HTTPS endpoint to receive the messages. This allows you to program webhooks for your applications to easily respond to various events.

Using the AWS SDK for PHP you can set up a listening script that can receive the message and handle subscription confirmations, message signature validation and handling the notifications.

tagged: amazon aws sns message receive webhook sdk

Link: http://blogs.aws.amazon.com/php/post/Tx2G9D94IE6KPAY/Receiving-Amazon-SNS-Messages-in-PHP

PHP/Cloudcast:
Getting Started with Stripe Webhooks
Nov 19, 2012 @ 15:20:51

On the PHP/Cloudcast site today they've released another screencast showing you how to integrate your application with Stripe, the popular (and programmer friendly) payment gateway for your applications. This is the third part of their series.

In this, the third episode of PHP Cloud Development Casts, we go through how to integrate Stripe Webhooks in to our PHP applications. We extend the PHP Kohana application we created in episode 2 and show how simple it is to create a webhook and to receive the information and store it in a MySQL database.

Through the use of Stripe's webhooks, you can have a transaction call back to your application on a specified URL and perform further actions. In his example, he shows how to make the request, handling the "payment success" event. He includes all of the code (controller, view, etc) that you'll need to plug into Kohana to make it all work.

tagged: cloudcast screencast stripe tutorial callback webhook kohana

Link:


Trending Topics: