Ruby on rails 检索装运信息的条带费用
我正试图通过分条收费创建订单。目前,我可以通过账单地址:charge.source.address\u line1从账单中获取账单地址,但我无法获取配送信息 充电器控制器Ruby on rails 检索装运信息的条带费用,ruby-on-rails,stripe-payments,Ruby On Rails,Stripe Payments,我正试图通过分条收费创建订单。目前,我可以通过账单地址:charge.source.address\u line1从账单中获取账单地址,但我无法获取配送信息 充电器控制器 class ChargesController < ApplicationController def create @product = Product.find(params[:product_id]) #1 Create a charge customer = Stripe::Customer.creat
class ChargesController < ApplicationController
def create
@product = Product.find(params[:product_id])
#1 Create a charge
customer = Stripe::Customer.create(
email: current_user.email,
card: params[:stripeToken]
)
charge = Stripe::Charge.create(
customer: customer.id, # Note -- this is NOT the user_id in your app
amount: (@product.price * 100).to_i,
description: @product.title,
currency: 'usd',
)
#3 Create an Order
Order.create(
user: current_user,
billing_address: charge.source.address_line1
)
flash[:notice] = "Thank you for your order, #{current_user.email}! "
redirect_to books_path # or wherever
rescue Stripe::CardError => e
flash[:error] = e.message
redirect_to new_charge_path
end
end
def show
@stripe_btn_data = {
key: "#{ Rails.configuration.stripe[:publishable_key] }",
description: @product.title,
amount: (@product.price * 100),
shipping: :true,
billing: :true
}
如何从条纹费用中获取运输信息 经过一番尝试和错误,我想出了如何用配送地址:参数[:stripeShippingAddressLine1]
Order.create(
user: current_user,
billing_address: charge.source.address_line1,
billing_city: charge.source.address_city,
billing_state: charge.source.address_state,
billing_zip: charge.source.address_zip,
shipping_address: params[:stripeShippingAddressLine1]
)
经过一些尝试和错误,我想出了如何插入条纹电荷到我的db与配送地址:参数[:stripeShippingAddressLine1]
Order.create(
user: current_user,
billing_address: charge.source.address_line1,
billing_city: charge.source.address_city,
billing_state: charge.source.address_state,
billing_zip: charge.source.address_zip,
shipping_address: params[:stripeShippingAddressLine1]
)