public function update() { if ($this->item) { $this->item->update(); } elseif ($this->collection) { $this->collection->update(); } else { $this->_error = "Unable to update; no data loaded."; } }
public function update() { parent::update(); $classname = 'Sp4kAppsSubscriptionPaymentMethods' . ucfirst($this->getState()->get('billing')); if (class_exists($classname)) { /** @var Sp4kAppsSubscriptionPaymentMethodsBank $paymentProcessor */ $paymentProcessor = new $classname(new Registry(['agreement' => ['account_config' => $this->getState()->get('billing'), 'user' => $this->getState()->get('juser'), 'paymentMonthInYear' => (int) strftime('%m', $this->getState()->get('billing_start')), 'paymentDayInMonth' => $this->getState()->get('paydate'), 'start' => strftime('%d/%m/%Y', $this->getState()->get('billing_start'))], 'paymentinfo' => $this->getState()->get('payinfo')])); //set up an account for this user if one does not already exist with the payment provider. $paymentProcessor->initializeAgreement(); if ($payment_error = $paymentProcessor->getError()) { $this->_error = $payment_error; } else { $this->state = 1; $this->status = 1; //failed/complete/unresolved/abandoned/cancelled/rejected $this->pm_ref_agreement_id = $paymentProcessor->agreement_id; $this->bind(); parent::update(); } } return; }