Skip to content

Instantly share code, notes, and snippets.

@dsternlicht
dsternlicht / i18n.js
Created November 13, 2017 11:38
i18n.js file with moment.js
import ReactNative from 'react-native';
import I18n from 'react-native-i18n';
import moment from 'moment';
// Import all locales
import en from './en.json';
import he from './he.json';
// Should the app fallback to English if user locale doesn't exists
I18n.fallbacks = true;
@dsternlicht
dsternlicht / app.js
Created July 24, 2018 07:37
Creating a PayPal IPN Endpoint With NodeJS - app.js
import express from 'express';
import bodyParser from 'body-parser';
import routes from './server/routes';
const app = express();
// ...
// Parse application/x-www-form-urlencoded
@dsternlicht
dsternlicht / routes.js
Created July 24, 2018 07:46
Creating a PayPal IPN Endpoint With NodeJS - routes.js
import IPNController from './controllers/ipn.ctrl';
function routes(app) {
// ...
// PayPal IPN endpoint
app.post('/ipn', IPNController.index);
// ...
}
@dsternlicht
dsternlicht / ipn.ctrl.js
Last active July 24, 2018 08:20
Creating a PayPal IPN Endpoint With NodeJS - ipn.ctrl.js - Basic Structure
class IPNController {
static index(req, res) {
console.log('It works! 😀');
res.status(200).send('OK');
res.end();
}
}
@dsternlicht
dsternlicht / paypal.service.js
Last active July 16, 2019 05:07
Creating a PayPal IPN Endpoint With NodeJS - paypal.service.js - Validating IPN messages
import request from 'request';
import querystring from 'querystring';
import Promise from 'bluebird';
class PayPalService {
static validate(body = {}) {
return new Promise((resolve, reject) => {
// Prepend 'cmd=_notify-validate' flag to the post string
let postreq = 'cmd=_notify-validate';
@dsternlicht
dsternlicht / ipn.ctrl.js
Created July 24, 2018 09:19
Creating a PayPal IPN Endpoint With NodeJS - ipn.ctrl.js - With IPN message validation
class IPNController {
static async index(req, res) {
// Send 200 status back to PayPal
res.status(200).send('OK');
res.end();
const body = req.body || {};
// Validate IPN message with PayPal
@dsternlicht
dsternlicht / ipn.ctrl.js
Created July 24, 2018 09:51
Creating a PayPal IPN Endpoint With NodeJS - ipn.ctrl.js - Processing an IPN message
class IPNController {
static async index(req, res) {
// Send 200 status back to PayPal
res.status(200).send('OK');
res.end();
const body = req.body || {};
// Validate IPN message with PayPal
@dsternlicht
dsternlicht / modal.html
Last active November 27, 2018 15:03
HTML Mock for our modal component
<div class="modal">
<div class="overlay"></div>
<div class="modal_content">
<!-- Dynamic Section -->
<h2>Hey Awesome Modal!</h2>
<p style="text-align: center;">
Cupcake ipsum dolor sit amet pie brownie. Carrot cake wafer I love pie bear claw. Sweet cake cheesecake candy canes carrot cake marshmallow. Sweet roll I love sweet fruitcake donut chupa.
</p>
<!-- End of Dynamic Section -->
<button title="Close" class="close_modal">
@dsternlicht
dsternlicht / style.css
Last active November 27, 2018 15:03
CSS Mock for our modal component
.modal {
position: fixed;
left: 0;
top: 0;
width: 100%;
height: 100%;
z-index: 990;
}
.modal .overlay {
@dsternlicht
dsternlicht / index.html
Last active November 27, 2018 15:02
HTML Mock for our vanilla modal component
<div class="modal" style="display: none">
<div class="overlay"></div>
<div class="modal_content">
<!-- Dynamic Section -->
<h2>Told Ya!</h2>
<iframe src="https://giphy.com/embed/l52CGyJ4LZPa0" width="480" height="273" frameBorder="0" class="giphy-embed" allowFullScreen></iframe><p><a href="https://giphy.com/gifs/sandler-sentences-sounding-l52CGyJ4LZPa0">via GIPHY</a></p>
<!-- End of Dynamic Section -->
<button title="Close" class="close_modal">
<i class="fas fa-times"></i>
</button>