mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-31 07:34:35 -04:00
Detach payment methods from Stripe
This commit is contained in:
parent
020005d20d
commit
71ca5d108c
@ -304,7 +304,7 @@ class StripePaymentDriver extends BasePaymentDriver
|
|||||||
$customer = \Stripe\Customer::create($data);
|
$customer = \Stripe\Customer::create($data);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! $customer) {
|
if (!$customer) {
|
||||||
throw new \Exception('Unable to create gateway customer');
|
throw new \Exception('Unable to create gateway customer');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -379,7 +379,7 @@ class StripePaymentDriver extends BasePaymentDriver
|
|||||||
* @param float $amount The amount of the payment
|
* @param float $amount The amount of the payment
|
||||||
* @return Payment The payment object
|
* @return Payment The payment object
|
||||||
*/
|
*/
|
||||||
public function createPaymentRecord($data, $amount) :?Payment
|
public function createPaymentRecord($data, $amount): ?Payment
|
||||||
{
|
{
|
||||||
$payment = PaymentFactory::create($this->client->company_id, $this->client->user_id);
|
$payment = PaymentFactory::create($this->client->company_id, $this->client->user_id);
|
||||||
$payment->client_id = $this->client->id;
|
$payment->client_id = $this->client->id;
|
||||||
@ -395,4 +395,26 @@ class StripePaymentDriver extends BasePaymentDriver
|
|||||||
|
|
||||||
return $payment->service()->applyNumber()->save();
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user