Google checkout API - Last ditch effort!

greyhat

English Gent
Nov 30, 2009
853
8
0
UK
Hi there. I have been trying to set up digital delivery on single items with the google checkout API. All is working in the sandbox exept the key and url are not delivered. I am yet to switch from HTML to XML/PHP but i wanted to get it working before coding the php part. Any help much appreciated. I am so stressed right now.
Thanks.
 


Help!

Code:
<?php
include ("GlobalAPIFunctions.php");

$xml = '<?xml version="1.0" encoding="UTF-8"?>
<checkout-shopping-cart xmlns="https://sandbox.google.com/checkout/api/checkout/v2/checkout/Merchant/*****************">
  <shopping-cart>
    <items>
      <item>
        <item-name>Super Software 5000</item-name>
        <item-description>Super Software 5000 improves download speeds.</item-description>
        <unit-price currency="USD">1.00</unit-price>
        <quantity>1</quantity>
        <digital-content>
          <display-disposition>OPTIMISTIC</display-disposition>
          <description>
            Please go to &lt;a href="http://test.co.uk"&gt;our website&lt;/a&gt;,
            and enter your access key so that you can download our software.
          </description>
          <key>1456-1514-3657-2198</key>
          <url>http://test.co.uk</url>
        </digital-content>
      </item>
    </items>
  </shopping-cart>
  <checkout-flow-support>
    <merchant-checkout-flow-support/>
  </checkout-flow-support>
</checkout-shopping-cart>';

$key = '********************';

$bkey =  base64_encode(CalcHmacSha1($key));
$bxml =  base64_encode($xml);
?>
<html>
<body>
<form method="POST" action="https://sandbox.google.com/checkout/api/checkout/v2/checkout/Merchant/*****************">
    <input type="hidden" name="cart" value="<?php echo $bxml; ?>">
    <input type="hidden" name="signature" value="<?php echo $bkey;?>">
    <input type="image" name="Google Checkout" alt="Fast checkout through Google"
        src="http://sandbox.google.com/checkout/buttons/checkout.gif?merchant_id=*****************
              &w=180&h=46&style=white&variant=text&loc=en_US"  height="46" width="180">
</form>
</body>
</html>
:angryfire:

Hi people.. i would really appreciate it if somebody could tell me where i am going wrong... i have been at this for a while now and i keep getting the same ' Bad Signature on Cart' error... any help much appreciated!!
:D
 
Hi people.. i would really appreciate it if somebody could tell me where i am going wrong... i have been at this for a while now and i keep getting the same ' Bad Signature on Cart' error... any help much appreciated!!
:D

Error message - Bad signature on cart : Custom-built shopping carts (API) - Google Checkout Merchant Help

I believe you need to remove the base64_encode() function from this line:
Code:
$bkey =  base64_encode(CalcHmacSha1($key));

it doesn't say anything about base64 encoding. where did you get this script or is this your code?
 
I got it working. Thanks anyway. I might write a tutorial and put it up.. it's needed this has taken me ages and there is no help out there!

Code:
<?php
include ("GlobalAPIFunctions.php");
$xml = '<?xml version="1.0" encoding="UTF-8"?>
<checkout-shopping-cart xmlns="[URL]http://checkout.google.com/schema/2[/URL]">
  <shopping-cart>
    <items>
      <item>
        <item-name>Super Software 5000</item-name>
        <item-description>Super Software 5000 improves download speeds.</item-description>
        <unit-price currency="GBP">0.01</unit-price>
        <quantity>1</quantity>
        <digital-content>
          <display-disposition>OPTIMISTIC</display-disposition>
          <description>
            Please go to &lt;a href="[URL]http://sound-agency.co.uk"&gt;our[/URL] website&lt;/a&gt;,
            and enter your access key so that you can download our software.
          </description>
          <key>1456-1514-3657-2198</key>
          <url>http://XXX.co.uk</url>
        </digital-content>
      </item>
    </items>
  </shopping-cart>
  <checkout-flow-support>
    <merchant-checkout-flow-support/>
  </checkout-flow-support>
</checkout-shopping-cart>';
$key = 'XXX';
$shakey =  CalcHmacSha1($xml,$key);
$bxml =  base64_encode($xml);
$bkey = base64_encode($shakey);
?>
<html>
<body>
<form method="POST" action="[URL]https://sandbox.google.com/checkout/api/checkout/v2/checkout/Merchant/XXX[/URL]">
    <input type="hidden" name="cart" value="<?php echo $bxml; ?>">
    <input type="hidden" name="signature" value="<?php echo $bkey;?>">
    <input type="image" name="Google Checkout" alt="Fast checkout through Google"
        src="[URL]http://sandbox.google.com/checkout/buttons/checkout.gif?merchant_id=XXX[/URL]
              &w=180&h=46&style=white&variant=text&loc=en_US"  height="46" width="180">
</form>
</body>
</html>

(you need the globalAPIfunctions.php file, pm me anybody if you need it)

I followed this diagram:

shopping_cart_direct_POST2.gif


Thanks!!

:rasta: