Loading...
X

Add additional information to PayPal transaction

1 0

It depends of what PayPal Add-On we are using, PayPal Standard, PayPal Payments Pro, or PayPal Pro.

In the following examples you can see how to pass the address to PayPal.

PayPal Standard

add_filter('gform_paypal_query', 'add_shipping_address', 10, 3);    
function add_shipping_address($query_string, $form, $entry) {

    // break the query string into an array
    // after removing the initial '&' character
    parse_str(ltrim($query_string, '&'), $query);

    // add shipping address to query string
    $query['SHIPTONAME'] = rgpost("input_6_3") .  " " . rgpost("input_6_6") ;
    $query['SHIPTOSTREET'] = rgpost("input_53");
    $query['SHIPTOSTREET2'] = rgpost("input_59");
    $query['SHIPTOCITY'] = rgpost("input_62");
    $query['SHIPTOSTATE'] = rgpost("input_60");
    $query['SHIPTOZIP'] = rgpost("input_61");
    $query['SHIPTOCOUNTRY'] = GFCommon::get_country_code(rgpost("input_58")); 

    // put it all back together again
    $query_string = '&' . http_build_query($query);
    
    return $query_string;
    
}

PayPal Payments Pro

add_filter('gform_paypalpaymentspro_args_before_payment','add_shipping_address', 10, 2 );
function add_shipping_address($args, $form_id) {

    $args["SHIPTOLASTNAME"] = $args["LASTNAME"];
    $args["SHIPTOSTREET"] = $args["STREET"];
    $args["SHIPTOCITY"] = $args["CITY"];
    $args["SHIPTOSTATE"] = $args["STATE"];
    $args["SHIPTOZIP"] = $args["ZIP"];
    $args["SHIPTOCOUNTRY"] = $args["BILLTOCOUNTRY"];
        
    return $args;
}

PayPal Pro

add_filter('gform_paypalpro_query', 'add_shipping_address', 10, 3); 
function add_shipping_address($query_string, $form, $entry) {

    // break the query string into an array
    // after removing the initial '&' character
    parse_str(ltrim($query_string, '&'), $query);

    // add shipping address to query string
    $query['SHIPTONAME'] = rgpost("input_6_3") .  " " . rgpost("input_6_6") ;
    $query['SHIPTOSTREET'] = rgpost("input_53");
    $query['SHIPTOSTREET2'] = rgpost("input_59");
    $query['SHIPTOCITY'] = rgpost("input_62");
    $query['SHIPTOSTATE'] = rgpost("input_60");
    $query['SHIPTOZIP'] = rgpost("input_61");
    $query['SHIPTOCOUNTRY'] = GFCommon::get_country_code(rgpost("input_58")); 

    // put it all back together again
    $query_string = '&' . http_build_query($query);
    
    return $query_string;
    
}

You’ll need to check with PayPal’s support or documentation for all the available parameters name that you can use in the query. This document is outdated but seemed relevant.

Leave Your Observation

Your email address will not be published. Required fields are marked *