Skip to content

Instantly share code, notes, and snippets.

Avatar
👋

Cornelius Ashley-Osuzoka Corvus97

👋
View GitHub Profile
@Corvus97
Corvus97 / sample.js
Created Jun 8, 2021
Sample Node script to get response body from webhooks.
View sample.js
// This example uses Express to receive webhooks
const app = require("express");
app.post("/my/webhook/url", function(request, response) {
/* It is a good idea to log all events received. Add code *
* here to log the signature and body to db or file */
// retrieve the signature from the header
var hash = req.headers["verif-hash"];
if(!hash) {
// discard the request,only a post with the right Flutterwave signature header gets our attention
}
@Corvus97
Corvus97 / sample.php
Created Jun 8, 2021
Sample PHP script to get response body from a webhook
View sample.php
<?php
// Retrieve the request's body
$body = @file_get_contents("php://input");
// retrieve the signature sent in the reques header's.
$signature = (isset($_SERVER['HTTP_VERIF_HASH']) ? $_SERVER['HTTP_VERIF_HASH'] : '');
/* It is a good idea to log all events received. Add code *
* here to log the signature and body to db or file */
if (!$signature) {
// only a post with Flutterwave signature header gets our attention
exit();
View single_meta.json
{
"cardno": "5438898014560229",
"cvv": "890",
"expirymonth": "09",
"expiryyear": "19",
"currency": "NGN",
"country": "NG",
"amount": "10",
"email": "user@gmail.com",
"phonenumber": "0902620185",