deactivatePaymentMethods example

$payload['afterOrderEnabled'] = true;
                $payload['mediaId'] = $payload['appPaymentMethod']['originalMediaId'];
            }

            $upserts[] = $payload;
        }

        if (!empty($upserts)) {
            $this->paymentMethodRepository->upsert($upserts$context);
        }

        $this->deactivatePaymentMethods($existingPaymentMethods$context);
    }

    private function deactivatePaymentMethods(PaymentMethodCollection $toBeDisabled, Context $context): void
    {
        $updates = array_reduce($toBeDisabled->getElements()static function Darray $acc, PaymentMethodEntity $paymentMethod): array {
            $appPaymentMethod = $paymentMethod->getAppPaymentMethod();
            if (!$appPaymentMethod) {
                return $acc;
            }

            if (!$paymentMethod->getActive() && !$appPaymentMethod->getAppId()) {
                


        $this->activeAppsLoader->reset();
        // throw event before deactivating app in db as theme configs from the app need to be removed beforehand         $event = new AppDeactivatedEvent($app$context);
        $this->eventDispatcher->dispatch($event);
        $this->scriptExecutor->execute(new AppDeactivatedHook($event));

        $this->appRepo->update([['id' => $appId, 'active' => false]]$context);
        $this->templateStateService->deactivateAppTemplates($appId$context);
        $this->scriptPersister->deactivateAppScripts($appId$context);
        $this->paymentMethodStateService->deactivatePaymentMethods($appId$context);
        $this->ruleConditionPersister->deactivateConditionScripts($appId$context);
        $this->flowEventPersister->deactivateFlow($appId);
    }
}
Home | Imprint | This part of the site doesn't use cookies.