【发布时间】:2018-06-17 15:19:50
【问题描述】:
我正在尝试使用 Stripe 提供的代码在 Stripe Connect 上创建一个帐户。一切正常,我提交了创建,并将 stripe_id 记录到我的数据库中。但是,如果我也想获取密钥,我该如何检索它们?这样做的正确语法是什么?
这是我在视图中的代码:
if form.is_valid():
mail = form.cleaned_data['email']
name = form.cleaned_data['first_name']
lastName = form.cleaned_data['last_name']
country = form.cleaned_data['country']
stripeId = stripe.Account.create(type="custom", country=country, email=mail, )
p = UserStripe.objects.create(
user=request.user,
stripe_id=stripeId['id'])
print(p)
print(stripeId['id'])
API 返回的密钥如下:
<Account account id=... at 0x00000a> JSON: {
"id": "acct_1033zf2gFw4ArzaQ",
.
.
.
"keys": {
"secret": "sk_test_AdveEkmolYxHOzV4K4qLWoJt",
"publishable": "pk_test_Gt3Bk3C07gz2wnrI3hQWJQIi"
}
}
所以要获取我正在使用stripeId['id'] 的 id,但是如何获取密钥中的信息并将其传递到我的数据库?
谢谢。
【问题讨论】:
标签: python django stripe-payments stripe-connect