public function getCardFields()
 {
     $months = array();
     //generate list of months
     for ($x = 1; $x <= 12; $x++) {
         $months[$x] = date('m - F', mktime(0, 0, 0, $x, 1));
     }
     $year = date("Y");
     $range = 5;
     $startrange = range(date("Y", strtotime("-{$range} years")), $year);
     $expiryrange = range($year, date("Y", strtotime("+{$range} years")));
     $fields = array("type" => DropdownField::create('type', _t("PaymentForm.TYPE", "Type"), $this->getCardTypes()), "name" => TextField::create('name', _t("PaymentForm.NAME", "Name on Card")), "number" => TextField::create('number', _t("PaymentForm.NUMBER", "Card Number"))->setDescription(_t("PaymentForm.NUMBERDESCRIPTION", "no dashes or spaces")), "startMonth" => DropdownField::create('startMonth', _t("PaymentForm.STARTMONTH", "Month"), $months), "startYear" => DropdownField::create('startYear', _t("PaymentForm.STARTYEAR", "Year"), array_combine($startrange, $startrange), $year), "expiryMonth" => DropdownField::create('expiryMonth', _t("PaymentForm.EXPIRYMONTH", "Month"), $months), "expiryYear" => DropdownField::create('expiryYear', _t("PaymentForm.EXPIRYYEAR", "Year"), array_combine($expiryrange, $expiryrange), $year), "cvv" => TextField::create('cvv', _t("PaymentForm.CVV", "Security Code"))->setMaxLength(5), "issueNumber" => TextField::create('issueNumber', _t("PaymentForm.ISSUENUMBER", "Issue Number")));
     //assumption: no credit card fields are ever required for off-site gateways by default
     $defaults = GatewayInfo::is_offsite($this->gateway) ? array() : array('name', 'number', 'expiryMonth', 'expiryYear', 'cvv');
     $this->cullForGateway($fields, $defaults);
     //optionally group date fields
     if ($this->groupdatefields) {
         if (isset($fields['startMonth']) && isset($fields['startYear'])) {
             $fields['startMonth'] = new FieldGroup(_t("PaymentForm.START", "Start"), $fields['startMonth'], $fields['startYear']);
             unset($fields['startYear']);
         }
         if (isset($fields['expiryMonth']) && isset($fields['expiryYear'])) {
             $fields['expiryMonth'] = new FieldGroup(_t("PaymentForm.EXPIRY", "Expiry"), $fields['expiryMonth'], $fields['expiryYear']);
             unset($fields['expiryYear']);
         }
     }
     return FieldList::create($fields);
 }
 public function checkoutSubmit($data, $form)
 {
     // form validation has passed by this point, so we can save data
     $this->config->setData($form->getData());
     $order = $this->config->getOrder();
     $gateway = Checkout::get($order)->getSelectedPaymentMethod(false);
     if (GatewayInfo::is_offsite($gateway) || GatewayInfo::is_manual($gateway) || $this->config->getComponentByType('OnsitePaymentCheckoutComponent')) {
         return $this->submitpayment($data, $form);
     }
     return $this->controller->redirect($this->controller->Link('payment'));
 }
 public function testIsOffsite()
 {
     $this->assertFalse(GatewayInfo::is_offsite('\\GatewayInfoTest_OnsiteGateway'));
     $this->assertTrue(GatewayInfo::is_offsite('\\GatewayInfoTest_OffsiteGateway'));
 }