1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 13:12:50 +01:00

Refactor createPayment to accept custom status

This commit is contained in:
Benjamin Beganović 2020-06-09 13:07:18 +02:00
parent 5a3ec6342e
commit b38ff39771
4 changed files with 8 additions and 7 deletions

View File

@ -259,12 +259,12 @@ class BasePaymentDriver
->send(); ->send();
} }
public function createPayment($data): Payment public function createPayment($data, $status = Payment::STATUS_COMPLETED): 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;
$payment->company_gateway_id = $this->company_gateway->id; $payment->company_gateway_id = $this->company_gateway->id;
$payment->status_id = Payment::STATUS_COMPLETED; $payment->status_id = $status;
$payment->currency_id = $this->client->getSetting('currency_id'); $payment->currency_id = $this->client->getSetting('currency_id');
$payment->date = Carbon::now(); $payment->date = Carbon::now();

View File

@ -258,9 +258,9 @@ class PayPalExpressPaymentDriver extends BasePaymentDriver
return $items; return $items;
} }
public function createPayment($data): Payment public function createPayment($data, $status = Payment::STATUS_COMPLETED): Payment
{ {
$payment = parent::createPayment($data); $payment = parent::createPayment($data, $status);
$client_contact = $this->getContact(); $client_contact = $this->getContact();
$client_contact_id = $client_contact ? $client_contact->id : null; $client_contact_id = $client_contact ? $client_contact->id : null;

View File

@ -18,6 +18,7 @@ use App\Jobs\Util\SystemLogger;
use App\Models\ClientGatewayToken; use App\Models\ClientGatewayToken;
use App\Models\GatewayType; use App\Models\GatewayType;
use App\Models\Invoice; use App\Models\Invoice;
use App\Models\Payment;
use App\Models\PaymentType; use App\Models\PaymentType;
use App\Models\SystemLog; use App\Models\SystemLog;
use App\PaymentDrivers\StripePaymentDriver; use App\PaymentDrivers\StripePaymentDriver;
@ -176,7 +177,7 @@ class CreditCard
'amount' => $state['server_response']->amount, 'amount' => $state['server_response']->amount,
]; ];
$payment = $this->stripe->createPayment($data); $payment = $this->stripe->createPayment($data, $status = Payment::STATUS_COMPLETED);
$this->stripe->attachInvoices($payment, $state['hashed_ids']); $this->stripe->attachInvoices($payment, $state['hashed_ids']);

View File

@ -208,9 +208,9 @@ class StripePaymentDriver extends BasePaymentDriver
return $this->payment_method->paymentResponse($request); return $this->payment_method->paymentResponse($request);
} }
public function createPayment($data) :Payment public function createPayment($data, $status = Payment::STATUS_COMPLETED) :Payment
{ {
$payment = parent::createPayment($data); $payment = parent::createPayment($data, $status);
$client_contact = $this->getContact(); $client_contact = $this->getContact();
$client_contact_id = $client_contact ? $client_contact->id : null; $client_contact_id = $client_contact ? $client_contact->id : null;