-------------------------------------------------------
$key = 'Wpkdo4dlsorlf03l94kd';
$merchant_id = '1180294430430239';
$cart = new gCart($merchant_id,$key);
$cart->addItem('My Product title', 'My Product description, '1', '12.99');
$xml = $cart->getCart();
$hmac = CalcHmacSha1($xml,$key);
$cartxml = base64_encode($xml);
?>
<form method="POST"
action="https://sandbox.google.com/checkout
/cws/v2/Merchant/
<?php echo $merchant_id; ?>/checkoutForm">
<input type="hidden" name="cart"
value="<?php echo $cartxml; ?>">
<input type="hidden" name="signature"
value="<?php echo $hmac; ?>">
<input type="image" name="Google Checkout"
alt="Fast checkout through Google"
src="http://sandbox.google.com/checkout/buttons/checkout.gif?merchant_id=
<?php echo $merchant_id; ?>
&w=180&h=46&style=white&variant=text&loc=en_US" height="46"
width="180"> </form>
-------------------------------------------------------
As you can see, this is just an excerpt of the cart I built in php (php5) using some of phpgcheckout's code. This isn't that difficult to do.. but there's one problem, I don't get anything back from google to tell me the order processed successfully. My current project requires I create a user account to access a training program after the card is charged. Supposedly this can be done through the google checkout API and I think I'm about half way there. But to be honest, Google's documentation SUCKS and they don't have a full set of sample code for php5. You would think Google would be a step up on the game in this area...?
No comments:
Post a Comment