关于Google Checkout商家私人数据的问题

发布于 2024-10-16 15:01:34 字数 1354 浏览 1 评论 0原文

我正在集成 示例代码

我想启用商家私有项目数据,以便我可以传递用户 ID、期间和属性,

但我不明白该怎么做。

我的 googlecheckout 按钮出现在此处,如下所示:

require_once($jconfig->gc_path.'/googlecart.php');
require_once($jconfig->gc_path.'/googleitem.php');
require_once($jconfig->gc_path.'/googleshipping.php');
require_once($jconfig->gc_path.'/googletax.php');

$merchant_id = "SAMPLE";  // Your Merchant ID
$merchant_key = "SAMPLE";  // Your Merchant Key
$server_type = "sandbox";
$currency = "USD";
$cart = new GoogleCart($merchant_id, $merchant_key, $server_type,
$currency); 
$total_count = 1;
$item_1 = new GoogleItem('title',      // Item name
                         'descriptiom', 
                         $price,
                         1); 
$cart->AddItem($item_1);
$cart->SetContinueShoppingUrl($jconfig->response_handler.$generate_url);

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

// Display Google Checkout button
//echo $this->product[0]['welcome_pack']+$this->product[0]['airport_pick_up']+$this->product[0]['airport_drop_off']+$this->product[0]['textbooks']+$totle;
echo $cart->CheckoutButtonCode("SMALL");

我必须在 googlecart.php 中启用它吗?

I'm integrating the sample code

I want to enable merchant-private-item-data,so that i can pass the userid,period and attribute

I'm not able to understand how do i do it .

My googlecheckout button appears here as given below.:

require_once($jconfig->gc_path.'/googlecart.php');
require_once($jconfig->gc_path.'/googleitem.php');
require_once($jconfig->gc_path.'/googleshipping.php');
require_once($jconfig->gc_path.'/googletax.php');

$merchant_id = "SAMPLE";  // Your Merchant ID
$merchant_key = "SAMPLE";  // Your Merchant Key
$server_type = "sandbox";
$currency = "USD";
$cart = new GoogleCart($merchant_id, $merchant_key, $server_type,
$currency); 
$total_count = 1;
$item_1 = new GoogleItem('title',      // Item name
                         'descriptiom', 
                         $price,
                         1); 
$cart->AddItem($item_1);
$cart->SetContinueShoppingUrl($jconfig->response_handler.$generate_url);

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

// Display Google Checkout button
//echo $this->product[0]['welcome_pack']+$this->product[0]['airport_pick_up']+$this->product[0]['airport_drop_off']+$this->product[0]['textbooks']+$totle;
echo $cart->CheckoutButtonCode("SMALL");

Do I have to enable it in googlecart.php?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

假面具 2024-10-23 15:01:34

如果您查看源代码,您会看到 GoogleItem::SetMerchantPrivateItemData,它仅设置 GoogleItem::$merchant_private_item_data 属性。检查GoogleItem::GetXML 显示 GoogleItem::$merchant_private_item_data 可以是 MerchantPrivate (这似乎未实现,但您可以编写您的只要它具有 MerchantPrivate::AddMerchantPrivateToXML(gc_XmlBuilder $xml) 方法)或字符串(在通过 htmlentities 后)就会成为 < code>merchant-private-item-data 元素。如果您想使用 XML 构建私有数据,则必须实现 MerchantPrivate 类。

class MerchantPrivate {
    function AddMerchantPrivateToXML(gc_XmlBuilder $xml) {
        $xml->Push('merchant-private-item-data');
        $this->_addMyData($xml);
        $xml->Pop('merchant-private-item-data');            
    }

    abstract protected function _addMyData($xml);
}

class ItemData extends MerchantPrivate {
    public $userid, $period, $attribute;
    function _addMyData(gc_XmlBuilder $xml) {
        $xml->Element('userid', $this->userid);
        $xml->Element('period', $this->period);
        $xml->Element('attribute', $this->attribute);
    }
}

If you look at the source, you'll see a GoogleItem::SetMerchantPrivateItemData, which simply sets the GoogleItem::$merchant_private_item_data property. Examining GoogleItem::GetXML reveals GoogleItem::$merchant_private_item_data can be a MerchantPrivate (which appears to be unimplemented, but you can write your own as long as it has a MerchantPrivate::AddMerchantPrivateToXML(gc_XmlBuilder $xml) method) or a string, which (after a pass through htmlentities) becomes the content of the merchant-private-item-data element. If you want to structure your private data with XML, you'll have to implement class MerchantPrivate.

class MerchantPrivate {
    function AddMerchantPrivateToXML(gc_XmlBuilder $xml) {
        $xml->Push('merchant-private-item-data');
        $this->_addMyData($xml);
        $xml->Pop('merchant-private-item-data');            
    }

    abstract protected function _addMyData($xml);
}

class ItemData extends MerchantPrivate {
    public $userid, $period, $attribute;
    function _addMyData(gc_XmlBuilder $xml) {
        $xml->Element('userid', $this->userid);
        $xml->Element('period', $this->period);
        $xml->Element('attribute', $this->attribute);
    }
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文