This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
makePaymentRequest({ provider, name, email, amount }) | |
.then(response => { | |
switch (provider) { | |
case "banked": | |
window.location.href = response.url | |
break | |
case "stripe": | |
this.stripe.redirectToCheckout({ sessionId: response.sessionId }) | |
break | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function createStripePaymentRequest(req, res) { | |
const cors = require('cors')({ | |
origin: true, | |
}); | |
return cors(req, res, () => { | |
const functions = require('firebase-functions'); | |
const stripe = require('stripe')(functions.config().stripe.secret_key); | |
const recordPayment = require('../shared/recordPayment'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const functions = require('firebase-functions'); | |
function createBankedPaymentRequest(req, res) { | |
const cors = require('cors')({ | |
origin: true, | |
}); | |
return cors(req, res, () => { | |
const payerName = req.body.payerName; | |
const payerEmail = req.body.payerEmail; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getCookie(request, name) { | |
let result = null; | |
let cookieString = request.headers.get('Cookie'); | |
if (cookieString) { | |
let cookies = cookieString.split(';') | |
cookies.forEach(cookie => { | |
let cookieName = cookie.split('=')[0].trim() | |
if (cookieName === name) { | |
let cookieVal = cookie.split('=')[1] | |
result = cookieVal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<head> | |
<title>Your Application</title> | |
</head> | |
<body> | |
<script src="https://js.banked.com/v1" data-api-key="YOUR_CLIENT_KEY" type="text/javascript"></script> | |
<banked-provider-list payment-id="PAYMENT_ID"></banked-provider-list> | |
<banked-pay-button></banked-pay-button> | |
</body> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
document.getElementByID('banked-provider-list').addEventListener('banked-provider-set', function (e) { | |
window.location.replace(e.detail.redirectUrl); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
document.getElementByID('banked-provider-list').addEventListener('banked-provider-set', function (e) { | |
console.log(e.detail.redirectUrl); // e.g. https://bank.com/authorise/09234098-2983-029340/ | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<head> | |
<title>Your Application</title> | |
</head> | |
<body> | |
<script src="https://js.banked.com/v1" data-api-key="YOUR_CLIENT_KEY" type="text/javascript"></script> | |
<div id="banked-provider-list" data-payment-id="SOME_PAYMENT_ID"></div> | |
</body> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const hydrateRequest = (body) => { | |
return { | |
reference: 'Banked Demo', | |
success_url: `${process.env.BASE_URL}/cart/success`, | |
error_url: `${process.env.BASE_URL}/cart/error`, | |
line_items: body.map((item) => { | |
return { | |
name: item.name, | |
amount: item.amount * 100, // Amount is sent in whole pennies/cents | |
currency: 'GBP', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Banked = require('@banked/node') | |
// -- snip | |
const banked = new Banked({ | |
api_key: process.env.BANKED_API_KEY, | |
secret_key: process.env.BANKED_API_SECRET | |
}) | |
// -- snip | |
app.post('/checkout', async function (req, res) { | |
try { | |
const bankedResponse = await banked.payments.create(req.body) |
NewerOlder