dousheng3364 2012-05-08 11:10
浏览 25

Google Checkout,数据库更新失败

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");

}

  • 写回答

1条回答 默认 最新

  • drq9991 2012-05-08 14:47
    关注

    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).

    评论

报告相同问题?

悬赏问题

  • ¥15 用hfss做微带贴片阵列天线的时候分析设置有问题
  • ¥50 我撰写的python爬虫爬不了 要爬的网址有反爬机制
  • ¥15 Centos / PETSc / PETGEM
  • ¥15 centos7.9 IPv6端口telnet和端口监控问题
  • ¥120 计算机网络的新校区组网设计
  • ¥20 完全没有学习过GAN,看了CSDN的一篇文章,里面有代码但是完全不知道如何操作
  • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录
  • ¥20 海浪数据 南海地区海况数据,波浪数据
  • ¥20 软件测试决策法疑问求解答
  • ¥15 win11 23H2删除推荐的项目,支持注册表等