コード例 #1
0
 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::get_supported_gateways();
         //remove manual gateways
         foreach ($gateways as $gateway => $gatewayname) {
             if (GatewayInfo::is_manual($gateway)) {
                 unset($gateways[$gateway]);
             }
         }
         if (!empty($gateways)) {
             $fields->push(HeaderField::create("MakePaymentHeader", _t("OrderActionsForm.MAKEPAYMENT", "Make Payment")));
             $outstandingfield = Currency::create();
             $outstandingfield->setValue($order->TotalOutstanding());
             $fields->push(LiteralField::create("Outstanding", sprintf(_t("OrderActionsForm.OUTSTANDING", "Outstanding: %s"), $outstandingfield->Nice())));
             $fields->push(OptionsetField::create('PaymentMethod', _t("OrderActionsForm.PAYMENTMETHOD", "Payment Method"), $gateways, key($gateways)));
             $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);
     $this->extend("updateForm", $order);
 }
コード例 #2
0
 public function paymentmethod()
 {
     $gateways = GatewayInfo::get_supported_gateways();
     if (count($gateways) == 1) {
         return $this->owner->redirect($this->NextStepLink());
     }
     return array('OrderForm' => $this->PaymentMethodForm());
 }
コード例 #3
0
ファイル: Payment.php プロジェクト: ss23/silverstripe-omnipay
 /**
  * Change search context to use a dropdown for list of gateways.
  */
 public function getDefaultSearchContext()
 {
     $context = parent::getDefaultSearchContext();
     $fields = $context->getSearchFields();
     $fields->removeByName('Gateway');
     $fields->insertBefore(DropdownField::create('Gateway', 'Gateway', GatewayInfo::get_supported_gateways())->setHasEmptyDefault(true), 'Status');
     $fields->fieldByName('Status')->setHasEmptyDefault(true);
     return $context;
 }
 public function testSupportedGateways()
 {
     $expected = array('PayPal_Express' => 'PayPal Express', 'PaymentExpress_PxPay' => 'PaymentExpress PxPay', 'Manual' => 'Manual', 'Dummy' => 'Dummy');
     $gateways = GatewayInfo::get_supported_gateways();
     $this->assertArrayHasKey('PayPal_Express', $gateways);
     $this->assertArrayHasKey('PaymentExpress_PxPay', $gateways);
     $this->assertArrayHasKey('Manual', $gateways);
     $this->assertArrayHasKey('Dummy', $gateways);
 }
 public function getCMSFields()
 {
     $fields = parent::getCMSFields();
     $gateways = GatewayInfo::get_supported_gateways();
     $amountfields = $this->Fields()->map("ID", "Title");
     $fields->addFieldsToTab("Root.Payment", array(DropdownField::create("PaymentAmountFieldID", "Payment Amount Field", $amountfields)->setDescription("This must return a value like 20.00 (no dollar sign)"), new DropdownField("PaymentGateway", "Payment Gateway", $gateways), new TextField("PaymentCurrency", "Payment Currency"), new CheckboxField("PaymentFields_Card", "Show Card Fields"), new CheckboxField("PaymentFields_Billing", "Show Billing Fields"), new CheckboxField("PaymentFields_Shipping", "Show Shipping Fields"), new CheckboxField("PaymentFields_Company", "Show Company Fields"), new CheckboxField("PaymentFields_Email", "Show Email Fields")));
     // text to show on error
     $onErrorFieldSet = new CompositeField($label = new LabelField('OnErrorMessageLabel', _t('UserDefinedForm.ONERRORLABEL', 'Show on error')), $editor = new HtmlEditorField("OnErrorMessage", "", _t('UserDefinedForm.ONERRORMESSAGE', $this->OnErrorMessage)));
     $onErrorFieldSet->addExtraClass('field');
     $fields->insertAfter($onErrorFieldSet, "OnCompleteMessage");
     return $fields;
 }
コード例 #6
0
 public function validateData(Order $order, array $data)
 {
     $result = new ValidationResult();
     if (!isset($data['PaymentMethod'])) {
         $result->error("Payment method not provided", "PaymentMethod");
         throw new ValidationException($result);
     }
     $methods = GatewayInfo::get_supported_gateways();
     if (!isset($methods[$data['PaymentMethod']])) {
         $result->error("Gateway not supported", "PaymentMethod");
         throw new ValidationException($result);
     }
 }
コード例 #7
0
 public function validateData(Order $order, array $data)
 {
     $result = ValidationResult::create();
     if (!isset($data['PaymentMethod'])) {
         $result->error(_t('PaymentCheckoutComponent.NO_PAYMENT_METHOD', "Payment method not provided"), "PaymentMethod");
         throw new ValidationException($result);
     }
     $methods = GatewayInfo::get_supported_gateways();
     if (!isset($methods[$data['PaymentMethod']])) {
         $result->error(_t('PaymentCheckoutComponent.UNSUPPORTED_GATEWAY', "Gateway not supported"), "PaymentMethod");
         throw new ValidationException($result);
     }
 }
コード例 #8
0
 /**
  * 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.GATEWAY', 'Gateway'), GatewayInfo::get_supported_gateways())->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.MONEY', 'Money'));
     $context->addFilter(new PartialMatchFilter('Gateway'));
     return $context;
 }
コード例 #9
0
 public function getPaymentMethods()
 {
     return GatewayInfo::get_supported_gateways();
 }
コード例 #10
0
 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::get_supported_gateways()) > 1) {
         $this->addComponent(PaymentCheckoutComponent::create());
     }
     $this->addComponent(NotesCheckoutComponent::create());
     $this->addComponent(TermsCheckoutComponent::create());
 }
コード例 #11
0
 public function getPaymentMethodFields()
 {
     //TODO: only get one field if there is no option
     return OptionsetField::create('PaymentMethod', _t('CheckoutField.PAYMENT_TYPE', "Payment Type"), GatewayInfo::get_supported_gateways(), array_keys(GatewayInfo::get_supported_gateways()));
 }
コード例 #12
0
ファイル: PaymentController.php プロジェクト: 8secs/cocina
 /**
  * Form for selecting a gateway.
  */
 public function GatewaySelectForm()
 {
     $gateways = GatewayInfo::get_supported_gateways();
     $fields = new FieldList(new OptionsetField("Gateway", _t("PaymentController.METHOD", "Payment Method"), $gateways));
     $validator = new RequiredFields('Gateway');
     $actions = new FieldList(new FormAction("select", _t("PaymentController.DIFFERENTMETHOD", "Make Payment")));
     $form = new Form($this, "GatewaySelectForm", $fields, $actions, $validator);
     $this->extend('updateGatewaySelectForm', $form);
     return $form;
 }
コード例 #13
0
 public function getPaymentMethodFields()
 {
     //TODO: only get one field if there is no option
     return new OptionsetField('PaymentMethod', _t("Checkout", "Payment Type"), GatewayInfo::get_supported_gateways(), array_keys(GatewayInfo::get_supported_gateways()));
 }