Skip to content

Instantly share code, notes, and snippets.

@mitchlloyd
Created January 13, 2017 20:56
Show Gist options
  • Save mitchlloyd/85c35d799c80bd8558660d1f87efd570 to your computer and use it in GitHub Desktop.
Save mitchlloyd/85c35d799c80bd8558660d1f87efd570 to your computer and use it in GitHub Desktop.
Wrap Third Party APIs - Ideal Interface
beginApplePay() {
// ... snip!
this.get('applePay').charge(paymentRequest).then({ result, notify } => {
this.get('onChargeSuccess')({
shippingContact: result.shippingContact,
token: result.token.id,
price,
item,
description: `201 Created Sticker: ${item.get('name')}`
}).then(() => {
trySet(this, 'successMessage', 'Purchase is on its way');
notify.success();
}).catch(() => {
trySet(this, 'errorMessage', 'Purchase failed');
notify.failure();
});
}).catch(error => {
trySet(this, 'errorMessage', error.message);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment