def test_parse_response_returns_a_credit_card(self): payment_method_gateway = PaymentMethodGateway(BraintreeGateway(None)) credit_card = payment_method_gateway._parse_payment_method({"credit_card": {"bin": "411111", "last_4": "1111"}}) self.assertEquals(credit_card.__class__, CreditCard) self.assertEquals(credit_card.bin, "411111") self.assertEquals(credit_card.last_4, "1111")
def test_parse_response_returns_a_paypal_account(self): payment_method_gateway = PaymentMethodGateway(BraintreeGateway(None)) paypal_account = payment_method_gateway._parse_payment_method( {"paypal_account": {"token": "1234", "default": False}} ) self.assertEquals(paypal_account.__class__, PayPalAccount) self.assertEquals(paypal_account.token, "1234") self.assertFalse(paypal_account.default)
def test_parse_response_returns_an_unknown_payment_method(self): payment_method_gateway = PaymentMethodGateway(BraintreeGateway(None)) unknown_payment_method = payment_method_gateway._parse_payment_method( {"new_fancy_payment_method": {"token": "1234", "default": True, "other_fancy_thing": "is-shiny"}} ) self.assertEquals(unknown_payment_method.__class__, UnknownPaymentMethod) self.assertEquals(unknown_payment_method.token, "1234") self.assertTrue(unknown_payment_method.default)
def test_parse_response_returns_a_paypal_account(self): payment_method_gateway = PaymentMethodGateway(BraintreeGateway(None)) paypal_account = payment_method_gateway._parse_payment_method( {"paypal_account": { "token": "1234", "default": False }}) self.assertEquals(paypal_account.__class__, PayPalAccount) self.assertEquals(paypal_account.token, "1234") self.assertFalse(paypal_account.default)
def test_parse_response_returns_a_credit_card(self): payment_method_gateway = PaymentMethodGateway(BraintreeGateway(None)) credit_card = payment_method_gateway._parse_payment_method( {"credit_card": { "bin": "411111", "last_4": "1111" }}) self.assertEquals(credit_card.__class__, CreditCard) self.assertEquals(credit_card.bin, "411111") self.assertEquals(credit_card.last_4, "1111")
def test_parse_response_returns_an_unknown_payment_method(self): payment_method_gateway = PaymentMethodGateway(BraintreeGateway(None)) unknown_payment_method = payment_method_gateway._parse_payment_method({ "new_fancy_payment_method": { "token": "1234", "default": True, "other_fancy_thing": "is-shiny" } }) self.assertEquals(unknown_payment_method.__class__, UnknownPaymentMethod) self.assertEquals(unknown_payment_method.token, "1234") self.assertTrue(unknown_payment_method.default)
def __init__(self, config=None, **kwargs): if isinstance(config, braintree.configuration.Configuration): self.config = config else: self.config = Configuration( client_id=kwargs.get("client_id"), client_secret=kwargs.get("client_secret"), access_token=kwargs.get("access_token"), http_strategy=kwargs.get("http_strategy") ) self.add_on = AddOnGateway(self) self.address = AddressGateway(self) self.client_token = ClientTokenGateway(self) self.credit_card = CreditCardGateway(self) self.customer = CustomerGateway(self) self.discount = DiscountGateway(self) self.merchant_account = MerchantAccountGateway(self) self.merchant = MerchantGateway(self) self.oauth = OAuthGateway(self) self.plan = PlanGateway(self) self.settlement_batch_summary = SettlementBatchSummaryGateway(self) self.subscription = SubscriptionGateway(self) self.transaction = TransactionGateway(self) self.transparent_redirect = TransparentRedirectGateway(self) self.verification = CreditCardVerificationGateway(self) self.webhook_notification = WebhookNotificationGateway(self) self.webhook_testing = WebhookTestingGateway(self) self.payment_method = PaymentMethodGateway(self) self.payment_method_nonce = PaymentMethodNonceGateway(self) self.paypal_account = PayPalAccountGateway(self) self.testing = TestingGateway(self) self.us_bank_account = UsBankAccountGateway(self)
def test_nonce_revoke_params(self): payment_method_gateway = PaymentMethodGateway(BraintreeGateway(None)) with self.assertRaises(ValueError): payment_method_gateway.revoke("") with self.assertRaises(ValueError): payment_method_gateway.revoke("\t") with self.assertRaises(ValueError): payment_method_gateway.revoke(None)
def test_nonce_grant_params(self): """ We validate parameters to PaymentMethod.grant properly """ payment_method_gateway = PaymentMethodGateway(BraintreeGateway(None)) with self.assertRaises(ValueError): payment_method_gateway.grant("", False) with self.assertRaises(ValueError): payment_method_gateway.grant("\t", False) with self.assertRaises(ValueError): payment_method_gateway.grant(None, False)
def test_nonce_revoke_params(self): payment_method_gateway = PaymentMethodGateway(BraintreeGateway(None)) with self.assertRaises(ValueError): payment_method_gateway.revoke("") with self.assertRaises(ValueError): payment_method_gateway.revoke("\t") with self.assertRaises(ValueError): payment_method_gateway.revoke(None)
def test_nonce_grant_params(self): """ We validate parameters to PaymentMethod.grant properly """ payment_method_gateway = PaymentMethodGateway(BraintreeGateway(None)) options = {"include_billing_postal_code": True} with self.assertRaises(ValueError): payment_method_gateway.grant("", options) with self.assertRaises(ValueError): payment_method_gateway.grant("\t", False) with self.assertRaises(ValueError): payment_method_gateway.grant(None, True)
def test_nonce_grant_params(self): """ We validate parameters to PaymentMethod.grant properly """ payment_method_gateway = PaymentMethodGateway(BraintreeGateway(None)) with self.assertRaises(ValueError): payment_method_gateway.grant("", False) with self.assertRaises(ValueError): payment_method_gateway.grant("\t", False) with self.assertRaises(ValueError): payment_method_gateway.grant(None, False)
def test_nonce_grant_params(self): """ We validate parameters to PaymentMethod.grant properly """ payment_method_gateway = PaymentMethodGateway(BraintreeGateway(None)) options = { "include_billing_postal_code": True } with self.assertRaises(ValueError): payment_method_gateway.grant("", options) with self.assertRaises(ValueError): payment_method_gateway.grant("\t", False) with self.assertRaises(ValueError): payment_method_gateway.grant(None, True)
def __init__(self, config): self.config = config self.add_on = AddOnGateway(self) self.address = AddressGateway(self) self.client_token = ClientTokenGateway(self) self.credit_card = CreditCardGateway(self) self.customer = CustomerGateway(self) self.discount = DiscountGateway(self) self.merchant_account = MerchantAccountGateway(self) self.plan = PlanGateway(self) self.settlement_batch_summary = SettlementBatchSummaryGateway(self) self.subscription = SubscriptionGateway(self) self.transaction = TransactionGateway(self) self.transparent_redirect = TransparentRedirectGateway(self) self.verification = CreditCardVerificationGateway(self) self.webhook_notification = WebhookNotificationGateway(self) self.webhook_testing = WebhookTestingGateway(self) self.payment_method = PaymentMethodGateway(self) self.paypal_account = PayPalAccountGateway(self) self.testing = TestingGateway(self)
def __init__(self, config=None, **kwargs): if isinstance(config, braintree.configuration.Configuration): self.config = config else: self.config = Configuration( client_id=kwargs.get("client_id"), client_secret=kwargs.get("client_secret"), access_token=kwargs.get("access_token"), http_strategy=kwargs.get("http_strategy") ) self.graphql_client = self.config.graphql_client() self.add_on = AddOnGateway(self) self.address = AddressGateway(self) self.apple_pay = ApplePayGateway(self) self.client_token = ClientTokenGateway(self) self.credit_card = CreditCardGateway(self) self.customer = CustomerGateway(self) self.document_upload = DocumentUploadGateway(self) self.discount = DiscountGateway(self) self.dispute = DisputeGateway(self) self.merchant_account = MerchantAccountGateway(self) self.merchant = MerchantGateway(self) self.oauth = OAuthGateway(self) self.plan = PlanGateway(self) self.settlement_batch_summary = SettlementBatchSummaryGateway(self) self.subscription = SubscriptionGateway(self) self.transaction = TransactionGateway(self) self.transaction_line_item = TransactionLineItemGateway(self) self.transparent_redirect = TransparentRedirectGateway(self) self.verification = CreditCardVerificationGateway(self) self.webhook_notification = WebhookNotificationGateway(self) self.webhook_testing = WebhookTestingGateway(self) self.payment_method = PaymentMethodGateway(self) self.payment_method_nonce = PaymentMethodNonceGateway(self) self.paypal_account = PayPalAccountGateway(self) self.testing = TestingGateway(self) self.us_bank_account = UsBankAccountGateway(self) self.us_bank_account_verification = UsBankAccountVerificationGateway(self) # 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. self.ideal_payment = IdealPaymentGateway(self)
def setup_payment_method_gateway_and_mock_http(self): braintree_gateway = BraintreeGateway(Configuration.instantiate()) payment_method_gateway = PaymentMethodGateway(braintree_gateway) http_mock = MagicMock(name='config.http.delete') braintree_gateway.config.http = http_mock return payment_method_gateway, http_mock