mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-06-02 03:14:35 -04:00
Merge pull request #4398 from beganovich/v5-stripe-issue-with-refunding
(v5) Fix issues with Stripe refunding
This commit is contained in:
commit
686a98eec4
@ -116,9 +116,10 @@ class CreditCard
|
|||||||
'payment_method' => $this->stripe->payment_hash->data->server_response->payment_method,
|
'payment_method' => $this->stripe->payment_hash->data->server_response->payment_method,
|
||||||
'payment_type' => PaymentType::parseCardType(strtolower($stripe_method->card->brand)),
|
'payment_type' => PaymentType::parseCardType(strtolower($stripe_method->card->brand)),
|
||||||
'amount' => $this->stripe->convertFromStripeAmount($this->stripe->payment_hash->data->server_response->amount, $this->stripe->client->currency()->precision),
|
'amount' => $this->stripe->convertFromStripeAmount($this->stripe->payment_hash->data->server_response->amount, $this->stripe->client->currency()->precision),
|
||||||
'transaction_reference' => $this->stripe->payment_hash->data->server_response->id,
|
'transaction_reference' => optional($this->stripe->payment_hash->data->payment_intent->charges->data[0])->id,
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
$this->stripe->payment_hash->data = array_merge((array) $this->stripe->payment_hash->data, ['amount' => $data['amount']]);
|
$this->stripe->payment_hash->data = array_merge((array) $this->stripe->payment_hash->data, ['amount' => $data['amount']]);
|
||||||
$this->stripe->payment_hash->save();
|
$this->stripe->payment_hash->save();
|
||||||
|
|
||||||
|
@ -279,7 +279,7 @@ class StripePaymentDriver extends BaseDriver
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!$customer) {
|
if (!$customer) {
|
||||||
throw new Exception('Unable to create gateway customer');
|
throw new \Exception('Unable to create gateway customer');
|
||||||
}
|
}
|
||||||
|
|
||||||
return $customer;
|
return $customer;
|
||||||
@ -289,17 +289,16 @@ class StripePaymentDriver extends BaseDriver
|
|||||||
{
|
{
|
||||||
$this->init();
|
$this->init();
|
||||||
|
|
||||||
|
/** Response from Stripe SDK/API. */
|
||||||
|
$response = null;
|
||||||
|
|
||||||
|
try {
|
||||||
$response = $this->stripe
|
$response = $this->stripe
|
||||||
->refunds
|
->refunds
|
||||||
->create(['charge' => $payment->transaction_reference, 'amount' => $amount]);
|
->create(['charge' => $payment->transaction_reference, 'amount' => $this->convertToStripeAmount($amount, $this->client->currency()->precision)]);
|
||||||
|
|
||||||
// $response = $this->gateway
|
|
||||||
// ->refund(['transactionReference' => $payment->transaction_reference, 'amount' => $amount, 'currency' => $payment->client->getCurrencyCode()])
|
|
||||||
// ->send();
|
|
||||||
|
|
||||||
if ($response->status == $response::STATUS_SUCCEEDED) {
|
if ($response->status == $response::STATUS_SUCCEEDED) {
|
||||||
SystemLogger::dispatch(['server_response' => $response, 'data' => request()->all(),
|
SystemLogger::dispatch(['server_response' => $response, 'data' => request()->all(),], SystemLog::CATEGORY_GATEWAY_RESPONSE, SystemLog::EVENT_GATEWAY_SUCCESS, SystemLog::TYPE_STRIPE, $this->client);
|
||||||
], SystemLog::CATEGORY_GATEWAY_RESPONSE, SystemLog::EVENT_GATEWAY_SUCCESS, SystemLog::TYPE_STRIPE, $this->client);
|
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'transaction_reference' => $response->charge,
|
'transaction_reference' => $response->charge,
|
||||||
@ -310,8 +309,7 @@ class StripePaymentDriver extends BaseDriver
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
SystemLogger::dispatch(['server_response' => $response, 'data' => request()->all(),
|
SystemLogger::dispatch(['server_response' => $response, 'data' => request()->all(),], SystemLog::CATEGORY_GATEWAY_RESPONSE, SystemLog::EVENT_GATEWAY_FAILURE, SystemLog::TYPE_STRIPE, $this->client);
|
||||||
], SystemLog::CATEGORY_GATEWAY_RESPONSE, SystemLog::EVENT_GATEWAY_FAILURE, SystemLog::TYPE_STRIPE, $this->client);
|
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'transaction_reference' => null,
|
'transaction_reference' => null,
|
||||||
@ -320,6 +318,19 @@ class StripePaymentDriver extends BaseDriver
|
|||||||
'description' => $response->failure_reason,
|
'description' => $response->failure_reason,
|
||||||
'code' => 422,
|
'code' => 422,
|
||||||
];
|
];
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
SystemLogger::dispatch(['server_response' => $response, 'data' => request()->all(),], SystemLog::CATEGORY_GATEWAY_RESPONSE, SystemLog::EVENT_GATEWAY_FAILURE, SystemLog::TYPE_STRIPE, $this->client);
|
||||||
|
|
||||||
|
info($e->getMessage());
|
||||||
|
|
||||||
|
return [
|
||||||
|
'transaction_reference' => null,
|
||||||
|
'transaction_response' => json_encode($response),
|
||||||
|
'success' => false,
|
||||||
|
'description' => $e->getMessage(),
|
||||||
|
'code' => 422,
|
||||||
|
];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function verificationView(ClientGatewayToken $payment_method)
|
public function verificationView(ClientGatewayToken $payment_method)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user