【问题标题】:What am I doing wrong creating this Stripe charge using Flask and axios?使用 Flask 和 axios 创建这个 Stripe 费用我做错了什么?
【发布时间】:2019-03-16 15:41:31
【问题描述】:

我在前端使用 Vue,并且成功调用了结帐模式,并且在发送该模式的表单时成功创建了令牌。但是,我无法在后端实际创建费用。

这一切都是从我的 Vue 组件中的这个方法开始的,它在表单发送后处理令牌:

done ({token, args}) {
  // token - is the token object
  // args - is an object containing the billing and shipping address if enabled
  // do stuff...
  this.$refs.addBookModal.show();
  $backend.createStripeCharge(token.email, token)
},

backend.js 中的 createStripeCharge 函数如下:

createStripeCharge(电子邮件,令牌){ console.log('创建条带电荷调用')

return $axios.post(`/resource/${email}`)
  .then(response => response.data)
  .catch(error => {
    this.error = error.message
  })   
},

这是 Flask 中的路线:

@api_rest.route('/resource/<string:resource_id>')
class ResourceOne(Resource):
""" Unsecure Resource Class: Inherit from Resource """

def post(token, user_email):
    charge = stripe.Charge.create(
        customer = token.id,
        amount = 2500,
        currency='usd', 
        description='25',
        recipent_email=user_email
    )

但是,我收到 500 内部服务器错误。我做错了什么?

【问题讨论】:

    标签: flask stripe-payments


    【解决方案1】:

    我发现ResourceOne 的 post 方法的一个问题是它有两个参数,而您在backend.jscreateStripeCharge 函数中只传递了一个参数。

    (此外,如果您在此处发布错误日志,对其他 SO 用户总是有帮助的。)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-01-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多