import stripe
from django.conf import settings
import random
import string


def create_stripe_connectAccount(email):
	try:
		stripe.api_key = settings.STRIPE_SECRET_KEY
		customer = stripe.Account.create(
        type="express",
        country="US",
        email=email,
        capabilities={
            "card_payments": {"requested": True},
            "transfers": {"requested": True},
        },
        )
		if customer:
			connect_id = customer['id']
		else:
			connect_id = ''
	except Exception as e:
		print(e)
	return connect_id



def create_account_url(account_id,fortune_id):
	try:
		url = ''
		stripe.api_key = settings.STRIPE_SECRET_KEY
		connect_url = stripe.AccountLink.create(
			account=account_id,
			refresh_url="https://example.com/reauth",
			return_url="http://54.225.243.254:9009/fortune_teller/success-url?fortune=" + str(fortune_id),
			type="account_onboarding",
		)
		if connect_url:
			url = connect_url['url']
		else:
			url = ''
	except Exception as e:
		print(e)
	return url
