/** * @param Crowdfunding\Transaction $transaction * @param Crowdfunding\Project $project * @param array $data * * @return bool */ protected function processVoided(&$transaction, &$project, &$data) { // It is possible only to void a transaction with status "pending". if (!$transaction->isPending()) { return false; } // Set transaction data to canceled. $data['txn_status'] = 'canceled'; // Update the transaction data. // If the current status is pending and the new status is completed, // only store the transaction data, updating the status to completed. $transaction->bind($data, array('extra_data')); $transaction->addExtraData($data['extra_data']); $transaction->store(); $amount = Joomla\Utilities\ArrayHelper::getValue($data, 'txn_amount'); $project->removeFunds($amount); $project->storeFunds(); return true; }
/** * @param Crowdfunding\Transaction $transaction * @param Crowdfunding\Project $project * @param array $data * * @return bool */ protected function processVoided(&$transaction, &$project, &$data) { // It is possible only to void a transaction with status "pending". if (!$transaction->isPending()) { return; } // Merge existed extra data with the new one. if (!empty($data["extra_data"])) { $transaction->addExtraData($data["extra_data"]); unset($data["extra_data"]); } // Remove the status reason. $data["status_reason"] = ""; // Update the transaction data. // If the current status is pending and the new status is completed, // only store the transaction data, updating the status to completed. $transaction->bind($data); $transaction->store(); $amount = Joomla\Utilities\ArrayHelper::getValue($data, "txn_amount"); $project->removeFunds($amount); $project->storeFunds(); }