mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-03-18 02:21:47 -05:00
Fixed direct signup links not opening stripe checkout session
- state data is not available in actions when signing up directly via signup or offer query on page load - adds tier and cadence data directly to the action to bypass state data need when available
This commit is contained in:
parent
6216ff1971
commit
c96149198d
2 changed files with 18 additions and 9 deletions
|
@ -10,7 +10,7 @@ import {getActivePage, isAccountPage, isOfferPage} from './pages';
|
|||
import ActionHandler from './actions';
|
||||
import './App.css';
|
||||
import NotificationParser from './utils/notifications';
|
||||
import {createPopupNotification, getCurrencySymbol, getFirstpromoterId, getPriceIdFromPageQuery, getProductFromId, getQueryPrice, getSiteDomain, isActiveOffer, isComplimentaryMember, isInviteOnlySite, isPaidMember, isSentryEventAllowed, removePortalLinkFromUrl} from './utils/helpers';
|
||||
import {createPopupNotification, getCurrencySymbol, getFirstpromoterId, getPriceIdFromPageQuery, getProductCadenceFromPrice, getProductFromId, getQueryPrice, getSiteDomain, isActiveOffer, isComplimentaryMember, isInviteOnlySite, isPaidMember, isSentryEventAllowed, removePortalLinkFromUrl} from './utils/helpers';
|
||||
|
||||
const {handleDataAttributes} = require('./data-attributes');
|
||||
const React = require('react');
|
||||
|
@ -619,9 +619,11 @@ export default class App extends React.Component {
|
|||
page: 'loading'
|
||||
});
|
||||
if (member) {
|
||||
this.dispatchAction('checkoutPlan', {plan: price.id, offerId});
|
||||
const {tierId, cadence} = getProductCadenceFromPrice({site, priceId: price.id});
|
||||
this.dispatchAction('checkoutPlan', {plan: price.id, offerId, tierId, cadence});
|
||||
} else {
|
||||
this.dispatchAction('signup', {plan: price.id, offerId});
|
||||
const {tierId, cadence} = getProductCadenceFromPrice({site, priceId: price.id});
|
||||
this.dispatchAction('signup', {plan: price.id, offerId, tierId, cadence});
|
||||
}
|
||||
} else {
|
||||
this.dispatchAction('openPopup', {
|
||||
|
@ -659,7 +661,8 @@ export default class App extends React.Component {
|
|||
page: 'loading'
|
||||
});
|
||||
}
|
||||
this.dispatchAction('signup', {plan});
|
||||
const {tierId, cadence} = getProductCadenceFromPrice({site, priceId: plan});
|
||||
this.dispatchAction('signup', {plan, tierId, cadence});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -95,12 +95,16 @@ async function signin({data, api, state}) {
|
|||
|
||||
async function signup({data, state, api}) {
|
||||
try {
|
||||
const {plan, email, name, newsletters, offerId} = data;
|
||||
let {plan, tierId, cadence, email, name, newsletters, offerId} = data;
|
||||
if (plan.toLowerCase() === 'free') {
|
||||
await api.member.sendMagicLink(data);
|
||||
} else {
|
||||
const {tierId, cadence} = getProductCadenceFromPrice({site: state?.site, priceId: plan});
|
||||
await api.member.checkoutPlan({plan, tierId, cadence, email, name, newsletters, offerId});
|
||||
if (tierId && cadence) {
|
||||
await api.member.checkoutPlan({plan, tierId, cadence, email, name, newsletters, offerId});
|
||||
} else {
|
||||
({tierId, cadence} = getProductCadenceFromPrice({site: state?.site, priceId: plan}));
|
||||
await api.member.checkoutPlan({plan, tierId, cadence, email, name, newsletters, offerId});
|
||||
}
|
||||
}
|
||||
return {
|
||||
page: 'magiclink',
|
||||
|
@ -119,8 +123,10 @@ async function signup({data, state, api}) {
|
|||
|
||||
async function checkoutPlan({data, state, api}) {
|
||||
try {
|
||||
const {plan, offerId} = data;
|
||||
const {tierId, cadence} = getProductCadenceFromPrice({site: state?.site, priceId: plan});
|
||||
let {plan, offerId, tierId, cadence} = data;
|
||||
if (!tierId || !cadence) {
|
||||
({tierId, cadence} = getProductCadenceFromPrice({site: state?.site, priceId: plan}));
|
||||
}
|
||||
await api.member.checkoutPlan({
|
||||
plan,
|
||||
tierId,
|
||||
|
|
Loading…
Add table
Reference in a new issue