def mint_stripe_customers_for_all_profiles():

    stripe.api_key = os.getenv("STRIPE_API_KEY")

    for profile in page_query(Profile.query.order_by(Profile.email.asc())):

        if profile.stripe_id:
            print u"Already a Stripe customer for {email}; skipping".format(
                email=profile.email
            )
            continue


        full_name = u"{first} {last}".format(
            first=profile.given_name,
            last=profile.surname
        )
        if profile.is_advisor:
            print u"making an Advisor Stripe customer for {email} ".format(email=profile.email)
            stripe_customer = stripe.Customer.create(
                description=full_name,
                email=profile.email,
                plan="base",
                coupon="ADVISOR_96309"
            )
        else:
            print u"making a regular Stripe customer for {email} ".format(email=profile.email)            
            stripe_customer = stripe.Customer.create(
                description=full_name,
                email=profile.email,
                plan="base" 
            )

        print u"Successfully made stripe id " + stripe_customer.id

        profile.stripe_id = stripe_customer.id
        db.session.merge(profile)
        db.session.commit()
dataset/ETHPy150Open Impactstory/total-impact-webapp/scripts.py/mint_stripe_customers_for_all_profiles/original