Python Django Stripe Connect帐户创建
我正在尝试使用Stripe提供的代码在Stripe Connect上创建一个帐户。一切正常,我提交了创建,并将条带id记录到我的数据库中。但是,如果我也想获得密钥,我如何检索它们?这样做的正确语法是什么 以下是我在视图中的代码:Python Django Stripe Connect帐户创建,python,django,stripe-payments,stripe-connect,Python,Django,Stripe Payments,Stripe Connect,我正在尝试使用Stripe提供的代码在Stripe Connect上创建一个帐户。一切正常,我提交了创建,并将条带id记录到我的数据库中。但是,如果我也想获得密钥,我如何检索它们?这样做的正确语法是什么 以下是我在视图中的代码: if form.is_valid(): mail = form.cleaned_data['email'] name = form.cleaned_data['first_name'] lastName = form.cleaned_data['
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"
}
}
JSON:{
“id”:“账户号1033zf2gFw4ArzaQ”,
.
.
.
“钥匙”:{
“秘密”:“sk_test_adveekmolyxhozv4kqlwojt”,
“可出版”:“pk_测试Gt3Bk3C07gz2wnrI3hQWJQIi”
}
}
因此,要获取id,我使用的是stripeId['id']
,但如何获取密钥中的信息并将其传递到我的数据库?
谢谢。您可以这样做:
keys = stripeId['keys']
secret = keys['secret']
publishable = keys['publishable']
现在您可以在数据库中保存secret和publishable的值