0

我正在将 Google Checkout 集成到 PHP 中。完成付款后,我试图重定向到我的本地主机,但我没有收到来自 Google Checkout 的响应。当我使用 Paypal 时,我会得到 txn_id、item_name、payment_status、支付金额等。这是我的代码:

  echo "<h2>Standard Checkout Request</h2>";
  $merchant_id = "my merchant id";  // Your Merchant ID
  $merchant_key = "my merchant key";  // Your Merchant Key
  $server_type = "sandbox";
  $currency = "USD";
  $cart = new GoogleCart($merchant_id, $merchant_key, $server_type,
  $currency);
  $total_count = 12;

  $item_1 = new GoogleItem("item name",      // Item name
                           "T-shart", // Item      description
                           $total_count, // Quantity
                           1); // Unit price

  $cart->AddItem($item_1);


  // Add shipping options
  if($total_count < 3){
         $ship_1 = new GoogleFlatRateShipping("USPS Priority Mail", 4.55);
  }else{
         $ship_1 = new GoogleFlatRateShipping("USPS Priority Mail", 6.2);
  }
  $Gfilter = new GoogleShippingFilters();
  $Gfilter->SetAllowedCountryArea('CONTINENTAL_48');

  $ship_1->AddShippingRestrictions($Gfilter);

  $cart->AddShipping($ship_1);

  // Add tax rules
  $tax_rule = new GoogleDefaultTaxRule(0.05);
  $tax_rule->SetStateAreas(array("MA"));
  $cart->AddDefaultTaxRules($tax_rule);

  // Specify <edit-cart-url>
  $cart->SetEditCartUrl("http://localhost/Practice/PaymentDemo/library/googleRequestSecond.php");

  // Specify "Return to xyz" link
  $cart->SetContinueShoppingUrl("http://localhost/Practice/PaymentDemo/library/googleRequestSecond.php");

  // Request buyer's phone number
  $cart->SetRequestBuyerPhone(true);

  // Display Google Checkout button
  echo $cart->CheckoutButtonCode("SMALL");
4

1 回答 1

0

您没有花太多时间向 Google 寻求帮助吧?您可能对 ResponseHandlerAPIFunctions.php 库感兴趣

查看https://google-developers.appspot.com/checkout/samples/Google_Checkout_Sample_Code_PHP_ResponseHandlerAPIFunctions 上面写着:

ResponseHandlerAPIFunctions.php 库包含一组函数,用于处理 Google Checkout 在收到您的 API 请求时发送的同步响应。

于 2013-02-08T09:14:52.240 回答