public function __construct() { $username = Cart66Setting::getValue('paypalpro_api_username'); $password = Cart66Setting::getValue('paypalpro_api_password'); $signature = Cart66Setting::getValue('paypalpro_api_signature'); if (!($username && $password && $signature)) { throw new Cart66Exception('Invalid PayPal Pro Configuration', 66502); } parent::__construct(); }
<?php $settingsOk = true; $username = Cart66Setting::getValue('paypalpro_api_username'); $password = Cart66Setting::getValue('paypalpro_api_password'); $signature = Cart66Setting::getValue('paypalpro_api_signature'); if (!($username && $password && $signature)) { $settingsOk = false; throw new Cart66Exception('Invalid PayPal Express Configuration', 66501); } if ($_SERVER['REQUEST_METHOD'] == "POST" && isset($_POST['cart66-action']) && $_POST['cart66-action'] == 'paypalexpresscheckout') { // Set up the PayPal object $pp = new Cart66PayPalExpressCheckout(); $taxRate = new Cart66TaxRate(); // Calculate total amount to charge customer $total = Cart66Session::get('Cart66Cart')->getGrandTotal(false); $total = number_format($total, 2, '.', ''); Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] PayPal Express Checkout grand total: {$total}"); // Calculate total cost of all items in cart, not including tax and shipping $itemTotal = Cart66Session::get('Cart66Cart')->getNonSubscriptionAmount(); $itemTotal = number_format($itemTotal, 2, '.', ''); Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] PayPal Express Checkout item total: {$itemTotal}"); // Calculate shipping costs $shipping = Cart66Session::get('Cart66Cart')->getShippingCost(); $promotion = Cart66Session::get('Cart66Promotion'); $discount = Cart66Session::get('Cart66Cart')->getDiscountAmount(); if (is_object($promotion) && $promotion->apply_to == 'total') { $itemTotal = Cart66Session::get('Cart66Cart')->getNonSubscriptionAmount(); $itemDiscount = Cart66Session::get('Cart66Cart')->getDiscountAmount(); if ($itemDiscount > 0) { $itemTotal = $itemTotal - $itemDiscount;