Skip to content

Commit

Permalink
Merge pull request #474 from emcro/applepay-shipping
Browse files Browse the repository at this point in the history
Allow specifying requiredShippingContactFields in Apple Pay
  • Loading branch information
chrissrogers authored Aug 30, 2018
2 parents 7204a30 + d4d50f7 commit b2ca580
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/recurly/apple-pay.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ class ApplePay extends Emitter {
supportedNetworks: this.config.supportedNetworks,
merchantCapabilities: this.config.merchantCapabilities,
requiredBillingContactFields: ['postalAddress'],
requiredShippingContactFields: this.config.requiredShippingContactFields,
total: this.totalLineItem
});

Expand Down Expand Up @@ -199,6 +200,7 @@ class ApplePay extends Emitter {

this.config.merchantCapabilities = info.merchantCapabilities || [];
this.config.supportedNetworks = info.supportedNetworks || [];
this.config.requiredShippingContactFields = options.requiredShippingContactFields || [];

this.emit('ready');
}
Expand Down Expand Up @@ -301,6 +303,9 @@ class ApplePay extends Emitter {
onShippingContactSelected (event) {
const status = this.session.STATUS_SUCCESS;
const newShippingMethods = [];

this.emit('shippingContactSelected', event);

this.session.completeShippingContactSelection(status, newShippingMethods, this.finalTotalLineItem, this.lineItems);
}

Expand Down Expand Up @@ -345,6 +350,7 @@ class ApplePay extends Emitter {
debug('Token received', token);

this.session.completePayment(this.session.STATUS_SUCCESS);
this.emit('authorized', event);
this.emit('token', token);
}
});
Expand Down

0 comments on commit b2ca580

Please sign in to comment.