diff --git a/azbankgateways/banks/bmi.py b/azbankgateways/banks/bmi.py index aa1c524..f0a1d82 100644 --- a/azbankgateways/banks/bmi.py +++ b/azbankgateways/banks/bmi.py @@ -4,7 +4,7 @@ import requests from Crypto.Cipher import DES3 -from django.conf import settings + from azbankgateways.banks import BaseBank from azbankgateways.exceptions import BankGatewayConnectionError, SettingDoesNotExist from azbankgateways.exceptions.exceptions import ( @@ -23,7 +23,10 @@ class BMI(BaseBank): def __init__(self, **kwargs): super(BMI, 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 BMI gateway") + raise SettingDoesNotExist( + "SECURE_REFERRER_POLICY is not set to 'strict-origin-when-cross-origin'" + " in django setting, it's mandatory for BMI gateway" + ) self.set_gateway_currency(CurrencyEnum.IRR) self._token_api_url = "https://sadad.shaparak.ir/vpg/api/v0/Request/PaymentRequest" @@ -105,7 +108,8 @@ def verify(self, transaction_code): if str(response_json["ResCode"]) == "0": self._set_payment_status(PaymentStatus.COMPLETE) extra_information = ( - f"RetrivalRefNo={response_json['RetrivalRefNo']},SystemTraceNo={response_json['SystemTraceNo']}" + f"RetrivalRefNo={response_json['RetrivalRefNo']}" + ",SystemTraceNo={response_json['SystemTraceNo']}" ) self._bank.extra_information = extra_information self._bank.save() @@ -116,10 +120,13 @@ def verify(self, transaction_code): def prepare_verify_from_gateway(self): super(BMI, self).prepare_verify_from_gateway() request = self.get_request() - for method in ["POST", "GET", "data", "PUT"]: - token = getattr(request, method, {}).get("token", None) - if token: + method_data = getattr(request, "POST", {}) + token = None + for key, value in method_data.items(): + if key.lower() == "token": + token = value break + if not token: raise BankGatewayStateInvalid self._set_reference_number(token)