【发布时间】:2015-11-13 06:45:58
【问题描述】:
我正在尝试实施条带支付,我知道条带要求您设置两次金额。一次在结帐时,另一次在服务器端。
我使用 web2py 作为我的框架。
所以我的问题是如何让它们匹配?
我通过 JS 使服务器端动态化,但我正在努力让服务器端拥有相同的数量。
# Set your secret key: remember to change this to your live secret key in production
# See your keys here https://dashboard.stripe.com/account/apikeys
stripe.api_key = "sk_test_BQokikJOvBiI2HlWgH4olfQ2"
# Get the credit card details submitted by the form
token = request.POST['stripeToken']
# Create the charge on Stripe's servers - this will charge the user's card
try:
charge = stripe.Charge.create(
amount=1000, # how to make this portion match the check out amount
currency="usd",
source=token,
description="Example charge"
)
except stripe.error.CardError, e:
# The card has been declined
pass
是否可以获取更多信息?
【问题讨论】:
-
您将令牌传递给您的服务器以通过
POST变量完成结帐。为什么不通过金额呢? -
我尝试用谷歌搜索,但我不知道如何使用 json/jquery 来做到这一点。但是很好
-
你是如何传递
stripeToken变量的?不管你怎么做,对金额做同样的事情。 -
stripeToken变量是使用 stripe 在网站上提供的 api 传递的。所以我不太确定这是怎么发生的。