This file contains hidden or 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 add = (a, b, c) => { | |
return a + b + c | |
} | |
add(1, 2, 3, 4, 5, 6) // still 6 |
This file contains hidden or 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 add = (a, b, c) => { | |
return a + b + c | |
} | |
add(1, 2, 3) // 6 |
This file contains hidden or 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 ProtectedRoute = (props, component: Component, ...rest) => { | |
// stuff here | |
} |
This file contains hidden or 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
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') |
This file contains hidden or 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
buyButton.addEventListener('click', () => { | |
const request = new PaymentRequest( | |
buildSupportedPaymentMethodData(), | |
buildShoppingCartDetails() | |
); | |
request.show().then(paymentResponse => { | |
console.log(paymentResponse) | |
}) | |
}) |
This file contains hidden or 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 buildShoppingCartDetails() { | |
return { | |
id: 'count-order', | |
displayItems: [ | |
{ | |
label: 'Example item', | |
amount: {currency: 'USD', value: '1.00'} | |
} | |
], | |
total: { |
This file contains hidden or 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 buildSupportedPaymentMethodData() { | |
// Example supported payment methods: | |
return [{ | |
supportedMethods: 'basic-card', | |
data: { | |
supportedNetworks: ['visa', 'mastercard'], | |
supportedTypes: ['debit', 'credit'] | |
} | |
}]; |
This file contains hidden or 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
buyButton.addEventListener('click', () => { | |
const request = new PaymentRequest( | |
buildSupportedPaymentMethodData(), | |
buildShoppingCartDetails() | |
); | |
}) |
This file contains hidden or 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
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', () => { |
This file contains hidden or 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
new PaymentRequest(methodData: fn, details: fn, options?); |