public function paymentmethod() { $gateways = GatewayInfo::getSupportedGateways(); if (count($gateways) == 1) { return $this->owner->redirect($this->NextStepLink()); } return array('OrderForm' => $this->PaymentMethodForm()); }
public function validateData(Order $order, array $data) { $result = ValidationResult::create(); if (!isset($data['PaymentMethod'])) { $result->error(_t('PaymentCheckoutComponent.NoPaymentMethod', "Payment method not provided"), "PaymentMethod"); throw new ValidationException($result); } $methods = GatewayInfo::getSupportedGateways(); if (!isset($methods[$data['PaymentMethod']])) { $result->error(_t('PaymentCheckoutComponent.UnsupportedGateway', "Gateway not supported"), "PaymentMethod"); throw new ValidationException($result); } }
/** * Change search context to use a dropdown for list of gateways. */ public function getDefaultSearchContext() { $context = parent::getDefaultSearchContext(); $fields = $context->getSearchFields(); $fields->removeByName('Gateway'); $fields->removeByName('Created'); $fields->insertAfter(DropdownField::create('Gateway', _t('Payment.db_Gateway', 'Gateway'), GatewayInfo::getSupportedGateways())->setHasEmptyDefault(true), 'Money'); // create a localized status dropdown for the search-context $fields->insertAfter(DropdownField::create('Status', _t('Payment.db_Status', 'Status'), $this->getStatusValues())->setHasEmptyDefault(true), 'Gateway'); // update "money" to localized title $fields->fieldByName('Money')->setTitle(_t('Payment.db_Money', 'Money')); $context->addFilter(new PartialMatchFilter('Gateway')); return $context; }
/** * Get all available payment types */ private function PaymentTypes() { $factory = new \Omnipay\Common\GatewayFactory(); // since the omnipay gateway factory only returns gateways from the composer.json extra data, // we should merge it with user-defined gateways from Payment.allowed_gateways $gateways = array_unique(array_merge($factory->find(), array_keys(GatewayInfo::getSupportedGateways(false)))); $supportedGateways = array(); array_walk($gateways, function ($name, $index) use(&$supportedGateways, &$factory) { try { $instance = $factory->create($name); $supportedGateways[$name] = $instance; } catch (\Exception $e) { } }); return $supportedGateways; }
public function __construct($controller, $name, Order $order) { $this->order = $order; $fields = FieldList::create(HiddenField::create('OrderID', '', $order->ID)); $actions = FieldList::create(); //payment if (self::config()->allow_paying && $order->canPay()) { $gateways = GatewayInfo::getSupportedGateways(); //remove manual gateways foreach ($gateways as $gateway => $gatewayname) { if (GatewayInfo::isManual($gateway)) { unset($gateways[$gateway]); } } if (!empty($gateways)) { $fields->push(HeaderField::create("MakePaymentHeader", _t("OrderActionsForm.MakePayment", "Make Payment"))); $outstandingfield = Currency::create(); $outstandingfield->setValue($order->TotalOutstanding(true)); $fields->push(LiteralField::create("Outstanding", _t('Order.OutstandingWithAmount', 'Outstanding: {Amount}', '', array('Amount' => $outstandingfield->Nice())))); $fields->push(OptionsetField::create('PaymentMethod', _t("OrderActionsForm.PaymentMethod", "Payment Method"), $gateways, key($gateways))); if ($ccFields = $this->getCCFields($gateways)) { if ($this->config()->include_jquery) { Requirements::javascript(THIRDPARTY_DIR . '/jquery/jquery.min.js'); } Requirements::javascript(SHOP_DIR . '/javascript/OrderActionsForm.js'); $fields->push($ccFields); } $actions->push(FormAction::create('dopayment', _t('OrderActionsForm.PayOrder', 'Pay outstanding balance'))); } } //cancelling if (self::config()->allow_cancelling && $order->canCancel()) { $actions->push(FormAction::create('docancel', _t('OrderActionsForm.CancelOrder', 'Cancel this order'))); } parent::__construct($controller, $name, $fields, $actions, OrderActionsForm_Validator::create(array('PaymentMethod'))); $this->extend("updateForm", $order); }
public function __construct(Order $order) { parent::__construct($order); $this->addComponent(CustomerDetailsCheckoutComponent::create()); $this->addComponent(ShippingAddressCheckoutComponent::create()); $this->addComponent(BillingAddressCheckoutComponent::create()); if (Checkout::member_creation_enabled() && !Member::currentUserID()) { $this->addComponent(MembershipCheckoutComponent::create()); } if (count(GatewayInfo::getSupportedGateways()) > 1) { $this->addComponent(PaymentCheckoutComponent::create()); } $this->addComponent(NotesCheckoutComponent::create()); $this->addComponent(TermsCheckoutComponent::create()); }
public function getPaymentMethodFields() { //TODO: only get one field if there is no option return OptionsetField::create('PaymentMethod', _t('CheckoutField.PaymentType', "Payment Type"), GatewayInfo::getSupportedGateways(), array_keys(GatewayInfo::getSupportedGateways())); }
public function getPaymentMethods() { return GatewayInfo::getSupportedGateways(); }