Fixes for WePay

This commit is contained in:
David Bomba 2022-10-05 11:21:55 +11:00
parent df0e9e0a73
commit f072b921c7
5 changed files with 29 additions and 14 deletions

View File

@ -40,7 +40,10 @@ class WePayController extends BaseController
$company = Company::where('company_key', $hash['company_key'])->firstOrFail(); $company = Company::where('company_key', $hash['company_key'])->firstOrFail();
$data['user_id'] = $user->id; $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); $wepay_driver = new WePayPaymentDriver(new CompanyGateway, null, null);

View File

@ -37,7 +37,7 @@ class AdjustProductInventory implements ShouldQueue
public array $old_invoice; 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->company = $company;
$this->invoice = $invoice; $this->invoice = $invoice;

View File

@ -27,7 +27,7 @@ class Setup
{ {
/* /*
'user_id', 'user_id',
'company', 'user_company',
*/ */
return render('gateways.wepay.signup.index', $data); return render('gateways.wepay.signup.index', $data);

View File

@ -33,17 +33,29 @@ class DeletePayment
public function run() public function run()
{ {
if ($this->payment->is_deleted) {
return $this->payment;
}
return $this->setStatus(Payment::STATUS_CANCELLED) //sets status of payment \DB::connection(config('database.default'))->transaction(function () {
->updateCreditables() //return the credits first
->adjustInvoices()
->updateClient() if ($this->payment->is_deleted) {
->deletePaymentables() return $this->payment;
->cleanupPayment() }
->save();
$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() private function cleanupPayment()

View File

@ -7,7 +7,7 @@
<img src="{{ asset('images/wepay.svg') }}" alt="We Pay"> <img src="{{ asset('images/wepay.svg') }}" alt="We Pay">
</div> </div>
@livewire('wepay-signup', ['user_id' => $user_id, 'company' => $company]) @livewire('wepay-signup', ['user_id' => $user_id, 'company' => $user_company])
</div> </div>
@endsection @endsection