【问题标题】:Django Stripe Connect account creationDjango Stripe Connect 帐户创建
【发布时间】: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


    【解决方案1】:

    你可以这样做:

    keys = stripeId['keys']
    secret = keys['secret']
    publishable = keys['publishable']
    

    现在您可以在数据库中保存秘密和可发布的值。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-09-30
      • 2021-06-24
      • 2021-03-30
      • 2021-07-13
      • 2020-11-06
      • 2021-05-15
      • 2017-12-16
      • 2020-07-28
      相关资源
      最近更新 更多