• Resolved RC2102

    (@rc2102)


    I have a form displayed in a post using the shortcode [charitable_donation_form campaign_id=2200]. This works fine. The problem is when a user is on PayPal and decides to cancel and return to its previous post, the system does not redirect you to the previous post (where form is displayed using shortcode) but to the campaign page. Can this be corrected? And however cancels, the user is redirected back to the original post? Thank you.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author WPCharitable

    (@wpcharitable)

    @rc2102 Thanks for reaching out.

    So yes, in this instance you are correct – because by default Paypal tries to go back to the donation form of the campaign page if you cancel. When you cancel (typically, depending on setup) get back to not your shortcode page but this:

    https://test.site/campaigns/my-campaign/donate/?donation_id=556&cancel=1

    It might be possible to change the cancel return via filtering out what Charitable sends to Paypal. There is a filter ‘charitable_paypal_redirect_args’ that’s found in charitable/includes/gateways/class-charitable-gateway-paypal.php. If you or your developer is familiar with WordPress filters, you might be able to drop something like this into your functions.php file in your theme:

    add_filter( 'charitable_paypal_redirect_args', 'my_redirect_args', 10, 3);
    
    function my_redirect_args( $settings, $donation_id, $processor ) {
    	$settings['cancel_return'] = 'https://www.mysitelink.com';
    	return $settings;
    }

    How you determine what to populate the return URL is up to you, but this would be the recommended way to attempt to change the cancel URL of Paypal. Hope this helps!

    Plugin Author WPCharitable

    (@wpcharitable)

    We are going to go ahead and close this thread for now. But if you’d like us to assist further, please feel welcome to continue the conversation.

    Thanks!

    Thread Starter RC2102

    (@rc2102)

    Thank you for the filter code. Unfortunately I got the following syntax error:

    Unexpected T_RETURN

    return $settings;

    Plugin Author WPCharitable

    (@wpcharitable)

    @rc2102 Thanks for update.

    The code as shared works for us in our tests, so double check and make sure the snippet you provided doesn’t have any unusual characters or spaces and located in your functions.php file. The above error you are shown is usually a syntax error (a character is off or missing). If you are copy and pasting try re-typing to remove the chance there are any character issues.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘PayPal cancel does not redirect to it’s original post’ is closed to new replies.