/** * Updates a payment method. * * @param int $customer_id Customer ID. * @param int $id Payment method ID. * * @return void */ public function put_index($customer_id = null, $id = null) { $customer = $this->get_customer($customer_id); $payment_method = $this->get_paymentmethod($id, $customer); $validator = \Validation_Customer_Paymentmethod::update($payment_method->gateway); if (!$validator->run(\Input::put())) { throw new HttpBadRequestException($validator->errors()); } $data = $validator->validated(); $payment_method = \Service_Customer_Paymentmethod::update($payment_method, $data); if (!$payment_method) { throw new HttpServerErrorException(); } $this->response($payment_method); }
/** * POST Edit action. * * @param int $customer_id Customer ID. * @param int $id Payment method ID. * * @return void */ public function post_edit($customer_id = null, $id = null) { $this->get_edit($customer_id, $id); $validator = Validation_Customer_Paymentmethod::update($this->get_gateway()); if (!$validator->run()) { Session::set_alert('error', __('form.error')); $this->view->errors = $validator->error(); return; } $customer = $this->get_customer($customer_id); $paymentmethod = $this->get_paymentmethod($id); $data = $validator->validated(); if (!Service_Customer_Paymentmethod::update($paymentmethod, $data)) { Session::set_alert('error', 'There was an error updating the customer payment method.'); return; } Session::set_alert('success', 'The customer payment method has been updated.'); Response::redirect($customer->link('paymentmethods')); }