【发布时间】: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