Skip to content

Commit

Permalink
Updated members api and gateway to pass coupo
Browse files Browse the repository at this point in the history
no-issue

This will allow the auth pages and members sdk to pass coupons through
to the api.
  • Loading branch information
allouis committed Apr 17, 2019
1 parent cdc3971 commit 88368d0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
7 changes: 4 additions & 3 deletions core/server/lib/members/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ module.exports = function MembersApi({
}

/* subscriptions */
apiRouter.post('/subscription', getData('adapter', 'plan', 'stripeToken'), ssoOriginCheck, (req, res) => {
apiRouter.post('/subscription', getData('adapter', 'plan', 'stripeToken', 'coupon'), ssoOriginCheck, (req, res) => {
const {signedin} = getCookie(req);
if (!signedin) {
res.writeHead(401, {
Expand All @@ -127,7 +127,7 @@ module.exports = function MembersApi({
return res.end();
}

const {plan, adapter, stripeToken} = req.data;
const {plan, adapter, stripeToken, coupon} = req.data;

subscriptions.getAdapters()
.then((adapters) => {
Expand All @@ -140,7 +140,8 @@ module.exports = function MembersApi({
return subscriptions.createSubscription(member, {
adapter,
plan,
stripeToken
stripeToken,
coupon
});
})
.then(() => {
Expand Down
5 changes: 3 additions & 2 deletions core/server/lib/members/static/gateway/bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@

addMethod('getToken', getToken);

addMethod('createSubscription', function createSubscription({adapter, plan, stripeToken}) {
addMethod('createSubscription', function createSubscription({adapter, plan, stripeToken, coupon}) {
return fetch(`${membersApiUrl}subscription`, {
method: 'POST',
headers: {
Expand All @@ -151,7 +151,8 @@
origin,
adapter,
plan,
stripeToken
stripeToken,
coupon
})
}).then((res) => {
if (res.ok) {
Expand Down

0 comments on commit 88368d0

Please sign in to comment.