Ghost/core/server/api/canary/membersStripeConnect.js
Fabien O'Carroll 33d1148cff Supported test mode in members_stripe_connect API
no-issue

We've added a "mode" query param to the members_stripe_connect api auth
method, allowing the client to easily switch between live and test mode.
2020-06-10 14:06:57 +02:00

30 lines
952 B
JavaScript

const membersService = require('../../services/members');
module.exports = {
docName: 'members_stripe_connect',
auth: {
permissions: true,
options: [
'mode'
],
validation: {
options: {
mode: {
values: ['live', 'test']
}
}
},
query(frame) {
// This is something you have to do if you want to use the "framework" with access to the raw req/res
frame.response = async function (req, res) {
function setSessionProp(prop, val) {
req.session[prop] = val;
}
const mode = frame.options.mode || 'live';
const stripeConnectAuthURL = await membersService.stripeConnect.getStripeConnectOAuthUrl(setSessionProp, mode);
return res.redirect(stripeConnectAuthURL);
};
}
}
};