def put(account_number: str): """Create the payment account records.""" current_app.logger.info('<Account.post') request_json = request.get_json() current_app.logger.debug(request_json) # Validate the input request valid_format, errors = schema_utils.validate(request_json, 'account_info') if not valid_format: return error_to_response( Error.INVALID_REQUEST, invalid_params=schema_utils.serialize(errors)) try: response = PaymentAccountService.update(account_number, request_json) except ServiceUnavailableException as exception: return exception.response() status = HTTPStatus.ACCEPTED \ if response.cfs_account_id and response.cfs_account_status == CfsAccountStatus.PENDING.value \ else HTTPStatus.OK current_app.logger.debug('>Account.post') return jsonify(response.asdict()), status
def test_update_online_banking_to_credit(session): """Assert that update from online banking to credit card works.""" online_banking_account = PaymentAccountService.create( get_basic_account_payload( payment_method=PaymentMethod.ONLINE_BANKING.value)) credit_account = PaymentAccountService.update( online_banking_account.auth_account_id, get_basic_account_payload()) assert credit_account.payment_method == PaymentMethod.DIRECT_PAY.value
def test_create_pad_account_to_drawdown(session): """Assert updating PAD to DRAWDOWN works.""" # Create a PAD Account first pad_account = PaymentAccountService.create(get_unlinked_pad_account_payload()) # Update this payment account with drawdown and assert payment method bcol_account = PaymentAccountService.update(pad_account.auth_account_id, get_premium_account_payload()) assert bcol_account.auth_account_id == bcol_account.auth_account_id assert bcol_account.payment_method == PaymentMethod.DRAWDOWN.value
def test_create_pad_to_bcol_to_pad(session): """Assert that update from BCOL to PAD works.""" # Create a PAD Account first pad_account_1 = PaymentAccountService.create(get_unlinked_pad_account_payload(bank_number='009')) assert pad_account_1.bank_number == '009' # Update this payment account with drawdown and assert payment method bcol_account = PaymentAccountService.update(pad_account_1.auth_account_id, get_premium_account_payload()) assert bcol_account.auth_account_id == bcol_account.auth_account_id assert bcol_account.payment_method == PaymentMethod.DRAWDOWN.value # Update to PAD again pad_account_2 = PaymentAccountService.update(pad_account_1.auth_account_id, get_unlinked_pad_account_payload(bank_number='010')) assert pad_account_2.bank_number == '010' assert pad_account_2.payment_method == PaymentMethod.PAD.value assert pad_account_2.cfs_account_id != pad_account_1.cfs_account_id
def test_update_credit_to_online_banking(session): """Assert that update from credit card to online banking works.""" credit_account = PaymentAccountService.create(get_basic_account_payload()) online_banking_account = PaymentAccountService.update(credit_account.auth_account_id, get_basic_account_payload( payment_method=PaymentMethod.ONLINE_BANKING.value)) assert online_banking_account.payment_method == PaymentMethod.ONLINE_BANKING.value assert online_banking_account.cfs_account_id assert online_banking_account.cfs_account is None assert online_banking_account.cfs_party is None assert online_banking_account.cfs_site is None assert online_banking_account.bank_number is None
def test_create_bcol_account_to_pad(session): """Assert that update from BCOL to PAD works.""" # Create a DRAWDOWN Account first bcol_account = PaymentAccountService.create(get_premium_account_payload()) # Update to PAD pad_account = PaymentAccountService.update(bcol_account.auth_account_id, get_unlinked_pad_account_payload()) assert bcol_account.auth_account_id == bcol_account.auth_account_id assert pad_account.payment_method == PaymentMethod.PAD.value assert pad_account.cfs_account_id assert pad_account.cfs_account is None assert pad_account.cfs_party is None assert pad_account.cfs_site is None