-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'dev' of github.com:/sweeftdigital/accounts_G2 into dev
- Loading branch information
Showing
10 changed files
with
789 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Generated by Django 5.0.4 on 2024-11-02 11:42 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
("apis", "0018_customuser_two_factor_authentication_method"), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name="customuser", | ||
name="stripe_account_id", | ||
field=models.CharField(blank=True, max_length=255, null=True), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
# import stripe | ||
# import pycountry | ||
# from django.shortcuts import get_object_or_404 | ||
# | ||
# from django.urls import reverse | ||
# | ||
# from apis.models import Company, Individual | ||
# | ||
# | ||
# def get_country_code(country_name): | ||
# """Convert country name to ISO 3166-1 alpha-2 code""" | ||
# try: | ||
# # Try direct lookup first | ||
# country = pycountry.countries.get(name=country_name) | ||
# | ||
# if country: | ||
# return country.alpha_2 | ||
# | ||
# # If direct lookup fails, try searching | ||
# countries = pycountry.countries.search_fuzzy(country_name) | ||
# if countries: | ||
# return countries[0].alpha_2 | ||
# | ||
# except (AttributeError, LookupError): | ||
# return "US" # Default fallback | ||
# | ||
# return "US" | ||
# | ||
# | ||
# def create_stripe_connect_account(user, request): | ||
# country_code = get_country_code(user.country) | ||
# | ||
# print(country_code) | ||
# print("* *" * 50) | ||
# | ||
# # Get the appropriate profile based on user type | ||
# if user.user_profile_type == "Individual": | ||
# profile = get_object_or_404(Individual, user=user) | ||
# | ||
# # Create Stripe Connect account for Individual | ||
# account = stripe.Account.create( | ||
# type="express", | ||
# country=country_code, | ||
# email=user.email, | ||
# business_type="individual", | ||
# individual={ | ||
# "first_name": profile.first_name, | ||
# "last_name": profile.last_name, | ||
# "email": user.email, | ||
# "phone": str(user.phone_number) if user.phone_number else None, | ||
# "dob": { | ||
# "day": profile.date_of_birth.day if profile.date_of_birth else None, | ||
# "month": profile.date_of_birth.month if profile.date_of_birth else None, | ||
# "year": profile.date_of_birth.year if profile.date_of_birth else None, | ||
# } if profile.date_of_birth else None, | ||
# "address": { | ||
# "line1": user.address_one, | ||
# "line2": user.address_two, | ||
# "city": user.city, | ||
# "state": user.state, | ||
# "postal_code": user.zip_code, | ||
# "country": country_code, | ||
# } | ||
# }, | ||
# capabilities = { | ||
# # Only request the capabilities you actually need | ||
# "transfers": {"requested": True}, # Basic transfer capability | ||
# # Remove other capabilities like: | ||
# # "card_payments": {"requested": True}, | ||
# # "tax_reporting_us_1099_k": {"requested": True}, | ||
# }, | ||
# settings = { | ||
# 'payouts': { | ||
# 'schedule': { | ||
# 'interval': 'manual' # Simplifies payout setup | ||
# } | ||
# } | ||
# } | ||
# | ||
# ) | ||
# else: # Company | ||
# profile = get_object_or_404(Company, user=user) | ||
# | ||
# # Create Stripe Connect account for Company | ||
# account = stripe.Account.create( | ||
# type="express", | ||
# country=country_code, | ||
# email=user.email, | ||
# business_type="company", | ||
# company={ | ||
# "name": profile.company_name, | ||
# "tax_id": profile.company_code, # If company_code is a tax ID | ||
# "phone": str(user.phone_number) if user.phone_number else None, | ||
# }, | ||
# business_profile={ | ||
# "name": profile.company_name, | ||
# "support_email": profile.contact_person or user.email, | ||
# "support_phone": str(user.phone_number) if user.phone_number else None, | ||
# "url": None, # Add website URL if you have it in your model | ||
# }, | ||
# ) | ||
# | ||
# user.stripe_account_id = account.id | ||
# user.save() | ||
# | ||
# # Generate onboarding link | ||
# return_url = request.build_absolute_uri(reverse("stripe_account_return")) | ||
# refresh_url = request.build_absolute_uri(reverse("stripe_account_refresh")) | ||
# | ||
# account_link = stripe.AccountLink.create( | ||
# account=account.id, | ||
# refresh_url=refresh_url, | ||
# return_url=return_url, | ||
# type="account_onboarding", | ||
# collect="eventually_due", | ||
# ) | ||
# | ||
# return account_link.url |
Oops, something went wrong.