def test_create_pad_payment_request(session, client, jwt, app): """Assert payment request works for PAD accounts.""" token = jwt.create_jwt(get_claims(role=Role.SYSTEM.value), token_header) headers = { 'Authorization': f'Bearer {token}', 'content-type': 'application/json' } # Create account first rv = client.post('/api/v1/accounts', data=json.dumps( get_unlinked_pad_account_payload(account_id=1234)), headers=headers) auth_account_id = rv.json.get('authAccountId') # Update the payment account as ACTIVE activate_pad_account(auth_account_id) token = jwt.create_jwt(get_claims(), token_header) headers = { 'Authorization': f'Bearer {token}', 'content-type': 'application/json', 'Account-Id': auth_account_id } rv = client.post('/api/v1/payment-requests', data=json.dumps( get_payment_request_with_no_contact_info( corp_type='BEN', filing_type_code='BCINC', payment_method=PaymentMethod.PAD.value)), headers=headers) assert rv.json.get('paymentMethod') == PaymentMethod.PAD.value assert not rv.json.get('isOnlineBankingAllowed')
def test_create_pad_payment_request_when_account_is_pending( session, client, jwt, app): """Assert payment request works for PAD accounts.""" token = jwt.create_jwt(get_claims(role=Role.SYSTEM.value), token_header) headers = { 'Authorization': f'Bearer {token}', 'content-type': 'application/json' } # Create account first rv = client.post('/api/v1/accounts', data=json.dumps( get_unlinked_pad_account_payload(account_id=1234)), headers=headers) auth_account_id = rv.json.get('authAccountId') token = jwt.create_jwt(get_claims(), token_header) headers = { 'Authorization': f'Bearer {token}', 'content-type': 'application/json', 'Account-Id': auth_account_id } rv = client.post('/api/v1/payment-requests', data=json.dumps( get_payment_request_with_no_contact_info( corp_type='BEN', filing_type_code='BCINC', payment_method=PaymentMethod.PAD.value)), headers=headers) assert rv.status_code == 400 assert rv.json.get('type') == 'ACCOUNT_IN_PAD_CONFIRMATION_PERIOD'
def test_create_pad_payment_receipt(session, client, jwt, app): """Assert payment request works for PAD accounts.""" token = jwt.create_jwt(get_claims(role=Role.SYSTEM.value), token_header) headers = { 'Authorization': f'Bearer {token}', 'content-type': 'application/json' } # Create account first rv = client.post('/api/v1/accounts', data=json.dumps( get_unlinked_pad_account_payload(account_id=1234)), headers=headers) auth_account_id = rv.json.get('accountId') # Update the payment account as ACTIVE payment_account: PaymentAccountModel = PaymentAccountModel.find_by_auth_account_id( auth_account_id) payment_account.pad_activation_date = datetime.now() payment_account.save() cfs_account: CfsAccountModel = CfsAccountModel.find_effective_by_account_id( payment_account.id) cfs_account.status = 'ACTIVE' cfs_account.save() token = jwt.create_jwt(get_claims(), token_header) headers = { 'Authorization': f'Bearer {token}', 'content-type': 'application/json', 'Account-Id': auth_account_id } rv = client.post('/api/v1/payment-requests', data=json.dumps( get_payment_request_with_no_contact_info( corp_type='BEN', filing_type_code='BCINC', payment_method=PaymentMethod.PAD.value)), headers=headers) assert rv.json.get('paymentMethod') == PaymentMethod.PAD.value inv_id = rv.json.get('id') filing_data = { 'corpName': 'CP0001234', 'filingDateTime': 'June 27, 2019', 'fileName': 'director-change' } rv = client.post(f'/api/v1/payment-requests/{inv_id}/receipts', data=json.dumps(filing_data), headers=headers) assert rv.status_code == 201
def test_premium_payment_with_no_contact_info(session, client, jwt, app): """Assert that the endpoint returns 201.""" token = jwt.create_jwt(get_claims(), token_header) headers = { 'Authorization': f'Bearer {token}', 'content-type': 'application/json', 'Account-Id': '1234' } rv = client.post('/api/v1/payment-requests', data=json.dumps( get_payment_request_with_no_contact_info( payment_method='DRAWDOWN', corp_type='PPR')), headers=headers) assert rv.status_code == 201 assert rv.json.get('_links') is not None assert schema_utils.validate(rv.json, 'invoice')[0] assert rv.json.get('paymentMethod') == 'DRAWDOWN'
def test_premium_payment_creation_with_ob_disabled(session, client, jwt, app): """Assert that the endpoint returns 201.""" token = jwt.create_jwt(get_claims(), token_header) headers = { 'Authorization': f'Bearer {token}', 'content-type': 'application/json', 'Account-Id': '1' } rv = client.post('/api/v1/payment-requests', data=json.dumps( get_payment_request_with_no_contact_info( corp_type='NRO', filing_type_code='NM620', payment_method='ONLINE_BANKING')), headers=headers) assert rv.status_code == 201 assert rv.json.get('paymentMethod') == 'ONLINE_BANKING' assert not rv.json.get('isOnlineBankingAllowed')