public function mijirehCheckout()
 {
     if (Cart66Session::get('Cart66Cart')->countItems() > 0) {
         $gatewayName = Cart66Common::postVal('cart66-gateway-name');
         if ($_SERVER['REQUEST_METHOD'] == 'POST' && $gatewayName != 'Cart66Mijireh') {
             return $gatewayName == "Cart66ManualGateway" ? $this->manualCheckout() : "";
         }
         if (!Cart66Session::get('Cart66Cart')->hasPayPalSubscriptions()) {
             require_once CART66_PATH . "/gateways/Cart66Mijireh.php";
             if (Cart66Session::get('Cart66Cart')->getGrandTotal() > 0 || Cart66Session::get('Cart66Cart')->hasSpreedlySubscriptions()) {
                 try {
                     $mj = new Cart66Mijireh();
                     $view = $this->_buildCheckoutView($mj);
                 } catch (Cart66Exception $e) {
                     $exception = Cart66Exception::exceptionMessages($e->getCode(), $e->getMessage());
                     $view = Cart66Common::getView('views/error-messages.php', $exception);
                 }
                 return $view;
             } elseif (Cart66Session::get('Cart66Cart')->countItems() > 0) {
                 Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] Displaying manual checkout instead of Mijireh Checkout because the cart value is \$0.00");
                 return $this->manualCheckout();
             }
         } else {
             Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] Not rendering Mijireh checkout form because the cart contains a PayPal subscription");
         }
     }
 }
 public function section_notifications_settings()
 {
     $tab = 'notifications-email_receipt_settings';
     $data = array('tab' => $tab);
     if (CART66_PRO) {
         $reminder = new Cart66MembershipReminders();
         $orderFulfillment = new Cart66OrderFulfillment();
         $errorMessage = '';
         $successMessage = '';
         if ($_SERVER['REQUEST_METHOD'] == "POST") {
             if ($_POST['cart66-action'] == 'email log settings') {
                 foreach ($_POST['emailLog'] as $key => $value) {
                     Cart66Setting::setValue($key, $value);
                 }
                 $tab = 'notifications-email_log_settings';
             }
             if ($_POST['cart66-action'] == 'save reminder') {
                 try {
                     $reminder->load($_POST['reminder']['id']);
                     $reminder->setData($_POST['reminder']);
                     $reminder->save();
                     $reminder->clear();
                 } catch (Cart66Exception $e) {
                     $errorCode = $e->getCode();
                     // Reminder save failed
                     if ($errorCode == 66302) {
                         $errors = $reminder->getErrors();
                         $exception = Cart66Exception::exceptionMessages($e->getCode(), __("The reminder could not be saved for the following reasons", "cart66"), $errors);
                         $errorMessage = Cart66Common::getView('views/error-messages.php', $exception);
                     }
                 }
                 $tab = 'notifications-reminder_settings';
             }
             if ($_POST['cart66-action'] == 'save order fulfillment') {
                 try {
                     $orderFulfillment->load($_POST['fulfillment']['id']);
                     $orderFulfillment->setData($_POST['fulfillment']);
                     $orderFulfillment->save();
                     $orderFulfillment->clear();
                 } catch (Cart66Exception $e) {
                     $errorCode = $e->getCode();
                     if ($errorCode == 66303) {
                         $errors = $orderFulfillment->getErrors();
                         $exception = Cart66Exception::exceptionMessages($e->getCode(), __("The order fulfillment could not be saved for the following reasons", "cart66"), $errors);
                         $errorMessage = Cart66Common::getView('views/error-messages.php', $exception);
                     }
                 }
                 $tab = 'notifications-fulfillment_settings';
             }
             if ($_POST['cart66-action'] == 'advanced notifications') {
                 Cart66Setting::setValue('enable_advanced_notifications', $_POST['enable_advanced_notifications']);
                 $successMessage = __('Your notification settings have been saved.', 'cart66');
                 $tab = 'notifications-advanced_notifications';
             }
         } elseif ($_SERVER['REQUEST_METHOD'] == "GET") {
             if (isset($_GET['task']) && $_GET['task'] == 'edit_reminder' && isset($_GET['id']) && $_GET['id'] > 0) {
                 $id = Cart66Common::getVal('id');
                 $reminder->load($id);
                 $tab = 'notifications-reminder_settings';
             } elseif (isset($_GET['task']) && $_GET['task'] == 'delete_reminder' && isset($_GET['id']) && $_GET['id'] > 0) {
                 $id = Cart66Common::getVal('id');
                 $reminder->load($id);
                 $reminder->deleteMe();
                 $reminder->clear();
                 $tab = 'notifications-reminder_settings';
             } elseif (isset($_GET['task']) && $_GET['task'] == 'cancel_reminder') {
                 $tab = 'notifications-reminder_settings';
             } elseif (isset($_GET['task']) && $_GET['task'] == 'edit_fulfillment' && isset($_GET['id']) && $_GET['id'] > 0) {
                 $id = Cart66Common::getVal('id');
                 $orderFulfillment->load($id);
                 $tab = 'notifications-fulfillment_settings';
             } elseif (isset($_GET['task']) && $_GET['task'] == 'delete_fulfillment' && isset($_GET['id']) && $_GET['id'] > 0) {
                 $id = Cart66Common::getVal('id');
                 $orderFulfillment->load($id);
                 $orderFulfillment->deleteMe();
                 $orderFulfillment->clear();
                 $tab = 'notifications-fulfillment_settings';
             } elseif (isset($_GET['task']) && $_GET['task'] == 'cancel_fulfillment') {
                 $tab = 'notifications-fulfillment_settings';
             }
         }
         $data = array('reminder' => $reminder, 'order_fulfillment' => $orderFulfillment, 'tab' => $tab, 'error_message' => $errorMessage, 'success_message' => $successMessage);
     }
     echo Cart66Common::getView('admin/settings/notifications.php', $data, false);
 }
                    <option value='0'><?php 
    _e('None', 'cart66');
    ?>
</option>
                    <?php 
    try {
        $gr = new Cart66GravityReader($product->gravityFormId);
        $fields = $gr->getStandardFields();
        foreach ($fields as $id => $label) {
            $id = str_replace("'", "", $id);
            Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] Gravity Form Fields :: {$id} => {$label}");
            $selected = $product->gravityFormQtyId == $id ? 'selected="selected"' : '';
            echo "<option value='{$id}' {$selected}>{$label}</option>\n";
        }
    } catch (Cart66Exception $e) {
        $exception = Cart66Exception::exceptionMessages($e->getCode(), $e->getMessage());
        $gravityError = Cart66Common::getView('views/error-messages.php', $exception);
    }
    ?>
                  </select>
                  <?php 
    echo isset($gravityError) ? $gravityError : '';
    ?>
                  <span class="label_desc"><?php 
    _e('Use one of the Gravity Form fields as the quantity for your product.', 'cart66');
    ?>
</span>
                </li>
              <?php 
}
?>
    $ecUrls = array('RETURNURL' => $returnUrl, 'CANCELURL' => $cancelUrl, 'LOCALECODE' => $localeCode);
    $pp->setEcUrls($ecUrls);
    $response = $pp->SetExpressCheckout();
    $ack = strtoupper($response['ACK']);
    if ('SUCCESS' == $ack || 'SUCCESSWITHWARNING' == $ack) {
        Cart66Session::set('PayPalProToken', $response['TOKEN']);
        $expressCheckoutUrl = $pp->getExpressCheckoutUrl($response['TOKEN']);
        wp_redirect($expressCheckoutUrl);
        exit;
    } elseif (empty($ack)) {
        echo '<pre>Failed to connect via curl to PayPal. The most likely cause is that your PHP installation failed to verify that the CA cert is OK</pre>';
    } else {
        try {
            throw new Cart66Exception(ucwords($response['L_SHORTMESSAGE0']), 66503);
        } catch (Cart66Exception $e) {
            $exception = Cart66Exception::exceptionMessages($e->getCode(), $e->getMessage(), array('Error Number: ' . $response['L_ERRORCODE0'], $response['L_LONGMESSAGE0']));
            echo Cart66Common::getView('views/error-messages.php', $exception);
        }
    }
}
?>

<?php 
if ($settingsOk) {
    ?>
<form action="" method='post' id="paypalexpresscheckout">
  <input type='hidden' name='cart66-action' value='paypalexpresscheckout'>
  <?php 
    $paypalImageUrl = 'https://www.paypal.com/en_US/i/btn/btn_xpressCheckout.gif';
    if (CART66_PRO && Cart66Setting::getValue('custom_paypal_express_image')) {
        $paypalImageUrl = Cart66Setting::getValue('custom_paypal_express_image');
Пример #5
0
                    } elseif (CART66_EMAILS) {
                        $notify = new Cart66Notifications($orderId);
                        $notify->sendEmailReceipts();
                    }
                    // Send buyer to receipt page
                    $receiptVars = strpos($receiptLink, '?') ? '&' : '?';
                    $receiptVars .= "ouid=" . $newOrder->ouid;
                    wp_redirect($receiptLink . $receiptVars);
                    exit;
                } else {
                    // Attempt to discover reason for transaction failure
                    try {
                        throw new Cart66Exception(__('Your order could not be completed for the following reasons:', 'cart66'), 66500);
                    } catch (Cart66Exception $e) {
                        $gatewayResponse = $gateway->getTransactionResponseDescription();
                        $exception = Cart66Exception::exceptionMessages($e->getCode(), $e->getMessage(), array('error_code' => 'Error: ' . $gatewayResponse['errorcode'], strtolower($gatewayResponse['errormessage'])));
                        echo Cart66Common::getView('views/error-messages.php', $exception);
                    }
                    //$errors['Could Not Process Transaction'] = $gateway->getTransactionResponseDescription();
                }
            }
        }
    }
    // End if supported gateway
}
// End if POST
// Show inventory warning if there is one
if (Cart66Session::get('Cart66InventoryWarning')) {
    echo Cart66Session::get('Cart66InventoryWarning');
    Cart66Session::drop('Cart66InventoryWarning');
}
Пример #6
0
 public function initCheckout($amount)
 {
     $cart = Cart66Session::get('Cart66Cart');
     $tax = $this->getTaxAmount();
     $order = array('return_url' => Cart66Common::appendWurlQueryString('task=mijireh_notification'), 'tax' => $tax, 'shipping' => $cart->getShippingCost(), 'discount' => $cart->getDiscountAmount(), 'subtotal' => $cart->getSubTotal(), 'total' => number_format($cart->getGrandTotal() + $tax, 2, '.', ''), 'items' => array());
     // Prepare the shipping address if it is available
     if (strlen($this->_shipping['address']) > 3) {
         $order['shipping_address'] = array('first_name' => $this->_shipping['firstName'], 'last_name' => $this->_shipping['lastName'], 'street' => $this->_shipping['address'], 'apt_suite' => $this->_shipping['address2'], 'city' => $this->_shipping['city'], 'state_province' => $this->_shipping['state'], 'zip_code' => $this->_shipping['zip'], 'country' => $this->_shipping['country'], 'phone' => $this->_payment['phone']);
     }
     // Add shipping method and promotion code as meta_data
     $order['meta_data'] = array('shipping_method' => Cart66Session::get('Cart66Cart')->getShippingMethodName(), 'coupon' => Cart66Common::getPromoMessage(), 'custom-field' => $this->_payment['custom-field']);
     // Add logged in users id to the meta_data for membership product upgrades/extensions
     $account_id = Cart66Common::isLoggedIn();
     if ($account_id) {
         $order['meta_data']['account_id'] = $account_id;
     }
     // Add coupon code as meta_data
     foreach ($cart->getItems() as $key => $item) {
         $sku = $item->getItemNumber();
         $order_item_data = array('sku' => $sku, 'name' => $item->getFullDisplayName(), 'price' => $item->getProductPrice(), 'quantity' => $item->getQuantity());
         if ($custom_desc = $item->getCustomFieldDesc()) {
             $order_item_data['name'] .= "\n" . $custom_desc;
         }
         if ($custom_info = $item->getCustomFieldInfo()) {
             $order_item_data['name'] .= "\n" . $custom_info;
         }
         $order['items'][$key] = $order_item_data;
         $option_info = trim($item->getOptionInfo());
         if (!empty($option_info)) {
             $order['meta_data']['options_' . $sku] = $option_info;
         }
         if ($item->hasAttachedForms()) {
             $form_ids = $item->getFormEntryIds();
             if (is_array($form_ids) && count($form_ids)) {
                 $form_ids = implode(',', $form_ids);
                 $order['meta_data'][$key]['gforms_' . $sku] = $form_ids;
             }
         }
     }
     // DBG
     /*
     echo "<pre>";
     print_r($order);
     echo "</pre>";
     die();
     */
     try {
         //Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] Sending Order To Mijireh" . print_r($order, true));
         $access_key = Cart66Setting::getValue('mijireh_access_key');
         $rest = new PestJSON(MIJIREH_CHECKOUT);
         $rest->setupAuth($access_key, '');
         Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] Sending Order To Mijireh: " . print_r($order, true));
         $result = $rest->post('/api/1/orders', $order);
         wp_redirect($result['checkout_url']);
         //wp_redirect(MIJIREH_CHECKOUT .  '/checkout/' . $result['order_number']);
         exit;
     } catch (Pest_Unauthorized $e) {
         Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] REST Request Failed because it was unauthorized: " . $e->getMessage());
         $this->response['error_message'] = __("Your Mijireh Access key is invalid, please check your access settings and try again", "cart66");
         $this->response['error_code'] = 1;
         if (strlen($this->_shipping['address']) < 3) {
             $gatewayResponse = $this->getTransactionResponseDescription();
             $exception = Cart66Exception::exceptionMessages(66500, __('Your order could not be processed for the following reasons:', 'cart66'), array('error_code' => 'Error: ' . $gatewayResponse['errorcode'], strtolower($gatewayResponse['errormessage'])));
             echo Cart66Common::getView('views/error-messages.php', $exception);
         }
     } catch (Exception $e) {
         Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] REST Request Failed: " . $e->getMessage());
     }
 }