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"))
Beispiel #2
0
    def __init__(self, gateway, attributes):
        Resource.__init__(self, gateway, attributes)
        self.payment_methods = []

        if "credit_cards" in attributes:
            self.credit_cards = [CreditCard(gateway, credit_card) for credit_card in self.credit_cards]
            self.payment_methods += self.credit_cards
        if "addresses" in attributes:
            self.addresses = [Address(gateway, address) for address in self.addresses]

        if "paypal_accounts" in attributes:
            self.paypal_accounts  = [PayPalAccount(gateway, paypal_account) for paypal_account in self.paypal_accounts]
            self.payment_methods += self.paypal_accounts

        if "apple_pay_cards" in attributes:
            self.apple_pay_cards  = [ApplePayCard(gateway, apple_pay_card) for apple_pay_card in self.apple_pay_cards]
            self.payment_methods += self.apple_pay_cards

        if "android_pay_cards" in attributes:
            self.android_pay_cards  = [AndroidPayCard(gateway, android_pay_card) for android_pay_card in self.android_pay_cards]
            self.payment_methods += self.android_pay_cards

        if "europe_bank_accounts" in attributes:
            self.europe_bank_accounts = [EuropeBankAccount(gateway, europe_bank_account) for europe_bank_account in self.europe_bank_accounts]
            self.payment_methods += self.europe_bank_accounts

        if "coinbase_accounts" in attributes:
            self.coinbase_accounts = [CoinbaseAccount(gateway, coinbase_account) for coinbase_account in self.coinbase_accounts]
            self.payment_methods += self.coinbase_accounts
Beispiel #3
0
def parse_payment_method(gateway, attributes):
    if "paypal_account" in attributes:
        return PayPalAccount(gateway, attributes["paypal_account"])
    elif "credit_card" in attributes:
        return CreditCard(gateway, attributes["credit_card"])
    elif "europe_bank_account" in attributes:
        return EuropeBankAccount(gateway, attributes["europe_bank_account"])
    elif "apple_pay_card" in attributes:
        return ApplePayCard(gateway, attributes["apple_pay_card"])
    elif "android_pay_card" in attributes:
        return AndroidPayCard(gateway, attributes["android_pay_card"])
    elif "amex_express_checkout_card" in attributes:
        return AmexExpressCheckoutCard(gateway, attributes["amex_express_checkout_card"])
    elif "venmo_account" in attributes:
        return VenmoAccount(gateway, attributes["venmo_account"])
    elif "us_bank_account" in attributes:
        return UsBankAccount(gateway, attributes["us_bank_account"])
    elif "visa_checkout_card" in attributes:
        return VisaCheckoutCard(gateway, attributes["visa_checkout_card"])
    elif "masterpass_card" in attributes:
        return MasterpassCard(gateway, attributes["masterpass_card"])
    elif "samsung_pay_card" in attributes:
        return SamsungPayCard(gateway, attributes["samsung_pay_card"])
    else:
        name = list(attributes)[0]
        return UnknownPaymentMethod(gateway, attributes[name])
Beispiel #4
0
 def _parse_payment_method(self, response):
     if "paypal_account" in response:
         return PayPalAccount(self.gateway, response["paypal_account"])
     elif "credit_card" in response:
         return CreditCard(self.gateway, response["credit_card"])
     elif "europe_bank_account" in response:
         return EuropeBankAccount(self.gateway, response["europe_bank_account"])
     elif "apple_pay_card" in response:
         return ApplePayCard(self.gateway, response["apple_pay_card"])
     elif "android_pay_card" in response:
         return AndroidPayCard(self.gateway, response["android_pay_card"])
     elif "amex_express_checkout_card" in response:
         return AmexExpressCheckoutCard(self.gateway, response["amex_express_checkout_card"])
     elif "coinbase_account" in response:
         return CoinbaseAccount(self.gateway, response["coinbase_account"])
     elif "venmo_account" in response:
         return VenmoAccount(self.gateway, response["venmo_account"])
     elif "us_bank_account" in response:
         return UsBankAccount(self.gateway, response["us_bank_account"])
     elif "visa_checkout_card" in response:
         return VisaCheckoutCard(self.gateway, response["visa_checkout_card"])
     elif "masterpass_card" in response:
         return MasterpassCard(self.gateway, response["masterpass_card"])
     elif "payment_method_nonce" in response:
         return PaymentMethodNonce(self.gateway, response["payment_method_nonce"])
     elif "success" in response:
         return None
     else:
         name = list(response)[0]
         return UnknownPaymentMethod(self.gateway, response[name])
Beispiel #5
0
 def find(self, credit_card_token):
     try:
         response = self.config.http().get("/payment_methods/" +
                                           credit_card_token)
         return CreditCard(self.gateway, response["credit_card"])
     except NotFoundError:
         raise NotFoundError("payment method with token " +
                             credit_card_token + " not found")
Beispiel #6
0
 def _post(self, url, params={}):
     response = self.config.http().post(url, params)
     if "credit_card" in response:
         return SuccessfulResult({
             "credit_card":
             CreditCard(self.gateway, response["credit_card"])
         })
     elif "api_error_response" in response:
         return ErrorResult(self.gateway, response["api_error_response"])
Beispiel #7
0
 def from_nonce(self, nonce):
     try:
         if nonce is None or nonce.strip() == "":
             raise NotFoundError()
         response = self.config.http().get("/payment_methods/from_nonce/" +
                                           nonce)
         return CreditCard(self.gateway, response["credit_card"])
     except NotFoundError:
         raise NotFoundError("payment method with nonce " + nonce +
                             " locked, consumed or not found")
Beispiel #8
0
 def __fetch_existing_between(self, query, ids):
     criteria = {}
     criteria["ids"] = IdsSearch.ids.in_list(ids).to_param()
     response = self.config.http().post(
         "/payment_methods/all/expiring?" + query, {"search": criteria})
     return [
         CreditCard(self.gateway, item)
         for item in ResourceCollection._extract_as_array(
             response["payment_methods"], "credit_card")
     ]
 def _parse_payment_method(self, response):
     if "paypal_account" in response:
         return PayPalAccount(self.gateway, response["paypal_account"])
     elif "credit_card" in response:
         return CreditCard(self.gateway, response["credit_card"])
     elif "sepa_bank_account" in response:
         return SEPABankAccount(self.gateway, response["sepa_bank_account"])
     else:
         name = list(response)[0]
         return UnknownPaymentMethod(self.gateway, response[name])
Beispiel #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
 def update(self, credit_card_token, params={}):
     Resource.verify_keys(params, CreditCard.update_signature())
     response = self.config.http().put(
         "/payment_methods/" + credit_card_token, {"credit_card": params})
     if "credit_card" in response:
         return SuccessfulResult({
             "credit_card":
             CreditCard(self.gateway, response["credit_card"])
         })
     elif "api_error_response" in response:
         return ErrorResult(self.gateway, response["api_error_response"])
Beispiel #12
0
 def find(self, credit_card_token):
     try:
         if credit_card_token is None or credit_card_token.strip() == "":
             raise NotFoundError()
         response = self.config.http().get(
             self.config.base_merchant_path() +
             "/payment_methods/credit_card/" + credit_card_token)
         return CreditCard(self.gateway, response["credit_card"])
     except NotFoundError:
         raise NotFoundError("payment method with token " +
                             repr(credit_card_token) + " not found")
Beispiel #13
0
 def __init__(self, gateway, attributes):
     Resource.__init__(self, gateway, attributes)
     if "credit_cards" in attributes:
         self.credit_cards = [
             CreditCard(gateway, credit_card)
             for credit_card in self.credit_cards
         ]
     if "addresses" in attributes:
         self.addresses = [
             Address(gateway, address) for address in self.addresses
         ]
Beispiel #14
0
 def _post(self, url, params=None):
     if params is None:
         params = {}
     response = self.config.http().post(
         self.config.base_merchant_path() + url, params)
     if "credit_card" in response:
         return SuccessfulResult({
             "credit_card":
             CreditCard(self.gateway, response["credit_card"])
         })
     elif "api_error_response" in response:
         return ErrorResult(self.gateway, response["api_error_response"])
    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"]
 def _parse_payment_method(self, response):
     if "paypal_account" in response:
         return PayPalAccount(self.gateway, response["paypal_account"])
     elif "credit_card" in response:
         return CreditCard(self.gateway, response["credit_card"])
     elif "europe_bank_account" in response:
         return EuropeBankAccount(self.gateway, response["europe_bank_account"])
     elif "apple_pay_card" in response:
         return ApplePayCard(self.gateway, response["apple_pay_card"])
     elif "coinbase_account" in response:
         return CoinbaseAccount(self.gateway, response["coinbase_account"])
     else:
         name = list(response)[0]
         return UnknownPaymentMethod(self.gateway, response[name])
Beispiel #17
0
    def __init__(self, gateway, attributes):
        Resource.__init__(self, gateway, attributes)
        self.payment_methods = []

        if "credit_cards" in attributes:
            self.credit_cards = [CreditCard(gateway, credit_card) for credit_card in self.credit_cards]
            self.payment_methods += self.credit_cards
        if "addresses" in attributes:
            self.addresses = [Address(gateway, address) for address in self.addresses]

        if "paypal_accounts" in attributes:
            self.paypal_accounts  = [PayPalAccount(gateway, paypal_account) for paypal_account in self.paypal_accounts]
            self.payment_methods += self.paypal_accounts

        if "apple_pay_cards" in attributes:
            self.apple_pay_cards  = [ApplePayCard(gateway, apple_pay_card) for apple_pay_card in self.apple_pay_cards]
            self.payment_methods += self.apple_pay_cards

        if "android_pay_cards" in attributes:
            self.android_pay_cards  = [AndroidPayCard(gateway, android_pay_card) for android_pay_card in self.android_pay_cards]
            self.payment_methods += self.android_pay_cards

        if "amex_express_checkout_cards" in attributes:
            self.amex_express_checkout_cards  = [AmexExpressCheckoutCard(gateway, amex_express_checkout_card) for amex_express_checkout_card in self.amex_express_checkout_cards]
            self.payment_methods += self.amex_express_checkout_cards

        if "europe_bank_accounts" in attributes:
            self.europe_bank_accounts = [EuropeBankAccount(gateway, europe_bank_account) for europe_bank_account in self.europe_bank_accounts]
            self.payment_methods += self.europe_bank_accounts

        if "coinbase_accounts" in attributes:
            self.coinbase_accounts = [CoinbaseAccount(gateway, coinbase_account) for coinbase_account in self.coinbase_accounts]
            self.payment_methods += self.coinbase_accounts

        if "venmo_accounts" in attributes:
            self.venmo_accounts = [VenmoAccount(gateway, venmo_account) for venmo_account in self.venmo_accounts]
            self.payment_methods += self.venmo_accounts

        if "us_bank_accounts" in attributes:
            self.us_bank_accounts = [UsBankAccount(gateway, us_bank_account) for us_bank_account in self.us_bank_accounts]
            self.payment_methods += self.us_bank_accounts

        if "visa_checkout_cards" in attributes:
            self.visa_checkout_cards = [VisaCheckoutCard(gateway, visa_checkout_card) for visa_checkout_card in self.visa_checkout_cards]
            self.payment_methods += self.visa_checkout_cards

        if "masterpass_cards" in attributes:
            self.masterpass_cards = [MasterpassCard(gateway, masterpass_card) for masterpass_card in self.masterpass_cards]
            self.payment_methods += self.masterpass_cards
Beispiel #18
0
 def update(self, credit_card_token, params=None):
     if params is None:
         params = {}
     Resource.verify_keys(params, CreditCard.update_signature())
     self.__check_for_deprecated_attributes(params)
     response = self.config.http().put(
         self.config.base_merchant_path() +
         "/payment_methods/credit_card/" + credit_card_token,
         {"credit_card": params})
     if "credit_card" in response:
         return SuccessfulResult({
             "credit_card":
             CreditCard(self.gateway, response["credit_card"])
         })
     elif "api_error_response" in response:
         return ErrorResult(self.gateway, response["api_error_response"])
Beispiel #19
0
    def __init__(self, gateway, attributes):
        Resource.__init__(self, gateway, attributes)
        if "credit_cards" in attributes:
            self.credit_cards = [
                CreditCard(gateway, credit_card)
                for credit_card in self.credit_cards
            ]
        if "addresses" in attributes:
            self.addresses = [
                Address(gateway, address) for address in self.addresses
            ]

        if "paypal_accounts" in attributes:
            self.paypal_accounts = [
                PayPalAccount(gateway, paypal_account)
                for paypal_account in self.paypal_accounts
            ]
Beispiel #20
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
            ]
Beispiel #21
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"]
    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"))