Skip to content

Instantly share code, notes, and snippets.

View indreklasn's full-sized avatar
👋

Trevor I. Lasn indreklasn

👋
View GitHub Profile
const add = (a, b, c) => {
return a + b + c
}
add(1, 2, 3, 4, 5, 6) // still 6
const add = (a, b, c) => {
return a + b + c
}
add(1, 2, 3) // 6
const ProtectedRoute = (props, component: Component, ...rest) => {
// stuff here
}
buyButton.addEventListener('click', () => {
const request = new PaymentRequest(buildSupportedPaymentMethodData(), buildShoppingCartDetails());
request.canMakePayment().then(result => {
if (result) {
request.show().then(paymentResponse => {
console.log(paymentResponse.details)
// Here we would process the payment. For this demo, simulate immediate success:
paymentResponse.complete('success')
buyButton.addEventListener('click', () => {
const request = new PaymentRequest(
buildSupportedPaymentMethodData(),
buildShoppingCartDetails()
);
request.show().then(paymentResponse => {
console.log(paymentResponse)
})
})
function buildShoppingCartDetails() {
return {
id: 'count-order',
displayItems: [
{
label: 'Example item',
amount: {currency: 'USD', value: '1.00'}
}
],
total: {
function buildSupportedPaymentMethodData() {
// Example supported payment methods:
return [{
supportedMethods: 'basic-card',
data: {
supportedNetworks: ['visa', 'mastercard'],
supportedTypes: ['debit', 'credit']
}
}];
buyButton.addEventListener('click', () => {
const request = new PaymentRequest(
buildSupportedPaymentMethodData(),
buildShoppingCartDetails()
);
})
let count = 0
const cartIncrementButton = document.getElementById('cartIncrement')
const cartDecrementButton = document.getElementById('cartDecrement')
const countElement = document.getElementById('count')
const buyButton = document.getElementById('purchase')
function init() {
countElement.innerHTML = count
cartIncrementButton.addEventListener('click', () => {
new PaymentRequest(methodData: fn, details: fn, options?);