def new_recipient(self, recipient, **params): if 'code' in params: return self.send_code(recipient, **params) if recipient.iban[:2] not in ('FR', 'MC'): raise AddRecipientBankError(message=u"LCL n'accepte que les iban commençant par MC ou FR.") for _ in range(2): self.add_recip.go() if self.add_recip.is_here(): break if self.no_perm.is_here() and self.page.get_error_msg(): raise AddRecipientBankError(message=self.page.get_error_msg()) assert self.add_recip.is_here(), 'Navigation failed: not on add_recip' self.page.validate(recipient.iban, recipient.label) assert self.recip_confirm.is_here(), 'Navigation failed: not on recip_confirm' self.page.check_values(recipient.iban, recipient.label) # Send sms to user. self.open('/outil/UWBE/Otp/envoiCodeOtp?telChoisi=MOBILE') raise AddRecipientStep(self.get_recipient_object(recipient.iban, recipient.label), Value('code', label='Saisissez le code.'))
def new_recipient(self, recipient, **params): if 'code' in params: self.validate_rcpt_with_sms(params['code']) return self.page.rcpt_after_sms(recipient) data = { 'n_nbOccurences': 1000, 'n_nbOccurences_affichees': 0, 'n_rang': 0, } self.recipients.go(data=data) step_urls = { 'first_recipient_check': self.absurl('/ord-web/ord//ord-valider-destinataire-avant-maj.json', base=True), 'get_bic': self.absurl('/ord-web/ord//ord-tiers-calcul-bic.json', base=True), 'get_token': self.absurl('/ord-web/ord//ord-preparer-signature-destinataire.json', base=True), 'get_sign_info': self.absurl('/sec/getsigninfo.json', base=True), 'send_otp_to_user': self.absurl('/sec/csa/send.json', base=True), } self.add_recipient.go(method='POST', headers={'Content-Type': 'application/json;charset=UTF-8'}) countries = self.page.get_countries() # first recipient check data = { 'an_codeAction': 'ajout_tiers', 'an_refSICoordonnee': '', 'an_refSITiers': '', 'cl_iban': recipient.iban, 'cl_raisonSociale': recipient.label, } self.location(step_urls['first_recipient_check'], data=data) # get bic data = { 'an_activateCMU': 'true', 'an_codePaysBanque': '', 'an_nature': 'C', 'an_numeroCompte': recipient.iban, 'an_topIBAN': 'true', 'cl_adresse': '', 'cl_adresseBanque': '', 'cl_codePays': recipient.iban[:2], 'cl_libellePaysBanque': '', 'cl_libellePaysDestinataire': countries[recipient.iban[:2]], 'cl_nomBanque': '', 'cl_nomRaisonSociale': recipient.label, 'cl_ville': '', 'cl_villeBanque': '', } self.location(step_urls['get_bic'], data=data) bic = self.page.get_response_data() # get token data = { 'an_coordonnee_codePaysBanque': '', 'an_coordonnee_nature': 'C', 'an_coordonnee_numeroCompte': recipient.iban, 'an_coordonnee_topConfidentiel': 'false', 'an_coordonnee_topIBAN': 'true', 'an_refSICoordonnee': '', 'an_refSIDestinataire': '', 'cl_adresse': '', 'cl_codePays': recipient.iban[:2], 'cl_coordonnee_adresseBanque': '', 'cl_coordonnee_bic': bic, 'cl_coordonnee_categories_libelle': '', 'cl_coordonnee_categories_refSi': '', 'cl_coordonnee_libellePaysBanque': '', 'cl_coordonnee_nomBanque': '', 'cl_coordonnee_villeBanque': '', 'cl_libellePaysDestinataire': countries[recipient.iban[:2]], 'cl_nomRaisonSociale': recipient.label, 'cl_ville': '', } self.location(step_urls['get_token'], data=data) self.new_rcpt_validate_form = data payload = self.page.get_response_data() # get sign info data = { 'b64_jeton_transaction': payload['jeton'], 'action_level': payload['sensibilite'], } self.location(step_urls['get_sign_info'], data=data) # send otp to user data = { 'context': payload['jeton'], 'csa_op': 'sign' } self.location(step_urls['send_otp_to_user'], data=data) self.new_rcpt_validate_form.update(data) rcpt = self.copy_recipient_obj(recipient) raise AddRecipientStep(rcpt, Value('code', label='Veuillez entrer le code reçu par SMS.'))
def new_recipient(self, recipient, **params): if not re.match(u"^[-+.,:/?() éèêëïîñàâäãöôòõùûüÿ0-9a-z']+$", recipient.label, re.I): raise RecipientInvalidLabel( 'Recipient label contains invalid characters') if 'sms_code' in params and not re.match(r'^[a-z0-9]{6}$', params['sms_code'], re.I): # check before send sms code because it can crash website if code is invalid raise AddRecipientBankError("SMS code %s is invalid" % params['sms_code']) # avoid `iter_accounts` if there is only one perimeter if len(self.perimeters) > 1: accounts = list(self.iter_accounts()) assert recipient.origin_account_id, 'Origin account id is mandatory for multispace' account = find_object(accounts, id=recipient.origin_account_id, error=AccountNotFound) self.go_to_perimeter(account._perimeter) self.transfer_init_page.go() assert self.transfer_init_page.is_here() if not self.page.add_recipient_is_allowed(): if not [ rec for rec in self.page.iter_recipients() if rec.category == 'Externe' ]: raise AddRecipientBankError( 'Vous ne pouvez pas ajouter de bénéficiaires, veuillez contacter votre banque.' ) assert False, 'Xpath for a recipient add is not catched' self.location(self.page.url_list_recipients()) # there are 2 pages from where we can add a new recipient: # - RecipientListPage, but the link is sometimes missing # - TransferPage, start making a transfer with a new recipient but don't complete the transfer # but it seems dangerous since we have to set an amount, etc. # so we implement it in 2 ways with a preference for RecipientListPage if self.page.url_add_recipient(): self.logger.debug( 'good, we can add a recipient from the recipient list') else: # in this case, the link was missing self.logger.warning( 'cannot add a recipient from the recipient list page, pretending to make a transfer in order to add it' ) self.transfer_init_page.go() assert self.transfer_init_page.is_here() self.location(self.page.url_add_recipient()) if not ('sms_code' in params and self.page.can_send_code()): self.page.send_sms() # go to a GET page, so StatesMixin can reload it self.accounts.go() raise AddRecipientStep( self.build_recipient(recipient), Value('sms_code', label='Veuillez saisir le code SMS')) else: self.page.submit_code(params['sms_code']) err = hasattr(self.page, 'get_sms_error') and self.page.get_sms_error() if err: raise AddRecipientBankError(message=err) self.page.submit_recipient(recipient.label, recipient.iban) self.page.confirm_recipient() self.page.check_recipient_error() if self.transfer_page.is_here(): # in this case, we were pretending to make a transfer, just to add the recipient # go back to transfer page to abort the transfer and see the new recipient self.transfer_init_page.go() assert self.transfer_init_page.is_here() res = self.page.find_recipient(recipient.iban) assert res, 'Recipient with iban %s could not be found' % recipient.iban return res