def __init__(self, gateway, attributes): Resource.__init__(self, gateway, attributes) if "api_error_response" in attributes["subject"]: node_wrapper = attributes["subject"]["api_error_response"] else: node_wrapper = attributes["subject"] if "subscription" in node_wrapper: self.subscription = Subscription(gateway, node_wrapper['subscription']) elif "merchant_account" in node_wrapper: self.merchant_account = MerchantAccount( gateway, node_wrapper['merchant_account']) elif "transaction" in node_wrapper: self.transaction = Transaction(gateway, node_wrapper['transaction']) elif "partner_merchant" in node_wrapper: self.partner_merchant = PartnerMerchant( gateway, node_wrapper['partner_merchant']) elif "disbursement" in node_wrapper: self.disbursement = Disbursement(gateway, node_wrapper['disbursement']) if "errors" in node_wrapper: self.errors = ValidationErrorCollection(node_wrapper['errors']) self.message = node_wrapper['message']
def __init__(self, gateway, attributes): Resource.__init__(self, gateway, attributes) if "source_merchant_id" not in attributes: self.source_merchant_id = None if "api_error_response" in attributes["subject"]: node_wrapper = attributes["subject"]["api_error_response"] else: node_wrapper = attributes["subject"] if "subscription" in node_wrapper: self.subscription = Subscription(gateway, node_wrapper['subscription']) elif "merchant_account" in node_wrapper: self.merchant_account = MerchantAccount( gateway, node_wrapper['merchant_account']) elif "transaction" in node_wrapper: self.transaction = Transaction(gateway, node_wrapper['transaction']) elif "connected_merchant_status_transitioned" in node_wrapper: self.connected_merchant_status_transitioned = ConnectedMerchantStatusTransitioned( gateway, node_wrapper['connected_merchant_status_transitioned']) elif "connected_merchant_paypal_status_changed" in node_wrapper: self.connected_merchant_paypal_status_changed = ConnectedMerchantPayPalStatusChanged( gateway, node_wrapper['connected_merchant_paypal_status_changed']) elif "partner_merchant" in node_wrapper: self.partner_merchant = PartnerMerchant( gateway, node_wrapper['partner_merchant']) elif "oauth_application_revocation" in node_wrapper: self.oauth_access_revocation = OAuthAccessRevocation( node_wrapper["oauth_application_revocation"]) elif "disbursement" in node_wrapper: self.disbursement = Disbursement(gateway, node_wrapper['disbursement']) elif "dispute" in node_wrapper: self.dispute = Dispute(node_wrapper['dispute']) elif "account_updater_daily_report" in node_wrapper: self.account_updater_daily_report = AccountUpdaterDailyReport( gateway, node_wrapper['account_updater_daily_report']) elif "ideal_payment" in node_wrapper: self.ideal_payment = IdealPayment(gateway, node_wrapper['ideal_payment']) elif "granted_payment_instrument_update" in node_wrapper: self.granted_payment_instrument_update = GrantedPaymentInstrumentUpdate( gateway, node_wrapper["granted_payment_instrument_update"]) elif WebhookNotification.Kind.GrantedPaymentMethodRevoked == attributes[ "kind"]: self.revoked_payment_method_metadata = RevokedPaymentMethodMetadata( gateway, node_wrapper) elif "local_payment" in node_wrapper: self.local_payment_completed = LocalPaymentCompleted( gateway, node_wrapper["local_payment"]) if "errors" in node_wrapper: self.errors = ValidationErrorCollection(node_wrapper['errors']) self.message = node_wrapper['message']
def __init__(self, gateway, attributes): Resource.__init__(self, gateway, attributes) if "merchant_accounts" in attributes: self.merchant_accounts = [ MerchantAccount(gateway, ma) for ma in attributes.get("merchant_accounts") ]
def find(self, merchant_account_id): try: if merchant_account_id == None or merchant_account_id.strip() == "": raise NotFoundError() response = self.config.http().get("/merchant_accounts/" + merchant_account_id) return MerchantAccount(self.gateway, response["merchant_account"]) except NotFoundError: raise NotFoundError("merchant account with id " + merchant_account_id + " not found")
def _put(self, url, params={}): response = self.config.http().put(url, params) if "merchant_account" in response: return SuccessfulResult({ "merchant_account": MerchantAccount(self.gateway, response["merchant_account"]) }) elif "api_error_response" in response: return ErrorResult(self.gateway, response["api_error_response"])
def _put(self, url, params=None): if params is None: params = {} response = self.config.http().put( self.config.base_merchant_path() + url, params) if "merchant_account" in response: return SuccessfulResult({ "merchant_account": MerchantAccount(self.gateway, response["merchant_account"]) }) elif "api_error_response" in response: return ErrorResult(self.gateway, response["api_error_response"])
def _fetch_merchant_accounts(self, current_page): response = self.config.http().get(self.config.base_merchant_path() + "/merchant_accounts/?page=" + str(current_page)) body = response["merchant_accounts"] merchant_accounts = [ MerchantAccount(self.gateway, merchant_account) for merchant_account in ResourceCollection._extract_as_array( body, "merchant_account") ] return PaginatedResult(body["total_items"], body["page_size"], merchant_accounts)
def __init__(self, gateway, attributes): Resource.__init__(self, gateway, attributes) if "api_error_response" in attributes["subject"]: node_wrapper = attributes["subject"]["api_error_response"] else: node_wrapper = attributes["subject"] if "subscription" in node_wrapper: self.subscription = Subscription(gateway, node_wrapper['subscription']) elif "merchant_account" in node_wrapper: self.merchant_account = MerchantAccount( gateway, node_wrapper['merchant_account']) elif "transaction" in node_wrapper: self.transaction = Transaction(gateway, node_wrapper['transaction']) elif "connected_merchant_status_transitioned" in node_wrapper: self.connected_merchant_status_transitioned = ConnectedMerchantStatusTransitioned( gateway, node_wrapper['connected_merchant_status_transitioned']) elif "connected_merchant_paypal_status_changed" in node_wrapper: self.connected_merchant_paypal_status_changed = ConnectedMerchantPayPalStatusChanged( gateway, node_wrapper['connected_merchant_paypal_status_changed']) elif "partner_merchant" in node_wrapper: self.partner_merchant = PartnerMerchant( gateway, node_wrapper['partner_merchant']) elif "disbursement" in node_wrapper: self.disbursement = Disbursement(gateway, node_wrapper['disbursement']) elif "dispute" in node_wrapper: self.dispute = Dispute(node_wrapper['dispute']) elif "account_updater_daily_report" in node_wrapper: self.account_updater_daily_report = AccountUpdaterDailyReport( gateway, node_wrapper['account_updater_daily_report']) elif "ideal_payment" in node_wrapper: self.ideal_payment = IdealPayment(gateway, node_wrapper['ideal_payment']) elif "granted_payment_instrument_update" in node_wrapper: self.granted_payment_instrument_update = GrantedPaymentInstrumentUpdate( gateway, node_wrapper["granted_payment_instrument_update"]) if "errors" in node_wrapper: self.errors = ValidationErrorCollection(node_wrapper['errors']) self.message = node_wrapper['message']
def __init__(self, gateway, attributes): Resource.__init__(self, gateway, attributes) self.amount = Decimal(self.amount) self.merchant_account = MerchantAccount(gateway, attributes["merchant_account"])
def create(self, params={}): Resource.verify_keys(params, MerchantAccount.create_signature()) return self._post("/merchant_accounts/create_via_api", {"merchant_account": params})
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']