Skip to content

Tests

A Fake or multiple fakes for each stripe object.

Originally collected using API VERSION 2015-07-28. Updated to API VERSION 2016-03-07 with bogus fields.

Attributes

tests.FAKE_ACCOUNT = {'id': 'acct_1032D82eZvKYlo2C', 'object': 'account', 'business_profile': {'name': 'dj-stripe', 'support_email': 'djstripe@example.com', 'support_phone': None, 'support_url': 'https://djstripe.com/support/', 'url': 'https://djstripe.com'}, 'settings': {'branding': {'icon': 'file_4hshrsKatMEEd6736724HYAXyj', 'logo': 'file_1E3fssKatMEEd6736724HYAXyj', 'primary_color': '#092e20'}, 'dashboard': {'display_name': 'dj-stripe', 'timezone': 'Etc/UTC'}, 'payments': {'statement_descriptor': 'DJSTRIPE'}}, 'charges_enabled': True, 'country': 'US', 'default_currency': 'usd', 'details_submitted': True, 'email': 'djstripe@example.com', 'payouts_enabled': True, 'type': 'standard'} module-attribute

tests.FAKE_BALANCE_TRANSACTION = load_fixture('balance_transaction_txn_fake_ch_fakefakefakefakefake0001.json') module-attribute

tests.FAKE_BALANCE_TRANSACTION_II = {'id': 'txn_16g5h62eZvKYlo2CQ2AHA89s', 'object': 'balance_transaction', 'amount': 65400, 'available_on': 1441670400, 'created': 1441079064, 'currency': 'usd', 'description': None, 'fee': 1927, 'fee_details': [{'amount': 1927, 'currency': 'usd', 'type': 'stripe_fee', 'description': 'Stripe processing fees', 'application': None}], 'net': 63473, 'source': 'ch_16g5h62eZvKYlo2CMRXkSqa0', 'sourced_transfers': {'object': 'list', 'total_count': 0, 'has_more': False, 'url': '/v1/transfers?source_transaction=ch_16g5h62eZvKYlo2CMRXkSqa0', 'data': []}, 'status': 'pending', 'type': 'charge'} module-attribute

tests.FAKE_BALANCE_TRANSACTION_III = {'id': 'txn_16g5h62eZvKYlo2CQ2AHA89s', 'object': 'balance_transaction', 'amount': 2000, 'available_on': 1441670400, 'created': 1441079064, 'currency': 'usd', 'description': None, 'fee': 1927, 'fee_details': [{'amount': 1927, 'currency': 'usd', 'type': 'stripe_fee', 'description': 'Stripe processing fees', 'application': None}], 'net': 73, 'source': 'ch_16g5h62eZvKYlo2CMRXkSqa0', 'sourced_transfers': {'object': 'list', 'total_count': 0, 'has_more': False, 'url': '/v1/transfers?source_transaction=ch_16g5h62eZvKYlo2CMRXkSqa0', 'data': []}, 'status': 'pending', 'type': 'charge'} module-attribute

tests.FAKE_BALANCE_TRANSACTION_IV = {'id': 'txn_16g5h62eZvKYlo2CQ2AHA89s', 'object': 'balance_transaction', 'amount': 19010, 'available_on': 1441670400, 'created': 1441079064, 'currency': 'usd', 'description': None, 'fee': 1927, 'fee_details': [{'amount': 1927, 'currency': 'usd', 'type': 'stripe_fee', 'description': 'Stripe processing fees', 'application': None}], 'net': 17083, 'source': 'ch_16g5h62eZvKYlo2CMRXkSqa0', 'sourced_transfers': {'object': 'list', 'total_count': 0, 'has_more': False, 'url': '/v1/transfers?source_transaction=ch_16g5h62eZvKYlo2CMRXkSqa0', 'data': []}, 'status': 'pending', 'type': 'charge'} module-attribute

tests.FAKE_BALANCE_TRANSACTION_REFUND = {'id': 'txn_1E0he8KaGRDEd998TDswMZuN', 'amount': -1 * FAKE_CHARGE_REFUNDED['amount_refunded'], 'available_on': 1549425864, 'created': 1549425864, 'currency': 'usd', 'description': 'REFUND FOR CHARGE (Payment for invoice G432DF1C-0028)', 'exchange_rate': None, 'fee': 0, 'fee_details': [], 'net': -1 * FAKE_CHARGE_REFUNDED['amount_refunded'], 'object': 'balance_transaction', 'source': FAKE_REFUND['id'], 'status': 'available', 'type': 'refund'} module-attribute

tests.FAKE_BANK_ACCOUNT = {'id': 'ba_16hTzo2eZvKYlo2CeSjfb0tS', 'object': 'bank_account', 'account_holder_name': None, 'account_holder_type': None, 'bank_name': 'STRIPE TEST BANK', 'country': 'US', 'currency': 'usd', 'fingerprint': '1JWtPxqbdX5Gamtc', 'last4': '6789', 'routing_number': '110000000', 'status': 'new'} module-attribute

tests.FAKE_BANK_ACCOUNT_II = {'id': 'ba_17O4Tz2eZvKYlo2CMYsxroV5', 'object': 'bank_account', 'account_holder_name': None, 'account_holder_type': None, 'bank_name': None, 'country': 'US', 'currency': 'usd', 'fingerprint': '1JWtPxqbdX5Gamtc', 'last4': '6789', 'routing_number': '110000000', 'status': 'new'} module-attribute

tests.FAKE_BANK_ACCOUNT_IV = BankAccountDict(load_fixture('bank_account_ba_fakefakefakefakefake0004.json')) module-attribute

tests.FAKE_BANK_ACCOUNT_SOURCE = BankAccountDict(load_fixture('bank_account_ba_fakefakefakefakefake0003.json')) module-attribute

tests.FAKE_CARD = CardDict(load_fixture('card_card_fakefakefakefakefake0001.json')) module-attribute

tests.FAKE_CARD_AS_PAYMENT_METHOD = PaymentMethodDict(load_fixture('payment_method_card_fakefakefakefakefake0001.json')) module-attribute

tests.FAKE_CARD_II = CardDict(load_fixture('card_card_fakefakefakefakefake0002.json')) module-attribute

tests.FAKE_CARD_III = CardDict(load_fixture('card_card_fakefakefakefakefake0003.json')) module-attribute

tests.FAKE_CARD_IV = CardDict(load_fixture('card_card_fakefakefakefakefake0004.json')) module-attribute

tests.FAKE_CHARGE = ChargeDict(load_fixture('charge_ch_fakefakefakefakefake0001.json')) module-attribute

tests.FAKE_CHARGE_II = ChargeDict({'id': 'ch_16ag432eZvKYlo2CGDe6lvVs', 'object': 'charge', 'amount': 3000, 'amount_captured': 0, 'amount_refunded': 0, 'application_fee': None, 'application_fee_amount': None, 'balance_transaction': FAKE_BALANCE_TRANSACTION['id'], 'billing_details': {'address': {'city': None, 'country': 'US', 'line1': None, 'line2': None, 'postal_code': '92082', 'state': None}, 'email': 'kyoung@hotmail.com', 'name': 'John Foo', 'phone': None}, 'calculated_statement_descriptor': 'Stripe', 'captured': False, 'created': 1439788903, 'currency': 'usd', 'customer': 'cus_4UbFSo9tl62jqj', 'description': None, 'destination': None, 'dispute': None, 'disputed': False, 'failure_code': 'expired_card', 'failure_message': 'Your card has expired.', 'fraud_details': {}, 'invoice': 'in_16af5A2eZvKYlo2CJjANLL81', 'livemode': False, 'metadata': {}, 'on_behalf_of': None, 'order': None, 'outcome': {'network_status': 'declined_by_network', 'reason': 'expired_card', 'risk_level': 'normal', 'risk_score': 1, 'seller_message': 'The bank returned the decline code `expired_card`.', 'type': 'issuer_declined'}, 'paid': False, 'payment_intent': FAKE_PAYMENT_INTENT_II['id'], 'payment_method': FAKE_CARD_AS_PAYMENT_METHOD['id'], 'payment_method_details': {'card': {'brand': 'visa', 'checks': {'address_line1_check': None, 'address_postal_code_check': None, 'cvc_check': None}, 'country': 'US', 'exp_month': 6, 'exp_year': 2021, 'fingerprint': '88PuXw9tEmvYe69o', 'funding': 'credit', 'installments': None, 'last4': '4242', 'network': 'visa', 'three_d_secure': None, 'wallet': None}, 'type': 'card'}, 'receipt_email': None, 'receipt_number': None, 'receipt_url': None, 'refunded': False, 'refunds': {'object': 'list', 'total_count': 0, 'has_more': False, 'url': '/v1/charges/ch_16ag432eZvKYlo2CGDe6lvVs/refunds', 'data': []}, 'review': None, 'shipping': None, 'source': deepcopy(FAKE_CARD_II), 'source_transfer': None, 'statement_descriptor': None, 'statement_descriptor_suffix': None, 'status': 'failed', 'transfer_data': None, 'transfer_group': None}) module-attribute

tests.FAKE_CHARGE_REFUNDED = FAKE_CHARGE_REFUNDED.refund(amount=FAKE_CHARGE_REFUNDED['amount']) module-attribute

tests.FAKE_COUPON = {'id': 'fake-coupon-1', 'object': 'coupon', 'applies_to': {'products': ['prod_fake1']}, 'amount_off': None, 'created': 1490157071, 'currency': None, 'duration': 'once', 'duration_in_months': None, 'livemode': False, 'max_redemptions': None, 'metadata': {}, 'percent_off': 1, 'redeem_by': None, 'times_redeemed': 0, 'valid': True} module-attribute

tests.FAKE_CUSTOMER = CustomerDict(load_fixture('customer_cus_6lsBvm5rJ0zyHc.json')) module-attribute

tests.FAKE_CUSTOMER_II = CustomerDict(load_fixture('customer_cus_4UbFSo9tl62jqj.json')) module-attribute

tests.FAKE_CUSTOMER_III = CustomerDict(load_fixture('customer_cus_4QWKsZuuTHcs7X.json')) module-attribute

tests.FAKE_CUSTOMER_IV = CustomerDict(load_fixture('customer_cus_example_with_bank_account.json')) module-attribute

tests.FAKE_CUSTOM_ACCOUNT = AccountDict(load_fixture('account_custom_acct_1IuHosQveW0ONQsd.json')) module-attribute

tests.FAKE_DISCOUNT = {'id': 'di_fakefakefakefakefake0001', 'object': 'discount', 'description': '', 'checkout_session': None, 'coupon': deepcopy(FAKE_COUPON), 'customer': FAKE_CUSTOMER, 'end': None, 'invoice': None, 'invoice_item': None, 'promotion_code': '', 'start': 1493206114, 'subscription': 'sub_fakefakefakefakefake0001'} module-attribute

tests.FAKE_DISCOUNT_CUSTOMER = {'id': 'di_fakefakefakefakefake0002', 'object': 'discount', 'coupon': deepcopy(FAKE_COUPON), 'customer': deepcopy(FAKE_CUSTOMER), 'start': 1493206114, 'end': None, 'subscription': None} module-attribute

tests.FAKE_DISPUTE_BALANCE_TRANSACTION = load_fixture('dispute_txn_fakefakefakefake01.json') module-attribute

tests.FAKE_DISPUTE_BALANCE_TRANSACTION_REFUND_FULL = deepcopy(FAKE_DISPUTE_BALANCE_TRANSACTION) module-attribute

tests.FAKE_DISPUTE_BALANCE_TRANSACTION_REFUND_PARTIAL = deepcopy(FAKE_DISPUTE_BALANCE_TRANSACTION) module-attribute

tests.FAKE_DISPUTE_CHARGE = load_fixture('dispute_ch_fakefakefakefake01.json') module-attribute

tests.FAKE_DISPUTE_I = load_fixture('dispute_dp_fakefakefakefake01.json') module-attribute

tests.FAKE_DISPUTE_II = load_fixture('dispute_dp_fakefakefakefake02.json') module-attribute

tests.FAKE_DISPUTE_III = deepcopy(FAKE_DISPUTE_II) module-attribute

tests.FAKE_DISPUTE_IV = deepcopy(FAKE_DISPUTE_II) module-attribute

tests.FAKE_DISPUTE_PAYMENT_INTENT = load_fixture('dispute_pi_fakefakefakefake01.json') module-attribute

tests.FAKE_DISPUTE_PAYMENT_METHOD = load_fixture('dispute_pm_fakefakefakefake01.json') module-attribute

tests.FAKE_DISPUTE_V_FULL = load_fixture('dispute_dp_funds_reinstated_full.json') module-attribute

tests.FAKE_DISPUTE_V_PARTIAL = load_fixture('dispute_dp_funds_reinstated_full.json') module-attribute

tests.FAKE_EVENT_ACCOUNT_APPLICATION_AUTHORIZED = dict(load_fixture('event_account_application_authorized.json')) module-attribute

tests.FAKE_EVENT_ACCOUNT_APPLICATION_DEAUTHORIZED = dict(load_fixture('event_account_application_deauthorized.json')) module-attribute

tests.FAKE_EVENT_ACCOUNT_EXTERNAL_ACCOUNT_BANK_ACCOUNT_CREATED = dict(load_fixture('event_external_account_bank_account_created.json')) module-attribute

tests.FAKE_EVENT_ACCOUNT_EXTERNAL_ACCOUNT_BANK_ACCOUNT_DELETED = dict(load_fixture('event_external_account_bank_account_deleted.json')) module-attribute

tests.FAKE_EVENT_ACCOUNT_EXTERNAL_ACCOUNT_BANK_ACCOUNT_UPDATED = dict(load_fixture('event_external_account_bank_account_updated.json')) module-attribute

tests.FAKE_EVENT_ACCOUNT_EXTERNAL_ACCOUNT_CARD_CREATED = dict(load_fixture('event_external_account_card_created.json')) module-attribute

tests.FAKE_EVENT_ACCOUNT_EXTERNAL_ACCOUNT_CARD_DELETED = dict(load_fixture('event_external_account_card_deleted.json')) module-attribute

tests.FAKE_EVENT_ACCOUNT_EXTERNAL_ACCOUNT_CARD_UPDATED = dict(load_fixture('event_external_account_card_updated.json')) module-attribute

tests.FAKE_EVENT_CARD_PAYMENT_METHOD_ATTACHED = {'id': 'evt_1FDOwDKatMEEd998o5Fghgfh', 'object': 'event', 'api_version': '2019-08-14', 'created': 1567228549, 'data': {'object': deepcopy(FAKE_CARD_AS_PAYMENT_METHOD)}, 'livemode': False, 'pending_webhooks': 0, 'request': {'id': 'req_9c9djVqxUhgfh', 'idempotency_key': None}, 'type': 'payment_method.attached'} module-attribute

tests.FAKE_EVENT_CARD_PAYMENT_METHOD_DETACHED = {'id': 'evt_1FDOwDKatMEEd998o5435345', 'object': 'event', 'api_version': '2019-08-14', 'created': 1567228549, 'data': {'object': deepcopy(FAKE_CARD_AS_PAYMENT_METHOD)}, 'livemode': False, 'pending_webhooks': 0, 'request': {'id': 'req_9c9djVqx6tgeg', 'idempotency_key': None}, 'type': 'payment_method.detached'} module-attribute

tests.FAKE_EVENT_CHARGE_SUCCEEDED = {'id': 'evt_16YKQi2eZvKYlo2CT2oe5ff3', 'object': 'event', 'api_version': '2016-03-07', 'created': 1439229084, 'data': {'object': deepcopy(FAKE_CHARGE)}, 'livemode': False, 'pending_webhooks': 0, 'request': 'req_6lsB7hkicwhaDj', 'type': 'charge.succeeded'} module-attribute

tests.FAKE_EVENT_CUSTOMER_CREATED = {'id': 'evt_38DHch3whaDvKYlo2CT2oe5ff3', 'object': 'event', 'api_version': '2016-03-07; orders_beta=v3', 'created': 1439229084, 'data': {'object': deepcopy(FAKE_CUSTOMER)}, 'livemode': False, 'pending_webhooks': 0, 'request': 'req_6l38DHch3whaDj', 'type': 'customer.created'} module-attribute

tests.FAKE_EVENT_CUSTOMER_DELETED = deepcopy(FAKE_EVENT_CUSTOMER_CREATED) module-attribute

tests.FAKE_EVENT_CUSTOMER_DISCOUNT_CREATED = {'id': 'AGBWvF5zBm4sMCsLLPZrw9YY', 'object': 'event', 'api_version': '2018-05-21', 'created': 1439229084, 'data': {'object': deepcopy(FAKE_DISCOUNT_CUSTOMER)}, 'livemode': False, 'pending_webhooks': 0, 'request': 'req_6l38DHch3whaDj', 'type': 'customer.discount.created'} module-attribute

tests.FAKE_EVENT_CUSTOMER_DISCOUNT_DELETED = {'id': 'AGBWvF5zBm4sMCsLLPZrw9XX', 'type': 'customer.discount.deleted', 'api_version': '2017-02-14', 'created': 1439229084, 'object': 'event', 'livemode': False, 'pending_webhooks': 0, 'request': 'req_6l38DHch3whaDj', 'data': {'object': deepcopy(FAKE_DISCOUNT_CUSTOMER)}} module-attribute

tests.FAKE_EVENT_CUSTOMER_SOURCE_CREATED = {'id': 'evt_DvKYlo38huDvKYlo2C7SXedrZk', 'object': 'event', 'api_version': '2016-03-07', 'created': 1439229084, 'data': {'object': deepcopy(FAKE_CARD)}, 'livemode': False, 'pending_webhooks': 0, 'request': 'req_o3whaDvh3whaDj', 'type': 'customer.source.created'} module-attribute

tests.FAKE_EVENT_CUSTOMER_SOURCE_DELETED = deepcopy(FAKE_EVENT_CUSTOMER_SOURCE_CREATED) module-attribute

tests.FAKE_EVENT_CUSTOMER_SOURCE_DELETED_DUPE = deepcopy(FAKE_EVENT_CUSTOMER_SOURCE_DELETED) module-attribute

tests.FAKE_EVENT_CUSTOMER_SUBSCRIPTION_CREATED = {'id': 'evt_38DHch3wHD2eZvKYlCT2oe5ff3', 'object': 'event', 'api_version': '2016-03-07', 'created': 1439229084, 'data': {'object': deepcopy(FAKE_SUBSCRIPTION)}, 'livemode': False, 'pending_webhooks': 0, 'request': 'req_6l87IHch3diaDj', 'type': 'customer.subscription.created'} module-attribute

tests.FAKE_EVENT_CUSTOMER_SUBSCRIPTION_DELETED = deepcopy(FAKE_EVENT_CUSTOMER_SUBSCRIPTION_CREATED) module-attribute

tests.FAKE_EVENT_CUSTOMER_UPDATED = deepcopy(FAKE_EVENT_CUSTOMER_CREATED) module-attribute

tests.FAKE_EVENT_CUSTOM_ACCOUNT_UPDATED = dict(load_fixture('event_account_updated_custom.json')) module-attribute

tests.FAKE_EVENT_DISPUTE_CLOSED = {'id': 'evt_1JAyTxJSZQVUcJYgNk1Jqu8o', 'object': 'event', 'api_version': '2020-08-27', 'created': 1439229084, 'data': {'object': deepcopy(FAKE_DISPUTE_IV)}, 'livemode': False, 'pending_webhooks': 0, 'request': 'req_6lsB7hkicwhaDj', 'type': 'charge.dispute.closed'} module-attribute

tests.FAKE_EVENT_DISPUTE_CREATED = {'id': 'evt_16YKQi2eZvKYlo2CT2oe5ff3', 'object': 'event', 'api_version': '2017-08-15', 'created': 1439229084, 'data': {'object': deepcopy(FAKE_DISPUTE_I)}, 'livemode': False, 'pending_webhooks': 0, 'request': 'req_6lsB7hkicwhaDj', 'type': 'charge.dispute.created'} module-attribute

tests.FAKE_EVENT_DISPUTE_FUNDS_REINSTATED_FULL = {'id': 'evt_1JAyTxJSZQVUcJYgNk1Jqu8o', 'object': 'event', 'api_version': '2020-08-27', 'created': 1439229084, 'data': {'object': deepcopy(FAKE_DISPUTE_V_FULL)}, 'livemode': False, 'pending_webhooks': 0, 'request': 'req_6lsB7hkicwhaDj', 'type': 'charge.dispute.funds_reinstated'} module-attribute

tests.FAKE_EVENT_DISPUTE_FUNDS_REINSTATED_PARTIAL = {'id': 'evt_1JAyTxJSZQVUcJYgNk1Jqu8o', 'object': 'event', 'api_version': '2020-08-27', 'created': 1439229084, 'data': {'object': deepcopy(FAKE_DISPUTE_V_PARTIAL)}, 'livemode': False, 'pending_webhooks': 0, 'request': 'req_6lsB7hkicwhaDj', 'type': 'charge.dispute.funds_reinstated'} module-attribute

tests.FAKE_EVENT_DISPUTE_FUNDS_WITHDRAWN = {'id': 'evt_1JAyTxJSZQVUcJYgNk1Jqu8o', 'object': 'event', 'api_version': '2020-08-27', 'created': 1439229084, 'data': {'object': deepcopy(FAKE_DISPUTE_II)}, 'livemode': False, 'pending_webhooks': 0, 'request': 'req_6lsB7hkicwhaDj', 'type': 'charge.dispute.funds_withdrawn'} module-attribute

tests.FAKE_EVENT_DISPUTE_UPDATED = {'id': 'evt_1JAyTxJSZQVUcJYgNk1Jqu8o', 'object': 'event', 'api_version': '2020-08-27', 'created': 1439229084, 'data': {'object': deepcopy(FAKE_DISPUTE_III)}, 'livemode': False, 'pending_webhooks': 0, 'request': 'req_6lsB7hkicwhaDj', 'type': 'charge.dispute.funds_withdrawn'} module-attribute

tests.FAKE_EVENT_EXPRESS_ACCOUNT_UPDATED = dict(load_fixture('event_account_updated_express.json')) module-attribute

tests.FAKE_EVENT_FILE_CREATED = {'id': 'evt_1J5TusR44xKqawmIQVXSrGyf', 'object': 'event', 'api_version': '2020-08-27', 'created': 1439229084, 'data': {'object': deepcopy(FAKE_FILEUPLOAD_ICON)}, 'livemode': False, 'pending_webhooks': 0, 'request': 'req_sTSstDDIOpKi2w', 'type': 'file.created'} module-attribute

tests.FAKE_EVENT_INVOICEITEM_CREATED = {'id': 'evt_187IHD2eZvKYlo2C7SXedrZk', 'object': 'event', 'api_version': '2016-03-07', 'created': 1462338623, 'data': {'object': deepcopy(FAKE_INVOICEITEM)}, 'livemode': False, 'pending_webhooks': 0, 'request': 'req_8O4Qbs2EDobDVT', 'type': 'invoiceitem.created'} module-attribute

tests.FAKE_EVENT_INVOICEITEM_DELETED = deepcopy(FAKE_EVENT_INVOICEITEM_CREATED) module-attribute

tests.FAKE_EVENT_INVOICE_CREATED = {'id': 'evt_187IHD2eZvKYlo2C6YKQi2eZ', 'object': 'event', 'api_version': '2016-03-07', 'created': 1462338623, 'data': {'object': deepcopy(FAKE_INVOICE)}, 'livemode': False, 'pending_webhooks': 0, 'request': 'req_8O4sB7hkDobVT', 'type': 'invoice.created'} module-attribute

tests.FAKE_EVENT_INVOICE_DELETED = deepcopy(FAKE_EVENT_INVOICE_CREATED) module-attribute

tests.FAKE_EVENT_INVOICE_UPCOMING = {'id': 'evt_187IHD2eZvKYlo2C6YKQi2bc', 'object': 'event', 'api_version': '2017-02-14', 'created': 1501859641, 'data': {'object': deepcopy(FAKE_INVOICE)}, 'livemode': False, 'pending_webhooks': 0, 'request': 'req_8O4sB7hkDobZA', 'type': 'invoice.upcoming'} module-attribute

tests.FAKE_EVENT_ORDER_CANCELLED = deepcopy(FAKE_EVENT_ORDER_UPDATED) module-attribute

tests.FAKE_EVENT_ORDER_COMPLETED = deepcopy(FAKE_EVENT_ORDER_UPDATED) module-attribute

tests.FAKE_EVENT_ORDER_CREATED = {'id': 'evt_16igNU2eZvKYlo2CYyMkYvet', 'object': 'event', 'api_version': '2016-03-07', 'created': 1441696732, 'data': {'object': deepcopy(FAKE_ORDER_WITH_CUSTOMER_WITHOUT_PAYMENT_INTENT)}, 'livemode': False, 'pending_webhooks': 0, 'request': 'req_6wZW9MskhYU15Y', 'type': 'order.created'} module-attribute

tests.FAKE_EVENT_ORDER_PROCESSING = deepcopy(FAKE_EVENT_ORDER_UPDATED) module-attribute

tests.FAKE_EVENT_ORDER_SUBMITTED = deepcopy(FAKE_EVENT_ORDER_UPDATED) module-attribute

tests.FAKE_EVENT_ORDER_UPDATED = {'id': 'evt_16igNU2eZvKYlo2CYyMkYvet', 'object': 'event', 'api_version': '2016-03-07', 'created': 1441696732, 'data': {'object': deepcopy(FAKE_ORDER_WITH_CUSTOMER_WITH_PAYMENT_INTENT)}, 'livemode': False, 'pending_webhooks': 0, 'request': 'req_6wZW9MskhYU15Y', 'type': 'order.created'} module-attribute

tests.FAKE_EVENT_PAYMENT_INTENT_SUCCEEDED_DESTINATION_CHARGE = {'id': 'evt_1FG74XB7kbjcJ8Qq22i2BPdt', 'object': 'event', 'api_version': '2019-05-16', 'created': 1567874857, 'data': {'object': deepcopy(FAKE_PAYMENT_INTENT_DESTINATION_CHARGE)}, 'livemode': False, 'pending_webhooks': 1, 'request': {'id': 'req_AJAmnJE4eiPIzb', 'idempotency_key': None}, 'type': 'payment_intent.succeeded'} module-attribute

tests.FAKE_EVENT_PAYMENT_METHOD_ATTACHED = {'id': 'evt_1FDOwDKatMEEd998o5FyxxAB', 'object': 'event', 'api_version': '2019-08-14', 'created': 1567228549, 'data': {'object': deepcopy(FAKE_PAYMENT_METHOD_I)}, 'livemode': False, 'pending_webhooks': 0, 'request': {'id': 'req_9c9djVqxUZIKNr', 'idempotency_key': None}, 'type': 'payment_method.attached'} module-attribute

tests.FAKE_EVENT_PAYMENT_METHOD_DETACHED = {'id': 'evt_1FDOwDKatMEEd998o5Fdadfds', 'object': 'event', 'api_version': '2019-08-14', 'created': 1567228549, 'data': {'object': deepcopy(FAKE_PAYMENT_METHOD_I)}, 'livemode': False, 'pending_webhooks': 0, 'request': {'id': 'req_9c9djVqxcxgdfg', 'idempotency_key': None}, 'type': 'payment_method.detached'} module-attribute

tests.FAKE_EVENT_PLAN_CREATED = {'id': 'evt_1877X72eZvKYlo2CLK6daFxu', 'object': 'event', 'api_version': '2016-03-07', 'created': 1462297325, 'data': {'object': deepcopy(FAKE_PLAN)}, 'livemode': False, 'pending_webhooks': 0, 'request': 'req_8NtJXPttxSvFyM', 'type': 'plan.created'} module-attribute

tests.FAKE_EVENT_PLAN_DELETED = deepcopy(FAKE_EVENT_PLAN_CREATED) module-attribute

tests.FAKE_EVENT_PLAN_REQUEST_IS_OBJECT = {'id': 'evt_1AcdbXXXXXXXXXXXXXXXXXXX', 'object': 'event', 'api_version': '2017-06-05', 'created': 1499361420, 'data': {'object': FAKE_PLAN, 'previous_attributes': {'name': 'Plan anual test4'}}, 'livemode': False, 'pending_webhooks': 1, 'request': {'id': 'req_AyamqQWoi5AMR2', 'idempotency_key': None}, 'type': 'plan.updated'} module-attribute

tests.FAKE_EVENT_PRICE_CREATED = {'id': 'evt_1HlZWCFz0jfFqjGsXOiPW10r', 'object': 'event', 'api_version': '2020-03-02', 'created': 1604925044, 'data': {'object': deepcopy(FAKE_PRICE)}, 'livemode': False, 'pending_webhooks': 0, 'request': {'id': 'req_Nq7dDuP0HRrqcP', 'idempotency_key': None}, 'type': 'price.created'} module-attribute

tests.FAKE_EVENT_PRICE_DELETED = deepcopy(FAKE_EVENT_PRICE_CREATED) module-attribute

tests.FAKE_EVENT_PRICE_UPDATED = {'id': 'evt_1HlZbxFz0jfFqjGsZwiHHf7h', 'object': 'event', 'api_version': '2020-03-02', 'created': 1604925401, 'data': {'object': FAKE_PRICE, 'previous_attributes': {'unit_amount': 2000, 'unit_amount_decimal': '2000'}}, 'livemode': False, 'pending_webhooks': 0, 'request': {'id': 'req_78pnxbwPMvOIwe', 'idempotency_key': None}, 'type': 'price.updated'} module-attribute

tests.FAKE_EVENT_SESSION_COMPLETED = {'id': 'evt_1JAyTxJSZQVUcJYgNk1Jqu8o', 'object': 'event', 'api_version': '2020-08-27', 'created': 1439229084, 'data': {'object': deepcopy(FAKE_SESSION_I)}, 'livemode': False, 'pending_webhooks': 0, 'request': 'req_6lsB7hkicwhaDj', 'type': 'checkout.session.completed'} module-attribute

tests.FAKE_EVENT_STANDARD_ACCOUNT_UPDATED = dict(load_fixture('event_account_updated_standard.json')) module-attribute

tests.FAKE_EVENT_SUBSCRIPTION_SCHEDULE_ABORTED = deepcopy(FAKE_EVENT_SUBSCRIPTION_SCHEDULE_CREATED) module-attribute

tests.FAKE_EVENT_SUBSCRIPTION_SCHEDULE_CANCELED = deepcopy(FAKE_EVENT_SUBSCRIPTION_SCHEDULE_CREATED) module-attribute

tests.FAKE_EVENT_SUBSCRIPTION_SCHEDULE_COMPLETED = deepcopy(FAKE_EVENT_SUBSCRIPTION_SCHEDULE_CREATED) module-attribute

tests.FAKE_EVENT_SUBSCRIPTION_SCHEDULE_CREATED = {'id': 'evt_1Hm7q6Fz0jfFqjGsJSG4N91w', 'object': 'event', 'api_version': '2020-03-02', 'created': 1605056974, 'data': {'object': deepcopy(FAKE_SUBSCRIPTION_SCHEDULE)}, 'livemode': False, 'pending_webhooks': 0, 'request': {'id': 'req_Pttj3aW5RJwees', 'idempotency_key': 'd2a77191-cc07-4c60-abab-5fb11357bd63'}, 'type': 'subscription_schedule.created'} module-attribute

tests.FAKE_EVENT_SUBSCRIPTION_SCHEDULE_EXPIRING = deepcopy(FAKE_EVENT_SUBSCRIPTION_SCHEDULE_CREATED) module-attribute

tests.FAKE_EVENT_SUBSCRIPTION_SCHEDULE_RELEASED = deepcopy(FAKE_EVENT_SUBSCRIPTION_SCHEDULE_CREATED) module-attribute

tests.FAKE_EVENT_SUBSCRIPTION_SCHEDULE_UPDATED = deepcopy(FAKE_EVENT_SUBSCRIPTION_SCHEDULE_CREATED) module-attribute

tests.FAKE_EVENT_TAX_ID_CREATED = {'id': 'evt_16YKQi2eZvKYlo2CT2oe5ff3', 'object': 'event', 'api_version': '2020-08-27', 'created': 1439229084, 'data': {'object': deepcopy(FAKE_TAX_ID)}, 'livemode': False, 'pending_webhooks': 0, 'request': 'req_ZoH080M8fny6yR', 'type': 'customer.tax_id.created'} module-attribute

tests.FAKE_EVENT_TAX_ID_DELETED = deepcopy(FAKE_EVENT_TAX_ID_UPDATED) module-attribute

tests.FAKE_EVENT_TAX_ID_UPDATED = {'id': 'evt_1J6Fy3JSZQVUcJYgnddjnMzx', 'object': 'event', 'api_version': '2020-08-27', 'created': 1439229084, 'data': {'object': deepcopy(FAKE_TAX_ID_UPDATED)}, 'livemode': False, 'pending_webhooks': 0, 'request': 'req_ZoH080M8fny6yR', 'type': 'customer.tax_id.updated'} module-attribute

tests.FAKE_EVENT_TEST_CHARGE_SUCCEEDED = deepcopy(FAKE_EVENT_CHARGE_SUCCEEDED) module-attribute

tests.FAKE_EVENT_TRANSFER_CREATED = {'id': 'evt_16igNU2eZvKYlo2CYyMkYvet', 'object': 'event', 'api_version': '2016-03-07', 'created': 1441696732, 'data': {'object': deepcopy(FAKE_TRANSFER)}, 'livemode': False, 'pending_webhooks': 0, 'request': 'req_6wZW9MskhYU15Y', 'type': 'transfer.created'} module-attribute

tests.FAKE_EVENT_TRANSFER_DELETED = deepcopy(FAKE_EVENT_TRANSFER_CREATED) module-attribute

tests.FAKE_EXPRESS_ACCOUNT = AccountDict(load_fixture('account_express_acct_1IuHosQveW0ONQsd.json')) module-attribute

tests.FAKE_FILEUPLOAD_ICON = {'created': 1550134074, 'filename': 'icon_preview.png', 'id': 'file_4hshrsKatMEEd6736724HYAXyj', 'links': {'data': [{'created': 1550134074, 'expired': False, 'expires_at': 1850134074, 'file': 'file_4hshrsKatMEEd6736724HYAXyj', 'id': 'link_4jsdgsKatMEEd673672V0JSH', 'livemode': False, 'metadata': {}, 'object': 'file_link', 'url': 'https://files.stripe.com/links/fl_test_69vG4ISDx9Chjklasrf06BJeQo'}], 'has_more': False, 'object': 'list', 'url': '/v1/file_links?file=file_4hshrsKatMEEd6736724HYAXyj'}, 'object': 'file_upload', 'purpose': 'business_logo', 'size': 6650, 'type': 'png', 'url': 'https://files.stripe.com/files/f_test_BTJFKcS7VDahgkjqw8EVNWlM'} module-attribute

tests.FAKE_INVOICE = InvoiceDict(FAKE_INVOICE) module-attribute

tests.FAKE_INVOICEITEM = {'id': 'ii_fakefakefakefakefake0001', 'object': 'invoiceitem', 'amount': 2000, 'currency': 'usd', 'customer': FAKE_CUSTOMER['id'], 'date': 1439033216, 'description': 'One-time setup fee', 'discountable': True, 'discounts': [], 'invoice': FAKE_INVOICE['id'], 'livemode': False, 'metadata': {'key1': 'value1', 'key2': 'value2'}, 'period': {'start': 1439033216, 'end': 1439033216}, 'plan': None, 'price': None, 'proration': False, 'quantity': None, 'subscription': None, 'subscription_item': None, 'tax_rates': [], 'unit_amount': 2000, 'unit_amount_decimal': '2000'} module-attribute

tests.FAKE_INVOICEITEM_II = {'id': 'ii_fakefakefakefakefake0001', 'object': 'invoiceitem', 'amount': 2000, 'currency': 'usd', 'customer': FAKE_CUSTOMER_II['id'], 'date': 1439033216, 'description': 'One-time setup fee', 'discountable': True, 'discounts': [], 'invoice': FAKE_INVOICE_II['id'], 'livemode': False, 'metadata': {'key1': 'value1', 'key2': 'value2'}, 'period': {'start': 1439033216, 'end': 1439033216}, 'plan': None, 'price': None, 'proration': False, 'quantity': None, 'subscription': None, 'subscription_item': None, 'tax_rates': [], 'unit_amount': 2000, 'unit_amount_decimal': '2000'} module-attribute

tests.FAKE_INVOICEITEM_III = {'id': 'ii_fakefakefakefakefake0001', 'object': 'invoiceitem', 'amount': 2000, 'currency': 'usd', 'customer': FAKE_CUSTOMER_II['id'], 'date': 1439033216, 'description': 'One-time setup fee', 'discountable': True, 'discounts': [], 'invoice': FAKE_INVOICE_II['id'], 'livemode': False, 'metadata': {'key1': 'value1', 'key2': 'value2'}, 'period': {'start': 1439033216, 'end': 1439033216}, 'plan': None, 'price': None, 'proration': False, 'quantity': None, 'subscription': None, 'subscription_item': None, 'tax_rates': [FAKE_TAX_RATE_EXAMPLE_1_VAT], 'unit_amount': 2000, 'unit_amount_decimal': '2000'} module-attribute

tests.FAKE_INVOICE_II = InvoiceDict({'id': 'in_16af5A2eZvKYlo2CJjANLL81', 'object': 'invoice', 'amount_due': 3000, 'amount_paid': 0, 'amount_remaining': 3000, 'application_fee_amount': None, 'attempt_count': 1, 'attempted': True, 'auto_advance': True, 'collection_method': 'charge_automatically', 'charge': FAKE_CHARGE_II['id'], 'currency': 'usd', 'customer': 'cus_4UbFSo9tl62jqj', 'created': 1439785128, 'description': None, 'discount': None, 'discounts': [], 'due_date': None, 'ending_balance': 0, 'lines': {'data': [deepcopy(FAKE_LINE_ITEM_SUBSCRIPTION)], 'total_count': 1, 'object': 'list', 'url': '/v1/invoices/in_16af5A2eZvKYlo2CJjANLL81/lines'}, 'livemode': False, 'metadata': {}, 'next_payment_attempt': 1440048103, 'number': 'XXXXXXX-0002', 'paid': False, 'period_end': 1439784771, 'period_start': 1439698371, 'receipt_number': None, 'starting_balance': 0, 'statement_descriptor': None, 'subscription': FAKE_SUBSCRIPTION_III['id'], 'subtotal': 3000, 'tax': None, 'tax_percent': None, 'total': 3000, 'webhooks_delivered_at': 1439785139}) module-attribute

tests.FAKE_INVOICE_III = InvoiceDict({'id': 'in_16Z9dP2eZvKYlo2CgFHgFx2Z', 'object': 'invoice', 'amount_due': 0, 'amount_paid': 0, 'amount_remaining': 0, 'application_fee_amount': None, 'attempt_count': 0, 'attempted': True, 'auto_advance': True, 'collection_method': 'charge_automatically', 'charge': None, 'created': 1439425915, 'currency': 'usd', 'customer': 'cus_6lsBvm5rJ0zyHc', 'description': None, 'discount': None, 'discounts': [], 'due_date': None, 'ending_balance': 20, 'lines': {'data': [deepcopy(FAKE_LINE_ITEM_SUBSCRIPTION)], 'total_count': 1, 'object': 'list', 'url': '/v1/invoices/in_16Z9dP2eZvKYlo2CgFHgFx2Z/lines'}, 'livemode': False, 'metadata': {}, 'next_payment_attempt': None, 'number': 'XXXXXXX-0003', 'paid': False, 'period_end': 1439424571, 'period_start': 1436746171, 'receipt_number': None, 'starting_balance': 0, 'statement_descriptor': None, 'subscription': FAKE_SUBSCRIPTION['id'], 'subtotal': 20, 'tax': None, 'tax_percent': None, 'total': 20, 'webhooks_delivered_at': 1439426955}) module-attribute

tests.FAKE_INVOICE_IV = InvoiceDict(load_fixture('invoice_in_fakefakefakefakefake0004.json')) module-attribute

tests.FAKE_INVOICE_METERED_SUBSCRIPTION = InvoiceDict({'id': 'in_1JGGM6JSZQVUcJYgpWqfBOIl', 'livemode': False, 'created': 1439425915, 'metadata': {}, 'description': '', 'amount_due': '1.05', 'amount_paid': '1.05', 'amount_remaining': '0.00', 'application_fee_amount': None, 'attempt_count': 1, 'attempted': True, 'auto_advance': False, 'collection_method': 'charge_automatically', 'currency': 'usd', 'customer': FAKE_CUSTOMER_II['id'], 'object': 'invoice', 'charge': None, 'discount': None, 'discounts': [], 'due_date': None, 'ending_balance': 0, 'lines': {'data': [deepcopy(FAKE_LINE_ITEM_SUBSCRIPTION)], 'total_count': 1, 'object': 'list', 'url': '/v1/invoices/in_1JGGM6JSZQVUcJYgpWqfBOIl/lines'}, 'next_payment_attempt': None, 'number': '84DE1540-0004', 'paid': True, 'period_end': 1439424571, 'period_start': 1436746171, 'receipt_number': None, 'starting_balance': 0, 'statement_descriptor': None, 'subscription': FAKE_INVOICE_METERED_SUBSCRIPTION_USAGE['id'], 'subtotal': '1.00', 'tax': None, 'tax_percent': None, 'total': '1.00', 'webhooks_delivered_at': 1439426955}) module-attribute

tests.FAKE_INVOICE_METERED_SUBSCRIPTION_USAGE = deepcopy(FAKE_SUBSCRIPTION_METERED) module-attribute

tests.FAKE_LINE_ITEM = load_fixture('line_item_il_invoice_item_fakefakefakefakefake0001.json') module-attribute

tests.FAKE_LINE_ITEM_SUBSCRIPTION = load_fixture('line_item_il_invoice_item_fakefakefakefakefake0002.json') module-attribute

tests.FAKE_ORDER_WITHOUT_CUSTOMER_WITHOUT_PAYMENT_INTENT = deepcopy(FAKE_ORDER_WITH_CUSTOMER_WITH_PAYMENT_INTENT) module-attribute

tests.FAKE_ORDER_WITHOUT_CUSTOMER_WITH_PAYMENT_INTENT = deepcopy(FAKE_ORDER_WITH_CUSTOMER_WITH_PAYMENT_INTENT) module-attribute

tests.FAKE_ORDER_WITH_CUSTOMER_WITHOUT_PAYMENT_INTENT = deepcopy(FAKE_ORDER_WITH_CUSTOMER_WITH_PAYMENT_INTENT) module-attribute

tests.FAKE_ORDER_WITH_CUSTOMER_WITH_PAYMENT_INTENT = load_fixture('order_order_fakefakefakefake0001.json') module-attribute

tests.FAKE_PAYMENT_INTENT_DESTINATION_CHARGE = load_fixture('payment_intent_pi_destination_charge.json') module-attribute

tests.FAKE_PAYMENT_INTENT_I = load_fixture('payment_intent_pi_fakefakefakefakefake0001.json') module-attribute

tests.FAKE_PAYMENT_INTENT_II = deepcopy(FAKE_PAYMENT_INTENT_I) module-attribute

tests.FAKE_PAYMENT_METHOD_I = PaymentMethodDict(load_fixture('payment_method_pm_fakefakefakefake0001.json')) module-attribute

tests.FAKE_PAYMENT_METHOD_II = deepcopy(FAKE_PAYMENT_METHOD_I) module-attribute

tests.FAKE_PAYOUT_CUSTOM_BANK_ACCOUNT = PayoutDict(load_fixture('payout_custom_bank_account.json')) module-attribute

tests.FAKE_PAYOUT_CUSTOM_CARD = PayoutDict(load_fixture('payout_custom_card.json')) module-attribute

tests.FAKE_PLAN = load_fixture('plan_gold21323.json') module-attribute

tests.FAKE_PLAN_II = load_fixture('plan_silver41294.json') module-attribute

tests.FAKE_PLAN_METERED = {'id': 'plan_fakemetered', 'billing_scheme': 'per_unit', 'object': 'plan', 'active': True, 'aggregate_usage': 'sum', 'amount': 200, 'collection_method': 'per_unit', 'created': 1552632817, 'currency': 'usd', 'interval': 'month', 'interval_count': 1, 'livemode': False, 'metadata': {}, 'nickname': 'Sum Metered Plan', 'product': FAKE_PRODUCT['id'], 'tiers': None, 'tiers_mode': None, 'transform_usage': None, 'trial_period_days': None, 'usage_type': 'metered'} module-attribute

tests.FAKE_PLATFORM_ACCOUNT = deepcopy(FAKE_STANDARD_ACCOUNT) module-attribute

tests.FAKE_PRICE = load_fixture('price_gold21323.json') module-attribute

tests.FAKE_PRICE_II = load_fixture('price_silver41294.json') module-attribute

tests.FAKE_PRICE_METERED = {'active': True, 'billing_scheme': 'per_unit', 'created': 1552632817, 'currency': 'usd', 'id': 'price_fakemetered', 'livemode': False, 'lookup_key': None, 'metadata': {}, 'nickname': 'Sum Metered Price', 'object': 'price', 'product': FAKE_PRODUCT['id'], 'recurring': {'aggregate_usage': 'sum', 'interval': 'month', 'interval_count': 1, 'trial_period_days': None, 'usage_type': 'metered'}, 'tiers_mode': None, 'transform_quantity': None, 'type': 'recurring', 'unit_amount': 200, 'unit_amount_decimal': '200'} module-attribute

tests.FAKE_PRICE_ONETIME = {'active': True, 'billing_scheme': 'per_unit', 'created': 1552632818, 'currency': 'usd', 'id': 'price_fakeonetime', 'livemode': False, 'lookup_key': None, 'metadata': {}, 'nickname': 'One-Time Price', 'object': 'price', 'product': FAKE_PRODUCT['id'], 'recurring': None, 'tiers_mode': None, 'transform_quantity': None, 'type': 'one_time', 'unit_amount': 2000, 'unit_amount_decimal': '2000'} module-attribute

tests.FAKE_PRICE_TIER = {'active': True, 'billing_scheme': 'tiered', 'created': 1386247539, 'currency': 'usd', 'id': 'price_tier21323', 'livemode': False, 'lookup_key': None, 'metadata': {}, 'nickname': 'New price name', 'object': 'price', 'product': FAKE_PRODUCT['id'], 'recurring': {'aggregate_usage': None, 'interval': 'month', 'interval_count': 1, 'trial_period_days': None, 'usage_type': 'licensed'}, 'tiers': [{'flat_amount': 4900, 'flat_amount_decimal': '4900', 'unit_amount': 1000, 'unit_amount_decimal': '1000', 'up_to': 5}, {'flat_amount': None, 'flat_amount_decimal': None, 'unit_amount': 900, 'unit_amount_decimal': '900', 'up_to': None}], 'tiers_mode': 'graduated', 'transform_quantity': None, 'type': 'recurring', 'unit_amount': None, 'unit_amount_decimal': None} module-attribute

tests.FAKE_PRODUCT = load_fixture('product_prod_fake1.json') module-attribute

tests.FAKE_REFUND = {'id': 're_1E0he8KatMEEd8456454S01Vc', 'object': 'refund', 'amount': FAKE_CHARGE_REFUNDED['amount_refunded'], 'balance_transaction': 'txn_1E0he8KaGRDEd998TDswMZuN', 'charge': FAKE_CHARGE_REFUNDED['id'], 'created': 1549425864, 'currency': 'usd', 'metadata': {}, 'reason': None, 'receipt_number': None, 'source_transfer_reversal': None, 'status': 'succeeded', 'transfer_reversal': None} module-attribute

tests.FAKE_SESSION_I = {'id': 'cs_test_OAgNmy75Td25OeREvKUs8XZ7SjMPO9qAplqHO1sBaEjOg9fYbaeMh2nA', 'object': 'checkout.session', 'amount_total': 1500, 'amount_subtotal': 1500, 'billing_address_collection': None, 'cancel_url': 'https://example.com/cancel', 'client_reference_id': None, 'currency': 'usd', 'customer': 'cus_6lsBvm5rJ0zyHc', 'customer_email': None, 'display_items': [{'amount': 1500, 'currency': 'usd', 'custom': {'description': 'Comfortable cotton t-shirt', 'images': None, 'name': 'T-shirt'}, 'quantity': 2, 'type': 'custom'}], 'livemode': False, 'locale': None, 'mode': None, 'payment_intent': FAKE_PAYMENT_INTENT_I['id'], 'payment_method_types': ['card'], 'payment_status': 'unpaid', 'setup_intent': FAKE_SETUP_INTENT_II['id'], 'shipping_address_collection': {}, 'shipping_cost': {}, 'shipping_details': {}, 'shipping_options': {}, 'status': 'open', 'submit_type': None, 'subscription': None, 'success_url': 'https://example.com/success', 'metadata': {}, 'line_tems': {}, 'url': '', 'total_details': {}} module-attribute

tests.FAKE_SETUP_INTENT_DESTINATION_CHARGE = load_fixture('setup_intent_pi_destination_charge.json') module-attribute

tests.FAKE_SETUP_INTENT_I = {'id': 'seti_fakefakefakefake0001', 'object': 'setup_intent', 'cancellation_reason': None, 'payment_method_types': ['card'], 'status': 'requires_payment_method', 'usage': 'off_session', 'payment_method': None, 'on_behalf_of': None, 'customer': None} module-attribute

tests.FAKE_SETUP_INTENT_II = {'application': None, 'cancellation_reason': None, 'client_secret': 'seti_1J0g0WJSZQVUcJYgWE2XSi1K_secret_Jdxw2mOaIEHBdE6eTsfJ2IfmamgNJaF', 'created': 1623301244, 'customer': 'cus_6lsBvm5rJ0zyHc', 'description': None, 'id': 'seti_1J0g0WJSZQVUcJYgWE2XSi1K', 'last_setup_error': None, 'latest_attempt': 'setatt_1J0g0WJSZQVUcJYgsrFgwxVh', 'livemode': False, 'mandate': None, 'metadata': {}, 'next_action': None, 'object': 'setup_intent', 'on_behalf_of': None, 'payment_method': 'pm_fakefakefakefake0001', 'payment_method_options': {'card': {'request_three_d_secure': 'automatic'}}, 'payment_method_types': ['card'], 'single_use_mandate': None, 'status': 'succeeded', 'usage': 'off_session'} module-attribute

tests.FAKE_SHIPPING_RATE = load_fixture('shipping_rate_shr_fakefakefakefakefake0001.json') module-attribute

tests.FAKE_SHIPPING_RATE_WITH_TAX_CODE = load_fixture('shipping_rate_shr_fakefakefakefakefake0002.json') module-attribute

tests.FAKE_SOURCE = SourceDict(load_fixture('source_src_fakefakefakefakefake0001.json')) module-attribute

tests.FAKE_SOURCE_II = SourceDict({'id': 'src_1DuuGjkE6hxDGaasasjdlajl', 'object': 'source', 'amount': None, 'card': {'address_line1_check': None, 'address_zip_check': 'pass', 'brand': 'Visa', 'country': 'US', 'cvc_check': 'pass', 'dynamic_last4': None, 'exp_month': 10, 'exp_year': 2029, 'fingerprint': 'TmOrYzPdAoO6YFNB', 'funding': 'credit', 'last4': '4242', 'name': None, 'three_d_secure': 'optional', 'tokenization_method': None}, 'client_secret': 'src_client_secret_ENg5dyB1KTXCAEJGJQWEf67X', 'created': 1548046215, 'currency': None, 'flow': 'none', 'livemode': False, 'metadata': {'djstripe_test_fake_id': 'src_fakefakefakefakefake0002'}, 'owner': {'address': {'city': None, 'country': None, 'line1': None, 'line2': None, 'postal_code': '90210', 'state': None}, 'email': None, 'name': None, 'phone': None, 'verified_address': None, 'verified_email': None, 'verified_name': None, 'verified_phone': None}, 'statement_descriptor': None, 'status': 'consumed', 'type': 'card', 'usage': 'reusable'}) module-attribute

tests.FAKE_SOURCE_TRANSACTION = load_fixture('sourcetransaction_srctxn_fakefakefakefakefake0001.json') module-attribute

tests.FAKE_STANDARD_ACCOUNT = AccountDict(load_fixture('account_standard_acct_1Fg9jUA3kq9o1aTc.json')) module-attribute

tests.FAKE_SUBSCRIPTION = SubscriptionDict(load_fixture('subscription_sub_fakefakefakefakefake0001.json')) module-attribute

tests.FAKE_SUBSCRIPTION_CANCELED = deepcopy(FAKE_SUBSCRIPTION) module-attribute

tests.FAKE_SUBSCRIPTION_CANCELED_AT_PERIOD_END = deepcopy(FAKE_SUBSCRIPTION) module-attribute

tests.FAKE_SUBSCRIPTION_II = SubscriptionDict(load_fixture('subscription_sub_fakefakefakefakefake0002.json')) module-attribute

tests.FAKE_SUBSCRIPTION_III = SubscriptionDict(load_fixture('subscription_sub_fakefakefakefakefake0003.json')) module-attribute

tests.FAKE_SUBSCRIPTION_ITEM = {'id': 'si_JiphMAMFxZKW8s', 'object': 'subscription_item', 'metadata': {}, 'billing_thresholds': '', 'created': 1441907581, 'plan': deepcopy(FAKE_PLAN_METERED), 'price': deepcopy(FAKE_PRICE_METERED), 'quantity': 1, 'subscription': FAKE_INVOICE_METERED_SUBSCRIPTION_USAGE['id'], 'tax_rates': []} module-attribute

tests.FAKE_SUBSCRIPTION_ITEM_METERED = {'id': 'si_JiphMAMFxZKW8s', 'object': 'subscription_item', 'metadata': {}, 'billing_thresholds': '', 'created': 1441907581, 'plan': deepcopy(FAKE_PLAN_METERED), 'price': deepcopy(FAKE_PRICE_METERED), 'quantity': 1, 'subscription': FAKE_SUBSCRIPTION_METERED['id'], 'tax_rates': []} module-attribute

tests.FAKE_SUBSCRIPTION_ITEM_MULTI_PLAN = {'id': 'si_JiphMAMFxZKW8s', 'object': 'subscription_item', 'metadata': {}, 'billing_thresholds': '', 'created': 1441907581, 'plan': deepcopy(FAKE_PLAN), 'price': deepcopy(FAKE_PRICE), 'quantity': 1, 'subscription': FAKE_SUBSCRIPTION_MULTI_PLAN['id'], 'tax_rates': []} module-attribute

tests.FAKE_SUBSCRIPTION_ITEM_TAX_RATES = {'id': 'si_JiphMAMFxZKW8s', 'object': 'subscription_item', 'metadata': {}, 'billing_thresholds': '', 'created': 1441907581, 'plan': deepcopy(FAKE_PLAN_II), 'price': deepcopy(FAKE_PRICE_II), 'quantity': 1, 'subscription': FAKE_SUBSCRIPTION_II['id'], 'tax_rates': [{'id': 'txr_fakefakefakefakefake0001', 'object': 'tax_rate', 'active': True, 'created': 1593225980, 'description': None, 'display_name': 'VAT', 'inclusive': True, 'jurisdiction': 'Example1', 'livemode': False, 'metadata': {'djstripe_test_fake_id': 'txr_fakefakefakefakefake0001'}, 'percentage': 15.0}]} module-attribute

tests.FAKE_SUBSCRIPTION_METERED = SubscriptionDict({'id': 'sub_1rn1dp7WgjMtx9', 'object': 'subscription', 'application_fee_percent': None, 'collection_method': 'charge_automatically', 'cancel_at_period_end': False, 'canceled_at': None, 'current_period_end': 1441907581, 'current_period_start': 1439229181, 'customer': 'cus_6lsBvm5rJ0zyHc', 'discount': None, 'ended_at': None, 'metadata': {'djstripe_test_fake_id': 'sub_fakefakefakefakefake0005'}, 'items': {'data': [{'created': 1441907581, 'id': 'si_UXYmKmJp6aWTw6', 'metadata': {}, 'object': 'subscription_item', 'plan': deepcopy(FAKE_PLAN_METERED), 'subscription': 'sub_1rn1dp7WgjMtx9'}]}, 'pause_collection': None, 'plan': deepcopy(FAKE_PLAN_METERED), 'quantity': 1, 'start': 1439229181, 'start_date': 1439229181, 'status': 'active', 'tax_percent': None, 'trial_end': None, 'trial_start': None}) module-attribute

tests.FAKE_SUBSCRIPTION_MULTI_PLAN = SubscriptionDict(load_fixture('subscription_sub_fakefakefakefakefake0004.json')) module-attribute

tests.FAKE_SUBSCRIPTION_NOT_PERIOD_CURRENT = deepcopy(FAKE_SUBSCRIPTION) module-attribute

tests.FAKE_SUBSCRIPTION_SCHEDULE = {'id': 'sub_sched_1Hm7q6Fz0jfFqjGs2OxOSCzD', 'object': 'subscription_schedule', 'canceled_at': None, 'completed_at': None, 'created': 1605056974, 'current_phase': {}, 'customer': 'cus_6lsBvm5rJ0zyHc', 'default_settings': {'billing_cycle_anchor': 'automatic', 'billing_thresholds': None, 'collection_method': 'charge_automatically', 'default_payment_method': None, 'default_source': None, 'invoice_settings': None, 'transfer_data': None}, 'end_behavior': 'release', 'livemode': False, 'metadata': {}, 'phases': [{'add_invoice_items': [], 'application_fee_percent': None, 'billing_cycle_anchor': None, 'billing_thresholds': None, 'collection_method': None, 'coupon': None, 'default_payment_method': None, 'default_tax_rates': [], 'end_date': 1637195591, 'invoice_settings': None, 'plans': [{'billing_thresholds': None, 'plan': FAKE_PLAN_II['id'], 'price': FAKE_PRICE_II['id'], 'quantity': None, 'tax_rates': []}], 'prorate': True, 'proration_behavior': 'create_prorations', 'start_date': 1605659591, 'tax_percent': None, 'transfer_data': None, 'trial_end': None}], 'released_at': None, 'released_subscription': None, 'renewal_interval': None, 'status': 'not_started', 'subscription': FAKE_SUBSCRIPTION['id']} module-attribute

tests.FAKE_TAX_CODE = load_fixture('tax_code_txcd_fakefakefakefakefake0001.json') module-attribute

tests.FAKE_TAX_ID = load_fixture('tax_id_txi_fakefakefakefakefake0001.json') module-attribute

tests.FAKE_TAX_ID_UPDATED = deepcopy(FAKE_TAX_ID) module-attribute

tests.FAKE_TAX_RATE_EXAMPLE_1_VAT = load_fixture('tax_rate_txr_fakefakefakefakefake0001.json') module-attribute

tests.FAKE_TAX_RATE_EXAMPLE_2_SALES = load_fixture('tax_rate_txr_fakefakefakefakefake0002.json') module-attribute

tests.FAKE_TIER_PLAN = {'id': 'tier21323', 'object': 'plan', 'active': True, 'amount': None, 'created': 1386247539, 'currency': 'usd', 'interval': 'month', 'interval_count': 1, 'livemode': False, 'metadata': {}, 'nickname': 'New plan name', 'product': FAKE_PRODUCT['id'], 'trial_period_days': None, 'usage_type': 'licensed', 'tiers_mode': 'graduated', 'tiers': [{'flat_amount': 4900, 'unit_amount': 1000, 'up_to': 5}, {'flat_amount': None, 'unit_amount': 900, 'up_to': None}]} module-attribute

tests.FAKE_TOKEN = {'id': 'tok_16YDIe2eZvKYlo2CPvqprIJd', 'object': 'token', 'card': deepcopy(FAKE_CARD), 'client_ip': None, 'created': 1439201676, 'livemode': False, 'type': 'card', 'used': False} module-attribute

tests.FAKE_TRANSFER = {'id': 'tr_16Y9BK2eZvKYlo2CR0ySu1BA', 'object': 'transfer', 'amount': 100, 'amount_reversed': 0, 'application_fee_amount': None, 'balance_transaction': deepcopy(FAKE_BALANCE_TRANSACTION_II), 'created': 1439185846, 'currency': 'usd', 'description': 'Test description - 1439185984', 'destination': FAKE_STANDARD_ACCOUNT['id'], 'destination_payment': 'py_16Y9BKFso9hLaeLueFmWAYUi', 'livemode': False, 'metadata': {}, 'recipient': None, 'reversals': {'object': 'list', 'total_count': 0, 'has_more': False, 'url': '/v1/transfers/tr_16Y9BK2eZvKYlo2CR0ySu1BA/reversals', 'data': []}, 'reversed': False, 'source_transaction': None, 'source_type': 'bank_account'} module-attribute

tests.FAKE_TRANSFER_WITH_1_REVERSAL = {'id': 'tr_16Y9BK2eZvKYlo2CR0ySu1BA', 'object': 'transfer', 'amount': 100, 'amount_reversed': 0, 'application_fee_amount': None, 'balance_transaction': deepcopy(FAKE_BALANCE_TRANSACTION_II), 'created': 1439185846, 'currency': 'usd', 'description': 'Test description - 1439185984', 'destination': FAKE_STANDARD_ACCOUNT['id'], 'destination_payment': 'py_16Y9BKFso9hLaeLueFmWAYUi', 'livemode': False, 'metadata': {}, 'recipient': None, 'reversals': {'object': 'list', 'total_count': 1, 'has_more': False, 'url': '/v1/transfers/tr_16Y9BK2eZvKYlo2CR0ySu1BA/reversals', 'data': [{'id': 'trr_1J5UlFJSZQVUcJYgb38m1OZO', 'object': 'transfer_reversal', 'amount': 20, 'balance_transaction': deepcopy(FAKE_BALANCE_TRANSACTION_II), 'created': 1624449653, 'currency': 'usd', 'destination_payment_refund': 'pyr_1J5UlFR44xKqawmIBvFa6gW9', 'metadata': {}, 'source_refund': None, 'transfer': deepcopy(FAKE_TRANSFER)}]}, 'reversed': False, 'source_transaction': None, 'source_type': 'bank_account'} module-attribute

tests.FAKE_UPCOMING_INVOICE = InvoiceDict({'id': 'in', 'object': 'invoice', 'amount_due': 2000, 'amount_paid': 0, 'amount_remaining': 2000, 'application_fee_amount': None, 'attempt_count': 1, 'attempted': False, 'collection_method': 'charge_automatically', 'charge': None, 'created': 1439218864, 'currency': 'usd', 'customer': FAKE_CUSTOMER['id'], 'description': None, 'default_tax_rates': [{'id': 'txr_fakefakefakefakefake0001', 'object': 'tax_rate', 'active': True, 'created': 1570921289, 'description': None, 'display_name': 'VAT', 'inclusive': True, 'jurisdiction': 'Example1', 'livemode': False, 'metadata': {'djstripe_test_fake_id': 'txr_fakefakefakefakefake0001'}, 'percentage': 15.0}], 'discount': None, 'discounts': [], 'due_date': None, 'ending_balance': None, 'lines': {'data': [deepcopy(FAKE_LINE_ITEM_SUBSCRIPTION)], 'total_count': 1, 'object': 'list', 'url': '/v1/invoices/in_fakefakefakefakefake0001/lines'}, 'livemode': False, 'metadata': {}, 'next_payment_attempt': 1439218689, 'number': None, 'paid': False, 'period_end': 1439218689, 'period_start': 1439132289, 'receipt_number': None, 'starting_balance': 0, 'statement_descriptor': None, 'subscription': FAKE_SUBSCRIPTION['id'], 'subtotal': 2000, 'tax': 261, 'tax_percent': None, 'total': 2000, 'total_tax_amounts': [{'amount': 261, 'inclusive': True, 'tax_rate': 'txr_fakefakefakefakefake0001'}], 'webhooks_delivered_at': 1439218870}) module-attribute

tests.FAKE_USAGE_RECORD = {'id': 'mbur_1JPJz2JSZQVUcJYgK4otTE2V', 'livemode': False, 'object': 'usage_record', 'quantity': 100, 'subscription_item': FAKE_SUBSCRIPTION_ITEM['id'], 'timestamp': 1629174774, 'action': 'increment'} module-attribute

tests.FAKE_USAGE_RECORD_SUMMARY = UsageRecordSummaryDict(load_fixture('usage_record_summary_sis_fakefakefakefakefake0001.json')) module-attribute

tests.FAKE_WEBHOOK_ENDPOINT_1 = WebhookEndpointDict(load_fixture('webhook_endpoint_fake0001.json')) module-attribute

tests.FIXTURE_DIR_PATH = Path(__file__).parent.joinpath('fixtures') module-attribute

tests.FUTURE_DATE = datetime.datetime(2100, 4, 30, tzinfo=get_timezone_utc()) module-attribute

tests.logger = logging.getLogger(__name__) module-attribute

Classes

tests.AccountDict

Bases: dict

Source code in tests/__init__.py
232
233
234
235
236
237
238
239
240
241
242
243
244
245
class AccountDict(dict):
    def save(self, idempotency_key=None):
        return self

    @property
    def external_accounts(self):
        return ExternalAccounts(
            external_account_fakes=self["external_accounts"]["data"]
        )

    def create(self):
        from djstripe.models import Account

        return Account.sync_from_stripe_data(self)

Attributes

tests.AccountDict.external_accounts property

Functions

tests.AccountDict.create()
Source code in tests/__init__.py
242
243
244
245
def create(self):
    from djstripe.models import Account

    return Account.sync_from_stripe_data(self)
tests.AccountDict.save(idempotency_key=None)
Source code in tests/__init__.py
233
234
def save(self, idempotency_key=None):
    return self

tests.AssertStripeFksMixin

Source code in tests/__init__.py
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
class AssertStripeFksMixin:
    def _get_field_str(self, field) -> str:
        if isinstance(field, models.OneToOneRel):
            if field.parent_link:
                return ""
            else:
                reverse_id_name = str(field.remote_field.foreign_related_fields[0])
                return (
                    reverse_id_name.replace("djstripe_id", field.name)
                    + " (related name)"
                )

        elif isinstance(field, models.ForeignKey):
            return str(field)

        else:
            return ""

    def assert_fks(self, obj, expected_blank_fks, processed_stripe_ids=None):
        """
        Recursively walk through fks on obj, asserting they're not-none
        :param obj:
        :param expected_blank_fks: fields that are expected to be None
        :param processed_stripe_ids: set of objects ids already processed
        :return:
        """

        if processed_stripe_ids is None:
            processed_stripe_ids = set()

        processed_stripe_ids.add(obj.id)

        for field in obj._meta.get_fields():
            field_str = self._get_field_str(field)
            if not field_str or field_str.endswith(".djstripe_owner_account"):
                continue

            try:
                field_value = getattr(obj, field.name)
            except ObjectDoesNotExist:
                field_value = None

            if field_str in expected_blank_fks:
                self.assertIsNone(field_value, field_str)
            else:
                self.assertIsNotNone(field_value, field_str)

                if field_value.id not in processed_stripe_ids:
                    # recurse into the object if it's not already been checked
                    self.assert_fks(
                        field_value, expected_blank_fks, processed_stripe_ids
                    )

                logger.warning("checked %s", field_str)

Functions

tests.AssertStripeFksMixin.assert_fks(obj, expected_blank_fks, processed_stripe_ids=None)

Recursively walk through fks on obj, asserting they're not-none :param obj: :param expected_blank_fks: fields that are expected to be None :param processed_stripe_ids: set of objects ids already processed :return:

Source code in tests/__init__.py
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
def assert_fks(self, obj, expected_blank_fks, processed_stripe_ids=None):
    """
    Recursively walk through fks on obj, asserting they're not-none
    :param obj:
    :param expected_blank_fks: fields that are expected to be None
    :param processed_stripe_ids: set of objects ids already processed
    :return:
    """

    if processed_stripe_ids is None:
        processed_stripe_ids = set()

    processed_stripe_ids.add(obj.id)

    for field in obj._meta.get_fields():
        field_str = self._get_field_str(field)
        if not field_str or field_str.endswith(".djstripe_owner_account"):
            continue

        try:
            field_value = getattr(obj, field.name)
        except ObjectDoesNotExist:
            field_value = None

        if field_str in expected_blank_fks:
            self.assertIsNone(field_value, field_str)
        else:
            self.assertIsNotNone(field_value, field_str)

            if field_value.id not in processed_stripe_ids:
                # recurse into the object if it's not already been checked
                self.assert_fks(
                    field_value, expected_blank_fks, processed_stripe_ids
                )

            logger.warning("checked %s", field_str)

tests.BankAccountDict

Bases: LegacySourceDict

Source code in tests/__init__.py
368
369
class BankAccountDict(LegacySourceDict):
    pass

tests.CardDict

Bases: LegacySourceDict

Source code in tests/__init__.py
409
410
class CardDict(LegacySourceDict):
    pass

tests.ChargeDict

Bases: StripeItem

Source code in tests/__init__.py
690
691
692
693
694
695
696
697
698
699
700
701
702
class ChargeDict(StripeItem):
    def __init__(self, *args, **kwargs):
        """Match Stripe's behavior: return a stripe iterable on `charge.refunds`."""
        super().__init__(*args, **kwargs)
        self.refunds = StripeList(self.refunds)

    def refund(self, amount=None, reason=None):
        self.update({"refunded": True, "amount_refunded": amount})
        return self

    def capture(self):
        self.update({"captured": True})
        return self

Attributes

tests.ChargeDict.refunds = StripeList(self.refunds) instance-attribute

Functions

tests.ChargeDict.__init__(*args, **kwargs)

Match Stripe's behavior: return a stripe iterable on charge.refunds.

Source code in tests/__init__.py
691
692
693
694
def __init__(self, *args, **kwargs):
    """Match Stripe's behavior: return a stripe iterable on `charge.refunds`."""
    super().__init__(*args, **kwargs)
    self.refunds = StripeList(self.refunds)
tests.ChargeDict.capture()
Source code in tests/__init__.py
700
701
702
def capture(self):
    self.update({"captured": True})
    return self
tests.ChargeDict.refund(amount=None, reason=None)
Source code in tests/__init__.py
696
697
698
def refund(self, amount=None, reason=None):
    self.update({"refunded": True, "amount_refunded": amount})
    return self

tests.CustomerDict

Bases: dict

Source code in tests/__init__.py
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
class CustomerDict(dict):
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

        self["default_source"] = convert_source_dict(self["default_source"])

        for n, d in enumerate(self["sources"].get("data", [])):
            self["sources"]["data"][n] = convert_source_dict(d)

    def save(self, idempotency_key=None):
        return self

    def delete(self):
        return self

    @property
    def sources(self):
        return Sources(card_fakes=self["sources"]["data"])

    def create_for_user(self, user):
        from djstripe.models import Customer

        stripe_customer = Customer.sync_from_stripe_data(self)
        stripe_customer.subscriber = user
        stripe_customer.save()
        return stripe_customer

Attributes

tests.CustomerDict.sources property

Functions

tests.CustomerDict.__init__(*args, **kwargs)
Source code in tests/__init__.py
1351
1352
1353
1354
1355
1356
1357
def __init__(self, *args, **kwargs):
    super().__init__(*args, **kwargs)

    self["default_source"] = convert_source_dict(self["default_source"])

    for n, d in enumerate(self["sources"].get("data", [])):
        self["sources"]["data"][n] = convert_source_dict(d)
tests.CustomerDict.create_for_user(user)
Source code in tests/__init__.py
1369
1370
1371
1372
1373
1374
1375
def create_for_user(self, user):
    from djstripe.models import Customer

    stripe_customer = Customer.sync_from_stripe_data(self)
    stripe_customer.subscriber = user
    stripe_customer.save()
    return stripe_customer
tests.CustomerDict.delete()
Source code in tests/__init__.py
1362
1363
def delete(self):
    return self
tests.CustomerDict.save(idempotency_key=None)
Source code in tests/__init__.py
1359
1360
def save(self, idempotency_key=None):
    return self

tests.ExternalAccounts

Bases: object

Source code in tests/__init__.py
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
class ExternalAccounts(object):
    def __init__(self, external_account_fakes):
        self.external_account_fakes = external_account_fakes

    def create(self, source, api_key=None):
        for fake_external_account in self.external_account_fakes:
            if fake_external_account["id"] == source:
                return fake_external_account

    def retrieve(self, id, expand=None):
        for fake_external_account in self.external_account_fakes:
            if fake_external_account["id"] == id:
                return fake_external_account

    def list(self, **kwargs):
        return StripeList(data=self.external_account_fakes)

Attributes

tests.ExternalAccounts.external_account_fakes = external_account_fakes instance-attribute

Functions

tests.ExternalAccounts.__init__(external_account_fakes)
Source code in tests/__init__.py
215
216
def __init__(self, external_account_fakes):
    self.external_account_fakes = external_account_fakes
tests.ExternalAccounts.create(source, api_key=None)
Source code in tests/__init__.py
218
219
220
221
def create(self, source, api_key=None):
    for fake_external_account in self.external_account_fakes:
        if fake_external_account["id"] == source:
            return fake_external_account
tests.ExternalAccounts.list(**kwargs)
Source code in tests/__init__.py
228
229
def list(self, **kwargs):
    return StripeList(data=self.external_account_fakes)
tests.ExternalAccounts.retrieve(id, expand=None)
Source code in tests/__init__.py
223
224
225
226
def retrieve(self, id, expand=None):
    for fake_external_account in self.external_account_fakes:
        if fake_external_account["id"] == id:
            return fake_external_account

tests.InvoiceDict

Bases: StripeItem

Source code in tests/__init__.py
1431
1432
1433
1434
1435
1436
1437
1438
class InvoiceDict(StripeItem):
    def __init__(self, *args, **kwargs):
        """Match Stripe's behavior: return a stripe iterable on `invoice.lines`."""
        super().__init__(*args, **kwargs)
        self.lines = StripeList(self.lines)

    def pay(self):
        return self

Attributes

tests.InvoiceDict.lines = StripeList(self.lines) instance-attribute

Functions

tests.InvoiceDict.__init__(*args, **kwargs)

Match Stripe's behavior: return a stripe iterable on invoice.lines.

Source code in tests/__init__.py
1432
1433
1434
1435
def __init__(self, *args, **kwargs):
    """Match Stripe's behavior: return a stripe iterable on `invoice.lines`."""
    super().__init__(*args, **kwargs)
    self.lines = StripeList(self.lines)
tests.InvoiceDict.pay()
Source code in tests/__init__.py
1437
1438
def pay(self):
    return self

tests.LegacySourceDict

Bases: dict

Source code in tests/__init__.py
363
364
365
class LegacySourceDict(dict):
    def delete(self):
        return self

Functions

tests.LegacySourceDict.delete()
Source code in tests/__init__.py
364
365
def delete(self):
    return self

tests.PaymentMethodDict

Bases: dict

Source code in tests/__init__.py
500
501
502
503
class PaymentMethodDict(dict):
    def detach(self):
        self.pop("customer")
        return self

Functions

tests.PaymentMethodDict.detach()
Source code in tests/__init__.py
501
502
503
def detach(self):
    self.pop("customer")
    return self

tests.PayoutDict

Bases: StripeItem

Source code in tests/__init__.py
1899
1900
class PayoutDict(StripeItem):
    pass

tests.SourceDict

Bases: dict

Source code in tests/__init__.py
423
424
425
426
427
class SourceDict(dict):
    def detach(self):
        self.pop("customer")
        self.update({"status": "consumed"})
        return self

Functions

tests.SourceDict.detach()
Source code in tests/__init__.py
424
425
426
427
def detach(self):
    self.pop("customer")
    self.update({"status": "consumed"})
    return self

tests.Sources

Bases: object

Source code in tests/__init__.py
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
class Sources(object):
    def __init__(self, card_fakes):
        self.card_fakes = card_fakes

    def create(self, source, api_key=None):
        for fake_card in self.card_fakes:
            if fake_card["id"] == source:
                return fake_card

    def retrieve(self, id, expand=None):
        for fake_card in self.card_fakes:
            if fake_card["id"] == id:
                return fake_card

    def list(self, **kwargs):
        return StripeList(data=self.card_fakes)

Attributes

tests.Sources.card_fakes = card_fakes instance-attribute

Functions

tests.Sources.__init__(card_fakes)
Source code in tests/__init__.py
1318
1319
def __init__(self, card_fakes):
    self.card_fakes = card_fakes
tests.Sources.create(source, api_key=None)
Source code in tests/__init__.py
1321
1322
1323
1324
def create(self, source, api_key=None):
    for fake_card in self.card_fakes:
        if fake_card["id"] == source:
            return fake_card
tests.Sources.list(**kwargs)
Source code in tests/__init__.py
1331
1332
def list(self, **kwargs):
    return StripeList(data=self.card_fakes)
tests.Sources.retrieve(id, expand=None)
Source code in tests/__init__.py
1326
1327
1328
1329
def retrieve(self, id, expand=None):
    for fake_card in self.card_fakes:
        if fake_card["id"] == id:
            return fake_card

tests.StripeItem

Bases: dict

Flexible class built to mock any generic Stripe object.

Implements object access + deletion methods to match the behavior of Stripe's library, which allows both object + dictionary access.

Has a delete method since (most) Stripe objects can be deleted.

Source code in tests/__init__.py
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
class StripeItem(dict):
    """Flexible class built to mock any generic Stripe object.

    Implements object access + deletion methods to match the behavior
    of Stripe's library, which allows both object + dictionary access.

    Has a delete method since (most) Stripe objects can be deleted.
    """

    def __getattr__(self, name):
        """Give StripeItem normal object access to match Stripe behavior."""
        if name in self:
            return self[name]
        else:
            raise AttributeError("No such attribute: " + name)

    def __setattr__(self, name, value):
        self[name] = value

    def __delattr__(self, name):
        if name in self:
            del self[name]
        else:
            raise AttributeError("No such attribute: " + name)

    def delete(self) -> bool:
        """Superficial mock that adds a deleted attribute."""
        self.deleted = True

        return self.deleted

    @classmethod
    def class_url(cls):
        return "/v1/test-items/"

    def instance_url(self):
        """Superficial mock that emulates instance_url."""
        id = self.get("id")
        base = self.class_url()
        return "%s/%s" % (base, id)

    def request(self, method, url, params) -> Dict:
        """Superficial mock that emulates request method."""
        assert method == "post"
        for key, value in params.items():
            self.__setattr__(key, value)
        return self

Functions

tests.StripeItem.__delattr__(name)
Source code in tests/__init__.py
116
117
118
119
120
def __delattr__(self, name):
    if name in self:
        del self[name]
    else:
        raise AttributeError("No such attribute: " + name)
tests.StripeItem.__getattr__(name)

Give StripeItem normal object access to match Stripe behavior.

Source code in tests/__init__.py
106
107
108
109
110
111
def __getattr__(self, name):
    """Give StripeItem normal object access to match Stripe behavior."""
    if name in self:
        return self[name]
    else:
        raise AttributeError("No such attribute: " + name)
tests.StripeItem.__setattr__(name, value)
Source code in tests/__init__.py
113
114
def __setattr__(self, name, value):
    self[name] = value
tests.StripeItem.class_url() classmethod
Source code in tests/__init__.py
128
129
130
@classmethod
def class_url(cls):
    return "/v1/test-items/"
tests.StripeItem.delete()

Superficial mock that adds a deleted attribute.

Source code in tests/__init__.py
122
123
124
125
126
def delete(self) -> bool:
    """Superficial mock that adds a deleted attribute."""
    self.deleted = True

    return self.deleted
tests.StripeItem.instance_url()

Superficial mock that emulates instance_url.

Source code in tests/__init__.py
132
133
134
135
136
def instance_url(self):
    """Superficial mock that emulates instance_url."""
    id = self.get("id")
    base = self.class_url()
    return "%s/%s" % (base, id)
tests.StripeItem.request(method, url, params)

Superficial mock that emulates request method.

Source code in tests/__init__.py
138
139
140
141
142
143
def request(self, method, url, params) -> Dict:
    """Superficial mock that emulates request method."""
    assert method == "post"
    for key, value in params.items():
        self.__setattr__(key, value)
    return self

tests.StripeList

Bases: dict

Mock a generic Stripe Iterable.

It has the relevant attributes of a stripe iterable (has_more, data).

This mock is important so we can use stripe's list method in our testing. StripeList.list() will return the StripeList.

Additionally, iterating over instances of MockStripeIterable will iterate over the data attribute, just like Stripe iterables.

Attributes:

Name Type Description
has_more

mock has_more flag. Default False.

**kwargs

all of the fields of the stripe object, generally as a dictionary.

Source code in tests/__init__.py
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
class StripeList(dict):
    """Mock a generic Stripe Iterable.

    It has the relevant attributes of a stripe iterable (has_more, data).

    This mock is important so we can use stripe's `list` method in our testing.
    StripeList.list() will return the StripeList.

    Additionally, iterating over instances of MockStripeIterable will iterate over
    the data attribute, just like Stripe iterables.

    Attributes:
        has_more: mock has_more flag. Default False.
        **kwargs: all of the fields of the stripe object, generally as a dictionary.
    """

    object = "list"
    url = "/v1/fakes"
    has_more = False

    def __getattr__(self, name):
        """Give StripeItem normal object access to match Stripe behavior."""
        if name in self:
            return self[name]
        else:
            raise AttributeError("No such attribute: " + name)

    def __setattr__(self, name, value):
        self[name] = value

    def __delattr__(self, name):
        if name in self:
            del self[name]
        else:
            raise AttributeError("No such attribute: " + name)

    def __iter__(self) -> Any:
        """Make StripeList an iterable, to match the Stripe iterable behavior."""
        self.iter_copy = self.data.copy()
        return self

    def __next__(self) -> StripeItem:
        """Define iteration for StripeList."""
        if len(self.iter_copy) > 0:
            return self.iter_copy.pop(0)
        else:
            raise StopIteration()

    def list(self, **kwargs: Any) -> "StripeList":
        """Add a list method to the StripeList which returns itself.

        list() accepts arbitrary kwargs, be careful is you expect the
        argument-accepting functionality of Stripe's list() method.
        """
        return self

    def auto_paging_iter(self) -> "StripeList":
        """Add an auto_paging_iter method to the StripeList which returns itself.

        The StripeList is an iterable, so this mimics the real behavior.
        """
        return self

    @property
    def total_count(self):
        return len(self.data)

Attributes

tests.StripeList.has_more = False class-attribute instance-attribute
tests.StripeList.object = 'list' class-attribute instance-attribute
tests.StripeList.total_count property
tests.StripeList.url = '/v1/fakes' class-attribute instance-attribute

Functions

tests.StripeList.__delattr__(name)
Source code in tests/__init__.py
176
177
178
179
180
def __delattr__(self, name):
    if name in self:
        del self[name]
    else:
        raise AttributeError("No such attribute: " + name)
tests.StripeList.__getattr__(name)

Give StripeItem normal object access to match Stripe behavior.

Source code in tests/__init__.py
166
167
168
169
170
171
def __getattr__(self, name):
    """Give StripeItem normal object access to match Stripe behavior."""
    if name in self:
        return self[name]
    else:
        raise AttributeError("No such attribute: " + name)
tests.StripeList.__iter__()

Make StripeList an iterable, to match the Stripe iterable behavior.

Source code in tests/__init__.py
182
183
184
185
def __iter__(self) -> Any:
    """Make StripeList an iterable, to match the Stripe iterable behavior."""
    self.iter_copy = self.data.copy()
    return self
tests.StripeList.__next__()

Define iteration for StripeList.

Source code in tests/__init__.py
187
188
189
190
191
192
def __next__(self) -> StripeItem:
    """Define iteration for StripeList."""
    if len(self.iter_copy) > 0:
        return self.iter_copy.pop(0)
    else:
        raise StopIteration()
tests.StripeList.__setattr__(name, value)
Source code in tests/__init__.py
173
174
def __setattr__(self, name, value):
    self[name] = value
tests.StripeList.auto_paging_iter()

Add an auto_paging_iter method to the StripeList which returns itself.

The StripeList is an iterable, so this mimics the real behavior.

Source code in tests/__init__.py
202
203
204
205
206
207
def auto_paging_iter(self) -> "StripeList":
    """Add an auto_paging_iter method to the StripeList which returns itself.

    The StripeList is an iterable, so this mimics the real behavior.
    """
    return self
tests.StripeList.list(**kwargs)

Add a list method to the StripeList which returns itself.

list() accepts arbitrary kwargs, be careful is you expect the argument-accepting functionality of Stripe's list() method.

Source code in tests/__init__.py
194
195
196
197
198
199
200
def list(self, **kwargs: Any) -> "StripeList":
    """Add a list method to the StripeList which returns itself.

    list() accepts arbitrary kwargs, be careful is you expect the
    argument-accepting functionality of Stripe's list() method.
    """
    return self

tests.SubscriptionDict

Bases: StripeItem

Source code in tests/__init__.py
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
class SubscriptionDict(StripeItem):
    def __init__(self, *args, **kwargs):
        """Match Stripe's behavior: return a stripe iterable on `subscription.items`."""
        super().__init__(*args, **kwargs)
        self["items"] = StripeList(self["items"])

    def __setattr__(self, name, value):
        if type(value) == datetime.datetime:
            value = datetime_to_unix(value)

        # Special case for price and plan
        if name == "price":
            for price in [
                FAKE_PRICE,
                FAKE_PRICE_II,
                FAKE_PRICE_TIER,
                FAKE_PRICE_METERED,
            ]:
                if value == price["id"]:
                    value = price
        elif name == "plan":
            for plan in [FAKE_PLAN, FAKE_PLAN_II, FAKE_TIER_PLAN, FAKE_PLAN_METERED]:
                if value == plan["id"]:
                    value = plan

        self[name] = value

    def delete(self, **kwargs):
        if "at_period_end" in kwargs:
            self["cancel_at_period_end"] = kwargs["at_period_end"]

        return self

    def save(self, idempotency_key=None):
        return self

Functions

tests.SubscriptionDict.__init__(*args, **kwargs)

Match Stripe's behavior: return a stripe iterable on subscription.items.

Source code in tests/__init__.py
1093
1094
1095
1096
def __init__(self, *args, **kwargs):
    """Match Stripe's behavior: return a stripe iterable on `subscription.items`."""
    super().__init__(*args, **kwargs)
    self["items"] = StripeList(self["items"])
tests.SubscriptionDict.__setattr__(name, value)
Source code in tests/__init__.py
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
def __setattr__(self, name, value):
    if type(value) == datetime.datetime:
        value = datetime_to_unix(value)

    # Special case for price and plan
    if name == "price":
        for price in [
            FAKE_PRICE,
            FAKE_PRICE_II,
            FAKE_PRICE_TIER,
            FAKE_PRICE_METERED,
        ]:
            if value == price["id"]:
                value = price
    elif name == "plan":
        for plan in [FAKE_PLAN, FAKE_PLAN_II, FAKE_TIER_PLAN, FAKE_PLAN_METERED]:
            if value == plan["id"]:
                value = plan

    self[name] = value
tests.SubscriptionDict.delete(**kwargs)
Source code in tests/__init__.py
1119
1120
1121
1122
1123
def delete(self, **kwargs):
    if "at_period_end" in kwargs:
        self["cancel_at_period_end"] = kwargs["at_period_end"]

    return self
tests.SubscriptionDict.save(idempotency_key=None)
Source code in tests/__init__.py
1125
1126
def save(self, idempotency_key=None):
    return self

tests.UsageRecordSummaryDict

Bases: StripeItem

Source code in tests/__init__.py
1881
1882
class UsageRecordSummaryDict(StripeItem):
    pass

tests.WebhookEndpointDict

Bases: StripeItem

Source code in tests/__init__.py
1890
1891
class WebhookEndpointDict(StripeItem):
    pass

Functions

tests.convert_source_dict(data)

Source code in tests/__init__.py
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
def convert_source_dict(data):
    if data:
        source_type = data["object"]
        if source_type == "card":
            data = CardDict(data)
        elif source_type == "bank_account":
            data = BankAccountDict(data)
        elif source_type == "source":
            data = SourceDict(data)
        else:
            raise ValueError(f"Unknown source type: {source_type}")

    return data

tests.datetime_to_unix(datetime_)

Source code in tests/__init__.py
93
94
def datetime_to_unix(datetime_):
    return int(dateformat.format(datetime_, "U"))

tests.load_fixture(filename)

Source code in tests/__init__.py
88
89
90
def load_fixture(filename):
    with FIXTURE_DIR_PATH.joinpath(filename).open("r") as f:
        return json.load(f)