/** * Process a payment. * @param string $id debt id * @param array $data * @return Response */ public function pay($id, $data = []) { extract_args($data, ['payment_info' => [], 'nickname' => null, 'pay_account_id' => null, 'amount' => null, 'future_date' => null]); if (empty($data['payment_info'])) { return Response::error('Invalid Payment Information Specified', 1080); } // TODO, validate return $this->post("debt/{$id}/payment", $data); }
/** * Change the recurring pay account. * @param $id * @param $acct * @param array $data * @return Response|string */ public function changeRecurringPayAccount($id, $acct, $data = []) { extract_args($data, ['pay_account_id' => $acct, 'nickname' => 'Auto Monthly', 'active' => true, 'replace_existing' => true]); if (!$acct) { $created = $this->create($data); if (!$created->pay_account_id) { return Response::error('Failed to Create Requested Pay Account', 1080); } $data['pay_account_id'] = $created->pay_account_id; } return $this->post("debt/{$id}/autopayments/create", $data); }