Пример #1
0
 def decorated_function(self, *args):
     customer = emoji_customer.get(self.phone_number) or {}
     if not customer:
         raise UserNotFoundException
     if int(customer['consumptions']['N']) < 1 and not customer.get('override', None):
         raise CorjiFreeloaderException
     fn = f(self, *args)
     if fn:
         emoji_customer.modify_consumptions(self.phone_number, 1)
     return fn
Пример #2
0
    def test_modify_consumptions(self):
        phone_number = "Hiya"

        customer = emoji_customer.get(phone_number)
        first_consumptions = int(customer["consumptions"]["N"])

        emoji_customer.modify_consumptions(phone_number, consumptions=-10)

        customer = emoji_customer.get(phone_number)
        second_consumptions = int(customer["consumptions"]["N"])

        assert first_consumptions + 10 == second_consumptions
Пример #3
0
def process_charge():

    email = request.form['stripeEmail']
    customer = stripe.Customer.create(
        card=request.form['stripeToken'],
        email=email
    )

    amount = settings.Config.RECHARGE_PRICE
    stripe.Charge.create(
        customer=customer.id,
        amount=amount,
        currency='usd',
        description='Corji'
    )

    phone_number = request.form['phone_number']

    emoji_customer.modify_consumptions(phone_number, settings.Config.CONSUMPTIONS_PER_RECHARGE)
    emoji_customer.add_metadata(phone_number, 'email', email)

    return render_template('html/stripe/stripe_success.html')