Skip to content

Commit

Permalink
Merge pull request #113 from birddevelper/fix/saman-referrer
Browse files Browse the repository at this point in the history
Fix/saman referrer
  • Loading branch information
ali-zahedi authored Aug 2, 2024
2 parents 416d9af + 5407753 commit a4f648c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -287,9 +287,9 @@ def go_to_gateway_view(request):
return render(request, "redirect_to_bank.html")
```

<h3 dir="rtl"> تنظیم SECURE_REFERRER_POLICY برای درگاه بانک ملی </h3>
<h3 dir="rtl"> تنظیم SECURE_REFERRER_POLICY برای درگاه بانک ملی و سامان </h3>
<p dir="rtl">
برای استفاده از درگاه بانک ملی تنظیم SECURE_REFERRER_POLICY در setting جنگو به صورت زیر الزامیست
برای استفاده از درگاه بانک ملی و سامان تنظیم SECURE_REFERRER_POLICY در setting جنگو به صورت زیر الزامیست
</p>

```python
Expand Down
14 changes: 10 additions & 4 deletions azbankgateways/banks/sep.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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()

Expand Down

0 comments on commit a4f648c

Please sign in to comment.