完成付款后如何从Google Checkout获得回复

时间:2012-11-20 15:14:50

标签: php payment-gateway

我正在将Google Checkout集成到PHP中。完成付款后,我正在尝试重定向到我的localhost,但我没有收到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");

1 个答案:

答案 0 :(得分:0)

您没有花太多时间向Google寻求帮助吗? 您可能对ResponseHandlerAPIFunctions.php library

感兴趣

查看https://google-developers.appspot.com/checkout/samples/Google_Checkout_Sample_Code_PHP_ResponseHandlerAPIFunctions,其中包含:

  

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