Skip to content

Instantly share code, notes, and snippets.

@thangman22
Last active August 13, 2016 08:27
Show Gist options
  • Save thangman22/f7e9d5b15b8ede14012fc4bea8f50322 to your computer and use it in GitHub Desktop.
Save thangman22/f7e9d5b15b8ede14012fc4bea8f50322 to your computer and use it in GitHub Desktop.
function onBuy() {
// Define supported credit card
var supportedInstruments = [{
supportedMethods: ['amex', 'diners', 'discover', 'jcb', 'mastercard',
'unionpay', 'visa']
}];
//Order detail
var details = {
total: {label: 'Product', amount: {currency: 'THB', value: '10.00'}},
displayItems: [
{
label: 'Product Item #1',
amount: {currency: 'THB', value: '10.00'}
}
]
};
// Make payment Request
new PaymentRequest(supportedInstruments, details) // eslint-disable-line no-undef
.show()
.then(function(instrumentResponse) {
sendPaymentToServer(instrumentResponse);
})
.catch(function(err) {
console.log(err)
});
}
function sendPaymentToServer(instrumentResponse) {
// Implement sent data to Server here
instrumentResponse.complete('success')
.then(function() {
console.log(instrumentResponse)
})
.catch(function(err) {
console.log(err);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment