PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

Extra data to order summary paypal via gform_paypal_query hook

  1. brubrant2
    Member

    Anyone know if is there possible to add extra data to order summary of paypal?

    Order Summary http://imageshack.us/a/img32/9984/paywithapaypalaccountpa.png

    I tried to send transaction_subject variable through gform_paypal_query but does not work.

    add_filter('gform_paypal_query', 'update_paypal_query', 10, 3);
    
    function update_paypal_query($query_string, $form, $entry){
    
    	//put PayPal querystring into an array
        parse_str($query_string, $query);
    
        $query['transaction_subject'] = "$entry[12] cotas reembolsáveis para o evento $entry[13]";
    
        $query_string = http_build_query($query, '', '&');
    
        return '&' . $query_string;
    }

    References:

    https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_admin_IPNIntro

    https://cms.paypal.com/cms_content/US/en_US/files/developer/PP_WebsitePaymentsStandard_IntegrationGuide.pdf

    Any thoughts will be apreciated, thanks all!

    Posted 12 years ago on Wednesday October 10, 2012 | Permalink
  2. Can you echo the $query_string before it's returned from your function to be sure everything is present as you expect it? You may have to urlencode this "entry[12] cotas reembolsáveis para o evento $entry[13]" or something like that.

    Posted 12 years ago on Wednesday October 10, 2012 | Permalink
  3. brubrant2
    Member

    Hi Chris, thanks for your fast reply :)

    Also thanks for the tip about urlencode() function.

    I realized that the variable item_namex that holds the main description of transaction, in this case Preço por cota as we can see in attached image above and within IPN message &item_name1=Preço por cota.

    Now I'm trying to understand how GF PayPal Add-on handle this variable in gravityformspaypal/paypal.php.

    Also I could not echo the $query_string before it's returned from my function because the gform_paypal_query hook is fired immediately before the user is redirected to PayPal. So I'll try to print the $query_string in a text file.

    I changed my code but have not had success.

    add_filter('gform_paypal_query', 'update_paypal_query', 10, 3);
    
    function update_paypal_query($query_string, $form, $entry) {
    
    	//put PayPal querystring into an array
        parse_str($query_string, $query);
    
        $descricao = "$entry[12] cotas reembolsáveis para o evento $entry[13]";
    
        $query['item_name1'] = urlencode($descricao);
    
        $query_string = http_build_query($query, '', '&');
    
        print_r($query_string);
    
        return '&' . $query_string;
    }

    When I have some progress I post here.

    Cheers

    Posted 12 years ago on Thursday October 11, 2012 | Permalink
  4. Please let us know if you need more help. Writing the $query_string to a log file is a fine way to do it, if you can't echo it to the screen. At least you would know what it contains at that point.

    Posted 12 years ago on Friday October 12, 2012 | Permalink
  5. brubrant2
    Member

    Dah! I just typed wrong the variable name. Instead of item_name1 is item_name_1.

    Now the code look like this:

    add_filter('gform_paypal_query', 'update_paypal_query', 10, 3);
    
    function update_paypal_query($query_string, $form, $entry) {
    parse_str($query_string, $query);
    $query['item_name_1'] = get_the_title($entry[13]);
    $query_string = http_build_query($query, '', '&');
    return '&' . $query_string;
    }

    Now I run into another issue, the charset doesn't match. The special characters are displaying messed up in description of order summary.

    I added the title of post to query string variable item_name_1 (line 5), but when the title has special characters (like à á â ã) so this are not displaying correctly in description of order summary.

    I already tried the functions: utf8_encode(), esc_attr(strip_tags()), iconv() and urlencode() but have not had success yet. In fact the urlencode() was not necessary.

    I've also checked the default character encoding settings in PayPal, was Windows-1252 and I changed to UTF-8.

    Anyone has any thoughts?

    Posted 12 years ago on Tuesday October 16, 2012 | Permalink
  6. description of order summary

    Where is this seen? On screen or in a notification or in the admin entry view?

    Posted 12 years ago on Tuesday October 16, 2012 | Permalink