Exemplo n.º 1
0
function UseCase3()
{
    //Create a new shopping cart object
    $merchant_id = "";
    //Your Merchant ID
    $merchant_key = "";
    //Your Merchant Key
    $server_type = "sandbox";
    $cart = new GoogleCart($merchant_id, $merchant_key, $server_type);
    //Add items to the cart
    $item1 = new GoogleItem("Dry Food Pack AA1453", " pack of highly nutritious dried food for emergency", 1, 35);
    $item2 = new GoogleItem("MegaSound 2GB MP3 Player", "Portable MP3 player - stores 500 songs", 1, 178);
    $item3 = new GoogleItem("AA Rechargeable Battery Pack", "Battery pack containing four AA rechargeable batteries", 1, 12);
    $cart->AddItem($item1);
    $cart->AddItem($item2);
    $cart->AddItem($item3);
    //Set request buyer phone
    $cart->SetRequestBuyerPhone("true");
    //Add merchant calculations options
    $cart->SetMerchantCalculations("https://www.example.com/shopping/merchantCalc", "true", "true", "true");
    $ship = new GoogleShipping("merchant-calc", "merchant-calculated", 5, "USD", "ALL");
    $ship->SetAllowedStateAreas(array("NY", "CA"));
    $cart->AddShipping($ship);
    $tax_rule = new GoogleTaxRule("default", 0.2);
    $tax_rule->SetStateAreas(array("CA", "NY"));
    $tax_table = new GoogleTaxTable("default");
    $tax_table->AddTaxRules($tax_rule);
    $cart->AddTaxTables($tax_table);
    //Display XML data
    echo htmlentities($cart->GetXML());
    //Display a disabled, small button with a white background
    echo $cart->CheckoutButtonCode("small", "white", "disabled");
}