mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-06-01 02:54:36 -04:00
Merge pull request #4311 from beganovich/v5-stripe-failure
(v5) Fix bug with Stripe saving credit card
This commit is contained in:
commit
b886ceac4d
@ -17,6 +17,7 @@ use App\Models\GatewayType;
|
|||||||
use App\Models\Invoice;
|
use App\Models\Invoice;
|
||||||
use App\Models\Payment;
|
use App\Models\Payment;
|
||||||
use App\Models\PaymentHash;
|
use App\Models\PaymentHash;
|
||||||
|
use App\Models\SystemLog;
|
||||||
use App\PaymentDrivers\Authorize\AuthorizeCreditCard;
|
use App\PaymentDrivers\Authorize\AuthorizeCreditCard;
|
||||||
use App\PaymentDrivers\Authorize\AuthorizePaymentMethod;
|
use App\PaymentDrivers\Authorize\AuthorizePaymentMethod;
|
||||||
use App\PaymentDrivers\Authorize\ChargePaymentProfile;
|
use App\PaymentDrivers\Authorize\ChargePaymentProfile;
|
||||||
@ -43,6 +44,8 @@ class AuthorizePaymentDriver extends BaseDriver
|
|||||||
GatewayType::CREDIT_CARD => AuthorizeCreditCard::class,
|
GatewayType::CREDIT_CARD => AuthorizeCreditCard::class,
|
||||||
];
|
];
|
||||||
|
|
||||||
|
const SYSTEM_LOG_TYPE = SystemLog::TYPE_AUTHORIZE;
|
||||||
|
|
||||||
public function setPaymentMethod($payment_method_id)
|
public function setPaymentMethod($payment_method_id)
|
||||||
{
|
{
|
||||||
$class = self::$methods[$payment_method_id];
|
$class = self::$methods[$payment_method_id];
|
||||||
|
@ -308,11 +308,13 @@ class BaseDriver extends AbstractPaymentDriver
|
|||||||
$error = $e->getBody();
|
$error = $e->getBody();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$amount = optional($this->payment_hash->data)->value ?? optional($this->payment_hash->data)->amount;
|
||||||
|
|
||||||
PaymentFailureMailer::dispatch(
|
PaymentFailureMailer::dispatch(
|
||||||
$gateway->client,
|
$gateway->client,
|
||||||
$error,
|
$error,
|
||||||
$gateway->client->company,
|
$gateway->client->company,
|
||||||
$this->payment_hash->data->value
|
$amount
|
||||||
);
|
);
|
||||||
|
|
||||||
SystemLogger::dispatch(
|
SystemLogger::dispatch(
|
||||||
|
@ -84,6 +84,8 @@ class PayPalExpressPaymentDriver extends BasePaymentDriver
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const SYSTEM_LOG_TYPE = SystemLog::TYPE_PAYPAL;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Processes the payment with this gateway.
|
* Processes the payment with this gateway.
|
||||||
*
|
*
|
||||||
|
@ -120,14 +120,6 @@ class CreditCard
|
|||||||
{
|
{
|
||||||
$stripe_method = $this->stripe->getStripePaymentMethod($this->stripe->payment_hash->data->server_response->payment_method);
|
$stripe_method = $this->stripe->getStripePaymentMethod($this->stripe->payment_hash->data->server_response->payment_method);
|
||||||
|
|
||||||
if ($this->stripe->payment_hash->data->store_card) {
|
|
||||||
$customer = $this->stripe->findOrCreateCustomer();
|
|
||||||
|
|
||||||
$this->stripe->attach($this->stripe->payment_hash->data->server_response->payment_method, $customer);
|
|
||||||
|
|
||||||
$this->storePaymentMethod($stripe_method, $this->stripe->payment_hash->data->payment_method_id, $customer);
|
|
||||||
}
|
|
||||||
|
|
||||||
$data = [
|
$data = [
|
||||||
'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)),
|
||||||
@ -135,6 +127,20 @@ class CreditCard
|
|||||||
'transaction_reference' => $this->stripe->payment_hash->data->server_response->id,
|
'transaction_reference' => $this->stripe->payment_hash->data->server_response->id,
|
||||||
];
|
];
|
||||||
|
|
||||||
|
$this->stripe->payment_hash->data = array_merge((array) $this->stripe->payment_hash->data, ['amount' => $data['amount']]);
|
||||||
|
$this->stripe->payment_hash->save();
|
||||||
|
|
||||||
|
if ($this->stripe->payment_hash->data->store_card) {
|
||||||
|
$customer = new \stdClass;
|
||||||
|
$customer->id = $this->stripe->payment_hash->data->customer;
|
||||||
|
|
||||||
|
$this->stripe->attach($this->stripe->payment_hash->data->server_response->payment_method, $customer);
|
||||||
|
|
||||||
|
$stripe_method = $this->stripe->getStripePaymentMethod($this->stripe->payment_hash->data->server_response->payment_method);
|
||||||
|
|
||||||
|
$this->storePaymentMethod($stripe_method, $this->stripe->payment_hash->data->payment_method_id, $customer);
|
||||||
|
}
|
||||||
|
|
||||||
$payment = $this->stripe->createPayment($data, \App\Models\Payment::STATUS_COMPLETED);
|
$payment = $this->stripe->createPayment($data, \App\Models\Payment::STATUS_COMPLETED);
|
||||||
|
|
||||||
SystemLogger::dispatch(
|
SystemLogger::dispatch(
|
||||||
|
@ -68,6 +68,8 @@ class StripePaymentDriver extends BaseDriver
|
|||||||
GatewayType::SEPA => 1, // TODO
|
GatewayType::SEPA => 1, // TODO
|
||||||
];
|
];
|
||||||
|
|
||||||
|
const SYSTEM_LOG_TYPE = SystemLog::TYPE_STRIPE;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initializes the Stripe API.
|
* Initializes the Stripe API.
|
||||||
* @return void
|
* @return void
|
||||||
|
Loading…
x
Reference in New Issue
Block a user