mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-29 15:12:58 +03:00
Added stripe url handling for checkout success
refs https://github.com/TryGhost/membersjs/issues/10 We use stripe query param `?stripe=<state>` for redirects from checkout session, this handles the magic link popup for checkout success state on redirect.
This commit is contained in:
parent
712ac5cd74
commit
f813185cc3
@ -25,28 +25,39 @@ export default class ParentContainer extends React.Component {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getStripeUrlParam() {
|
||||||
|
const url = new URL(window.location);
|
||||||
|
return url.searchParams.get('stripe');
|
||||||
|
}
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
this.fetchData();
|
this.fetchData();
|
||||||
}
|
}
|
||||||
|
|
||||||
getDefaultPage(member) {
|
getDefaultPage({member, stripeParam}) {
|
||||||
// Change page here for testing local UI testing
|
// Change page here for testing local UI testing
|
||||||
if (process.env.NODE_ENV === 'development') {
|
if (process.env.NODE_ENV === 'development') {
|
||||||
return 'accountHome';
|
return {page: 'accountHome'};
|
||||||
}
|
}
|
||||||
|
if (!member && stripeParam === 'success') {
|
||||||
return member ? 'accountHome' : 'signup';
|
return {page: 'magiclink', showPopup: true};
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
page: member ? 'accountHome' : 'signup'
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
async fetchApiData(adminUrl) {
|
async fetchApiData(adminUrl) {
|
||||||
try {
|
try {
|
||||||
this.GhostApi = setupGhostApi({adminUrl});
|
this.GhostApi = setupGhostApi({adminUrl});
|
||||||
let {site, member} = await this.GhostApi.init();
|
const {site, member} = await this.GhostApi.init();
|
||||||
|
const stripeParam = this.getStripeUrlParam();
|
||||||
|
const {page, showPopup = false} = this.getDefaultPage({member, stripeParam});
|
||||||
this.setState({
|
this.setState({
|
||||||
site,
|
site,
|
||||||
member,
|
member,
|
||||||
page: this.getDefaultPage(member),
|
page,
|
||||||
|
showPopup,
|
||||||
action: 'init:success',
|
action: 'init:success',
|
||||||
initStatus: 'success'
|
initStatus: 'success'
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user