def _validate_currency_and_exponent(request, invalid_fields): if request.currency is None or not re.search(get_currency_Reg_Ex(), request.currency): invalid_fields.append(Constants.getCurrencyName()) if request.currency != getEurCurrencyName() and request.exponent is None: invalid_fields.append(Constants.getExponentName())
def _validate_common_fields(request, invalid_fields): if request.order_id is None or not re.search(get_order_id_Reg_Ex(), request.order_id): invalid_fields.append(Constants.getOrderIdName()) if request.operator_id is None or not re.search(get_operator_id_Reg_Ex(), request.operator_id): invalid_fields.append(Constants.getOperatorIdName())
def getHtml(url_vpos, parameters_map): base_template = "<div><form id=\"myForm\"action=\"[VPOS_URL]\" method=\"POST\"><input name=\"PAGE\" type=\"hidden\" value=\"[PAGE_VALUE]\">[PARAMETERS]</form><script type=\"text/javascript\">function subForm() {document.getElementById('myForm').submit();}</script></div>" base_template = base_template.replace("[VPOS_URL]", url_vpos) if Constants.getTokenName() in parameters_map and parameters_map.get( Constants.getTokenName()) is not None: base_template = base_template.replace("[PAGE_VALUE]", "TOKEN") else: base_template = base_template.replace("[PAGE_VALUE]", "LAND") base_template = base_template.replace("[PARAMETERS]", _generateHtmlParams(parameters_map)) return base_template
def validate_threeDSAuthorization2_request(request): invalid_fields = [] if request.operator_id is None or not re.search(get_operator_id_Reg_Ex(), request.operator_id): invalid_fields.append(Constants.getOperatorIdName()) if request.three_DS_trans_id is None: invalid_fields.append(Constants.getThreeDSTransIdName()) if len(invalid_fields) > 0: raise VPOSException("Invalid or missing config params: " + str(invalid_fields))
def get_request_base_xml(self, operation, operation_Tag): requestDict = OrderedDict() requestDict[TagConstants.getReleaseTag()] = Constants.getRelease() requestDict[TagConstants.getRequestTag()] = "" requestDict[TagConstants.getDataTag()] = "" request = Utils.dict_to_xml(TagConstants.getBPWXmlRequestTag(), requestDict) # Request <Request> Utils.addChild(request.find(TagConstants.getRequestTag()), TagConstants.getOperationTag(), operation) Utils.addChild(request.find(TagConstants.getRequestTag()), TagConstants.getTimestampTag(), self._timestamp) mac = Utils.addChild(request.find(TagConstants.getRequestTag()), TagConstants.getMACTag(), None) # Data <Data> operation = Utils.addChild(request.find(TagConstants.getDataTag()), operation_Tag, None) # OrderStatus header = Utils.addChild(operation, TagConstants.getHeaderTag(), None) # Header Utils.addChild(header, TagConstants.getShopIDTag(), self._shop_id) Utils.addChild(header, TagConstants.getOperatorIDTag(), self._operator_id) Utils.addChild(header, TagConstants.getReqRefNumTag(), self._reqRefNum) return request
def validate_redirect_request(request): invalid_fields = [] if not isinstance(request, PaymentInfo): raise VPOSException("invalid request type") if request.amount is None or not re.search(get_amount_Reg_Ex(), request.amount): invalid_fields.append(Constants.getAmountName()) _validate_currency_and_exponent(request, invalid_fields) if request.order_id is None or not re.search(get_order_id_Reg_Ex(), request.order_id): invalid_fields.append(Constants.getOrderIdName()) if request.url_back is None: invalid_fields.append(Constants.getUrlBackName()) if request.url_done is None: invalid_fields.append(Constants.getUrlDoneName()) if request.url_ms is None: invalid_fields.append(Constants.getUrlMsName()) if request.accounting_mode is None or not re.search( get_accounting_mode_Reg_Ex(), request.accounting_mode): invalid_fields.append(Constants.getAccountingModeName()) if request.author_mode is None or not re.search(get_author_mode_Reg_Ex(), request.author_mode): invalid_fields.append(Constants.getAuthorModeName()) if len(invalid_fields) > 0: raise VPOSException("Invalid or missing config params: " + str(invalid_fields))
def validate_config(config): invalid_fields = [] if not isinstance(config, VPosConfig): raise VPOSException("invalid config object") if config.shop_id is None or not re.search(get_shop_id_Reg_Ex(), config.shop_id): invalid_fields.append(Constants.getShopIdName()) if config.api_key is None: invalid_fields.append(Constants.getApiKeyName()) if config.api_url is None: invalid_fields.append(Constants.getApiUrlName()) if config.redirect_key is None: invalid_fields.append(Constants.getRedirectKeyName()) if config.redirect_url is None: invalid_fields.append(Constants.getRedirectUrlName()) if config.proxy_scheme is not None and config.proxy_scheme is not 'http' and config.proxy_scheme is not 'https': invalid_fields.append(Constants.getProxySchemeName()) if config.algorithm is not None: if config.algorithm == 'HMAC_SHA_256': config.algorithm = hashlib.sha256 elif config.algorithm.equals == 'HMAC_SHA_512': config.algorithm = hashlib.sha512 else: invalid_fields.append(Constants.getAlgorithmName()) if config.algorithm is None: config.algorithm = hashlib.sha256 if len(invalid_fields) > 0: raise VPOSException("Invalid or missing config params: " + str(invalid_fields))
def validate_capture_request(capture_request): invalid_fields = [] if not isinstance(capture_request, CaptureRequest): raise VPOSException("invalid request type") _validate_common_fields(capture_request, invalid_fields) _validate_currency_and_exponent(capture_request, invalid_fields) if capture_request.transaction_id is None: invalid_fields.append(Constants.getTransactionIdName()) if capture_request.amount is None or not re.search(get_amount_Reg_Ex(), capture_request.amount): invalid_fields.append(Constants.getAmountName()) if len(invalid_fields) > 0: raise VPOSException("Invalid or missing config params: " + str(invalid_fields))
def validate_order_status_request(order_status_request): invalid_fields = [] _validate_common_fields(order_status_request, invalid_fields) if order_status_request.product_ref is not None and not re.search( get_product_ref_Reg_Ex(), order_status_request.product_ref): invalid_fields.append(Constants.getProductRefName()) if len(invalid_fields) > 0: raise VPOSException("Invalid or missing config params: " + str(invalid_fields))
def _string_for_mac(self): macString = str() macString = Constants.getOperationName() + "=" + str(self._operation) macString = Utils.appendField(macString, Constants.getTimestampName(), self._timestamp) macString = Utils.appendField(macString, Constants.getShopIdName(), self._shop_id) macString = Utils.appendField(macString, Constants.getOperatorIdName(), self._operator_id) macString = Utils.appendField(macString, Constants.getReqRefNumName(), self._reqRefNum) macString = Utils.appendField(macString, Constants.getOrderIdName(), self._order_id) macString = Utils.appendField(macString, Constants.getOptionsName(), self._options) macString = Utils.appendField(macString, Constants.getProductRefName(), self._product_ref) return macString
def _string_for_mac(self): macString = Constants.getOperationName() + "=" + str(self._operation) macString = Utils.appendField(macString, Constants.getTimestampName(), self._timestamp) macString = Utils.appendField(macString, Constants.getShopIdName(), self._shop_id) macString = Utils.appendField(macString, Constants.getOperatorIdName(), self._operator_id) macString = Utils.appendField(macString, Constants.getReqRefNumName(), self._reqRefNum) macString = Utils.appendField(macString, Constants.getThreeDSTransIdName(), self._three_DS_trans_id) macString = Utils.appendField(macString, Constants.getThreeDSMtdComplIndName(), self._three_DS_Mtd_compl_ind) return macString
def _validate_data_3DS(data_3DS, invalid_fields): if data_3DS is None or not isinstance(data_3DS, Data3DSJson): invalid_fields.append(Constants.getThreeDSDataName()) if data_3DS.browserAcceptHeader is None: invalid_fields.append("browserAcceptHeader") if data_3DS.browserIP is None: invalid_fields.append("browserIP") if data_3DS.browserJavaEnabled is None: invalid_fields.append("browserJavaEnabled") if data_3DS.browserLanguage is None: invalid_fields.append("browserLanguage") if data_3DS.browserColorDepth is None: invalid_fields.append("browserColorDepth") if data_3DS.browserScreenHeight is None: invalid_fields.append("browserScreenHeight") if data_3DS.browserScreenWidth is None: invalid_fields.append("browserScreenWidth") if data_3DS.browserTZ is None: invalid_fields.append("browserTz") if data_3DS.browserUserAgent is None: invalid_fields.append("browserUserAgent")
def _string_for_mac(self, apiKey): macString = Constants.getUrlMsName() + "=" + self._url_ms macString = Utils.appendField(macString, Constants.getUrlDoneName(), self._url_done) macString = Utils.appendField(macString, Constants.getOrderIdName(), self._order_id) macString = Utils.appendField(macString, Constants.getShopIdName(), self._shop_id) macString = Utils.appendField(macString, Constants.getAmountName(), self._amount) macString = Utils.appendField(macString, Constants.getCurrencyName(), self._currency) macString = Utils.appendField(macString, Constants.getExponentName(), self._exponent) macString = Utils.appendField(macString, Constants.getAccountingModeName(), self._accounting_mode) macString = Utils.appendField(macString, Constants.getAuthorModeName(), self._author_mode) macString = Utils.appendField(macString, Constants.getOptionsName(), self._options) if self._options is not None and "B" in self._options: macString = Utils.appendField(macString, Constants.getNameName(), self._name) macString = Utils.appendField(macString, Constants.getSurnameName(), self._surname) macString = Utils.appendField(macString, Constants.getTaxIdName(), self._tax_id) macString = Utils.appendField(macString, Constants.getLockCardName(), self._lock_card) if self._options is not None and "F" in self._options: macString = Utils.appendField(macString, Constants.getCommisName(), self._commis) if self._options is not None and ("O" in self._options or "V" in self._options): macString = Utils.appendField(macString, Constants.getOrdDescrName(), self._ord_descr) macString = Utils.appendField(macString, Constants.getVSIDName(), self._VSID) macString = Utils.appendField(macString, Constants.getOpDescrName(), self._op_descr) if self._options is not None and "D" in self._options: macString = Utils.appendField(macString, Constants.getRemainingDurationName(), self._remaining_duration) macString = Utils.appendField(macString, Constants.getUserIdName(), self._userId) macString = Utils.appendField(macString, Constants.getBBPostepayName(), self._bb_poste_pay) macString = Utils.appendField(macString, Constants.getBPCardsName(), self._bp_cards) if self._network is not None and "91" in self._network: macString = Utils.appendField(macString, Constants.getPhoneNumberName(), self._phone_number) macString = Utils.appendField(macString, Constants.getCausationName(), self._causation) macString = Utils.appendField(macString, Constants.getUserName(), self._user) macString = Utils.appendField(macString, Constants.getProductRefName(), self._product_ref) macString = Utils.appendField(macString, Constants.getAntiFraudName(), self._anti_fraud) if self._data_3DS_json is not None: macString = Utils.appendField( macString, Constants.get3DSJsonDataName(), AES.AES_encrypt(self._data_3DS_json, apiKey)) macString = Utils.appendField(macString, Constants.getTrecurrName(), self._t_recurr) macString = Utils.appendField(macString, Constants.getCrecurrName(), self._c_recurr) macString = Utils.appendField(macString, Constants.getInstallmentsNumberName(), self._installments_number) macString = Utils.appendField(macString, Constants.getTokenName(), self._token) macString = Utils.appendField(macString, Constants.getExpDateName(), self._exp_date) macString = Utils.appendField(macString, Constants.getNetworkName(), self._network) macString = Utils.appendField(macString, Constants.getIBANName(), self._iban) return macString
def getParametersMap(self, redirect_key, api_result_key, digest_mode): map = OrderedDict() map[Constants.getUrlMsName()] = self._url_ms map[Constants.getUrlDoneName()] = self._url_done map[Constants.getOrderIdName()] = self._order_id map[Constants.getShopIdName()] = self._shop_id map[Constants.getAmountName()] = self._amount map[Constants.getCurrencyName()] = self._currency map[Constants.getExponentName()] = self._exponent map[Constants.getAccountingModeName()] = self._accounting_mode map[Constants.getAuthorModeName()] = self._author_mode # NOT COMPULSORY FIELDS map[Constants.getOptionsName()] = self._options map[Constants.getNameName()] = self._name map[Constants.getSurnameName()] = self._surname map[Constants.getTaxIdName()] = self._tax_id map[Constants.getLockCardName()] = self._lock_card map[Constants.getCommisName()] = self._commis map[Constants.getOrdDescrName()] = self._ord_descr map[Constants.getVSIDName()] = self._VSID map[Constants.getOpDescrName()] = self._op_descr map[Constants.getRemainingDurationName()] = self._remaining_duration map[Constants.getUserIdName()] = self._userId map[Constants.getBBPostepayName()] = self._bb_poste_pay map[Constants.getBPCardsName()] = self._bp_cards map[Constants.getPhoneNumberName()] = self._phone_number map[Constants.getCausationName()] = self._causation map[Constants.getUserName()] = self._user map[Constants.getProductRefName()] = self._product_ref map[Constants.getAntiFraudName()] = self._anti_fraud if self._data_3DS_json is not None: map[Constants.get3DSJsonDataName()] = AES.AES_encrypt( self._data_3DS_json, api_result_key) map[Constants.getTrecurrName()] = self._t_recurr map[Constants.getCrecurrName()] = self._c_recurr map[Constants.getInstallmentsNumberName()] = self._installments_number map[Constants.getTokenName()] = self._token map[Constants.getExpDateName()] = self._exp_date map[Constants.getNetworkName()] = self._network map[Constants.getIBANName()] = self._iban map[Constants.getMacName()] = Encoder.get_mac( self._string_for_mac(api_result_key), redirect_key, digest_mode) map[Constants.getUrlBackName()] = self._url_back map[Constants.getLangName()] = self._lang map[Constants.getShopEmailName()] = self._shop_email map[Constants.getEmailName()] = self._email map[Constants.getNameCHName()] = self._name_ch map[Constants.getSurnameCHName()] = self._surname_ch return map
def _string_for_mac(self, api_result_key): macString = Constants.getOperationName() + "=" + str(self._operation) macString = Utils.appendField(macString, Constants.getTimestampName(), self._timestamp) macString = Utils.appendField(macString, Constants.getShopIdName(), self._shop_id) macString = Utils.appendField(macString, Constants.getOrderIdName(), self._order_id) macString = Utils.appendField(macString, Constants.getOperatorIdName(), self._operator_id) macString = Utils.appendField(macString, Constants.getReqRefNumName(), self._reqRefNum) macString = Utils.appendField(macString, Constants.getPanName(), self._pan) macString = Utils.appendField(macString, Constants.getCvv2Name(), self._cvv2) macString = Utils.appendField(macString, Constants.getExpDateName(), self._exp_date) macString = Utils.appendField(macString, Constants.getAmountName(), self._amount) macString = Utils.appendField(macString, Constants.getCurrencyName(), self._currency) macString = Utils.appendField(macString, Constants.getExponentName(), self._exponent) macString = Utils.appendField(macString, Constants.getAccountingModeName(), self._accounting_mode) macString = Utils.appendField(macString, Constants.getNetworkName(), self._network) macString = Utils.appendField(macString, Constants.getEmailChName(), self._email_ch) macString = Utils.appendField(macString, Constants.getUserIdName(), self._user_id) macString = Utils.appendField(macString, Constants.getAcquirerName(), self._acquirer) macString = Utils.appendField(macString, Constants.getIpAddressName(), self._ip_address) macString = Utils.appendField(macString, Constants.getOpDescrName(), self._op_descr) macString = Utils.appendField(macString, Constants.getUsrAuthFlagName(), self._usr_auth_flag) macString = Utils.appendField(macString, Constants.getOptionsName(), self._options) macString = Utils.appendField(macString, Constants.getAntiFraudName(), self._anti_fraud) macString = Utils.appendField(macString, Constants.getProductRefName(), self._product_ref) macString = Utils.appendField(macString, Constants.getNameName(), self._name) macString = Utils.appendField(macString, Constants.getSurnameName(), self._surname) macString = Utils.appendField(macString, Constants.getTaxIdName(), self._tax_id) macString = Utils.appendField( macString, Constants.getThreeDSDataName(), AES.AES_encrypt(self._three_ds_data, api_result_key)) macString = Utils.appendField(macString, Constants.getNameCHName(), self._name_ch) macString = Utils.appendField(macString, Constants.getNotifUrl(), self._notify_url) macString = Utils.appendField(macString, Constants.getThreeDSMtdNotifUrlName(), self._three_ds_mtd_notify_url) macString = Utils.appendField(macString, Constants.getChallengeWinSizeName(), self._challenge_win_size) macString = Utils.appendField(macString, Constants.getTrecurrName(), self._tRecurr) macString = Utils.appendField(macString, Constants.getCrecurrName(), self._cRecurr) macString = Utils.appendField(macString, Constants.getInstallmentsNumberName(), self._installments_number) return macString
def map_for_verify_url_mac(values): mac_string = Constants.getOrderIdName() + "=" + values.get( Constants.getOrderIdName()) mac_string = appendField(mac_string, Constants.getShopIdName(), values.get(Constants.getShopIdName())) if values.get(Constants.getAuthNumberName()) is None: mac_string = appendField(mac_string, Constants.getAuthNumberName(), None) else: mac_string = appendField(mac_string, Constants.getAuthNumberName(), values.get(Constants.getAuthNumberName())) mac_string = appendField(mac_string, Constants.getAmountName(), values.get(Constants.getAmountName())) mac_string = appendField(mac_string, Constants.getCurrencyName(), values.get(Constants.getCurrencyName())) # mac_string = appendField(mac_string, Constants.getExponentName(), values.get(Constants.getExponentName())) mac_string = appendField(mac_string, Constants.getTransactionIdName(), values.get(Constants.getTransactionIdName())) mac_string = appendField(mac_string, Constants.getAccountingModeName(), values.get(Constants.getAccountingModeName())) mac_string = appendField(mac_string, Constants.getAuthorModeName(), values.get(Constants.getAuthorModeName())) mac_string = appendField(mac_string, Constants.getResultName(), values.get(Constants.getResultName())) mac_string = appendField(mac_string, Constants.getTransactionTypeName(), values.get(Constants.getTransactionTypeName())) mac_string = appendField(mac_string, Constants.getIssuerCountryName(), values.get(Constants.getIssuerCountryName())) mac_string = appendField(mac_string, Constants.getAuthCodeName(), values.get(Constants.getAuthCodeName())) mac_string = appendField(mac_string, Constants.getPayerIdName(), values.get(Constants.getPayerIdName())) mac_string = appendField(mac_string, Constants.getPayerName(), values.get(Constants.getPayerName())) mac_string = appendField(mac_string, Constants.getPayerStatusName(), values.get(Constants.getPayerStatusName())) mac_string = appendField(mac_string, Constants.getHashPanName(), values.get(Constants.getHashPanName())) mac_string = appendField(mac_string, Constants.getPanAliasRevName(), values.get(Constants.getPanAliasRevName())) mac_string = appendField(mac_string, Constants.getPanAliasName(), values.get(Constants.getPanAliasName())) mac_string = appendField(mac_string, Constants.getPanAliasExpDateName(), values.get(Constants.getPanAliasExpDateName())) mac_string = appendField(mac_string, Constants.getPanAliasTailName(), values.get(Constants.getPanAliasTailName())) mac_string = appendField(mac_string, Constants.getTrecurrName(), values.get(Constants.getTrecurrName())) mac_string = appendField(mac_string, Constants.getCrecurrName(), values.get(Constants.getCrecurrName())) mac_string = appendField(mac_string, Constants.getMaskedPanName(), values.get(Constants.getMaskedPanName())) mac_string = appendField(mac_string, Constants.getPanTailName(), values.get(Constants.getPanTailName())) mac_string = appendField(mac_string, Constants.getPanExpDateName(), values.get(Constants.getPanExpDateName())) mac_string = appendField(mac_string, Constants.getAccountHolderName(), values.get(Constants.getAccountHolderName())) mac_string = appendField(mac_string, Constants.getIBANName(), values.get(Constants.getIBANName())) mac_string = appendField(mac_string, Constants.getAliasStrName(), values.get(Constants.getAliasStrName())) mac_string = appendField(mac_string, Constants.getEmailChName(), values.get(Constants.getEmailChName())) mac_string = appendField(mac_string, Constants.getCFiscName(), values.get(Constants.getCFiscName())) mac_string = appendField(mac_string, Constants.getAcquirerBinName(), values.get(Constants.getAcquirerBinName())) mac_string = appendField(mac_string, Constants.getMerchantIdName(), values.get(Constants.getMerchantIdName())) mac_string = appendField(mac_string, Constants.getCardTypeName(), values.get(Constants.getCardTypeName())) mac_string = appendField(mac_string, Constants.getAmazonAuthIdName(), values.get(Constants.getAmazonAuthIdName())) mac_string = appendField(mac_string, Constants.getAmazonCaptureIdName(), values.get(Constants.getAmazonCaptureIdName())) mac_string = appendField(mac_string, Constants.getCHInfoName(), values.get(Constants.getCHInfoName())) return mac_string
def _string_for_mac(self): macString = Constants.getOperationName() + "=" + str(self._operation) macString = Utils.appendField(macString, Constants.getTimestampName(), self._timestamp) macString = Utils.appendField(macString, Constants.getShopIdName(), self._shop_id) macString = Utils.appendField(macString, Constants.getOrderIdName(), self._order_id) macString = Utils.appendField(macString, Constants.getOperatorIdName(), self._operator_id) macString = Utils.appendField(macString, Constants.getReqRefNumName(), self._reqRefNum) macString = Utils.appendField(macString, Constants.getPanName(), self._pan) macString = Utils.appendField(macString, Constants.getCvv2Name(), self._cvv2) macString = Utils.appendField(macString, Constants.getExpDateName(), self._exp_date) macString = Utils.appendField(macString, Constants.getAmountName(), self._amount) macString = Utils.appendField(macString, Constants.getCurrencyName(), self._currency) macString = Utils.appendField(macString, Constants.getExponentName(), self._exponent) macString = Utils.appendField(macString, Constants.getAccountingModeName(), self._accounting_mode) macString = Utils.appendField(macString, Constants.getNetworkName(), self._network) macString = Utils.appendField(macString, Constants.getEmailChName(), self._email_ch) macString = Utils.appendField(macString, Constants.getUserIdName(), self._user_id) macString = Utils.appendField(macString, Constants.getAcquirerName(), self._acquirer) macString = Utils.appendField(macString, Constants.getIpAddressName(), self._ip_address) macString = Utils.appendField(macString, Constants.getOpDescrName(), self._op_descr) macString = Utils.appendField(macString, Constants.getUsrAuthFlagName(), self._usr_auth_flag) macString = Utils.appendField(macString, Constants.getOptionsName(), self._options) macString = Utils.appendField(macString, Constants.getAntiFraudName(), self._anti_fraud) macString = Utils.appendField(macString, Constants.getProductRefName(), self._product_ref) macString = Utils.appendField(macString, Constants.getNameName(), self._name) macString = Utils.appendField(macString, Constants.getSurnameName(), self._surname) macString = Utils.appendField(macString, Constants.getTaxIdName(), self._tax_id) macString = Utils.appendField(macString, Constants.getTrecurrName(), self._tRecurr) macString = Utils.appendField(macString, Constants.getCrecurrName(), self._cRecurr) macString = Utils.appendField(macString, Constants.getInstallmentsNumberName(), self._installments_number) return macString
def validate_authorize(request): invalid_fields = [] if not isinstance(request, AuthorizationRequest): raise VPOSException("invalid request type") _validate_common_fields(request, invalid_fields) if request.pan is None or not re.search(get_pan_Reg_Ex(), request.pan): invalid_fields.append(Constants.getPanName()) if request.exp_date is None or not re.search(get_exp_date_Reg_Ex(), request.exp_date): invalid_fields.append(Constants.getExpDateName()) if request.cvv2 is not None and not re.search(get_cvv2_Reg_Ex(), request.cvv2): invalid_fields.append(Constants.getCvv2Name()) if request.accounting_mode is None or not re.search( get_accounting_mode_Reg_Ex(), request.accounting_mode): invalid_fields.append(Constants.getAccountingModeName()) if request.amount is None or not re.search(get_amount_Reg_Ex(), request.amount): invalid_fields.append(Constants.getAmountName()) _validate_currency_and_exponent(request, invalid_fields) if request.network is None or not re.search(get_network_Reg_Ex(), request.network): invalid_fields.append(Constants.getNetworkName()) if request.email_ch is not None and not re.search(get_email_ch_Reg_Ex(), request.email_ch): invalid_fields.append(Constants.getEmailChName()) if request.user_id is not None and not re.search(get_user_id_Reg_Ex(), request.user_id): invalid_fields.append(Constants.getUserIdName()) if request.acquirer is not None and not re.search(get_acquirer_Reg_Ex(), request.acquirer): invalid_fields.append(Constants.getAcquirerName()) if request.ip_address is not None and not re.search( get_ip_address_Reg_Ex(), request.ip_address): invalid_fields.append(Constants.getIpAddressName()) if request.usr_auth_flag is not None and not re.search( get_usr_auth_flag_Reg_Ex(), request.usr_auth_flag): invalid_fields.append(Constants.getUsrAuthFlagName()) if request.op_descr is not None and not re.search(get_op_descr_Reg_Ex(), request.op_descr): invalid_fields.append(Constants.getOpDescrName()) if request.anti_fraud is not None and not re.search( get_anti_fraud_Reg_Ex(), request.anti_fraud): invalid_fields.append(Constants.getAntiFraudName()) if request.product_ref is not None and not re.search( get_product_ref_Reg_Ex(), request.product_ref): invalid_fields.append(Constants.getProductRefName()) if request.name is not None and not re.search(get_name_Reg_Ex(), request.name): invalid_fields.append(Constants.getNameName()) if request.surname is not None and not re.search(get_surname_Reg_Ex(), request.surname): invalid_fields.append(Constants.getSurnameName()) if request.tax_id is not None and not re.search(get_tax_id_Reg_Ex(), request.tax_id): invalid_fields.append(Constants.getTaxIdName()) if len(invalid_fields) > 0: raise VPOSException("Invalid or missing config params: " + str(invalid_fields))
def _string_for_mac(self): macString = Constants.getOperationName() + "=" + str(self._operation) macString = Utils.appendField(macString, Constants.getTimestampName(), self._timestamp) macString = Utils.appendField(macString, Constants.getShopIdName(), self._shop_id) macString = Utils.appendField(macString, Constants.getOperatorIdName(), self._operator_id) macString = Utils.appendField(macString, Constants.getReqRefNumName(), self._reqRefNum) macString = Utils.appendField(macString, Constants.getTransactionIdName(), self._transaction_id) macString = Utils.appendField(macString, Constants.getOrderIdName(), self._order_id) macString = Utils.appendField(macString, Constants.getAmountName(), self._amount) macString = Utils.appendField(macString, Constants.getCurrencyName(), self._currency) macString = Utils.appendField(macString, Constants.getExponentName(), self._exponent) macString = Utils.appendField(macString, Constants.getOpDescrName(), self._op_descr) macString = Utils.appendField(macString, Constants.getOptionsName(), self._options) return macString
def genReqRefNum(): x = datetime.now() x = x.strftime('%Y%m%d') for i in range(0, Constants.getReqRefNumLength()): x = x + str(random.randint(0, 9)) return x