Ejemplo n.º 1
0
 public function onUpdatePaymentType()
 {
     if (!($invoice = $this->getInvoice())) {
         throw new ApplicationException('Invoice not found!');
     }
     if (!($methodId = post('payment_method'))) {
         throw new ApplicationException('Payment type not specified!');
     }
     if (!($method = TypeModel::find($methodId))) {
         throw new ApplicationException('Payment type not found!');
     }
     $invoice->payment_method = $method;
     $invoice->save();
     $this->page['invoice'] = $invoice;
     $this->page['paymentMethod'] = $method;
 }
Ejemplo n.º 2
0
 public function formCreateModelObject()
 {
     $model = new TypeModel();
     $model->applyGatewayClass($this->getGatewayClass());
     return $model;
 }
Ejemplo n.º 3
0
 public function afterFetch()
 {
     if (!$this->payment_method_id) {
         $this->payment_method = TypeModel::getDefault($this->country_id);
     }
 }
Ejemplo n.º 4
0
 /**
  * Loops over each payment type and ensures the editing theme has a payment form partial,
  * if the partial does not exist, it will create one.
  * @return void
  */
 public static function createPartials()
 {
     $partials = Partial::lists('baseFileName', 'baseFileName');
     $paymentMethods = TypeModel::all();
     foreach ($paymentMethods as $paymentMethod) {
         $class = $paymentMethod->class_name;
         if (!$class || get_parent_class($class) != 'Responsiv\\Pay\\Classes\\GatewayBase') {
             continue;
         }
         $partialName = 'pay/' . strtolower(class_basename($class));
         $partialExists = array_key_exists($partialName, $partials);
         if (!$partialExists) {
             $filePath = dirname(File::fromClass($class)) . '/' . strtolower(class_basename($class)) . '/payment_form.htm';
             self::createPartialFromFile($partialName, $filePath, Theme::getEditTheme());
         }
     }
 }