Updated portal stripe actions

no refs

- Updates stripe actions via portal to use custom parameter values to show notifications
- Updated parameter don't interfere with existing theme notifications
This commit is contained in:
Rish 2020-11-20 10:27:06 +05:30
parent 9dac6d9435
commit 4dc22ca568
3 changed files with 11 additions and 11 deletions

View File

@ -188,9 +188,9 @@ export default class Notification extends React.Component {
const type = this.state.type;
const deleteParams = [];
if (['signin', 'signup'].includes(type)) {
deleteParams.push('action', 'portal-action', 'success');
deleteParams.push('portal-action', 'success');
} else if (['stripe:checkout'].includes(type)) {
deleteParams.push('stripe', 'portal-stripe');
deleteParams.push('stripe');
}
clearURLParams(deleteParams);
this.setState({

View File

@ -130,13 +130,13 @@ function setupGhostApi({siteUrl = window.location.origin}) {
const url = endpointFor({type: 'members', resource: 'create-stripe-checkout-session'});
if (!successUrl) {
const checkoutSuccessUrl = new URL(siteUrl);
checkoutSuccessUrl.searchParams.set('portal-stripe', 'success');
checkoutSuccessUrl.searchParams.set('stripe', 'portal-success');
successUrl = checkoutSuccessUrl.href;
}
if (!cancelUrl) {
const checkoutCancelUrl = new URL(siteUrl);
checkoutCancelUrl.searchParams.set('portal-stripe', 'cancel');
checkoutCancelUrl.searchParams.set('stripe', 'portal-cancel');
cancelUrl = checkoutCancelUrl.href;
}
return makeRequest({
@ -181,13 +181,13 @@ function setupGhostApi({siteUrl = window.location.origin}) {
const url = endpointFor({type: 'members', resource: 'create-stripe-update-session'});
if (!successUrl) {
const checkoutSuccessUrl = new URL(siteUrl);
checkoutSuccessUrl.searchParams.set('portal-stripe', 'success');
checkoutSuccessUrl.searchParams.set('stripe', 'portal-billing-update-success');
successUrl = checkoutSuccessUrl.href;
}
if (!cancelUrl) {
const checkoutCancelUrl = new URL(siteUrl);
checkoutCancelUrl.searchParams.set('portal-stripe', 'cancel');
checkoutCancelUrl.searchParams.set('stripe', 'portal-billing-update-cancel');
cancelUrl = checkoutCancelUrl.href;
}
return makeRequest({

View File

@ -12,8 +12,8 @@ export const handleAuthActions = ({qsParams, action, status}) => {
};
export const handleStripeActions = ({status, billingOnly}) => {
if (!billingOnly && ['success'].includes(status)) {
const statusVal = status === 'success' ? 'success' : 'warning';
if (!billingOnly && ['portal-success'].includes(status)) {
const statusVal = status === 'portal-success' ? 'success' : 'warning';
return {
type: 'stripe:checkout',
status: statusVal,
@ -22,8 +22,8 @@ export const handleStripeActions = ({status, billingOnly}) => {
};
}
if (billingOnly && ['billing-update-success', 'billing-update-cancel'].includes(status)) {
const statusVal = status === 'billing-update-success' ? 'success' : 'warning';
if (billingOnly && ['portal-billing-update-success', 'portal-billing-update-cancel'].includes(status)) {
const statusVal = status === 'portal-billing-update-success' ? 'success' : 'warning';
return {
type: 'stripe:billing-update',
status: statusVal,
@ -53,7 +53,7 @@ export default function NotificationParser({billingOnly = false} = {}) {
const qsParams = new URLSearchParams(qs);
const action = qsParams.get('portal-action');
const successStatus = qsParams.get('success');
const stripeStatus = qsParams.get('stripe') || qsParams.get('portal-stripe');
const stripeStatus = qsParams.get('stripe');
let notificationData = null;
if (stripeStatus) {