Ejemplo n.º 1
0
 def update(self, customer_id, params={}):
     Resource.verify_keys(params, Customer.update_signature())
     response = self.config.http().put(self.config.base_merchant_path() + "/customers/" + customer_id, {"customer": params})
     if "customer" in response:
         return SuccessfulResult({"customer": Customer(self.gateway, response["customer"])})
     elif "api_error_response" in response:
         return ErrorResult(self.gateway, response["api_error_response"])
Ejemplo n.º 2
0
    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 "descriptor" in attributes:
            self.descriptor = Descriptor(gateway, attributes.pop("descriptor"))
Ejemplo n.º 3
0
    def create_new_customer(cls, user):
        """
        Create a new Braintree Customer for the user and store their Braintree ID linked to their Django user.
        Returns the braintree Customer for the user iof successful
        """
        # Check this user does not already have a Braintree ID
        if len(BraintreeUser.objects.filter(user=user)) > 0:
            LOGGER.error(
                "Tried to create a duplicate braintree account for user %s",
                user)
            raise BraintreeError(
                "This user already has a BraintreeUser instance associated with them. User: "
                + str(user))

        result = Customer.create({
            'first_name': user.first_name,
            'last_name': user.last_name,
            'email': user.email,
        })
        if not result.is_success:
            return None

        id = result.customer.id
        customerRef = BraintreeUser(user=user,
                                    customer_id=id,
                                    active=False,
                                    pending_cancel=False)
        customerRef.save()
        return customerRef
Ejemplo n.º 4
0
    def create_new_customer(cls,user):
        """
        Create a new Braintree Customer for the user and store their Braintree ID linked to their Django user.
        Returns the braintree Customer for the user iof successful
        """
        # Check this user does not already have a Braintree ID
        if len(BraintreeUser.objects.filter(user=user)) > 0:
            LOGGER.error("Tried to create a duplicate braintree account for user %s", user)
            raise BraintreeError("This user already has a BraintreeUser instance associated with them. User: " + str(user))

        result = Customer.create({
            'first_name': user.first_name,
            'last_name': user.last_name,
            'email': user.email,
        })
        if not result.is_success:
            return None

        id = result.customer.id
        customerRef = BraintreeUser(
            user=user,
            customer_id=id,
            active = False,
            pending_cancel = False
        )
        customerRef.save()
        return customerRef
Ejemplo n.º 5
0
 def find(self, customer_id):
     try:
         response = self.config.http().get("/customers/" + customer_id)
         return Customer(self.gateway, response["customer"])
     except NotFoundError:
         raise NotFoundError("customer with id " + customer_id +
                             " not found")
Ejemplo n.º 6
0
 def tr_data_for_update(self, tr_data, redirect_url):
     Resource.verify_keys(
         tr_data,
         ["customer_id", {
             "customer": Customer.update_signature()
         }])
     tr_data["kind"] = TransparentRedirect.Kind.UpdateCustomer
     return self.gateway.transparent_redirect.tr_data(tr_data, redirect_url)
Ejemplo n.º 7
0
 def find(self, customer_id):
     try:
         if customer_id == None or customer_id.strip() == "":
             raise NotFoundError()
         response = self.config.http().get(self.config.base_merchant_path() + "/customers/" + customer_id)
         return Customer(self.gateway, response["customer"])
     except NotFoundError:
         raise NotFoundError("customer with id " + repr(customer_id) + " not found")
Ejemplo n.º 8
0
def customer(**kw):
    customer = {
        'id': 'customer-id',
        'created_at': datetime.now(),
        'updated_at': datetime.now()
    }
    customer.update(**kw)
    return Customer(None, customer)
Ejemplo n.º 9
0
 def _post(self, url, params={}):
     response = self.config.http().post(self.config.base_merchant_path() + url, params)
     if "customer" in response:
         return SuccessfulResult({"customer": Customer(self.gateway, response["customer"])})
     elif "api_error_response" in response:
         return ErrorResult(self.gateway, response["api_error_response"])
     else:
         pass
Ejemplo n.º 10
0
    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
Ejemplo n.º 11
0
 def __fetch(self, query, ids):
     criteria = self.__criteria(query)
     criteria["ids"] = braintree.customer_search.CustomerSearch.ids.in_list(
         ids).to_param()
     response = self.config.http().post("/customers/advanced_search",
                                        {"search": criteria})
     return [
         Customer(self.gateway, item)
         for item in ResourceCollection._extract_as_array(
             response["customers"], "customer")
     ]
Ejemplo n.º 12
0
    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 "sepa_bank_account" in attributes:
            self.sepa_bank_account_details = SEPABankAccount(
                gateway, attributes.pop("sepa_bank_account"))
        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"]
Ejemplo n.º 13
0
    def find(self, customer_id, association_filter_id=None):
        try:
            if customer_id is None or customer_id.strip() == "":
                raise NotFoundError()

            query_params = ""
            if association_filter_id:
                query_params = "?association_filter_id=" + association_filter_id

            response = self.config.http().get(self.config.base_merchant_path() + "/customers/" + customer_id + query_params)
            return Customer(self.gateway, response["customer"])
        except NotFoundError:
            raise NotFoundError("customer with id " + repr(customer_id) + " not found")
Ejemplo n.º 14
0
    def __init__(self, attributes):
        if "billing" in attributes:
            attributes["billing_details"] = Address(attributes.pop("billing"))
        if "credit_card" in attributes:
            attributes["credit_card_details"] = CreditCard(
                attributes.pop("credit_card"))
        if "customer" in attributes:
            attributes["customer_details"] = Customer(
                attributes.pop("customer"))
        if "shipping" in attributes:
            attributes["shipping_details"] = Address(
                attributes.pop("shipping"))

        Resource.__init__(self, attributes)

        self.amount = Decimal(self.amount)
        if "status_history" in attributes:
            self.status_history = [
                StatusEvent(status_event)
                for status_event in self.status_history
            ]
Ejemplo n.º 15
0
    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"]
    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"]
Ejemplo n.º 17
0
    def vault_customer(self):
        """
        The vault customer associated with this transaction
        """

        return Customer.find(self.customer_details.id)
Ejemplo n.º 18
0
 def tr_data_for_update(self, tr_data, redirect_url):
     Resource.verify_keys(tr_data, ["customer_id", {"customer": Customer.update_signature()}])
     tr_data["kind"] = TransparentRedirect.Kind.UpdateCustomer
     return self.gateway.transparent_redirect.tr_data(tr_data, redirect_url)
Ejemplo n.º 19
0
 def create(self, params={}):
     Resource.verify_keys(params, Customer.create_signature())
     return self._post("/customers", {"customer": params})
Ejemplo n.º 20
0
    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 "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 "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 "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 "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"))
    def vault_customer(self):
        """
        The vault customer associated with this transaction
        """

        return Customer.find(self.customer_details.id)