mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-03-11 02:12:21 -05:00
Added support for stripe connect test mode
no-issue This adds the ability to pass a `mode` param of 'test' to the members stripe connect service, which will ensure we use a testmode client_id for the Stripe Connect OAuth flow. This will allow users to connect their account in testmode.
This commit is contained in:
parent
5595408c97
commit
2ff151a893
1 changed files with 6 additions and 2 deletions
|
@ -4,7 +4,8 @@ const {URL} = require('url');
|
|||
|
||||
const STATE_PROP = 'stripe-connect-state';
|
||||
|
||||
const clientID = 'ca_8LBuZWhYshxF0A55KgCXu8PRTquCKC5x';
|
||||
const liveClientID = 'ca_8LBuZWhYshxF0A55KgCXu8PRTquCKC5x';
|
||||
const testClientID = 'ca_8LBum4Ctv3mmJ1oD0ZRmxjdAhNrrBUy3';
|
||||
const redirectURI = 'https://stripe.ghost.org';
|
||||
|
||||
/**
|
||||
|
@ -12,14 +13,17 @@ const redirectURI = 'https://stripe.ghost.org';
|
|||
* @desc Returns a url for the auth endpoint for Stripe Connect, generates state and stores it on the session.
|
||||
*
|
||||
* @param {(prop: string, val: any) => Promise<void>} setSessionProp - A function to set data on the current session
|
||||
* @param {'live' | 'test'} mode - Which stripe mode to set up
|
||||
*
|
||||
* @returns {Promise<URL>}
|
||||
*/
|
||||
async function getStripeConnectOAuthUrl(setSessionProp) {
|
||||
async function getStripeConnectOAuthUrl(setSessionProp, mode = 'live') {
|
||||
const state = randomBytes(16).toString('hex');
|
||||
|
||||
await setSessionProp(STATE_PROP, state);
|
||||
|
||||
const clientID = mode === 'live' ? liveClientID : testClientID;
|
||||
|
||||
const authUrl = new URL('https://connect.stripe.com/oauth/authorize');
|
||||
authUrl.searchParams.set('response_type', 'code');
|
||||
authUrl.searchParams.set('scope', 'read_write');
|
||||
|
|
Loading…
Add table
Reference in a new issue