Skip to content

Commit

Permalink
Redirect users back to the plan page instead of the homepage in case of
Browse files Browse the repository at this point in the history
payment cancellation or technical errors.
  • Loading branch information
southp committed Apr 13, 2018
1 parent 7f455ed commit 53b7e6a
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions client/my-sites/checkout/checkout-thank-you/pending.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,29 +34,33 @@ class CheckoutPending extends PureComponent {

componentWillReceiveProps( nextProps ) {
const { transaction, error } = nextProps;
const { translate, showErrorNotice } = this.props;
const { translate, showErrorNotice, siteSlug } = this.props;

const retryOnError = () => {
page( `/checkout/${ this.props.siteSlug }` );
page( `/checkout/${ siteSlug }` );

showErrorNotice(
translate( "Sorry, we couldn't process your payment. Please try again later." )
);
};

const planRoute = `/plans/my-plan/${ siteSlug }`;

if ( transaction ) {
const { processingStatus } = transaction;

if ( ORDER_TRANSACTION_STATUS.SUCCESS === processingStatus ) {
page( `/checkout/thank-you/${ this.props.siteSlug }` );
page( `/checkout/thank-you/${ siteSlug }` );

return;
}

// It is mostly because the user has cancelled the payment.
// See the explanation in https://github.com/Automattic/wp-calypso/pull/23670#issuecomment-377186515
if ( ORDER_TRANSACTION_STATUS.FAILURE === processingStatus ) {
// Bring the user back to the homepage in this case.
page( '/' );
// Bring the user back to the plan page in this case.
page( planRoute );

return;
}

Expand All @@ -70,8 +74,8 @@ class CheckoutPending extends PureComponent {

// The API has responded a status string that we don't expect somehow.
if ( ORDER_TRANSACTION_STATUS.UNKNOWN === processingStatus ) {
// Redirect users back to the homepage so that they won't be stuck here.
page( '/' );
// Redirect users back to the plan page so that they won't be stuck here.
page( planRoute );

showErrorNotice( translate( 'Oops! Something went wrong. Please try again later.' ) );

Expand Down

0 comments on commit 53b7e6a

Please sign in to comment.