Update PaymentMethodController:destroy() with generic gateway detach

This commit is contained in:
Benjamin Beganović 2020-09-18 09:48:39 +02:00
parent e36ff351de
commit 020005d20d

View File

@ -135,6 +135,13 @@ class PaymentMethodController extends Controller
*/
public function destroy(ClientGatewayToken $payment_method)
{
$gateway = $this->getClientGateway();
$gateway
->driver(auth()->user()->client)
->setPaymentMethod(request()->query('method'))
->detach($payment_method);
try {
event(new MethodDeleted($payment_method, auth('contact')->user()->company, Ninja::eventVars()));
$payment_method->delete();