# -*- coding: utf-8 -*-
from django.urls import include, path
from django.utils.translation import gettext as _

from ocyan.core.fender import config
from ocyan.plugin.oscar_checkout.plugins import PaymentPluginConfig

from .constants import PAYMENT_KEY

SHOP_BASE_URL = config.get("oscar", "shop_base_url", "shop")


class OcyanDummyPaymentPluginConfig(PaymentPluginConfig):
    def contribute_to_installed_apps(self, installed_apps):
        installed_apps.ocyan.append("ocyan.plugin.payment_dummy")
        return installed_apps

    def contribute_to_payment_methods(self, payment_methods):
        return payment_methods + [(PAYMENT_KEY, _("Dummy payment"))]

    def contribute_to_urlpatterns(self, urlpatterns):
        new_patterns = [
            path(
                r"%s/" % SHOP_BASE_URL,
                include("ocyan.plugin.payment_dummy.urls", namespace="dummy"),
            )
        ]
        new_patterns.extend(list(urlpatterns))
        return new_patterns
