Last active
November 19, 2020 07:36
-
-
Save greathmaster/8207f0a145a946c13b9e to your computer and use it in GitHub Desktop.
Sets a custom Cancel URL for PayPal transactions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//From: http://www.paidmembershipspro.com/forums/topic/paypal-express-change-the-cancel-and-return-url/ | |
//Created by user @ultione | |
add_filter( "pmpro_set_express_checkout_nvpstr", "custom_set_paypal_express_cancel_url", 10, 2 ); | |
function custom_set_paypal_express_cancel_url ( $nvpStr, $order ) { | |
parse_str( $nvpStr, $payment_arr ); | |
$level_id = pmpro_getLevel( 'membership_level_name' ); | |
if ( ! empty( $level_id ) ) { | |
$payment_arr['CANCELURL'] = pmpro_url("checkout", "?level=" . $level_id, "https"); | |
} | |
//To prevent Recurring payment start date to be url encoded. | |
$endStr = "&PROFILESTARTDATE={$payment_arr['PROFILESTARTDATE']}"; | |
unset( $payment_arr['PROFILESTARTDATE'] ); | |
$nvpStr = '&' . http_build_query( $payment_arr ) . $endStr; | |
return $nvpStr; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment