function Usecase() { $merchant_id = ""; // Your Merchant ID $merchant_key = ""; // Your Merchant Key $server_type = "sandbox"; $currency = "USD"; $cart = new GoogleCart($merchant_id, $merchant_key, $server_type, $currency); $total_count = 1; $certificate_path = ""; // set your SSL CA cert path // Check this URL for more info about the two types of digital Delivery // http://code.google.com/apis/checkout/developer/Google_Checkout_Digital_Delivery.html // Key/URL delivery $item_1 = new GoogleItem("Download Digital Item1", "With S/N", $total_count, 10.99); // Unit price $item_1->SetURLDigitalContent('http://example.com/download.php?id=15', 'S/N: 123.123123-3213', "Download Item1"); $cart->AddItem($item_1); // Email delivery $item_2 = new GoogleItem("Email Digital Item2", "An email will be sent by the merchant", $total_count, 9.19); // Unit price $item_2->SetEmailDigitalDelivery('true'); $cart->AddItem($item_2); // Add tax rules $tax_rule = new GoogleDefaultTaxRule(0.05); $tax_rule->SetStateAreas(array("MA", "FL", "CA")); $cart->AddDefaultTaxRules($tax_rule); // Specify <edit-cart-url> $cart->SetEditCartUrl("https://www.example.com/cart/"); // Specify "Return to xyz" link $cart->SetContinueShoppingUrl("https://www.example.com/goods/"); // Request buyer's phone number $cart->SetRequestBuyerPhone(true); // Add analytics data to the cart if its setted if (isset($_POST['analyticsdata']) && !empty($_POST['analyticsdata'])) { $cart->SetAnalyticsData($_POST['analyticsdata']); } // This will do a server-2-server cart post and send an HTTP 302 redirect status // This is the best way to do it if implementing digital delivery // More info http://code.google.com/apis/checkout/developer/index.html#alternate_technique list($status, $error) = $cart->CheckoutServer2Server('', $certificate_path); // if i reach this point, something was wrong echo "An error had ocurred: <br />HTTP Status: " . $status . ":"; echo "<br />Error message:<br />"; echo $error; // }
function googlecheckout() { if ($this->input->post('googlesubmit')) { $this->load->model('payment_model'); $paymentGateways_google = $this->payment_model->getPaymentSettings(); $payment_amount = $this->input->post('item_price_1'); $tr_id = $this->input->post('trans'); $this->session->set_userdata('tr_id', $tr_id); $merchant_id = $paymentGateways_google['gch']['mail_id']; // Your Merchant ID $merchant_key = $paymentGateways_google['gch']['url']; // Your Merchant Key if ($paymentGateways_google['gch']['url_status'] == 0) { $server_type = "sandbox"; } else { $server_type = "Live"; } $currency = "USD"; $cart = new GoogleCart($merchant_id, $merchant_key, $server_type, $currency); $total_count = 1; // Check this URL for more info about the two types of digital Delivery // http://code.google.com/apis/checkout/developer/Google_Checkout_Digital_Delivery.html //Get the language details $item_1 = new GoogleItem($this->config->item('site_name') . 'Account Deposit', ' Account Deposit ', '1', $payment_amount); // Unit price // $item_1->SetURLDigitalContent('http://example.com/download.php?id=15','S/N: 123.123123-3213', "Download Item1"); $cart->AddItem($item_1); $cart->SetMerchantPrivateData(new MerchantPrivateData(array("transaction-id" => $tr_id))); // Specify "Return to xyz" link $cart->SetContinueShoppingUrl(site_url('payment/checkoutSuccess')); // Request buyer's phone number $cart->SetRequestBuyerPhone(true); // Add analytics data to the cart if its setted if (isset($_POST['analyticsdata']) && !empty($_POST['analyticsdata'])) { $cart->SetAnalyticsData($_POST['analyticsdata']); } // This will do a server-2-server cart post and send an HTTP 302 redirect status // This is the best way to do it if implementing digital delivery // More info http://code.google.com/apis/checkout/developer/index.html#alternate_technique list($status, $error) = $cart->CheckoutServer2Server(); // if i reach this point, something was wrong echo "An error had ocurred: <br />HTTP Status: " . $status . ":"; echo "<br />Error message:<br />"; echo $error; // } }