Last active
August 29, 2015 14:27
-
-
Save domenic/1392875f2df87f758ba0 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
var promise = paymentRequest(supportedInstruments, details, schemeData); | |
promise.then(function (paymentConfigurator) { // needs a slightly better name | |
paymentConfigurator.addEventListener("shippingAddressChange", function () { // no need for event | |
var newAddress = paymentConfigurator.address; | |
console.log(newAddress.street, newAddress.city, newAddress.state, newAddress.zip, newAddress.country); | |
// Return back new shipping options | |
paymentConfigurator.updateShippingOptions(newShippingOpions); | |
}); | |
return paymentConfigurator.instrumentResponse; | |
}) | |
.then(function (response) { | |
console.log("hurray, valid response from ", response.instrumentName, response.details); | |
}) | |
.catch(function (err) { | |
console.error("oh no, either popping up the configurator dialog or " + | |
"performing the transaction failed", err); | |
}); | |
// Simpler: | |
promise.then(function (paymentConfigurator) { // needs a slightly better name | |
return paymentConfigurator.instrumentResponse; | |
}) | |
.then(function (response) { | |
console.log("hurray, valid response from ", response.instrumentName, response.details); | |
}) | |
.catch(function (err) { | |
console.error("oh no, either popping up the configurator dialog or " + | |
"performing the transaction failed", err); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment