#theraihan

1 messages · Page 1 of 1 (latest)

jagged vaultBOT
gloomy jewel
#

Can you share an example API request you make to create Accounts and/or Account Links

cinder prawn
#

sure

#

@api_view(['GET'])
@permission_classes([IsAuthenticated])
def stripe_account_link(request):
"""summary
It will return an url which will be used in the frontend to redirect the user to that url for completing the onboarding process of stripe connected accounts.

Returns:
    {
        "object": "account_link",
        "created": 1680577733,
        "expires_at": 1680578033,
        "url": "https://connect.stripe.com/setup/c/acct_1Mt0CORHFI4mz9Rw/TqckGNUHg2mG"
    }
"""
vendor = Vendor.objects.filter(user = request.user).first()
if vendor is None:
    return Response({"error": "You are not vendor"})

stripe.api_key = STRIPE_API_KEY

if vendor.stripe_id is None:
    try:
        response = stripe.Account.create(
            type="custom",
            country=str(vendor.country),
            email=str(vendor.email),
            capabilities={
                "card_payments": {"requested": True},
                "transfers": {"requested": True},
            },
        )
        vendor.stripe_id = response.id
        vendor.save()
    except Exception as e:
        return Response({"error": f"{e}"})

if vendor.stripe_onboarding is False:
    try:
        response = stripe.AccountLink.create(
            account= vendor.stripe_id,
            refresh_url="https://vendors.pinksurfing.com/reauth", # if link expires or visited. this url may be the url where he can click to start the onboarding again.
            return_url="https://vendors.pinksurfing.com/", # after complition of onboarding process
            type="account_onboarding",
        )
        return Response(response)
    except Exception as e:
        print(e)
        return Response({"error": f"{e}"})
else:
#

This is an example python refrence

gloomy jewel
#

I suspect it's because you're passing the country parameter

#

And the value is likely US?

#

Which if true, means that the user can't change country during onboarding UI

cinder prawn
#

No vendor.country variable means that it’ll pass the vendors country

#

Suppose Canada, India…

gloomy jewel
#

What specificvally do you mean by ' stripe onboarding the default currency is set to USA'? Can you share a screenshot?

cinder prawn
#

Then would i get option to change my country to whatever i want?

#

Actually im creating a multivendor ecommerce so im using stripe onboarding to onboard vendors to my platform

cinder prawn
#

See even though my country is India then also United States is default

gloomy jewel
#

acct_1Mt0CORHFI4mz9Rw is a US account

cinder prawn
#

But if im onboarding then it should select my country right?

#

So how can i do onboarding sitting in India?

#

Or any other country

gloomy jewel
#

But otherwise, if you create a US account you need to provide US addresses as there needs to be a legal entity for the company located in the US

cinder prawn
#

Then after testing should switch to production?

cinder prawn
gloomy jewel
#

Then the same applies, but for those other countries. Whatever country you pass when creating the account you need to onboard with an address there

cinder prawn
#

And would i be able to change the home address?

gloomy jewel
#

I don't understand the question