我试图在我的Stripe.create中显示我的对象(服务)的数量,但是,每当我用一个包含该数字的变量替换该数字时,我从条带得到一个错误400。
我尝试用不同类型的变量替换数字,但似乎只有当我放置一个直接整数时它才有效。
@service_name = @service.name
@service_price = @service.price <-- {Tried this but doesn't work.}
@service_price = 9999 <-- {Tried this and it DOES work.}
require "stripe"
Stripe.api_key = Rails.application.credentials.stripe[:secret_key]
token = params[:stripeToken]
# Create a Customer:
customer = Stripe::Customer.create(
email: @email,
source: token,
)
# Charge the Customer instead of the card:
charge = Stripe::Charge.create({
amount: @service.price, <-- {This gives me an error}
currency: 'usd',
customer: customer.id,
description: @service_price <-- {But, this doesn't and it displays correctly}
})
每项服务都有价格,我希望它只显示该特定关联服务的价格。