我刚开始熟悉Google Checkout API,但是我有一个问题。在Google Checkout文档中,提交实际购物车的唯一方法是通过一个通过echo
呼叫创建的按钮,如echo $cart->CheckoutButtonCode("LARGE");
这不是我所需要的。我想从我的PHP脚本手动提交我的购物车。Google Checkout PHP提交问题
但是,与PayPal API不同,Google Checkout脚本似乎没有提交类型功能。经过一些进一步的研究,我注意到HTML
的例子发布到https://sandbox.google.com/checkout/api/checkout/v2/checkout/Merchant/MERCHANT_ID_HERE
。
我该如何在PHP中做到这一点?我正在使用他们的官方API。这是我迄今所做的:
$merchant_id = $google_merchant_ID;
$merchant_key = $google_merchant_key;
if ($enable_Google_Sandbox == 1)
{
$server_type = "sandbox";
}
$currency = $currency_code;
$cart = new GoogleCart($merchant_id, $merchant_key, $server_type,
$currency);
$shop_cart = $_SESSION['cart'];
foreach ($shop_cart as $value)
{
$k_product = $value['Product'];
$k_quantity = $value['Quantity'];
$k_price = $value['Price'];
$k_orderID = $_SESSION['order_id'];
if (isset($_SESSION['Discount']))
{
$k_discount = $_SESSION['Discount'];
$k_price = $k_price - $k_discount;
}
$cart_item = new GoogleItem($k_product,
"Some Product",
$k_quantity,
$k_price);
$cart_item->SetMerchantItemId(generateProductID());
$cart->AddItem($cart_item);
}
// Specify <edit-cart-url>
$cart->SetEditCartUrl("http://192.168.100.100:8888/order.php?action=showCart");
// Specify "Return to xyz" link
$cart->SetContinueShoppingUrl("http://192.168.100.100:8888/store.php");
// Request buyer's phone number
$cart->SetRequestBuyerPhone(false);
有没有$cart->submitCart();
型功能,所以我该怎么办?
感谢您详细的解答。然而,没有重定向到Google发生... – Pripyat
出现错误:[0] => ERR [1] =>服务器内部错误 – Pripyat
我正在使用旧的API。它适用于新的。我会尽快给你赏金。 – Pripyat