Esempio n. 1
0
File: db.py Progetto: deltron/veosan
def get_paid_from_origin(origin):
    if origin:
        provider_keys = Provider.query(Provider.signup_origin == origin).fetch(keys_only=True)
        if provider_keys:
            provider_account_count = ProviderAccount.query(ProviderAccount.provider.IN(provider_keys)).count()
            return provider_account_count
        else:
            return 0
Esempio n. 2
0
    def post(self, vanity_url=None):
        provider = db.get_provider_from_vanity_url(vanity_url)

        # set your secret key: remember to change this to your live secret key in production
        # see your keys here https://manage.stripe.com/account
        if util.is_dev_server(self.request):
            stripe.api_key = _STRIPE_TEST_KEY_SECRET
        else:
            stripe.api_key = _STRIPE_PROD_KEY_SECRET

        # get the credit card details submitted by the form
        token = self.request.POST['stripeToken']
        plan = self.request.POST['plan']

        try:
            customer = stripe.Customer.create(card=token,
                                              plan=plan,
                                              email=provider.email)

            # save the customer ID in your database so you can use it later
            provider_account = ProviderAccount()
            provider_account.provider = provider.key
            provider_account.stripe_customer_id = customer.id
            provider_account.stripe_plan_id = plan
            provider_account.put()

            provider.booking_enabled = True
            provider.upgrade_enabled = False

            provider.put()

            self.redirect("/provider/upgrade/success/" + provider.vanity_url)
        except CardError:
            self.render_template("provider/upgrade_failed.html",
                                 provider=provider)
Esempio n. 3
0
File: db.py Progetto: phiiil/veosan
def get_paid_from_origin(origin):
    if origin:
        provider_keys = Provider.query(Provider.signup_origin == origin).fetch(
            keys_only=True)
        if provider_keys:
            provider_account_count = ProviderAccount.query(
                ProviderAccount.provider.IN(provider_keys)).count()
            return provider_account_count
        else:
            return 0
Esempio n. 4
0
    def post(self, vanity_url=None):
        provider = db.get_provider_from_vanity_url(vanity_url)

        # set your secret key: remember to change this to your live secret key in production
        # see your keys here https://manage.stripe.com/account
        if util.is_dev_server(self.request):
            stripe.api_key = _STRIPE_TEST_KEY_SECRET
        else:
            stripe.api_key = _STRIPE_PROD_KEY_SECRET
        
        # get the credit card details submitted by the form
        token = self.request.POST['stripeToken']
        plan = self.request.POST['plan']

        try :
            customer = stripe.Customer.create(
                card=token,
                plan=plan,
                email=provider.email
            )
    
            # save the customer ID in your database so you can use it later
            provider_account = ProviderAccount()
            provider_account.provider = provider.key
            provider_account.stripe_customer_id = customer.id
            provider_account.stripe_plan_id = plan
            provider_account.put()
            
            provider.booking_enabled = True
            provider.upgrade_enabled = False

            provider.put()
            
            self.redirect("/provider/upgrade/success/" + provider.vanity_url)
        except CardError:
            self.render_template("provider/upgrade_failed.html", provider=provider)