Updated checkout flow to pre-fill member email

refs https://github.com/TryGhost/members.js/issues/10

- Takes advantage of change here - 24b83bdc49 - to pre-fill customer email in anonymous checkout flow
- Member cannot change their email in this checkout session, allowing consistency and correct linking post checkout
This commit is contained in:
Rish 2020-04-30 17:23:23 +05:30
parent f813185cc3
commit d11afe363f
2 changed files with 5 additions and 4 deletions

View File

@ -144,11 +144,11 @@ export default class ParentContainer extends React.Component {
page: 'magiclink'
});
} else if (action === 'signup') {
const {plan} = data;
const {plan, email} = data;
if (plan.toLowerCase() === 'free') {
await this.GhostApi.member.sendMagicLink(data);
} else {
await this.GhostApi.member.checkoutPlan({plan});
await this.GhostApi.member.checkoutPlan({plan, email});
}
this.setState({
action: 'signup:success',

View File

@ -111,7 +111,7 @@ function setupGhostApi({adminUrl}) {
});
},
async checkoutPlan({plan, checkoutCancelUrl, checkoutSuccessUrl}) {
async checkoutPlan({plan, checkoutCancelUrl, checkoutSuccessUrl, email: customerEmail}) {
const identity = await api.member.identity();
const url = endpointFor({type: 'members', resource: 'create-stripe-checkout-session'});
@ -125,7 +125,8 @@ function setupGhostApi({adminUrl}) {
plan: plan,
identity: identity,
successUrl: checkoutSuccessUrl,
cancelUrl: checkoutCancelUrl
cancelUrl: checkoutCancelUrl,
customerEmail: customerEmail
})
}).then(function (res) {
if (!res.ok) {