kiranpatil353 / google-checkout-php-sample-code

Automatically exported from code.google.com/p/google-checkout-php-sample-code
0 stars 0 forks source link

Improper handling of <merchant-private-data> and <merchant-private-item-data> #4

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Both instances are assumed by Google to be properly formatted XML however 
when they are processed through GetXML called from CheckoutButtonCode the 
XML is sent through a function which encodes it, consequently Google does 
not return it properly.

For example putting <my-order-number>12345</my-order-number> produces the 
following XML fragment for the cart.

<merchant-private-data>%lt; my-order-number %gt; 12345 %lt; /my-order-
number %gt;</merchant-private-data>

When the correct output should be:

<merchant-private-data>
  <my-order-number>12345</my-order-number>
</merchant-private-data>

This occurs both at the cart and the item level. There is also a typo in 
the library, at one point merchant-private-data is referred to as merchant-
private-date.

Original issue reported on code.google.com by ddslever...@gmail.com on 2 Feb 2007 at 8:48

GoogleCodeExporter commented 8 years ago
Here is the fix:

Open library/googlecart.php and find at around line 153:

$xml_data->Element('merchant-private-date',
            $item->merchant_private_data);

Replace this with:

$xml_data->Push('merchant-private-data');
            if(is_array($item->merchant_private_data))
            {
                foreach($item->merchant_private_data as $key => $value)
                {
                    $xml_data->Element($key,
                    $value);
                }
            }
            $xml_data->Pop('merchant-private-data');

Then all you have to do is send $private_data when Google_Item is called as a 
basic
array.

Original comment by abrookba...@gmail.com on 14 Feb 2007 at 12:34

GoogleCodeExporter commented 8 years ago
Sorry (idiot on the loose) the replacement code should be:

$xml_data->Push('merchant-private-item-data');
if(is_array($item->merchant_private_data))
{
    foreach($item->merchant_private_data as $key => $value)
    {
        $xml_data->Element($key,
        $value);
    }
}
$xml_data->Pop('merchant-private-item-data');

Original comment by a...@devellion.com on 14 Feb 2007 at 12:59

GoogleCodeExporter commented 8 years ago
Still does not work!
XML output for merchant-item-private-data is blank.
-note: I tried using both foreach($item->merchant_private_data as $key => 
$value)
and foreach($item->merchant_private_item_data as $key => $value)
in the file. Neither worked.
Current (non functional) configuration of my test page:

Using democart.php:
    $item_1 = new GoogleItem("MegaSound 2GB MP3 Player", // Item name
                             "Portable MP3 player - stores 500 songs", // Item
description
                             1, // Quantity
                             175.49); // Unit price
     $item_1->SetMerchantPrivateItemData('<color>blue</color><weight>3.2</weight>');

following mod made to googlecart.php:

     $xml_data->Push('merchant-private-item-data');
        if(is_array($item->merchant_private_item_data))
        {
            foreach($item->merchant_private_item_data as $key => $value)
                {
        $xml_data->Element($key,
        $value);
            }
        }
    $xml_data->Pop('merchant-private-item-data');

Original comment by gegam...@gmail.com on 1 Jun 2007 at 1:39

GoogleCodeExporter commented 8 years ago
hi, new v1.2 has 2 classes to handle merchant private data and merchant private 
item
data.

try it
ropu

Original comment by b8.atx.t...@gtempaccount.com on 13 Jun 2007 at 4:19

GoogleCodeExporter commented 8 years ago

Original comment by rovagn...@gmail.com on 13 Jun 2007 at 4:19