mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-17 23:44:39 -05:00
Added member data refresh for stripe checkout
no refs Does member data refresh when hiding notification to ensure subscription data for member is fetched if Stripe webhooks are delayed on server and shows no subscription in first request.
This commit is contained in:
parent
87f08919b7
commit
6566cc08e6
2 changed files with 23 additions and 0 deletions
|
@ -273,6 +273,27 @@ async function updateMemberData({data, state, api}) {
|
|||
return null;
|
||||
}
|
||||
|
||||
async function refreshMemberData({state, api}) {
|
||||
if (state.member) {
|
||||
try {
|
||||
const member = await api.member.sessionData();
|
||||
if (member) {
|
||||
return {
|
||||
member,
|
||||
success: true
|
||||
};
|
||||
}
|
||||
return null;
|
||||
} catch (err) {
|
||||
return {
|
||||
success: false,
|
||||
error: err
|
||||
};
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
async function updateProfile({data, state, api}) {
|
||||
const [dataUpdate, emailUpdate] = await Promise.all([updateMemberData({data, state, api}), updateMemberEmail({data, state, api})]);
|
||||
if (dataUpdate && emailUpdate) {
|
||||
|
@ -345,6 +366,7 @@ const Actions = {
|
|||
cancelSubscription,
|
||||
updateNewsletter,
|
||||
updateProfile,
|
||||
refreshMemberData,
|
||||
clearPopupNotification,
|
||||
editBilling,
|
||||
checkoutPlan
|
||||
|
|
|
@ -193,6 +193,7 @@ export default class Notification extends React.Component {
|
|||
deleteParams.push('stripe');
|
||||
}
|
||||
clearURLParams(deleteParams);
|
||||
this.context.onAction('refreshMemberData');
|
||||
this.setState({
|
||||
active: false
|
||||
});
|
||||
|
|
Loading…
Add table
Reference in a new issue