1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-05 18:52:44 +01:00

Store 'amount' in payment hash (Stripe/CC)

This commit is contained in:
Benjamin Beganović 2020-11-16 13:37:13 +01:00
parent 1ab8d1322b
commit 5457838c4d

View File

@ -120,6 +120,16 @@ 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);
$data = [
'payment_method' => $this->stripe->payment_hash->data->server_response->payment_method,
'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),
'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) { if ($this->stripe->payment_hash->data->store_card) {
$customer = $this->stripe->findOrCreateCustomer(); $customer = $this->stripe->findOrCreateCustomer();
@ -128,13 +138,6 @@ class CreditCard
$this->storePaymentMethod($stripe_method, $this->stripe->payment_hash->data->payment_method_id, $customer); $this->storePaymentMethod($stripe_method, $this->stripe->payment_hash->data->payment_method_id, $customer);
} }
$data = [
'payment_method' => $this->stripe->payment_hash->data->server_response->payment_method,
'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),
'transaction_reference' => $this->stripe->payment_hash->data->server_response->id,
];
$payment = $this->stripe->createPayment($data, \App\Models\Payment::STATUS_COMPLETED); $payment = $this->stripe->createPayment($data, \App\Models\Payment::STATUS_COMPLETED);
SystemLogger::dispatch( SystemLogger::dispatch(