【发布时间】:2021-09-27 08:47:24
【问题描述】:
我正在将条带集成到我的 Django Web 应用程序平台中。当卖家使用 Stripe Connect 时,会为他们创建一个帐户,并使用指定的 return_url 和 refresh_url 创建一个 AccountLink,Stripe 使用它来重定向回我的 Web 应用程序。但是,当卖家被重定向回我的 Web 应用程序时,他们不再登录到 Web 应用程序。有没有比强制用户重新登录更好的解决方案?
以下是一些sn-ps的代码:
views.py
def stripe_on_boarding(request):
if request.method == "GET":
stripe_sk = settings.STRIPE_SECRET_KEY
stripe.api_key = stripe_sk
user = request.user
account = None
print("I'm logged in as and am onboarding stripe [" + user.first_name + "]")
if user.stripe_account is None:
account = stripe.Account.create(type='express')
user.stripe_account = account.id
user.save()
print("Saved User Object!")
else:
account = stripe.Account.retrieve(user.stripe_account)
if account is not None and not account.details_submitted:
account_links = stripe.AccountLink.create(
account=account.id,
refresh_url='http://098c818fbf8a.ngrok.io/marketplace/stripe_on_boarding_refresh',
return_url='http://098c818fbf8a.ngrok.io/marketplace/seller_return',
type='account_onboarding',
)
return redirect(account_links.url)
return render(request, 'become_seller_part_1.html', {'msg' : "You've already registered with stripe.", 'is_registered' : True})
# TODO: render a page if this view was triggered by a method other than GET.
这可能是因为我使用 ngrok 重定向到我的本地主机吗?
【问题讨论】:
标签: python django stripe-payments