Skip to content

Instantly share code, notes, and snippets.

@johnotu
johnotu / payment-webview.ejs
Created December 7, 2018 18:44
Payment for Messenger - Payment Webview
<html lang="en">
<head>
<title>Card payment</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm"
crossorigin="anonymous"> >
<meta name="viewport" , content="user-scalable=no, width=device-width, initial-scale=1, maximum-scale=1">
<style>
@johnotu
johnotu / process-cardpayment.js
Created December 7, 2018 18:43
Payment for Messenger - Process Card payments
/**
* Handle card payment using Flutterwave API
*
*/
'use strict';
const express = require('express');
const router = express.Router();
const request = require('request');
@johnotu
johnotu / process-mobilemoney-gh.js
Created December 7, 2018 17:52
Payment for Messenger - Process Mobilemoney payments
/**
* Process mobile money payments using Mazzuma API
*
*/
'use strict';
const request = require('request');
const sendTextMessage = require('../actions/sendTextMsg');
@johnotu
johnotu / handle-postbacks.js
Created December 7, 2018 17:50
Payment for Messenger - Handle Bot Postbacks
/**
* Handle postbacks received by bot server
*
*/
'use strict';
// Assume you have these functions defined and exported in your project folder
const sendTextMessage = require('../actions/sendTextMsg');
const processMobilemoney = require('./process-mobilemoney-gh');
@johnotu
johnotu / handle-messages.js
Created December 7, 2018 17:49
Payment for Messenger - Handle Bot Messages
/**
* Handle messages received by bot server
*
*/
'use strict';
// Assume you have these functions defined and exported in your project folder
const sendTextMessage = require('../actions/sendTextMsg');
const sendButtonMsg = require('../actions/sendButtonMsg');
quickReplies.push({
"content_type": "text",
"title": "Next",
"payload": "nextslice_5_10"
});
@johnotu
johnotu / product-quickreplies.js
Last active December 11, 2017 01:40
Repeatedly generate different sets of quick replies from a products array
const productQuickreplies = (products, sliceSet, beginSlice, endSlice) => {
// slice the elements of the array to the desired set size
let slicedProducts = products.slice(beginSlice, endSlice);
// form an array of quick replies with title and payload
let quickReplies = slicedProducts.map(product => {
return {
"content_type": "text",
"title": product.title,
[
{
_id: '59ed1ed9be3ee700123e4e4a',
title: 'shoes',
status: 'Active',
__v: 0,
},
{
_id: '59ed1ee7be3ee700123e4e4b',
title: 'casual',
const quickReplyTags = (tags, sliceSet, beginSlice, endSlice) => {
// slice the elements of the array to the desired set size
let slicedTags = tags.slice(beginSlice, endSlice);
// form an array of quick replies with title and payload
let quickReplies = slicedTags.map(tag => {
return {
"content_type": "text",
"title": tag.title,
@johnotu
johnotu / index.css
Created August 19, 2017 02:46
Simple template for HNG Internship Stage-2 personal page task
.container {
text-align: center;
padding: 1.5em 0;
}
img {
width: 40%;
height: auto;
}