Last active
August 13, 2016 08:27
-
-
Save thangman22/f7e9d5b15b8ede14012fc4bea8f50322 to your computer and use it in GitHub Desktop.
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 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