예제 #1
0
 /**
  * Get the supported methods array set by the yaml configuraion
  *
  * @return array
  */
 public static function get_supported_methods()
 {
     $methodConfig = Config::inst()->get('PaymentProcessor', 'supported_methods');
     $environment = PaymentGateway::get_environment();
     // Check if all methods are defined in factory
     foreach ($methodConfig[$environment] as $method) {
         if (!PaymentFactory::get_factory_config($method)) {
             user_error("Method {$method} not defined in factory", E_USER_ERROR);
         }
     }
     return $methodConfig[$environment];
 }
 /**
  * Show the "choose payment method" form
  */
 function ProcessForm()
 {
     $fields = new FieldList();
     // Create a dropdown select field for choosing gateway
     $supported_methods = PaymentProcessor::get_supported_methods();
     $source = array();
     foreach ($supported_methods as $methodName) {
         $methodConfig = PaymentFactory::get_factory_config($methodName);
         $source[$methodName] = $methodConfig['title'];
     }
     $fields->push(new DropDownField('PaymentMethod', 'Select Payment Method', $source));
     $actions = new FieldList(new FormAction('proceed', 'Proceed'));
     $processForm = new Form($this, 'ProcessForm', $fields, $actions);
     $processForm->disableSecurityToken();
     return $processForm;
 }
예제 #3
0
파일: RepayForm.php 프로젝트: vinstah/body
 public function createFields()
 {
     $order = $this->order;
     $member = $this->customer;
     //Payment fields
     $supported_methods = PaymentProcessor::get_supported_methods();
     $source = array();
     foreach ($supported_methods as $methodName) {
         $methodConfig = PaymentFactory::get_factory_config($methodName);
         $source[$methodName] = $methodConfig['title'];
     }
     $outstanding = $order->TotalOutstanding()->Nice();
     $paymentFields = CompositeField::create(new HeaderField(_t('CheckoutPage.PAYMENT', "Payment"), 3), LiteralField::create('RepayLit', "<p>Process a payment for the oustanding amount: {$outstanding}</p>"), DropDownField::create('PaymentMethod', 'Select Payment Method', $source)->setCustomValidationMessage(_t('CheckoutPage.SELECT_PAYMENT_METHOD', "Please select a payment method.")))->setName('PaymentFields');
     $fields = FieldList::create($paymentFields);
     $this->extend('updateFields', $fields);
     $fields->setForm($this);
     return $fields;
 }
예제 #4
0
파일: OrderForm.php 프로젝트: vinstah/body
 public function createFields()
 {
     $order = $this->order;
     $member = $this->customer;
     //Personal details fields
     if (!$member->ID || $member->Password == '') {
         $link = $this->controller->Link();
         $note = _t('CheckoutPage.NOTE', 'NOTE:');
         $passwd = _t('CheckoutPage.PLEASE_CHOOSE_PASSWORD', 'Please choose a password, so you can login and check your order history in the future.');
         $mber = sprintf(_t('CheckoutPage.ALREADY_MEMBER', 'If you are already a member please %s log in. %s'), "<a href=\"Security/login?BackURL={$link}\">", '</a>');
         $personalFields = CompositeField::create(new HeaderField(_t('CheckoutPage.ACCOUNT', "Account"), 3), new CompositeField(EmailField::create('Email', _t('CheckoutPage.EMAIL', 'Email'))->setCustomValidationMessage(_t('CheckoutPage.PLEASE_ENTER_EMAIL_ADDRESS', "Please enter your email address."))), new CompositeField(new FieldGroup(new ConfirmedPasswordField('Password', _t('CheckoutPage.PASSWORD', "Password")))), new CompositeField(new LiteralField('AccountInfo', "\r\n\t\t\t\t\t\t<p class=\"alert alert-info\">\r\n\t\t\t\t\t\t\t<strong class=\"alert-heading\">{$note}</strong>\r\n\t\t\t\t\t\t\t{$passwd} <br /><br />\r\n\t\t\t\t\t\t\t{$mber}\r\n\t\t\t\t\t\t</p>\r\n\t\t\t\t\t\t")))->setID('PersonalDetails')->setName('PersonaDetails');
     }
     //Order item fields
     $items = $order->Items();
     $itemFields = CompositeField::create()->setName('ItemsFields');
     if ($items) {
         foreach ($items as $item) {
             $itemFields->push(new OrderForm_ItemField($item));
         }
     }
     //Order modifications fields
     $subTotalModsFields = CompositeField::create()->setName('SubTotalModificationsFields');
     $subTotalMods = $order->SubTotalModifications();
     if ($subTotalMods && $subTotalMods->exists()) {
         foreach ($subTotalMods as $modification) {
             $modFields = $modification->getFormFields();
             foreach ($modFields as $field) {
                 $subTotalModsFields->push($field);
             }
         }
     }
     $totalModsFields = CompositeField::create()->setName('TotalModificationsFields');
     $totalMods = $order->TotalModifications();
     if ($totalMods && $totalMods->exists()) {
         foreach ($totalMods as $modification) {
             $modFields = $modification->getFormFields();
             foreach ($modFields as $field) {
                 $totalModsFields->push($field);
             }
         }
     }
     //Payment fields
     $supported_methods = PaymentProcessor::get_supported_methods();
     $source = array();
     foreach ($supported_methods as $methodName) {
         $methodConfig = PaymentFactory::get_factory_config($methodName);
         $source[$methodName] = $methodConfig['title'];
     }
     $paymentFields = CompositeField::create(new HeaderField(_t('CheckoutPage.PAYMENT', "Payment"), 3), DropDownField::create('PaymentMethod', 'Select Payment Method', $source)->setCustomValidationMessage(_t('CheckoutPage.SELECT_PAYMENT_METHOD', "Please select a payment method.")))->setName('PaymentFields');
     $fields = FieldList::create($itemFields, $subTotalModsFields, $totalModsFields, $notesFields = CompositeField::create(TextareaField::create('Notes', _t('CheckoutPage.NOTES_ABOUT_ORDER', "Notes about this order")))->setName('NotesFields'), $paymentFields);
     if (isset($personalFields)) {
         $fields->push($personalFields);
     }
     $this->extend('updateFields', $fields);
     $fields->setForm($this);
     return $fields;
 }