from django.core.files.storage import FileSystemStorage
import os
import random,string
import stripe
from django.conf import settings

def randomStringFunctionForImage():
    import random,string
    str1 = ''.join((random.choice(string.ascii_letters) for x in range(8)))
    str1 += ''.join((random.choice(string.digits) for x in range(4)))
    sam_list = list(str1)
    random.shuffle(sam_list)
    finalString = ''.join(sam_list)
    return finalString

def uploadTheImages(image):
    fullPath='media/admin'
    fs = FileSystemStorage(location=fullPath)
    fullPath2='media/admin'
    filetype = os.path.splitext(image.name)[1]
    theName=randomStringFunctionForImage()
    theImageName=str(theName)+str(filetype)
    filename = fs.save(theImageName, image)
    return str(fullPath2)+'/'+filename


def TransferToConnectedAccount(connect_account_id,amount,appointment_id):
	stripe.api_key = settings.STRIPE_SECRET_KEY
	stripe.Transfer.create(
    amount=int(amount)*100,
    currency="usd",
    destination=connect_account_id,
    transfer_group=appointment_id,
    )