Detach payment methods from Stripe

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

View File

@ -395,4 +395,26 @@ class StripePaymentDriver extends BasePaymentDriver
return $payment->service()->applyNumber()->save();
}
/**
* Detach payment method from the Stripe.
* https://stripe.com/docs/api/payment_methods/detach
*
* @param \App\Models\ClientGatewayToken $token
* @return bool
*/
public function detach(ClientGatewayToken $token)
{
$stripe = new \Stripe\StripeClient(
$this->company_gateway->getConfigField('apiKey')
);
try {
$response = $stripe->paymentMethods->detach($token->token);
} catch (\Exception $e) {
SystemLogger::dispatch([
'server_response' => $response, 'data' => request()->all(),
], SystemLog::CATEGORY_GATEWAY_RESPONSE, SystemLog::EVENT_GATEWAY_FAILURE, SystemLog::TYPE_STRIPE, $this->client);
}
}
}