public static function getByID($pmID) { $db = Database::get(); $data = $db->GetRow("SELECT * FROM VividStorePaymentMethods WHERE pmID=?", $pmID); if (!empty($data)) { $method = new Method(); $method->setPropertiesFromArray($data); $method->setMethodController(); } return $method instanceof Method ? $method : false; }
public function uninstall() { $paypal = PaymentMethod::getByHandle('paypal_express'); if (is_object($paypal)) { $paypal->delete(); } parent::uninstall(); }
public function validate($args, $e) { $pm = PaymentMethod::getByHandle('paypal_standard'); if ($args['paymentMethodEnabled'][$pm->getPaymentMethodID()] == 1) { if ($args['paypalEmail'] == "") { $e->add(t("PayPal Email must be set")); } } return $e; }
public function validate($args, $e) { $pm = PaymentMethod::getByHandle('auth_net'); if ($args['paymentMethodEnabled'][$pm->getPaymentMethodID()] == 1) { if ($args['authnetTransactionKey'] == "") { $e->add(t("Transaction Key must be set")); } if ($args['authnetLoginID'] == "") { $e->add(t("Login ID must be set")); } } return $e; }
public function uninstall() { $authnetpm = PaymentMethod::getByHandle('auth_net'); if (is_object($authnetpm)) { $authnetpm->delete(); } $invoicepm = PaymentMethod::getByHandle('invoice'); if (is_object($invoicepm)) { $invoicepm->delete(); } $paypalpm = PaymentMethod::getByHandle('paypal_standard'); if (is_object($paypalpm)) { $paypalpm->delete(); } $shippingMethodType = ShippingMethodType::getByHandle('flat_rate'); if (is_object($shippingMethodType)) { $shippingMethodType->delete(); } $shippingMethodType = ShippingMethodType::getByHandle('free_shipping'); if (is_object($shippingMethodType)) { $shippingMethodType->delete(); } parent::uninstall(); }
public function validate($args) { $e = Loader::helper('validation/error'); if ($args['symbol'] == "") { $e->add(t('You must set a currency symbol')); } if ($args['taxEnabled'] == 'yes') { if (!is_numeric(trim($args['taxRate']))) { $e->add(t('Tax Rate must be set, and a number')); } } if ($args['shippingEnabled'] == 'yes') { if (!is_numeric(trim($args['shippingBasePrice']))) { $e->add(t('Shipping Base Rate must be set, and a number')); } if (!is_numeric(trim($args['shippingItemPrice']))) { $e->add(t('Shipping Base Rate must be set, and a number (even if just zero)')); } } $paymentMethodsEnabled = 0; foreach ($args['paymentMethodEnabled'] as $method) { if ($method == 1) { $paymentMethodsEnabled++; } } if ($paymentMethodsEnabled == 0) { $e->add(t('At least one payment method must be enabled')); } foreach ($args['paymentMethodEnabled'] as $pmID => $value) { $pm = PaymentMethod::getByID($pmID); $controller = $pm->getMethodController(); $e = $controller->validate($args, $e); } if (!isset($args['osName'])) { $e->add(t('You must have at least one Order Status.')); } return $e; }
public function uninstall() { $authpm = PaymentMethod::getByHandle('auth_net'); if (is_object($authpm)) { $authpm->delete(); } $invoicepm = PaymentMethod::getByHandle('invoice'); if (is_object($invoicepm)) { $invoicepm->delete(); } parent::uninstall(); }
public static function installPaymentMethod($handle, $name, $pkg = null, $displayName = null, $enabled = false) { $pm = StorePaymentMethod::getByHandle($handle); if (!is_object($pm)) { StorePaymentMethod::add($handle, $name, $pkg, $displayName, $enabled); } }
public function external() { $pm = Session::get('paymentMethod'); /*print_r($pm); exit();die(); */ foreach ($pm as $pmID => $handle) { $pm = PaymentMethod::getByID($pmID); } //$pm = PaymentMethod::getByHandle($pm[3]); $this->set('pm', $pm); $this->set('action', $pm->getMethodController()->getAction()); }
public function getPaymentMethodName() { $pm = PaymentMethod::getByID($this->pmID); if (is_object($pm)) { return $pm->getPaymentMethodName(); } }
public function validate($args) { $e = Loader::helper('validation/error'); if ($args['symbol'] == "") { $e->add(t('You must set a currency symbol')); } if ($args['taxEnabled'] == 'yes') { if (!is_numeric(trim($args['taxRate']))) { $e->add(t('Tax Rate must be set, and a number')); } } if ($args['shippingEnabled'] == 'yes') { if (!is_numeric(trim($args['shippingBasePrice']))) { $e->add(t('Shipping Base Rate must be set, and a number')); } if (!is_numeric(trim($args['shippingItemPrice']))) { $e->add(t('Shipping Base Rate must be set, and a number (even if just zero)')); } } $paymentMethodsEnabled = 0; foreach ($args['paymentMethodEnabled'] as $method) { if ($method == 1) { $paymentMethodsEnabled++; } } if ($paymentMethodsEnabled == 0) { $e->add(t('At least one payment method must be enabled')); } foreach ($args['paymentMethodEnabled'] as $pmID => $value) { $pm = StorePaymentMethod::getByID($pmID); $controller = $pm->getMethodController(); $e = $controller->validate($args, $e); } if (!isset($args['osName'])) { $e->add(t('You must have at least one Order Status.')); } //before changing tax settings to "Extract", make sure there's only one rate per class $taxClasses = StoreTaxClass::getTaxClasses(); foreach ($taxClasses as $taxClass) { $taxClassRates = $taxClass->getTaxClassRates(); if (count($taxClassRates) > 1) { $e->add(t("The %s Tax Class can't contain more than 1 Tax Rate if you change how the taxes are calculated", $taxClass->getTaxClassName())); } } return $e; }
/** * @param array $data * @param StorePaymentMethod $pm * @param string $transactionReference * @param boolean $status * @return Order */ public function add($data, $pm, $transactionReference = '', $status = null) { $customer = new StoreCustomer(); $now = new \DateTime(); $smName = StoreShippingMethod::getActiveShippingMethodName(); $shippingTotal = StoreCalculator::getShippingTotal(); $taxes = StoreTax::getConcatenatedTaxStrings(); $totals = StoreCalculator::getTotals(); $total = $totals['total']; $pmName = $pm->getPaymentMethodName(); $order = new Order(); $order->setCustomerID($customer->getUserID()); $order->setOrderDate($now); $order->setPaymentMethodName($pmName); $order->setShippingMethodName($smName); $order->setShippingTotal($shippingTotal); $order->setTaxTotals($taxes['taxTotals']); $order->setTaxIncluded($taxes['taxIncludedTotal']); $order->setTaxLabels($taxes['taxLabels']); $order->setOrderTotal($total); $order->save(); $customer->setLastOrderID($order->getOrderID()); $order->updateStatus($status); $order->addCustomerAddress($customer, $order->isShippable()); $order->addOrderItems(StoreCart::getCart()); $order->createNeededAccounts(); $order->assignFilePermissions(); if (!$pm->getMethodController()->external) { $order->completeOrder($transactionReference); } return $order; }
public function submit() { $data = $this->post(); //process payment $pmHandle = $data['payment-method']; $pm = PaymentMethod::getByHandle($pmHandle); if (!$pm instanceof PaymentMethod) { //There was no payment method enabled somehow. //so we'll force invoice. $pm = PaymentMethod::getByHandle('invoice'); } $payment = $pm->submitPayment(); if ($payment['error'] == 1) { $pmsess = Session::get('paymentMethod'); $pmsess[$pm->getPaymentMethodID()] = $data['payment-method']; Session::set('paymentMethod', $pmsess); $pesess = Session::get('paymentErrors'); $pesess = $payment['errorMessage']; Session::set('paymentErrors', $pesess); $this->redirect("/checkout/failed#payment"); } else { VividOrder::add($data, $pm); $this->redirect('/checkout/complete'); } }