Minor fixes for deleting payment methods

This commit is contained in:
David Bomba 2021-08-07 15:08:29 +10:00
parent 4f99830ed0
commit 7057ca30d6

View File

@ -118,25 +118,24 @@ class PaymentMethodController extends Controller
*/
public function destroy(ClientGatewayToken $payment_method)
{
// $gateway = $this->getClientGateway();
if($payment_method->gateway()->exists()){
$payment_method->gateway
->driver(auth()->user()->client)
->setPaymentMethod(request()->query('method'))
->detach($payment_method);
}
try {
$payment_method->gateway
->driver(auth()->user()->client)
->setPaymentMethod(request()->query('method'))
->detach($payment_method);
event(new MethodDeleted($payment_method, auth('contact')->user()->company, Ninja::eventVars(auth('contact')->user()->id)));
$payment_method->delete();
} catch (Exception $e) {
event(new MethodDeleted($payment_method, auth('contact')->user()->company, Ninja::eventVars(auth('contact')->user()->id)));
$payment_method->delete();
nlog($e->getMessage());
return back();