From f54bc9569e35680b164014352e4a43c1b19681ab Mon Sep 17 00:00:00 2001 From: Bilal Hussain Date: Tue, 8 Apr 2025 20:39:52 -0500 Subject: [PATCH 1/2] support for transactions, payment instruments & simulating credit scores + tests --- method/resources/Accounts/Account.py | 6 +- .../resources/Accounts/PaymentInstruments.py | 54 +++++++ method/resources/Accounts/Products.py | 1 + method/resources/Accounts/Subscriptions.py | 4 +- method/resources/Accounts/Transactions.py | 52 ++----- method/resources/Accounts/Types.py | 3 +- .../Accounts/VerificationSessions.py | 18 ++- method/resources/Simulate/CreditScores.py | 20 +++ method/resources/Simulate/Entities.py | 18 +++ method/resources/Simulate/Simulate.py | 4 + method/resources/__init__.py | 3 + test/resources/Account_test.py | 142 ++++++++++++------ test/resources/Event_test.py | 14 +- 13 files changed, 248 insertions(+), 91 deletions(-) create mode 100644 method/resources/Accounts/PaymentInstruments.py create mode 100644 method/resources/Simulate/CreditScores.py create mode 100644 method/resources/Simulate/Entities.py diff --git a/method/resources/Accounts/Account.py b/method/resources/Accounts/Account.py index bfae432..2a1b620 100644 --- a/method/resources/Accounts/Account.py +++ b/method/resources/Accounts/Account.py @@ -15,6 +15,8 @@ from method.resources.Accounts.VerificationSessions import AccountVerificationSession, AccountVerificationSessionResource from method.resources.Accounts.Products import AccountProduct, AccountProductResource from method.resources.Accounts.Attributes import AccountAttributes, AccountAttributesResource +from method.resources.Accounts.PaymentInstruments import AccountPaymentInstrument, AccountPaymentInstrumentsResource + class AccountCreateOpts(TypedDict): holder_id: str metadata: Optional[Dict[str, Any]] @@ -67,6 +69,7 @@ class Account(TypedDict): card_brand: Optional[Union[str, AccountCardBrand]] payoff: Optional[Union[str, AccountPayoff]] transaction: Optional[Union[str, AccountTransaction]] + payment_instrument: Optional[Union[str, AccountPaymentInstrument]] update: Optional[Union[str, AccountUpdate]] latest_verification_session: Optional[Union[str, AccountVerificationSession]] error: Optional[ResourceError] @@ -94,7 +97,7 @@ class AccountSubResources: verification_sessions: AccountVerificationSessionResource products: AccountProductResource attributes: AccountAttributesResource - + payment_instruments: AccountPaymentInstrumentsResource def __init__(self, _id: str, config: Configuration): self.balances = AccountBalancesResource(config.add_path(_id)) @@ -103,6 +106,7 @@ def __init__(self, _id: str, config: Configuration): self.sensitive = AccountSensitiveResource(config.add_path(_id)) self.subscriptions = AccountSubscriptionsResource(config.add_path(_id)) self.transactions = AccountTransactionsResource(config.add_path(_id)) + self.payment_instruments = AccountPaymentInstrumentsResource(config.add_path(_id)) self.updates = AccountUpdatesResource(config.add_path(_id)) self.verification_sessions = AccountVerificationSessionResource(config.add_path(_id)) self.products = AccountProductResource(config.add_path(_id)) diff --git a/method/resources/Accounts/PaymentInstruments.py b/method/resources/Accounts/PaymentInstruments.py new file mode 100644 index 0000000..4e34efd --- /dev/null +++ b/method/resources/Accounts/PaymentInstruments.py @@ -0,0 +1,54 @@ +from typing import TypedDict, Optional, Literal, List, Any + +from method.resource import MethodResponse, Resource, ResourceListOpts +from method.configuration import Configuration +from method.errors import ResourceError + +AccountPaymentInstrumentTypesLiterals = Literal[ + 'card', + 'network_token' +] + +class AccountPaymentInstrumentCreateOpts(TypedDict): + type: AccountPaymentInstrumentTypesLiterals + +class AccountPaymentInstrumentNetworkToken(TypedDict): + token: str + +class AccountPaymentInstrumentCard(TypedDict): + number: str + exp_month: int + exp_year: int + +AccountPaymentInstrumentStatusesLiterals = Literal[ + 'completed', + 'in_progress', + 'pending', + 'failed' +] + +class AccountPaymentInstrument(TypedDict): + id: str + account_id: str + type: AccountPaymentInstrumentTypesLiterals + network_token: Optional[AccountPaymentInstrumentNetworkToken] + card: Optional[AccountPaymentInstrumentCard] + chargeable: bool + status: AccountPaymentInstrumentStatusesLiterals + error: Optional[ResourceError] + created_at: str + updated_at: str + + +class AccountPaymentInstrumentsResource(Resource): + def __init__(self, config: Configuration): + super(AccountPaymentInstrumentsResource, self).__init__(config.add_path('payment_instruments')) + + def retrieve(self, pmt_inst_id: str) -> MethodResponse[AccountPaymentInstrument]: + return super(AccountPaymentInstrumentsResource, self)._get_with_id(pmt_inst_id) + + def list(self, params: Optional[ResourceListOpts] = None) -> MethodResponse[List[AccountPaymentInstrument]]: + return super(AccountPaymentInstrumentsResource, self)._list(params) + + def create(self, data: AccountPaymentInstrumentCreateOpts) -> MethodResponse[AccountPaymentInstrument]: + return super(AccountPaymentInstrumentsResource, self)._create(data) diff --git a/method/resources/Accounts/Products.py b/method/resources/Accounts/Products.py index 46c6a82..fe31895 100644 --- a/method/resources/Accounts/Products.py +++ b/method/resources/Accounts/Products.py @@ -32,6 +32,7 @@ class AccountProductListResponse(TypedDict): transactions: Optional[AccountProduct] payoff: Optional[AccountProduct] card_brand: Optional[AccountProduct] + payment_instruments: Optional[AccountProduct] class AccountProductResource(Resource): def __init__(self, config: Configuration): diff --git a/method/resources/Accounts/Subscriptions.py b/method/resources/Accounts/Subscriptions.py index 24fe4d7..9bb1d2c 100644 --- a/method/resources/Accounts/Subscriptions.py +++ b/method/resources/Accounts/Subscriptions.py @@ -5,7 +5,7 @@ AccountSubscriptionTypesLiterals = Literal[ - 'transactions', + 'transaction', 'update', 'update.snapshot' ] @@ -21,7 +21,7 @@ class AccountSubscription(TypedDict): AccountSubscriptionsResponse = TypedDict('AccountSubscriptionsResponse', { - 'transactions': Optional[AccountSubscription], + 'transaction': Optional[AccountSubscription], 'update': Optional[AccountSubscription], 'update.snapshot': Optional[AccountSubscription] }) diff --git a/method/resources/Accounts/Transactions.py b/method/resources/Accounts/Transactions.py index 20693e5..6ed6252 100644 --- a/method/resources/Accounts/Transactions.py +++ b/method/resources/Accounts/Transactions.py @@ -2,53 +2,33 @@ from method.resource import MethodResponse, Resource, ResourceListOpts from method.configuration import Configuration -from method.errors import ResourceError - - -AccountCurrencyTypesLiterals = Literal[ - 'USD' -] - AccountTransactionStatusLiterals = Literal[ - 'cleared', - 'auth', - 'refund', - 'unknown' + 'pending', + 'posted', + 'voided', ] - -class AccountTransactionMerchant(TypedDict): - name: str - category_code: str - city: str - state: str - country: str - acquirer_bin: str - acquirer_card_acceptor_id: str - - -class AccountTransactionNetworkData(TypedDict): - visa_merchant_id: Optional[str] - visa_merchant_name: Optional[str] - visa_store_id: Optional[str] - visa_store_name: Optional[str] - - class AccountTransaction(TypedDict): id: str account_id: str - merchant: AccountTransactionMerchant - network: str - network_data: AccountTransactionNetworkData + descriptor: str amount: int - currency: AccountCurrencyTypesLiterals - billing_amount: int - billing_currency: AccountCurrencyTypesLiterals + auth_amount: int + currency_code: str + transaction_amount: int + transaction_auth_amount: int + transaction_currency_code: str + merchant_category_code: str status: AccountTransactionStatusLiterals - error: Optional[ResourceError] + transacted_at: str + posted_at: Optional[str] + voided_at: Optional[str] + original_txn_id: Optional[str] created_at: str updated_at: str + + class AccountTransactionsResource(Resource): diff --git a/method/resources/Accounts/Types.py b/method/resources/Accounts/Types.py index 3b1ac03..f275414 100644 --- a/method/resources/Accounts/Types.py +++ b/method/resources/Accounts/Types.py @@ -22,7 +22,8 @@ 'payoff', 'update', 'attribute', - 'transactions' + 'transactions', + 'payment_instruments' ] diff --git a/method/resources/Accounts/VerificationSessions.py b/method/resources/Accounts/VerificationSessions.py index e18deb2..062696f 100644 --- a/method/resources/Accounts/VerificationSessions.py +++ b/method/resources/Accounts/VerificationSessions.py @@ -21,7 +21,8 @@ 'teller', 'standard', 'instant', - 'pre_auth' + 'pre_auth', + 'network' ] @@ -85,6 +86,13 @@ class AccountVerificationSessionPreAuth(AccountVerificationSessionInstant): pre_auth_check: Optional[AccountVerificationPassFailLiterals] +class AccountVerificationSessionNetwork(AccountVerificationSessionInstant): + cvv: str + cvv_check: Optional[AccountVerificationPassFailLiterals] + billing_zip_code: str + billing_zip_code_check: Optional[AccountVerificationPassFailLiterals] + network_check: Optional[AccountVerificationPassFailLiterals] + class AccountVerificationSessionCreateOpts(TypedDict): type: AccountVerificationSessionTypesLiterals @@ -117,6 +125,10 @@ class AccountVerificationSessionPreAuthUpdateOpts(TypedDict): pre_auth: AccountVerificationSessionPreAuth +class AccountVerificationSessionNetworkUpdateOpts(TypedDict): + network: AccountVerificationSessionNetwork + + AccountVerificationSessionUpdateOpts = Union[ AccountVerificationSessionMicroDepositsUpdateOpts, AccountVerificationSessionPlaidUpdateOpts, @@ -124,7 +136,8 @@ class AccountVerificationSessionPreAuthUpdateOpts(TypedDict): AccountVerificationSessionTellerUpdateOpts, AccountVerificationSessionStandardUpdateOpts, AccountVerificationSessionInstantUpdateOpts, - AccountVerificationSessionPreAuthUpdateOpts + AccountVerificationSessionPreAuthUpdateOpts, + AccountVerificationSessionNetworkUpdateOpts ] @@ -144,6 +157,7 @@ class AccountVerificationSession(TypedDict): pre_auth: Optional[AccountVerificationSessionPreAuth] three_ds: Optional[AccountVerificationSessionThreeDS] issuer: Optional[AccountVerificationSessionIssuer] + network: Optional[AccountVerificationSessionNetwork] created_at: str updated_at: str diff --git a/method/resources/Simulate/CreditScores.py b/method/resources/Simulate/CreditScores.py new file mode 100644 index 0000000..9ba3e35 --- /dev/null +++ b/method/resources/Simulate/CreditScores.py @@ -0,0 +1,20 @@ +from method.resource import MethodResponse, Resource +from method.configuration import Configuration +from typing import List, Dict, Any +from method.resources.Entities.CreditScores import EntityCreditScoresType, EntityCreditScores + + +class SimulateCreditScoresInstance(Resource): + def __init__(self, crs_id: str, config: Configuration): + super(SimulateCreditScoresInstance, self).__init__(config.add_path(crs_id)) + + def create(self, scores: List[EntityCreditScoresType]) -> MethodResponse[EntityCreditScores]: + return super(SimulateCreditScoresInstance, self)._create({"scores": scores}) + + +class SimulateCreditScoresResource(Resource): + def __init__(self, config: Configuration): + super(SimulateCreditScoresResource, self).__init__(config.add_path('credit_scores')) + + def __call__(self, crs_id: str) -> SimulateCreditScoresInstance: + return SimulateCreditScoresInstance(crs_id, self.config) diff --git a/method/resources/Simulate/Entities.py b/method/resources/Simulate/Entities.py new file mode 100644 index 0000000..13a229c --- /dev/null +++ b/method/resources/Simulate/Entities.py @@ -0,0 +1,18 @@ +from method.resource import Resource +from method.configuration import Configuration +from method.resources.Simulate.CreditScores import SimulateCreditScoresResource + + +class SimulateEntitySubResources: + credit_scores: SimulateCreditScoresResource + + def __init__(self, _id: str, config: Configuration): + self.credit_scores = SimulateCreditScoresResource(config.add_path(_id)) + + +class SimulateEntityResource(Resource): + def __init__(self, config: Configuration): + super(SimulateEntityResource, self).__init__(config.add_path('entities')) + + def __call__(self, ent_id) -> SimulateEntitySubResources: + return SimulateEntitySubResources(ent_id, self.config) diff --git a/method/resources/Simulate/Simulate.py b/method/resources/Simulate/Simulate.py index e1803c9..9f2d387 100644 --- a/method/resources/Simulate/Simulate.py +++ b/method/resources/Simulate/Simulate.py @@ -3,11 +3,13 @@ from method.resources.Simulate.Payments import SimulatePaymentResource from method.resources.Simulate.Accounts import SimulateAccountResource from method.resources.Simulate.Events import SimulateEventsResource +from method.resources.Simulate.Entities import SimulateEntityResource class SimulateResource(Resource): payments: SimulatePaymentResource accounts: SimulateAccountResource events: SimulateEventsResource + entities: SimulateEntityResource def __init__(self, config: Configuration): _config = config.add_path('simulate') @@ -15,3 +17,5 @@ def __init__(self, config: Configuration): self.payments = SimulatePaymentResource(_config) self.accounts = SimulateAccountResource(_config) self.events = SimulateEventsResource(_config) + self.entities = SimulateEntityResource(_config) + \ No newline at end of file diff --git a/method/resources/__init__.py b/method/resources/__init__.py index 6a3f311..30baf82 100644 --- a/method/resources/__init__.py +++ b/method/resources/__init__.py @@ -7,6 +7,9 @@ from method.resources.Simulate.Simulate import SimulateResource from method.resources.Simulate.Transactions import SimulateTransactionsResource from method.resources.Simulate.Payments import SimulatePaymentResource +from method.resources.Simulate.Entities import SimulateEntityResource +from method.resources.Simulate.Accounts import SimulateAccountResource +from method.resources.Simulate.CreditScores import SimulateCreditScoresResource from method.resources.HealthCheck import PingResponse, HealthCheckResource from method.resources.Merchant import Merchant, MerchantProviderIds, MerchantResource from method.resources.Report import Report, ReportCreateOpts, ReportResource diff --git a/test/resources/Account_test.py b/test/resources/Account_test.py index 587b906..65069ec 100644 --- a/test/resources/Account_test.py +++ b/test/resources/Account_test.py @@ -74,10 +74,18 @@ def setup(): }) test_credit_card_account = test_credit_card_accounts[0] + test_credit_card_accounts_1 = method.accounts.list({ + 'holder_id': holder_1_response['id'], + 'liability.type': 'credit_card', + 'liability.mch_id': 'mch_311289', + 'status': 'active', + }) + test_credit_card_account_1 = test_credit_card_accounts_1[0] + test_auto_loan_accounts = method.accounts.list({ 'holder_id': holder_1_response['id'], 'liability.type': 'auto_loan', - 'liability.mch_id': 'mch_2347', + 'liability.mch_id': 'mch_311130', 'status': 'active', }) test_auto_loan_account = test_auto_loan_accounts[0] @@ -86,6 +94,7 @@ def setup(): 'holder_1_response': holder_1_response, 'holder_connect_response': holder_connect_response, 'test_credit_card_account': test_credit_card_account, + 'test_credit_card_account_1': test_credit_card_account_1, 'test_auto_loan_account': test_auto_loan_account, 'phone_verification': phone_verification, 'identity_verification': identity_verification, @@ -158,6 +167,7 @@ def test_create_liability_account(setup): 'update': accounts_create_liability_response['update'], 'attribute': accounts_create_liability_response['attribute'], 'card_brand': None, + 'payment_instrument': None, 'products': accounts_create_liability_response['products'], 'restricted_products': accounts_create_liability_response['restricted_products'], 'subscriptions': accounts_create_liability_response['subscriptions'], @@ -597,13 +607,26 @@ async def test_list_account_sensitive(setup): def test_create_transaction_subscription(setup): global create_txn_subscriptions_response - test_credit_card_account = setup['test_credit_card_account'] + test_credit_card_account = setup['test_credit_card_account_1'] + + network_verification = method.accounts(test_credit_card_account['id']).verification_sessions.create({ + 'type': 'network' + }) + + method.accounts(test_credit_card_account['id']).verification_sessions.update(network_verification['id'], { + 'network': { + 'exp_month': '09', + 'exp_year': '2028', + 'billing_zip_code': '78758', + 'cvv': '539' + } + }) - create_txn_subscriptions_response = method.accounts(test_credit_card_account['id']).subscriptions.create('transactions') + create_txn_subscriptions_response = method.accounts(test_credit_card_account['id']).subscriptions.create('transaction') expect_results: AccountSubscription = { 'id': create_txn_subscriptions_response['id'], - 'name': 'transactions', + 'name': 'transaction', 'status': 'active', 'latest_request_id': None, 'created_at': create_txn_subscriptions_response['created_at'], @@ -651,20 +674,14 @@ def test_create_snapshot_subscription(setup): def test_list_subscriptions(setup): test_credit_card_account = setup['test_credit_card_account'] + test_credit_card_account_1 = setup['test_credit_card_account_1'] test_auto_loan_account = setup['test_auto_loan_account'] subscriptions_list_response = method.accounts(test_credit_card_account['id']).subscriptions.list() + subscriptions_transaction_list_response = method.accounts(test_credit_card_account_1['id']).subscriptions.list() subscriptions_update_snapshot_list_response = method.accounts(test_auto_loan_account['id']).subscriptions.list() expect_results_card: AccountSubscriptionsResponse = { - 'transactions': { - 'id': create_txn_subscriptions_response['id'], - 'name': 'transactions', - 'status': 'active', - 'latest_request_id': None, - 'created_at': create_txn_subscriptions_response['created_at'], - 'updated_at': create_txn_subscriptions_response['updated_at'] - }, 'update': { 'id': create_update_subscriptions_response['id'], 'name': 'update', @@ -675,6 +692,17 @@ def test_list_subscriptions(setup): } } + expect_results_transaction: AccountSubscriptionsResponse = { + 'transaction': { + 'id': create_txn_subscriptions_response['id'], + 'name': 'transaction', + 'status': 'active', + 'latest_request_id': None, + 'created_at': create_txn_subscriptions_response['created_at'], + 'updated_at': create_txn_subscriptions_response['updated_at'] + } + } + expect_results_auto_loan: AccountSubscriptionsResponse = { 'update.snapshot': { 'id': create_update_snapshot_subscriptions_response['id'], @@ -687,20 +715,22 @@ def test_list_subscriptions(setup): } assert subscriptions_list_response == expect_results_card + assert subscriptions_transaction_list_response == expect_results_transaction assert subscriptions_update_snapshot_list_response == expect_results_auto_loan def test_retrieve_subscription(setup): test_credit_card_account = setup['test_credit_card_account'] + test_credit_card_account_1 = setup['test_credit_card_account_1'] test_auto_loan_account = setup['test_auto_loan_account'] - retrieve_txn_subscription_response = method.accounts(test_credit_card_account['id']).subscriptions.retrieve(create_txn_subscriptions_response['id']) + retrieve_txn_subscription_response = method.accounts(test_credit_card_account_1['id']).subscriptions.retrieve(create_txn_subscriptions_response['id']) retrieve_update_subscription_response = method.accounts(test_credit_card_account['id']).subscriptions.retrieve(create_update_subscriptions_response['id']) retrieve_update_snapshot_subscription_response = method.accounts(test_auto_loan_account['id']).subscriptions.retrieve(create_update_snapshot_subscriptions_response['id']) expect_results_txn: AccountSubscription = { 'id': create_txn_subscriptions_response['id'], - 'name': 'transactions', + 'name': 'transaction', 'status': 'active', 'latest_request_id': None, 'created_at': retrieve_txn_subscription_response['created_at'], @@ -750,7 +780,7 @@ def test_delete_subscription(setup): def test_list_transactions(setup): global transactions_response - test_credit_card_account = setup['test_credit_card_account'] + test_credit_card_account = setup['test_credit_card_account_1'] simulated_transaction = method.simulate.accounts(test_credit_card_account['id']).transactions.create() transactions_response = method.accounts(test_credit_card_account['id']).transactions.list() @@ -760,15 +790,19 @@ def test_list_transactions(setup): expect_results: AccountTransaction = { 'id': transactions_response['id'], 'account_id': test_credit_card_account['id'], - 'merchant': simulated_transaction['merchant'], - 'network': 'visa', - 'network_data': None, + 'status': 'posted', + 'descriptor': simulated_transaction['descriptor'], 'amount': simulated_transaction['amount'], - 'currency': 'USD', - 'billing_amount': simulated_transaction['billing_amount'], - 'billing_currency': 'USD', - 'status': 'cleared', - 'error': None, + 'auth_amount': simulated_transaction['auth_amount'], + 'currency_code': simulated_transaction['currency_code'], + 'transaction_amount': simulated_transaction['transaction_amount'], + 'transaction_auth_amount': simulated_transaction['transaction_auth_amount'], + 'transaction_currency_code': simulated_transaction['transaction_currency_code'], + 'merchant_category_code': simulated_transaction['merchant_category_code'], + 'transacted_at': simulated_transaction['transacted_at'], + 'posted_at': simulated_transaction['posted_at'], + 'voided_at': None, + 'original_txn_id': None, 'created_at': transactions_response['created_at'], 'updated_at': transactions_response['updated_at'], } @@ -1001,15 +1035,15 @@ def test_list_account_products(setup): 'created_at': account_products_list_response.get('attribute', {}).get('created_at', ''), 'updated_at': account_products_list_response.get('attribute', {}).get('updated_at', ''), }, - 'transactions': { - 'id': account_products_list_response.get('transactions', {}).get('id', ''), - 'name': 'transactions', - 'status': 'available', - 'status_error': None, - 'latest_request_id': account_products_list_response.get('transactions', {}).get('latest_request_id', None), + 'transaction': { + 'id': account_products_list_response.get('transaction', {}).get('id', ''), + 'name': 'transaction', + 'status': 'unavailable', + 'status_error': account_products_list_response.get('transaction', {}).get('status_error', None), + 'latest_request_id': account_products_list_response.get('transaction', {}).get('latest_request_id', None), 'is_subscribable': True, - 'created_at': account_products_list_response.get('transactions', {}).get('created_at', ''), - 'updated_at': account_products_list_response.get('transactions', {}).get('updated_at', ''), + 'created_at': account_products_list_response.get('transaction', {}).get('created_at', ''), + 'updated_at': account_products_list_response.get('transaction', {}).get('updated_at', ''), }, 'payoff': { 'id': account_products_list_response.get('payoff', {}).get('id', ''), @@ -1030,6 +1064,16 @@ def test_list_account_products(setup): 'is_subscribable': False, 'created_at': account_products_list_response.get('card_brand', {}).get('created_at', ''), 'updated_at': account_products_list_response.get('card_brand', {}).get('updated_at', ''), + }, + 'payment_instrument': { + 'id': account_products_list_response.get('payment_instrument', {}).get('id', ''), + 'name': 'payment_instrument', + 'status': 'restricted', + 'status_error': account_products_list_response.get('payment_instrument', {}).get('status_error', None), + 'latest_request_id': account_products_list_response.get('payment_instrument', {}).get('latest_request_id', None), + 'is_subscribable': True, + 'created_at': account_products_list_response.get('payment_instrument', {}).get('created_at', ''), + 'updated_at': account_products_list_response.get('payment_instrument', {}).get('updated_at', ''), } } @@ -1045,14 +1089,16 @@ def test_retrieve_account_product(setup): sensitive_product_id = account_products_list_response.get('sensitive', {}).get('id', '') update_product_id = account_products_list_response.get('update', {}).get('id', '') attribute_product_id = account_products_list_response.get('attribute', {}).get('id', '') - transactions_product_id = account_products_list_response.get('transactions', {}).get('id', '') + transaction_product_id = account_products_list_response.get('transaction', {}).get('id', '') + payment_instrument_product_id = account_products_list_response.get('payment_instrument', {}).get('id', '') balance_product_response = method.accounts(test_credit_card_account['id']).products.retrieve(balance_product_id) payment_product_response = method.accounts(test_credit_card_account['id']).products.retrieve(payment_product_id) sensitive_product_response = method.accounts(test_credit_card_account['id']).products.retrieve(sensitive_product_id) update_product_response = method.accounts(test_credit_card_account['id']).products.retrieve(update_product_id) attribute_product_response = method.accounts(test_credit_card_account['id']).products.retrieve(attribute_product_id) - transactions_product_response = method.accounts(test_credit_card_account['id']).products.retrieve(transactions_product_id) + transaction_product_response = method.accounts(test_credit_card_account['id']).products.retrieve(transaction_product_id) + payment_instrument_product_response = method.accounts(test_credit_card_account['id']).products.retrieve(payment_instrument_product_id) expect_balance_results: AccountProduct = { 'id': balance_product_id, @@ -1109,15 +1155,26 @@ def test_retrieve_account_product(setup): 'updated_at': attribute_product_response['updated_at'] } - expect_transactions_results: AccountProduct = { - 'id': transactions_product_id, - 'name': 'transactions', - 'status': 'available', - 'status_error': None, - 'latest_request_id': transactions_product_response['latest_request_id'], + expect_transaction_results: AccountProduct = { + 'id': transaction_product_id, + 'name': 'transaction', + 'status': 'unavailable', + 'status_error': transaction_product_response['status_error'], + 'latest_request_id': transaction_product_response['latest_request_id'], + 'is_subscribable': True, + 'created_at': transaction_product_response['created_at'], + 'updated_at': transaction_product_response['updated_at'] + } + + expect_payment_instrument_results: AccountProduct = { + 'id': payment_instrument_product_id, + 'name': 'payment_instrument', + 'status': 'restricted', + 'status_error': payment_instrument_product_response['status_error'], + 'latest_request_id': payment_instrument_product_response['latest_request_id'], 'is_subscribable': True, - 'created_at': transactions_product_response['created_at'], - 'updated_at': transactions_product_response['updated_at'] + 'created_at': payment_instrument_product_response['created_at'], + 'updated_at': payment_instrument_product_response['updated_at'] } assert balance_product_response == expect_balance_results @@ -1125,7 +1182,8 @@ def test_retrieve_account_product(setup): assert sensitive_product_response == expect_sensitive_results assert update_product_response == expect_update_results assert attribute_product_response == expect_attribute_results - assert transactions_product_response == expect_transactions_results + assert transaction_product_response == expect_transaction_results + assert payment_instrument_product_response == expect_payment_instrument_results def test_withdraw_account_consent(setup): test_credit_card_account = setup['test_credit_card_account'] diff --git a/test/resources/Event_test.py b/test/resources/Event_test.py index c97d802..cb55aa5 100644 --- a/test/resources/Event_test.py +++ b/test/resources/Event_test.py @@ -47,17 +47,17 @@ def setup(): 'credit_score_response': credit_score_response } -def test_simulate_account_closed(setup): +def test_simulate_account_opened(setup): method.simulate.events.create({ - 'type': 'account.closed', - 'account_id': setup['account_response'][0]['id'] + 'type': 'account.opened', + 'entity_id': setup['entity_response']['id'] }) max_retries = 3 for _ in range(max_retries): sleep(10) events_list_response = method.events.list({ - 'resource_id': setup['account_response'][0]['id'] + 'type': 'account.opened' }) if events_list_response and len(events_list_response) > 0: break @@ -69,9 +69,9 @@ def test_simulate_account_closed(setup): 'id': event_response['id'], 'created_at': event_response['created_at'], 'updated_at': event_response['updated_at'], - 'type': 'account.closed', - 'resource_id': setup['account_response'][0]['id'], - 'resource_type': 'account', + 'type': 'account.opened', + 'resource_id': event_response['resource_id'], + 'resource_type': event_response['resource_type'], 'data': event_response['data'], 'diff': event_response['diff'] } From 26fbc7c539e5b89d6934b23658dea7a4e5736dbd Mon Sep 17 00:00:00 2001 From: Bilal Hussain Date: Tue, 8 Apr 2025 20:41:03 -0500 Subject: [PATCH 2/2] bump version --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 3cacde7..8aeb278 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ setup( name='method-python', - version='1.1.10', + version='1.1.11', description='Python library for the Method API', long_description='Python library for the Method API', long_description_content_type='text/x-rst',