diff --git a/app/GraphQL/Souk/Mutations/Orders/PaymentManagementMutation.php b/app/GraphQL/Souk/Mutations/Orders/PaymentManagementMutation.php index 3b5a90e1e..f5244d0c9 100644 --- a/app/GraphQL/Souk/Mutations/Orders/PaymentManagementMutation.php +++ b/app/GraphQL/Souk/Mutations/Orders/PaymentManagementMutation.php @@ -6,10 +6,12 @@ use Baka\Support\Str; use Kanvas\Apps\Models\Apps; +use Kanvas\Companies\Models\Companies; use Kanvas\Companies\Models\CompaniesBranches; use Kanvas\Connectors\Stripe\Enums\ConfigurationEnum; use Kanvas\Exceptions\ValidationException; use Kanvas\Souk\Orders\Models\Order; +use Kanvas\Users\Models\UserCompanyApps; use Stripe\PaymentIntent; use Stripe\Stripe; @@ -36,6 +38,12 @@ public function generatePaymentIntent(mixed $root, array $request): array $company = $user->getCurrentCompany(); $orderId = $request['id']; + if ($app->get('USE_B2B_COMPANY_GROUP')) { + if (UserCompanyApps::where('companies_id', $app->get('B2B_GLOBAL_COMPANY'))->where('apps_id', $app->getId())->first()) { + $company = Companies::getById($app->get('B2B_GLOBAL_COMPANY')); + } + } + $order = Order::getByIdFromCompanyApp($orderId, $company, $app); if ($order->isFulfilled()) {