コード例 #1
0
    def test_creates_transaction_using_ideal_payment_token_and_returns_result_object(
            self):
        ideal_payment_id = TestHelper.generate_valid_ideal_payment_id(
            amount=TransactionAmounts.Authorize)

        result = IdealPayment.sale(
            ideal_payment_id, {
                'order_id': 'ABC123',
                'merchant_account_id': 'ideal_merchant_account',
                'amount': TransactionAmounts.Authorize,
            })

        self.assertTrue(result.is_success)
        self.assertEqual(result.transaction.amount,
                         Decimal(TransactionAmounts.Authorize))
        self.assertEqual(result.transaction.type, 'sale')

        ideal_payment_details = result.transaction.ideal_payment_details
        self.assertRegexpMatches(ideal_payment_details.ideal_payment_id,
                                 r'^idealpayment_\w{6,}$')
        self.assertRegexpMatches(ideal_payment_details.ideal_transaction_id,
                                 r'^\d{16,}$')
        self.assertEqual(ideal_payment_details.image_url[:8], 'https://')
        self.assertNotEqual(ideal_payment_details.masked_iban, None)
        self.assertNotEqual(ideal_payment_details.bic, None)
コード例 #2
0
 def test_doesnt_create_transaction_with_ideal_payment(self):
     result = IdealPayment.sale(
         'invalid_id', {
             'merchant_account_id': 'ideal_merchant_account',
             'amount': TransactionAmounts.Authorize,
         })
     self.assertFalse(result.is_success)
コード例 #3
0
    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']
コード例 #4
0
    def find(self, ideal_payment_id):
        try:
            if ideal_payment_id is None or ideal_payment_id.strip() == "":
                raise NotFoundError()

            response = self.config.http().get(
                self.config.base_merchant_path() + "/ideal_payments/" +
                ideal_payment_id)
            if "ideal_payment" in response:
                return IdealPayment(self.gateway, response["ideal_payment"])
        except NotFoundError:
            raise NotFoundError("iDEAL payment with token" +
                                repr(ideal_payment_id) + " not found")
コード例 #5
0
    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']
コード例 #6
0
    def test_constructor(self):
        attributes = {
            "ideal_payment_id": "idealpayment_abc_123",
            "ideal_transaction_id": "1150000008857321",
            "image_url": "12************7890",
            "masked_iban": "RABONL2U",
            "bic": "http://www.example.com/ideal.png",
        }

        ideal_payment_details = IdealPayment({}, attributes)
        self.assertEqual(ideal_payment_details.ideal_payment_id,
                         "idealpayment_abc_123")
        self.assertEqual(ideal_payment_details.ideal_transaction_id,
                         "1150000008857321")
        self.assertEqual(ideal_payment_details.image_url, "12************7890")
        self.assertEqual(ideal_payment_details.masked_iban, "RABONL2U")
        self.assertEqual(ideal_payment_details.bic,
                         "http://www.example.com/ideal.png")
コード例 #7
0
    def test_find_ideal_payment_by_id(self):
        ideal_payment_id = TestHelper.generate_valid_ideal_payment_id(
            amount=TransactionAmounts.Authorize)
        ideal_payment = IdealPayment.find(ideal_payment_id)

        self.assertRegexpMatches(ideal_payment.id, r'^idealpayment_\w{6,}$')
        self.assertRegexpMatches(ideal_payment.ideal_transaction_id,
                                 r'^\d{16,}$')
        self.assertNotEqual(ideal_payment.currency, None)
        self.assertNotEqual(ideal_payment.amount, None)
        self.assertNotEqual(ideal_payment.status, None)
        self.assertNotEqual(ideal_payment.order_id, None)
        self.assertNotEqual(ideal_payment.issuer, None)
        self.assertEqual(ideal_payment.approval_url[:8], 'https://')
        self.assertNotEqual(
            ideal_payment.iban_bank_account.account_holder_name, None)
        self.assertNotEqual(ideal_payment.iban_bank_account.bic, None)
        self.assertNotEqual(ideal_payment.iban_bank_account.masked_iban, None)
        self.assertRegexpMatches(
            ideal_payment.iban_bank_account.iban_account_number_last_4,
            r'^\d{4}$')
        self.assertNotEqual(ideal_payment.iban_bank_account.iban_country, None)
        self.assertNotEqual(ideal_payment.iban_bank_account.description, None)
コード例 #8
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 "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"]
コード例 #9
0
 def find():
     IdealPayment.find('idealpayment_nxyqkq_s654wq_92jr64_mnr4kr_yjz')
コード例 #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 "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"))
コード例 #11
0
    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'])
        # 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.
        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 attributes["kind"] in [
                WebhookNotification.Kind.GrantedPaymentMethodRevoked,
                WebhookNotification.Kind.PaymentMethodRevokedByCustomer
        ]:
            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']