def test_constructor(self): attributes = { "transaction": { "id": "transaction_id", "amount": "100.00", }, "id": "123456", "currency_iso_code": "USD", "status": "open", "amount": "100.00", "received_date": date(2013, 4, 10), "reply_by_date": date(2013, 4, 10), "reason": "fraud", "transaction_ids": ["asdf", "qwer"], "date_opened": date(2013, 4, 1), "date_won": date(2013, 4, 2), "kind": "chargeback", } dispute = Dispute(attributes) self.assertEquals(dispute.id, "123456") self.assertEquals(dispute.amount, Decimal("100.00")) self.assertEquals(dispute.currency_iso_code, "USD") self.assertEquals(dispute.reason, Dispute.Reason.Fraud) self.assertEquals(dispute.status, Dispute.Status.Open) self.assertEquals(dispute.transaction_details.id, "transaction_id") self.assertEquals(dispute.transaction_details.amount, Decimal("100.00")) self.assertEquals(dispute.date_opened, date(2013, 4, 1)) self.assertEquals(dispute.date_won, date(2013, 4, 2)) self.assertEquals(dispute.kind, Dispute.Kind.Chargeback)
def __init__(self, gateway, attributes): Resource.__init__(self, gateway, attributes) if "api_error_response" in attributes["subject"]: node_wrapper = attributes["subject"]["api_error_response"] else: node_wrapper = attributes["subject"] if "subscription" in node_wrapper: self.subscription = Subscription(gateway, node_wrapper['subscription']) elif "merchant_account" in node_wrapper: self.merchant_account = MerchantAccount( gateway, node_wrapper['merchant_account']) elif "transaction" in node_wrapper: self.transaction = Transaction(gateway, node_wrapper['transaction']) elif "partner_merchant" in node_wrapper: self.partner_merchant = PartnerMerchant( gateway, node_wrapper['partner_merchant']) elif "disbursement" in node_wrapper: self.disbursement = Disbursement(gateway, node_wrapper['disbursement']) elif "dispute" in node_wrapper: self.dispute = Dispute(node_wrapper['dispute']) elif "account_updater_daily_report" in node_wrapper: self.account_updater_daily_report = AccountUpdaterDailyReport( gateway, node_wrapper['account_updater_daily_report']) if "errors" in node_wrapper: self.errors = ValidationErrorCollection(node_wrapper['errors']) self.message = node_wrapper['message']
def __init__(self, gateway, attributes): if "refund_id" in attributes.keys(): self._refund_id = attributes["refund_id"] del(attributes["refund_id"]) else: self._refund_id = None Resource.__init__(self, gateway, attributes) self.amount = Decimal(self.amount) if self.tax_amount: self.tax_amount = Decimal(self.tax_amount) if "billing" in attributes: self.billing_details = Address(gateway, attributes.pop("billing")) if "credit_card" in attributes: self.credit_card_details = CreditCard(gateway, attributes.pop("credit_card")) if "customer" in attributes: self.customer_details = Customer(gateway, attributes.pop("customer")) if "shipping" in attributes: self.shipping_details = Address(gateway, attributes.pop("shipping")) if "add_ons" in attributes: self.add_ons = [AddOn(gateway, add_on) for add_on in self.add_ons] if "discounts" in attributes: self.discounts = [Discount(gateway, discount) for discount in self.discounts] if "status_history" in attributes: self.status_history = [StatusEvent(gateway, status_event) for status_event in self.status_history] if "subscription" in attributes: self.subscription_details = SubscriptionDetails(attributes.pop("subscription")) if "descriptor" in attributes: self.descriptor = Descriptor(gateway, attributes.pop("descriptor")) if "disbursement_details" in attributes: self.disbursement_details = DisbursementDetail(attributes.pop("disbursement_details")) if "disputes" in attributes: self.disputes = [Dispute(dispute) for dispute in self.disputes]
def test_constructor_populates_new_fields(self): attributes = dict(self.attributes) del attributes["amount"] dispute = Dispute(attributes) self.assertEqual(dispute.amount_disputed, 100.0) self.assertEqual(dispute.amount_won, 0.00) self.assertEqual(dispute.case_number, "CB123456") self.assertEqual(dispute.created_at, datetime(2013, 4, 10, 10, 50, 39)) self.assertEqual(dispute.forwarded_comments, "Forwarded comments") self.assertEqual(dispute.processor_comments, "Forwarded comments") self.assertEqual(dispute.merchant_account_id, "abc123") self.assertEqual(dispute.original_dispute_id, "original_dispute_id") self.assertEqual(dispute.reason_code, "83") self.assertEqual(dispute.reason_description, "Reason code 83 description") self.assertEqual(dispute.reference_number, "123456") self.assertEqual(dispute.updated_at, datetime(2013, 4, 10, 10, 50, 39)) self.assertIsNone(dispute.evidence[0].comment) self.assertEqual(dispute.evidence[0].created_at, datetime(2013, 4, 11, 10, 50, 39)) self.assertEqual(dispute.evidence[0].id, "evidence1") self.assertIsNone(dispute.evidence[0].sent_to_processor_at) self.assertEqual(dispute.evidence[0].url, "url_of_file_evidence") self.assertEqual(dispute.evidence[1].comment, "text evidence") self.assertEqual(dispute.evidence[1].created_at, datetime(2013, 4, 11, 10, 50, 39)) self.assertEqual(dispute.evidence[1].id, "evidence2") self.assertEqual(dispute.evidence[1].sent_to_processor_at, "2009-04-11") self.assertIsNone(dispute.evidence[1].url) self.assertEqual(dispute.status_history[0].disbursement_date, "2013-04-11") self.assertEqual(dispute.status_history[0].effective_date, "2013-04-10") self.assertEqual(dispute.status_history[0].status, "open") self.assertEqual(dispute.status_history[0].timestamp, datetime(2013, 4, 10, 10, 50, 39))
def __init__(self, gateway, attributes): Resource.__init__(self, gateway, attributes) if "source_merchant_id" not in attributes: self.source_merchant_id = None if "api_error_response" in attributes["subject"]: node_wrapper = attributes["subject"]["api_error_response"] else: node_wrapper = attributes["subject"] if "subscription" in node_wrapper: self.subscription = Subscription(gateway, node_wrapper['subscription']) elif "merchant_account" in node_wrapper: self.merchant_account = MerchantAccount( gateway, node_wrapper['merchant_account']) elif "transaction" in node_wrapper: self.transaction = Transaction(gateway, node_wrapper['transaction']) elif "connected_merchant_status_transitioned" in node_wrapper: self.connected_merchant_status_transitioned = ConnectedMerchantStatusTransitioned( gateway, node_wrapper['connected_merchant_status_transitioned']) elif "connected_merchant_paypal_status_changed" in node_wrapper: self.connected_merchant_paypal_status_changed = ConnectedMerchantPayPalStatusChanged( gateway, node_wrapper['connected_merchant_paypal_status_changed']) elif "partner_merchant" in node_wrapper: self.partner_merchant = PartnerMerchant( gateway, node_wrapper['partner_merchant']) elif "oauth_application_revocation" in node_wrapper: self.oauth_access_revocation = OAuthAccessRevocation( node_wrapper["oauth_application_revocation"]) elif "disbursement" in node_wrapper: self.disbursement = Disbursement(gateway, node_wrapper['disbursement']) elif "dispute" in node_wrapper: self.dispute = Dispute(node_wrapper['dispute']) elif "account_updater_daily_report" in node_wrapper: self.account_updater_daily_report = AccountUpdaterDailyReport( gateway, node_wrapper['account_updater_daily_report']) elif "ideal_payment" in node_wrapper: self.ideal_payment = IdealPayment(gateway, node_wrapper['ideal_payment']) elif "granted_payment_instrument_update" in node_wrapper: self.granted_payment_instrument_update = GrantedPaymentInstrumentUpdate( gateway, node_wrapper["granted_payment_instrument_update"]) elif WebhookNotification.Kind.GrantedPaymentMethodRevoked == attributes[ "kind"]: self.revoked_payment_method_metadata = RevokedPaymentMethodMetadata( gateway, node_wrapper) elif "local_payment" in node_wrapper: self.local_payment_completed = LocalPaymentCompleted( gateway, node_wrapper["local_payment"]) if "errors" in node_wrapper: self.errors = ValidationErrorCollection(node_wrapper['errors']) self.message = node_wrapper['message']
def test_constructor_populates_transaction(self): dispute = Dispute(dict(self.attributes)) self.assertEqual(dispute.transaction.id, "transaction_id") self.assertEqual(dispute.transaction.amount, Decimal("100.00")) self.assertEqual(dispute.transaction.created_at, datetime(2013, 3, 19, 10, 50, 39)) self.assertIsNone(dispute.transaction.order_id) self.assertEqual(dispute.transaction.purchase_order_number, "po") self.assertEqual(dispute.transaction.payment_instrument_subtype, "Visa")
def __init__(self, gateway, attributes): if "refund_id" in attributes: self._refund_id = attributes["refund_id"] del(attributes["refund_id"]) else: self._refund_id = None Resource.__init__(self, gateway, attributes) self.amount = Decimal(self.amount) if self.tax_amount: self.tax_amount = Decimal(self.tax_amount) if "billing" in attributes: self.billing_details = Address(gateway, attributes.pop("billing")) if "credit_card" in attributes: self.credit_card_details = CreditCard(gateway, attributes.pop("credit_card")) if "paypal" in attributes: self.paypal_details = PayPalAccount(gateway, attributes.pop("paypal")) if "europe_bank_account" in attributes: self.europe_bank_account_details = EuropeBankAccount(gateway, attributes.pop("europe_bank_account")) if "apple_pay" in attributes: self.apple_pay_details = ApplePayCard(gateway, attributes.pop("apple_pay")) if "coinbase_account" in attributes: self.coinbase_details = CoinbaseAccount(gateway, attributes.pop("coinbase_account")) if "android_pay_card" in attributes: self.android_pay_card_details = AndroidPayCard(gateway, attributes.pop("android_pay_card")) if "customer" in attributes: self.customer_details = Customer(gateway, attributes.pop("customer")) if "shipping" in attributes: self.shipping_details = Address(gateway, attributes.pop("shipping")) if "add_ons" in attributes: self.add_ons = [AddOn(gateway, add_on) for add_on in self.add_ons] if "discounts" in attributes: self.discounts = [Discount(gateway, discount) for discount in self.discounts] if "status_history" in attributes: self.status_history = [StatusEvent(gateway, status_event) for status_event in self.status_history] if "subscription" in attributes: self.subscription_details = SubscriptionDetails(attributes.pop("subscription")) if "descriptor" in attributes: self.descriptor = Descriptor(gateway, attributes.pop("descriptor")) if "disbursement_details" in attributes: self.disbursement_details = DisbursementDetail(attributes.pop("disbursement_details")) if "disputes" in attributes: self.disputes = [Dispute(dispute) for dispute in self.disputes] if "payment_instrument_type" in attributes: self.payment_instrument_type = attributes["payment_instrument_type"] if "risk_data" in attributes: self.risk_data = RiskData(attributes["risk_data"]) else: self.risk_data = None if "three_d_secure_info" in attributes and not attributes["three_d_secure_info"] == None: self.three_d_secure_info = ThreeDSecureInfo(attributes["three_d_secure_info"]) else: self.three_d_secure_info = None
def find(self, dispute_id): try: if dispute_id is None or dispute_id.strip() == "": raise NotFoundError() response = self.config.http().get( self.config.base_merchant_path() + "/disputes/" + dispute_id) return Dispute(response["dispute"]) except NotFoundError: raise NotFoundError("dispute with id " + repr(dispute_id) + " not found")
def test_legacy_constructor(self): dispute = Dispute(dict(self.legacy_attributes)) self.assertEqual(dispute.id, "123456") self.assertEqual(dispute.amount, Decimal("100.00")) self.assertEqual(dispute.currency_iso_code, "USD") self.assertEqual(dispute.reason, Dispute.Reason.Fraud) self.assertEqual(dispute.status, Dispute.Status.Open) self.assertEqual(dispute.transaction_details.id, "transaction_id") self.assertEqual(dispute.transaction_details.amount, Decimal("100.00")) self.assertEqual(dispute.date_opened, date(2013, 4, 1)) self.assertEqual(dispute.date_won, date(2013, 4, 2)) self.assertEqual(dispute.kind, Dispute.Kind.Chargeback)
def __fetch_disputes(self, page): response = self.config.http().post( self.config.base_merchant_path() + "/disputes/advanced_search?page=" + str(page), {"search": self.search_criteria}) body = response["disputes"] disputes = [ Dispute(item) for item in ResourceCollection._extract_as_array( response["disputes"], "dispute") ] return PaginatedResult(body["total_items"], body["page_size"], disputes)
def __init__(self, gateway, attributes): Resource.__init__(self, gateway, attributes) if "api_error_response" in attributes["subject"]: node_wrapper = attributes["subject"]["api_error_response"] else: node_wrapper = attributes["subject"] if "subscription" in node_wrapper: self.subscription = Subscription(gateway, node_wrapper['subscription']) elif "merchant_account" in node_wrapper: self.merchant_account = MerchantAccount( gateway, node_wrapper['merchant_account']) elif "transaction" in node_wrapper: self.transaction = Transaction(gateway, node_wrapper['transaction']) elif "connected_merchant_status_transitioned" in node_wrapper: self.connected_merchant_status_transitioned = ConnectedMerchantStatusTransitioned( gateway, node_wrapper['connected_merchant_status_transitioned']) elif "connected_merchant_paypal_status_changed" in node_wrapper: self.connected_merchant_paypal_status_changed = ConnectedMerchantPayPalStatusChanged( gateway, node_wrapper['connected_merchant_paypal_status_changed']) elif "partner_merchant" in node_wrapper: self.partner_merchant = PartnerMerchant( gateway, node_wrapper['partner_merchant']) elif "disbursement" in node_wrapper: self.disbursement = Disbursement(gateway, node_wrapper['disbursement']) elif "dispute" in node_wrapper: self.dispute = Dispute(node_wrapper['dispute']) elif "account_updater_daily_report" in node_wrapper: self.account_updater_daily_report = AccountUpdaterDailyReport( gateway, node_wrapper['account_updater_daily_report']) elif "ideal_payment" in node_wrapper: self.ideal_payment = IdealPayment(gateway, node_wrapper['ideal_payment']) elif "granted_payment_instrument_update" in node_wrapper: self.granted_payment_instrument_update = GrantedPaymentInstrumentUpdate( gateway, node_wrapper["granted_payment_instrument_update"]) if "errors" in node_wrapper: self.errors = ValidationErrorCollection(node_wrapper['errors']) self.message = node_wrapper['message']
def test_constructor_handles_none_fields(self): attributes = dict(self.attributes) attributes.update({ "amount": None, "date_opened": None, "date_won": None, "evidence": None, "reply_by_date": None, "status_history": None }) dispute = Dispute(attributes) self.assertIsNone(dispute.reply_by_date) self.assertIsNone(dispute.amount) self.assertIsNone(dispute.date_opened) self.assertIsNone(dispute.date_won) self.assertIsNone(dispute.status_history)
def test_add_text_evidence_none_id_raises_not_found_exception(self): Dispute.add_text_evidence(None, "evidence")
def test_finalize_none_raises_not_found_exception(self): Dispute.finalize(None)
def test_add_file_evidence_none_id_raises_not_found_exception(self): Dispute.add_file_evidence(None, 1)
def test_add_text_evidence_tag_is_number_evidence_raises_value_exception( self): Dispute.add_text_evidence("dispute_id", { "content": "content", "tag": 5 })
def test_add_text_evidence_empty_evidence_raises_value_exception(self): Dispute.add_text_evidence("dispute_id", " ")
def test_accept_empty_id_raises_not_found_exception(self): Dispute.accept(" ")
def test_add_file_evidence_none_evidence_raises_value_exception(self): Dispute.add_file_evidence("dispute_id", None)
def test_add_file_evidence_empty_id_raises_not_found_exception(self): Dispute.add_file_evidence(" ", 1)
def test_add_text_evidence_category_is_number_evidence_raises_value_exception(self): Dispute.add_text_evidence("dispute_id", { "content": "content", "category": 5 })
def test_add_text_evidence_sequence_number_not_number_evidence_raises_value_exception(self): Dispute.add_text_evidence("dispute_id", { "content": "content", "sequence_number": "1abc" })
def test_remove_evidence_empty_evidence_id_raises_value_exception(self): Dispute.remove_evidence("dispute_id", " ")
def test_add_file_evidence_categorized_document_id_must_be_a_string(self): Dispute.add_file_evidence("dispute_id", { "document_id": "213", "category": 5 })
def test_accept_none_raises_not_found_exception(self): Dispute.accept(None)
def test_add_file_evidence_empty_categorized_evidence_raises_value_exception(self): Dispute.add_file_evidence("dispute_id", { "category": "DEVICE_ID" })
def test_finalize_empty_id_raises_not_found_exception(self): Dispute.finalize(" ")
def test_add_text_evidence_sequence_number_not_number_evidence_raises_value_exception( self): Dispute.add_text_evidence("dispute_id", { "content": "content", "sequence_number": "1abc" })
def __init__(self, gateway, attributes): if "refund_id" in attributes: self._refund_id = attributes["refund_id"] del (attributes["refund_id"]) else: self._refund_id = None Resource.__init__(self, gateway, attributes) self.amount = Decimal(self.amount) if "tax_amount" in attributes and self.tax_amount: self.tax_amount = Decimal(self.tax_amount) if "discount_amount" in attributes and self.discount_amount: self.discount_amount = Decimal(self.discount_amount) if "shipping_amount" in attributes and self.shipping_amount: self.shipping_amount = Decimal(self.shipping_amount) if "billing" in attributes: self.billing_details = Address(gateway, attributes.pop("billing")) if "credit_card" in attributes: self.credit_card_details = CreditCard( gateway, attributes.pop("credit_card")) if "paypal" in attributes: self.paypal_details = PayPalAccount(gateway, attributes.pop("paypal")) if "paypal_here" in attributes: self.paypal_here_details = PayPalHere( gateway, attributes.pop("paypal_here")) if "local_payment" in attributes: self.local_payment_details = LocalPayment( gateway, attributes.pop("local_payment")) if "europe_bank_account" in attributes: self.europe_bank_account_details = EuropeBankAccount( gateway, attributes.pop("europe_bank_account")) if "us_bank_account" in attributes: self.us_bank_account = UsBankAccount( gateway, attributes.pop("us_bank_account")) # NEXT_MAJOR_VERSION Remove this class as legacy Ideal has been removed/disabled in the Braintree Gateway # DEPRECATED If you're looking to accept iDEAL as a payment method contact [email protected] for a solution. if "ideal_payment" in attributes: self.ideal_payment_details = IdealPayment( gateway, attributes.pop("ideal_payment")) if "apple_pay" in attributes: self.apple_pay_details = ApplePayCard(gateway, attributes.pop("apple_pay")) if "coinbase_account" in attributes: self.coinbase_details = CoinbaseAccount( gateway, attributes.pop("coinbase_account")) if "android_pay_card" in attributes: self.android_pay_card_details = AndroidPayCard( gateway, attributes.pop("android_pay_card")) if "amex_express_checkout_card" in attributes: self.amex_express_checkout_card_details = AmexExpressCheckoutCard( gateway, attributes.pop("amex_express_checkout_card")) if "venmo_account" in attributes: self.venmo_account_details = VenmoAccount( gateway, attributes.pop("venmo_account")) if "visa_checkout_card" in attributes: self.visa_checkout_card_details = VisaCheckoutCard( gateway, attributes.pop("visa_checkout_card")) if "masterpass_card" in attributes: self.masterpass_card_details = MasterpassCard( gateway, attributes.pop("masterpass_card")) if "samsung_pay_card" in attributes: self.samsung_pay_card_details = SamsungPayCard( gateway, attributes.pop("samsung_pay_card")) if "customer" in attributes: self.customer_details = Customer(gateway, attributes.pop("customer")) if "shipping" in attributes: self.shipping_details = Address(gateway, attributes.pop("shipping")) if "add_ons" in attributes: self.add_ons = [AddOn(gateway, add_on) for add_on in self.add_ons] if "discounts" in attributes: self.discounts = [ Discount(gateway, discount) for discount in self.discounts ] if "status_history" in attributes: self.status_history = [ StatusEvent(gateway, status_event) for status_event in self.status_history ] if "subscription" in attributes: self.subscription_details = SubscriptionDetails( attributes.pop("subscription")) if "descriptor" in attributes: self.descriptor = Descriptor(gateway, attributes.pop("descriptor")) if "disbursement_details" in attributes: self.disbursement_details = DisbursementDetail( attributes.pop("disbursement_details")) if "disputes" in attributes: self.disputes = [Dispute(dispute) for dispute in self.disputes] if "authorization_adjustments" in attributes: self.authorization_adjustments = [ AuthorizationAdjustment(authorization_adjustment) for authorization_adjustment in self.authorization_adjustments ] if "payment_instrument_type" in attributes: self.payment_instrument_type = attributes[ "payment_instrument_type"] if "risk_data" in attributes: self.risk_data = RiskData(attributes["risk_data"]) else: self.risk_data = None if "three_d_secure_info" in attributes and not attributes[ "three_d_secure_info"] is None: self.three_d_secure_info = ThreeDSecureInfo( attributes["three_d_secure_info"]) else: self.three_d_secure_info = None if "facilitated_details" in attributes: self.facilitated_details = FacilitatedDetails( attributes.pop("facilitated_details")) if "facilitator_details" in attributes: self.facilitator_details = FacilitatorDetails( attributes.pop("facilitator_details")) if "network_transaction_id" in attributes: self.network_transaction_id = attributes["network_transaction_id"]
def test_finding_none_raises_not_found_exception(self): Dispute.find(None)
def test_remove_evidence_empty_dispute_id_raises_not_found_exception(self): Dispute.remove_evidence(" ", "evidence")
def test_finding_empty_id_raises_not_found_exception(self): Dispute.find(" ")
def test_remove_evidence_evidence_none_id_raises_not_found_exception(self): Dispute.remove_evidence("dispute_id", None)
def __init__(self, gateway, attributes): Resource.__init__(self, gateway, attributes) self.amount = Decimal(self.amount) if "tax_amount" in attributes and getattr(self, "tax_amount", None): self.tax_amount = Decimal(self.tax_amount) if "discount_amount" in attributes and getattr(self, "discount_amount", None): self.discount_amount = Decimal(self.discount_amount) if "shipping_amount" in attributes and getattr(self, "shipping_amount", None): self.shipping_amount = Decimal(self.shipping_amount) if "billing" in attributes: self.billing_details = Address(gateway, attributes.pop("billing")) if "credit_card" in attributes: self.credit_card_details = CreditCard( gateway, attributes.pop("credit_card")) if "paypal" in attributes: self.paypal_details = PayPalAccount(gateway, attributes.pop("paypal")) if "paypal_here" in attributes: self.paypal_here_details = PayPalHere( gateway, attributes.pop("paypal_here")) if "local_payment" in attributes: self.local_payment_details = LocalPayment( gateway, attributes.pop("local_payment")) if "europe_bank_account" in attributes: self.europe_bank_account_details = EuropeBankAccount( gateway, attributes.pop("europe_bank_account")) if "us_bank_account" in attributes: self.us_bank_account = UsBankAccount( gateway, attributes.pop("us_bank_account")) if "apple_pay" in attributes: self.apple_pay_details = ApplePayCard(gateway, attributes.pop("apple_pay")) # NEXT_MAJOR_VERSION rename to google_pay_card_details if "android_pay_card" in attributes: self.android_pay_card_details = AndroidPayCard( gateway, attributes.pop("android_pay_card")) # NEXT_MAJOR_VERSION remove amex express checkout if "amex_express_checkout_card" in attributes: self.amex_express_checkout_card_details = AmexExpressCheckoutCard( gateway, attributes.pop("amex_express_checkout_card")) if "venmo_account" in attributes: self.venmo_account_details = VenmoAccount( gateway, attributes.pop("venmo_account")) if "visa_checkout_card" in attributes: self.visa_checkout_card_details = VisaCheckoutCard( gateway, attributes.pop("visa_checkout_card")) # NEXt_MAJOR_VERSION remove masterpass if "masterpass_card" in attributes: self.masterpass_card_details = MasterpassCard( gateway, attributes.pop("masterpass_card")) if "samsung_pay_card" in attributes: self.samsung_pay_card_details = SamsungPayCard( gateway, attributes.pop("samsung_pay_card")) if "customer" in attributes: self.customer_details = Customer(gateway, attributes.pop("customer")) if "shipping" in attributes: self.shipping_details = Address(gateway, attributes.pop("shipping")) if "add_ons" in attributes: self.add_ons = [AddOn(gateway, add_on) for add_on in self.add_ons] if "discounts" in attributes: self.discounts = [ Discount(gateway, discount) for discount in self.discounts ] if "status_history" in attributes: self.status_history = [ StatusEvent(gateway, status_event) for status_event in self.status_history ] if "subscription" in attributes: self.subscription_details = SubscriptionDetails( attributes.pop("subscription")) if "descriptor" in attributes: self.descriptor = Descriptor(gateway, attributes.pop("descriptor")) if "disbursement_details" in attributes: self.disbursement_details = DisbursementDetail( attributes.pop("disbursement_details")) if "disputes" in attributes: self.disputes = [Dispute(dispute) for dispute in self.disputes] if "authorization_adjustments" in attributes: self.authorization_adjustments = [ AuthorizationAdjustment(authorization_adjustment) for authorization_adjustment in self.authorization_adjustments ] if "payment_instrument_type" in attributes: self.payment_instrument_type = attributes[ "payment_instrument_type"] if "risk_data" in attributes: self.risk_data = RiskData(attributes["risk_data"]) else: self.risk_data = None if "three_d_secure_info" in attributes and not attributes[ "three_d_secure_info"] is None: self.three_d_secure_info = ThreeDSecureInfo( attributes["three_d_secure_info"]) else: self.three_d_secure_info = None if "facilitated_details" in attributes: self.facilitated_details = FacilitatedDetails( attributes.pop("facilitated_details")) if "facilitator_details" in attributes: self.facilitator_details = FacilitatorDetails( attributes.pop("facilitator_details")) if "network_transaction_id" in attributes: self.network_transaction_id = attributes["network_transaction_id"]