Created
October 4, 2019 14:56
-
-
Save danielneu/fd526c4f546b26399d7c7d2e18c46020 to your computer and use it in GitHub Desktop.
Order Independent callback logic
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
// add Login and Pay callbacks | |
window.onAmazonPaymentsReady = () => { | |
this.createButton(sellerId, scope, type, color, size, mountLocation); | |
} | |
// if the OffAmazonPayments namespace is already available, call the callback manually - otherwise wait for Amazon to call it | |
if (typeof window.OffAmazonPayments !== 'undefined') { | |
window.onAmazonPaymentsReady(); | |
} | |
createButton(sellerId, scope, type, color, size, mountLocation) { | |
window.OffAmazonPayments.Button(mountLocation, sellerId, { | |
type, | |
color, | |
size, | |
authorization: () => { | |
const loginOptions = { scope }; | |
window.amazon.Login.authorize(loginOptions, this.onAuthorize); | |
}, | |
onError: this.onError, | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment