def update(self, subscription_id, params={}):
     Resource.verify_keys(params, Subscription.update_signature())
     response = self.config.http().put("/subscriptions/" + subscription_id, {"subscription": params})
     if "subscription" in response:
         return SuccessfulResult({"subscription": Subscription(self.gateway, response["subscription"])})
     elif "api_error_response" in response:
         return ErrorResult(self.gateway, response["api_error_response"])
Пример #2
0
 def create(self, params={}):
     Resource.verify_keys(params, Subscription.create_signature())
     response = self.config.http().post(self.config.base_merchant_path() + "/subscriptions", {"subscription": params})
     if "subscription" in response:
         return SuccessfulResult({"subscription": Subscription(self.gateway, response["subscription"])})
     elif "api_error_response" in response:
         return ErrorResult(self.gateway, response["api_error_response"])
 def update(self, subscription_id, params={}):
     Resource.verify_keys(params, Subscription.update_signature())
     response = self.config.http().put("/subscriptions/" + subscription_id, {"subscription": params})
     if "subscription" in response:
         return SuccessfulResult({"subscription": Subscription(self.gateway, response["subscription"])})
     elif "api_error_response" in response:
         return ErrorResult(self.gateway, response["api_error_response"])
 def create(self, params={}):
     Resource.verify_keys(params, Subscription.create_signature())
     response = self.config.http().post(self.config.base_merchant_path() + "/subscriptions", {"subscription": params})
     if "subscription" in response:
         return SuccessfulResult({"subscription": Subscription(self.gateway, response["subscription"])})
     elif "api_error_response" in response:
         return ErrorResult(self.gateway, response["api_error_response"])
Пример #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 "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']
Пример #6
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']
 def find(self, subscription_id):
     try:
         if subscription_id == None or subscription_id.strip() == "":
             raise NotFoundError()
         response = self.config.http().get("/subscriptions/" + subscription_id)
         return Subscription(self.gateway, response["subscription"])
     except NotFoundError:
         raise NotFoundError("subscription with id " + subscription_id + " not found")
Пример #8
0
def method(**kw):
    method = {
        'id': 'some:id',
        'created_at': datetime.now(),
        'updated_at': datetime.now(),
    }
    method.update(**kw)
    return Subscription(None, method)
 def cancel(self, subscription_id):
     response = self.config.http().put("/subscriptions/" + subscription_id +
                                       "/cancel")
     if "subscription" in response:
         return SuccessfulResult({
             "subscription":
             Subscription(self.gateway, response["subscription"])
         })
     elif "api_error_response" in response:
         return ErrorResult(self.gateway, response["api_error_response"])
Пример #10
0
 def find(self, subscription_id):
     try:
         if subscription_id is None or subscription_id.strip() == "":
             raise NotFoundError()
         response = self.config.http().get(
             self.config.base_merchant_path() + "/subscriptions/" +
             subscription_id)
         return Subscription(self.gateway, response["subscription"])
     except NotFoundError:
         raise NotFoundError("subscription with id " +
                             repr(subscription_id) + " not found")
 def __fetch(self, query, ids):
     criteria = self.__criteria(query)
     criteria[
         "ids"] = braintree.subscription_search.SubscriptionSearch.ids.in_list(
             ids).to_param()
     response = self.config.http().post("/subscriptions/advanced_search",
                                        {"search": criteria})
     return [
         Subscription(self.gateway, item)
         for item in ResourceCollection._extract_as_array(
             response["subscriptions"], "subscription")
     ]
Пример #12
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']
Пример #13
0
 def __init__(self, gateway, attributes):
     Resource.__init__(self, gateway, attributes)
     if "subscription" in attributes['subject']:
         self.subscription = Subscription(gateway, attributes['subject']['subscription'])
Пример #14
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']