mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-09-20 16:31:33 +02:00
Refactor createPayment to accept custom status
This commit is contained in:
parent
5a3ec6342e
commit
b38ff39771
@ -259,12 +259,12 @@ class BasePaymentDriver
|
||||
->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->client_id = $this->client->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->date = Carbon::now();
|
||||
|
||||
|
@ -258,9 +258,9 @@ class PayPalExpressPaymentDriver extends BasePaymentDriver
|
||||
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_id = $client_contact ? $client_contact->id : null;
|
||||
|
@ -18,6 +18,7 @@ use App\Jobs\Util\SystemLogger;
|
||||
use App\Models\ClientGatewayToken;
|
||||
use App\Models\GatewayType;
|
||||
use App\Models\Invoice;
|
||||
use App\Models\Payment;
|
||||
use App\Models\PaymentType;
|
||||
use App\Models\SystemLog;
|
||||
use App\PaymentDrivers\StripePaymentDriver;
|
||||
@ -176,7 +177,7 @@ class CreditCard
|
||||
'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']);
|
||||
|
||||
|
@ -208,9 +208,9 @@ class StripePaymentDriver extends BasePaymentDriver
|
||||
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_id = $client_contact ? $client_contact->id : null;
|
||||
|
Loading…
Reference in New Issue
Block a user