public function removePaymentMethod($publicId)
{
if (!($contact = $this->getContact())) {
return $this->returnError();
}
$client = $contact->client;
$account = $contact->account;
$paymentDriver = $account->paymentDriver(false, GATEWAY_TYPE_TOKEN);
$paymentMethod = PaymentMethod::clientId($client->id)->wherePublicId($publicId)->firstOrFail();
try {
$paymentDriver->removePaymentMethod($paymentMethod);
Session::flash('message', trans('texts.payment_method_removed'));
} catch (Exception $exception) {
Session::flash('error', $exception->getMessage());
}
return redirect()->to($client->account->enable_client_portal_dashboard ? '/client/dashboard' : '/client/payment_methods/');
}