Skip to content

Commit

Permalink
return success (closes $78)
Browse files Browse the repository at this point in the history
  • Loading branch information
edalzell committed Apr 9, 2020
1 parent dbbe3ed commit 07034c4
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions Charge/Traits/HasCustomers.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,7 @@ public function patchCustomer($id)
$customer->invoice_settings->default_payment_method = PaymentMethod::retrieve(request('payment_method'))->attach(['customer' => $id]);
$customer->save();

$redirect = request('redirect', false);

return $redirect ? redirect($redirect) : back();
return $this->updateSuccess($customer);
} catch (ApiErrorException $e) {
$error = $e->getError();

Expand Down Expand Up @@ -87,4 +85,24 @@ private function getCustomerId($email)

return Arr::get($yaml, 'customer_id');
}

/**
* @return Response|RedirectResponse
*/
private function updateSuccess(Customer $customer)
{
if (request()->ajax()) {
return response([
'status' => 'success',
'details' => $customer->toArray(),
]);
}

$this->flash->put('success', true);
$this->flash->put('details', $customer->toArray());

$redirect = request('redirect', false);

return $redirect ? redirect($redirect) : back();
}
}

0 comments on commit 07034c4

Please sign in to comment.