Skip to content

Instantly share code, notes, and snippets.

@mitchlloyd
Last active January 13, 2017 21:34
Show Gist options
  • Select an option

  • Save mitchlloyd/15980bc78fbccae76f421f6e9c6e9c78 to your computer and use it in GitHub Desktop.

Select an option

Save mitchlloyd/15980bc78fbccae76f421f6e9c6e9c78 to your computer and use it in GitHub Desktop.

Revisions

  1. mitchlloyd revised this gist Jan 13, 2017. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions apple-pay.js
    Original file line number Diff line number Diff line change
    @@ -18,6 +18,8 @@ export default Service.extend({
    return new RSVP.Promise((resolve, reject) => {
    resolve({
    result: {
    // Here we use stubbed data, but you may consider passing this information
    // into the fake to handle more test cases.
    token: { id: 'fake-token-id' },
    shippingContact 'Fake Shipping Contact'
    },
  2. mitchlloyd created this gist Jan 13, 2017.
    35 changes: 35 additions & 0 deletions apple-pay.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,35 @@
    import Ember from 'ember';
    const { Service, RSVP } = Ember;

    export default Service.extend({
    init() {
    this._super(...arguments);

    // We record both the charges sent and notifications sent to verify in
    // our tests.
    this.chargesSent = [];
    this.notificationsSent = [];
    },

    charge(payment) {
    this.chargesSent.push(payment);
    let notificationsSent = this.notificationsSent;

    return new RSVP.Promise((resolve, reject) => {
    resolve({
    result: {
    token: { id: 'fake-token-id' },
    shippingContact 'Fake Shipping Contact'
    },
    notify: {
    success() {
    notificationsSent.push('success')
    },
    failure() {
    notificationsSent.push('failure')
    }
    }
    })
    });
    }
    });