1

I was download and edit the code for google checkout from google help.Here i specify murchent calculation url in my site.But that function donot work in my site.Here is my code function UseCase3() { //Create a new shopping cart object $merchant_id = "xxxxxxxxxxxxx"; // Your Merchant ID $merchant_key = "xxxxxxxxxxxxx"; $server_type = "sandbox"; $currency = "USD"; $cart = new GoogleCart($merchant_id, $merchant_key, $server_type, $currency);

// Add items to the cart
$item = new GoogleItem("MegaSound 2GB MP3 Player", 
    "Portable MP3 player - stores 500 songs", 1, 175.49);
$item->SetMerchantPrivateItemData("<color>blue</color><weight>3.2</weight>");
$cart->AddItem($item);

// Add merchant calculations options
$cart->SetMerchantCalculations(
    "https://mysite.com/google2/demo/responsehandlerdemo.php",
    "false", // merchant-calculated tax
    "true", // accept-merchant-coupons
    "true"); // accept-merchant-gift-certificates

// Add merchant-calculated-shipping option
$ship = new GoogleMerchantCalculatedShipping("2nd Day Air", // Shippping method
                                             10.00); // Default, fallback price
$restriction = new GoogleShippingFilters();
$restriction->AddAllowedPostalArea("GB");
$restriction->AddAllowedPostalArea("US");
$restriction->SetAllowUsPoBox(false);
$ship->AddShippingRestrictions($restriction);

$address_filter = new GoogleShippingFilters();
$address_filter->AddAllowedPostalArea("GB");
$address_filter->AddAllowedPostalArea("US");
$address_filter->SetAllowUsPoBox(false);
$ship->AddAddressFilters($address_filter);

$cart->AddShipping($ship);

// Set default tax options
$tax_rule = new GoogleDefaultTaxRule(0.15);
$tax_rule->SetWorldArea(true);
$cart->AddDefaultTaxRules($tax_rule);

$cart->AddRoundingPolicy("UP", "TOTAL");
  // Specify <edit-cart-url>
$cart->SetEditCartUrl("https://mysite.com/google/demo/cartdemo.php");

// Specify "Return to xyz" link
$cart->SetContinueShoppingUrl("https://mysite.com");
// Display XML data
// echo "<pre>";
// echo htmlentities($cart->GetXML());
// echo "</pre>";

// Display a disabled, small button
echo $cart->CheckoutButtonCode("SMALL");

}

Shin
  • 280
  • 1
  • 2
  • 11
  • Any error messages? You say it doesn't work, but how? – Liam Spencer May 08 '12 at 11:16
  • No error message.I call a mail function in the file "https://mysite.com/google2/demo/responsehandlerdemo.php" ,I check payment using sandbox ,payment completed successfully.But i can't get mail.So I assume the merchent calculation donot working. – Shin May 08 '12 at 11:24
  • Is this problem due to my SSL certificates??? – Shin May 08 '12 at 11:27
  • @Shin have you set error mode on? http://php.net/manual/en/function.error-reporting.php – Ozzy May 08 '12 at 11:45
  • My actual problem is not error reporting.I need to execute a php file after user pay through Google checkout – Shin May 08 '12 at 12:14

1 Answers1

0

Clarifications:

  1. Merchant Calculations URL - as the name implies is the URL that Google will use to send a callback request for Shipping and Tax, promotions calculations. That is its purpose as documented in Merchant Calculations API. It is part of the Checkout Phase (sending information to Google for checkout).
  2. API Callback URL - which is set in your account (Integration Settings) and not sent in any request (unlike merchant calculations url) and is the URL Google will send Notifications to as documented in Notification API. This is the API you need to implement in order to obtain data from Google (getting information from Google - e.g. after checkout)

So these urls/APIs serve different purposes.

Based on your comment:

I need to execute a php file after user pay through Google checkout

You need to implement the Notification API (the merchant calcuations url/api is not what you need).

EdSF
  • 11,753
  • 6
  • 42
  • 83