#hasnatt07_code
1 messages ¡ Page 1 of 1 (latest)
Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.
- hasnatt_payout-requirement, 2 days ago, 10 messages
đ Welcome to your new thread!
â˛ď¸ We'll be here soon! We typically respond in a few minutes, but in some cases we might need a bit more time (e.g., server's busy, you've got a complex question, etc.).
âąď¸ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can start a new thread if you have another question.
đ This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1249816437250588733
đ Have more to share? Add details, code, screenshots, videos, etc. below.
def transfer_to_driver_connected_account(driver, amount):
if not driver.stripe_account_id:
raise Exception("Driver does not have a Stripe account.")
try:
# Transfer funds to the driver's connected account
transfer = stripe.Transfer.create(
amount=int(amount * 100), # Convert to cents
currency="usd",
destination=driver.stripe_account_id,
)
return transfer
except stripe.error.StripeError as e:
print(f"Error creating transfer: {e}")
return None
def create_payout_to_driver_bank_account(driver, amount):
try:
# Create the payout from the driver's connected account to their bank account
payout = stripe.Payout.create(
amount=int(amount * 100), # Convert to cents
currency="usd",
stripe_account=driver.stripe_account_id,
)
return payout
except stripe.error.StripeError as e:
print(f"Error creating payout: {e}")
return None
finance dashboard
def finance_dashboard(request):
driver = request.user
total_earnings = calculate_driver_earnings(driver)
#requirements = check_account_requirements(driver)
#if requirements:
# print('update_stripe_account')
try:
balance = stripe.Balance.retrieve()
available_balance = balance['available'][0]['amount'] / 100 # Convert from cents to dollars
except Exception as e:
available_balance = None
error_message = str(e)
if request.method == 'POST':
amount = total_earnings
# Step 1: Transfer funds to the driver's connected account
transfer = transfer_to_driver_connected_account(driver, amount)
if transfer:
# Step 2: Create payout to the driver's bank account
payout = create_payout_to_driver_bank_account(driver, amount)
if payout:
return JsonResponse({'status': 'success', 'payout': payout})
else:
return JsonResponse({'status': 'error', 'message': 'Payout failed'})
else:
return JsonResponse({'status': 'error', 'message': 'Transfer failed'})
return render(request, 'finance/finance.html', {'total_earnings': total_earnings, 'available_balance': available_balance})
Hello, it looks like you are running in to our cross border payout restrictions. US connected accounts need a full service agreement and funds can't be sent to them from platforms that are not in their region. You can do our direct charge or on_behalf_of flows, but both of those make the connected account the merchant of record, which may not make sense for gig economy apps
https://docs.stripe.com/connect/cross-border-payouts
Another option is to create a US account to be the platform for your US accounts.
Can you tell me a bit more about what you are trying to build and the geography of your country/users?