diff --git a/README.md b/README.md index 360013b..95e652a 100644 --- a/README.md +++ b/README.md @@ -287,9 +287,9 @@ def go_to_gateway_view(request): return render(request, "redirect_to_bank.html") ``` -

تنظیم SECURE_REFERRER_POLICY برای درگاه بانک ملی

+

تنظیم SECURE_REFERRER_POLICY برای درگاه بانک ملی و سامان

-برای استفاده از درگاه بانک ملی تنظیم SECURE_REFERRER_POLICY در setting جنگو به صورت زیر الزامیست +برای استفاده از درگاه بانک ملی و سامان تنظیم SECURE_REFERRER_POLICY در setting جنگو به صورت زیر الزامیست

```python diff --git a/azbankgateways/banks/sep.py b/azbankgateways/banks/sep.py index 7b5d9fd..e09a9a1 100644 --- a/azbankgateways/banks/sep.py +++ b/azbankgateways/banks/sep.py @@ -16,6 +16,12 @@ class SEP(BaseBank): def __init__(self, **kwargs): super(SEP, self).__init__(**kwargs) + if not self._is_strict_origin_policy_enabled(): + raise SettingDoesNotExist( + "SECURE_REFERRER_POLICY is not set to 'strict-origin-when-cross-origin' in django setting," + " it's mandatory for Saman gateway" + ) + self.set_gateway_currency(CurrencyEnum.IRR) self._token_api_url = "https://sep.shaparak.ir/MobilePG/MobilePayment" self._payment_url = "https://sep.shaparak.ir/OnlinePG/OnlinePG" @@ -80,15 +86,15 @@ def _get_gateway_payment_parameter(self): def prepare_verify_from_gateway(self): super(SEP, self).prepare_verify_from_gateway() request = self.get_request() - tracking_code = request.GET.get("ResNum", None) - token = request.GET.get("Token", None) + tracking_code = request.GET.get("ResNum") + token = request.GET.get("Token") self._set_tracking_code(tracking_code) self._set_bank_record() - ref_num = request.GET.get("RefNum", None) + ref_num = request.GET.get("RefNum") if request.GET.get("State", "NOK") == "OK" and ref_num: self._set_reference_number(ref_num) self._bank.reference_number = ref_num - extra_information = f"TRACENO={request.GET.get('TRACENO', None)}, RefNum={ref_num}, Token={token}" + extra_information = f"TRACENO={request.GET.get('TRACENO')}, RefNum={ref_num}, Token={token}" self._bank.extra_information = extra_information self._bank.save()