Skip to content

Commit

Permalink
refactor: restore server/controllers/top-level/payments/amazon.js
Browse files Browse the repository at this point in the history
  • Loading branch information
CuriousMagpie committed Dec 17, 2024
1 parent 0b1c3fa commit 74e690c
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions website/server/controllers/top-level/payments/amazon.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import amzLib from '../../../libs/payments/amazon';
import {
authWithHeaders,
} from '../../../middlewares/auth';
import shared from '../../../../common';

const api = {};

Expand Down Expand Up @@ -88,6 +89,40 @@ api.checkout = {
},
};

/**
* @apiIgnore Payments are considered part of the private API
* @api {post} /amazon/subscribe Amazon Payments: subscribe
* @apiName AmazonSubscribe
* @apiGroup Payments
*
* @apiSuccess {Object} data Empty object
* */
api.subscribe = {
method: 'POST',
url: '/amazon/subscribe',
middlewares: [authWithHeaders()],
async handler (req, res) {
const { billingAgreementId } = req.body;
const sub = req.body.subscription
? shared.content.subscriptionBlocks[req.body.subscription]
: false;
const { coupon } = req.body;
const { user } = res.locals;
const { groupId } = req.body;

await amzLib.subscribe({
billingAgreementId,
sub,
coupon,
user,
groupId,
headers: req.headers,
});

res.respond(200);
},
};

/**
* @apiIgnore Payments are considered part of the private API
* @api {get} /amazon/subscribe/cancel Amazon Payments: subscribe cancel
Expand Down

0 comments on commit 74e690c

Please sign in to comment.