Commit 8dfba9da authored by Guillaume Risbourg's avatar Guillaume Risbourg Committed by Vincent A

[caissedepargne] Handle CloudCard for transfers

CloudCard (aka Secur'Pass) is a method that asks for an AppValidation
when adding new recipients or making transfer when not on the Caisse
d'Epargne application.
parent 82a15a2b
......@@ -1512,16 +1512,21 @@ class CaisseEpargne(LoginBrowser, StatesMixin):
if self.validation_option.is_here():
self.get_auth_mechanisms_validation_info()
if self.otp_validation['type'] == 'CLOUDCARD':
raise AuthMethodNotImplemented()
raise TransferStep(
transfer,
Value(
'otp_sms',
label='Veuillez renseigner le mot de passe unique qui vous a été envoyé par SMS dans le champ réponse.'
if self.otp_validation['type'] == 'SMS':
self.is_send_sms = True
raise TransferStep(
transfer,
Value(
'otp_sms',
label='Veuillez renseigner le mot de passe unique qui vous a été envoyé par SMS dans le champ réponse.'
)
)
elif self.otp_validation['type'] == 'CLOUDCARD':
self.is_app_validation = True
raise AppValidation(
resource=transfer,
message="Veuillez valider le transfert sur votre application mobile.",
)
)
if 'netpro' in self.url:
return self.page.create_transfer(account, recipient, transfer)
......@@ -1530,15 +1535,27 @@ class CaisseEpargne(LoginBrowser, StatesMixin):
return self.page.update_transfer(transfer, account, recipient)
@need_login
def otp_sms_continue_transfer(self, transfer, **params):
self.is_send_sms = False
assert 'otp_sms' in params, 'OTP SMS is missing'
def otp_validation_continue_transfer(self, transfer, **params):
assert (
'resume' in params
or 'otp_sms' in params
), 'otp_sms or resume is missing'
if 'resume' in params:
self.is_app_validation = False
self.do_authentication_validation(
authentication_method='CLOUDCARD',
feature='transfer',
)
elif 'otp_sms' in params:
self.is_send_sms = False
self.do_authentication_validation(
authentication_method='SMS',
feature='transfer',
otp_sms=params['otp_sms']
)
self.do_authentication_validation(
authentication_method='SMS',
feature='transfer',
otp_sms=params['otp_sms']
)
if self.transfer.is_here():
self.page.continue_transfer(transfer.account_label, transfer.recipient_label, transfer.label)
......
......@@ -115,8 +115,8 @@ class CaisseEpargneModule(Module, CapBankWealth, CapBankTransferAddRecipient, Ca
return self.browser.iter_recipients(origin_account)
def init_transfer(self, transfer, **params):
if 'otp_sms' in params:
return self.browser.otp_sms_continue_transfer(transfer, **params)
if 'otp_sms' in params or 'resume' in params:
return self.browser.otp_validation_continue_transfer(transfer, **params)
self.logger.info('Going to do a new transfer')
transfer.label = re.sub(r"[^0-9A-Z/?:().,'+ -]+", '', transfer.label.upper())
......
......@@ -47,6 +47,7 @@ from weboob.capabilities.bank import (
Transfer, TransferBankError, TransferInvalidOTP,
Recipient, AddRecipientBankError, RecipientInvalidOTP,
Emitter, EmitterNumberType, AddRecipientError,
TransferError,
)
from weboob.capabilities.wealth import Investment
from weboob.capabilities.bill import DocumentTypes, Subscription, Document
......@@ -188,8 +189,9 @@ class AuthenticationMethodPage(JsonPage):
def transfer_errors(self, error):
if error == 'FAILED_AUTHENTICATION':
# For the moment, only otp sms is handled
raise TransferInvalidOTP(message="Le code SMS que vous avez renseigné n'est pas valide")
elif error == 'AUTHENTICATION_CANCELED':
raise TransferError(message="Le virement a été annulée via l'application mobile.")
def recipient_errors(self, error):
if error == 'FAILED_AUTHENTICATION':
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment