mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-06-01 23:54:34 -04:00
fix stripe refunding & apply php-cs-fixer
This commit is contained in:
parent
4368dc7272
commit
b373a3df52
@ -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)
|
||||||
@ -395,8 +406,8 @@ class StripePaymentDriver extends BaseDriver
|
|||||||
* https://stripe.com/docs/api/payment_methods/detach
|
* https://stripe.com/docs/api/payment_methods/detach
|
||||||
*
|
*
|
||||||
* @param ClientGatewayToken $token
|
* @param ClientGatewayToken $token
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function detach(ClientGatewayToken $token)
|
public function detach(ClientGatewayToken $token)
|
||||||
{
|
{
|
||||||
$stripe = new StripeClient(
|
$stripe = new StripeClient(
|
||||||
|
@ -132,7 +132,7 @@ trait AppSetup
|
|||||||
|
|
||||||
if (is_null($position)) {
|
if (is_null($position)) {
|
||||||
$words_count > 1 ? $env[] = "{$property}=" . '"' . $value . '"' . "\n" : $env[] = "{$property}=" . $value . "\n";
|
$words_count > 1 ? $env[] = "{$property}=" . '"' . $value . '"' . "\n" : $env[] = "{$property}=" . $value . "\n";
|
||||||
} else if ($words_count > 1) {
|
} elseif ($words_count > 1) {
|
||||||
$env[$position] = "{$property}=" . '"' . $value . '"' . "\n"; // If value of variable is more than one word, surround with quotes.
|
$env[$position] = "{$property}=" . '"' . $value . '"' . "\n"; // If value of variable is more than one word, surround with quotes.
|
||||||
} else {
|
} else {
|
||||||
$env[$position] = "{$property}=" . $value . "\n"; // Just a normal variable update, with prexisting keys.
|
$env[$position] = "{$property}=" . $value . "\n"; // Just a normal variable update, with prexisting keys.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user