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; }
public function formCreateModelObject() { $model = new TypeModel(); $model->applyGatewayClass($this->getGatewayClass()); return $model; }
public function afterFetch() { if (!$this->payment_method_id) { $this->payment_method = TypeModel::getDefault($this->country_id); } }
/** * 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()); } } }