diff --git a/app/Http/Controllers/WePayController.php b/app/Http/Controllers/WePayController.php index e44103c125..aca370b4ec 100644 --- a/app/Http/Controllers/WePayController.php +++ b/app/Http/Controllers/WePayController.php @@ -40,7 +40,10 @@ class WePayController extends BaseController $company = Company::where('company_key', $hash['company_key'])->firstOrFail(); $data['user_id'] = $user->id; - $data['company'] = $company; + $data['user_company'] = $company; + + // $data['company_key'] = $company->company_key; + // $data['db'] = $company->db; $wepay_driver = new WePayPaymentDriver(new CompanyGateway, null, null); diff --git a/app/Jobs/Inventory/AdjustProductInventory.php b/app/Jobs/Inventory/AdjustProductInventory.php index 72b07d70d0..49cba52cec 100644 --- a/app/Jobs/Inventory/AdjustProductInventory.php +++ b/app/Jobs/Inventory/AdjustProductInventory.php @@ -37,7 +37,7 @@ class AdjustProductInventory implements ShouldQueue public array $old_invoice; - public function __construct(Company $company, Invoice $invoice, ?array $old_invoice = []) + public function __construct(Company $company, Invoice $invoice, $old_invoice = []) { $this->company = $company; $this->invoice = $invoice; diff --git a/app/PaymentDrivers/WePay/Setup.php b/app/PaymentDrivers/WePay/Setup.php index ade6c25676..d5e6156219 100644 --- a/app/PaymentDrivers/WePay/Setup.php +++ b/app/PaymentDrivers/WePay/Setup.php @@ -27,7 +27,7 @@ class Setup { /* 'user_id', - 'company', + 'user_company', */ return render('gateways.wepay.signup.index', $data); diff --git a/app/Services/Payment/DeletePayment.php b/app/Services/Payment/DeletePayment.php index a04aa04fe9..6454919238 100644 --- a/app/Services/Payment/DeletePayment.php +++ b/app/Services/Payment/DeletePayment.php @@ -33,17 +33,29 @@ class DeletePayment public function run() { - if ($this->payment->is_deleted) { - return $this->payment; - } - return $this->setStatus(Payment::STATUS_CANCELLED) //sets status of payment - ->updateCreditables() //return the credits first - ->adjustInvoices() - ->updateClient() - ->deletePaymentables() - ->cleanupPayment() - ->save(); + \DB::connection(config('database.default'))->transaction(function () { + + + if ($this->payment->is_deleted) { + return $this->payment; + } + + $this->payment = Payment::withTrashed()->where('id', $this->payment->id)->lockForUpdate()->first(); + + $this->setStatus(Payment::STATUS_CANCELLED) //sets status of payment + ->updateCreditables() //return the credits first + ->adjustInvoices() + ->updateClient() + ->deletePaymentables() + ->cleanupPayment() + ->save(); + + + }, 2); + + return $this->payment; + } private function cleanupPayment() diff --git a/resources/views/portal/ninja2020/gateways/wepay/signup/index.blade.php b/resources/views/portal/ninja2020/gateways/wepay/signup/index.blade.php index f898d9aaa6..3f0fe30775 100644 --- a/resources/views/portal/ninja2020/gateways/wepay/signup/index.blade.php +++ b/resources/views/portal/ninja2020/gateways/wepay/signup/index.blade.php @@ -7,7 +7,7 @@ We Pay - @livewire('wepay-signup', ['user_id' => $user_id, 'company' => $company]) + @livewire('wepay-signup', ['user_id' => $user_id, 'company' => $user_company]) @endsection