예제 #1
0
    def charge_recurring(self, grace_period=None):
        """
        Charge a cart's recurring item, if necessary.
        NOTE: Currently only one recurring item is supported per cart,
              so charge the first one found.
        We use braintree's subscriptions for recurring billing, so we don't manually
        charge recurring payments. Instead, we poll braintree to get new
        payments/transactions.
        """
        if not grace_period:
            grace_period = self.settings.get("CHARGE_RECURRING_GRACE_PERIOD",
                                             None)
        recurring = [
            li for li in self.cart.recurring_lineitems if li.is_active
        ]
        if not recurring or not recurring[0].is_expired(
                grace_period=grace_period):
            return
        item = recurring[0]

        handler = BraintreeIPN(self.cart)
        result = braintree.Subscription.find(item.payment_token)
        transactions = result.transactions
        for t in transactions:
            handler.accept_payment(t)
예제 #2
0
파일: gateway.py 프로젝트: pajju/hiicart
    def charge_recurring(self, grace_period=None):
        """
        Charge a cart's recurring item, if necessary.
        NOTE: Currently only one recurring item is supported per cart,
              so charge the first one found.
        We use braintree's subscriptions for recurring billing, so we don't manually
        charge recurring payments. Instead, we poll braintree to get new
        payments/transactions.
        """
        if not grace_period:
            grace_period = self.settings.get("CHARGE_RECURRING_GRACE_PERIOD", None)
        recurring = [li for li in self.cart.recurring_lineitems if li.is_active]
        if not recurring or not recurring[0].is_expired(grace_period=grace_period):
            return
        item = recurring[0]

        handler = BraintreeIPN(self.cart)
        result = braintree.Subscription.find(item.payment_token)
        transactions = result.transactions
        for t in transactions:
            handler.accept_payment(t)