bookmark_bordergform_paypal_request

Description

Use this filter to modify the URL string that will be sent to PayPal. This filter is fired immediately before the user is redirected to PayPal.

Usage

add_filter( 'gform_paypal_request', 'your_function_name', 10, 5 ) ;

You can also specify this per form by adding the form id after the hook name.

add_filter( 'gform_paypal_request_1', 'your_function_name', 10, 5 ) ;

Parameters

  • $url string

    The entire url that will be sent to PayPal, including the query string; includes the return url, cancel url, notify url, invoice ID, currency, customer fields, products, quantities, prices, and various other PayPal settings.

  • $form

    The Form Object of the entry created.

  • $entry Entry Object

    The Entry Object created.

  • $feed Feed Object

    The feed currently being processed.

  • $submission_data Submission Data

    Contains the form title, payment amount, setup fee amount, trial amount, line items created using the submitted pricing field values and any discounts from coupons. Added in PayPal 2.4.4.

Examples

This example changes the “return” url in the query string. This is where PayPal returns to after payment is made and should be your form.

add_filter( 'gform_paypal_request', 'update_url', 10, 3 );
function update_url( $url, $form, $entry ) {
    //parse url into its individual pieces (host, path, querystring, etc.)
    $url_array = parse_url( $url );
    //start rebuilding url
    $new_url = $url_array['scheme'] . '://' . $url_array['host'] . $url_array['path'] . '?';
    $query = $url_array['query']; //get querystring
    //parse querystring into pieces
    parse_str( $query, $qs_param );
    $return = $qs_param['return']; //return url
    //parse return url so the querystring is left alone while modifying the url
    $return_url = parse_url( $return );
    //rebuild url with new location
    $new_return_url = $return_url['scheme'] . '://' . 'rocketgenius.com/contact-us/?' . $return_url['query'];
    $qs_param['return'] = $new_return_url; //update return querystring parameter to new value
    $new_qs = http_build_query( $qs_param ); //rebuild querystring
    $new_url .= $new_qs; //add querystring to url
    return $new_url;
}

Placement

This code should be placed in the functions.php file of your active theme

Source Code

gf_apply_filters( 'gform_paypal_request', $form['id'], $url, $form, $entry, $feed, $submission_data )

This filter is located in GFPayPal::redirect_url() in class-gf-paypal.php