Skip to content

Instantly share code, notes, and snippets.

@indreklasn
Created July 1, 2019 12:30
Show Gist options
  • Save indreklasn/36c7f135d03e6a1c05e7172e67e1e6f4 to your computer and use it in GitHub Desktop.
Save indreklasn/36c7f135d03e6a1c05e7172e67e1e6f4 to your computer and use it in GitHub Desktop.
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')
.then(() => thankYouMessage.style.opacity = 1)
})
}
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment