自定义参数未使用 Stripe 帐户保存,Rails

Custom params not saving with Stripe account, Rails

这是我第一次使用 API,我正在尝试使用 Stripe Connect 创建一个托管帐户。我创建帐户没有问题,但是我似乎无法从要在创建时发送到 Stripe 的表单中获取参数。

stripe/new.html.erb

<%= form_for(@payment) do |f| %>
  <%= f.text_field :first_name %>
  <%= f.text_field :last_name %>
  <%= f.select :country, options_for_select(country_select)%>
  <%= f.text_field :month %>
  <%= f.text_field :day %>
  <%= f.text_field :year %>
  <%= f.submit "create merchant account" %>
<% end %>

stripe_controller.rb

def create
  @artist = current_artist

  Stripe.api_key = Rails.configuration.stripe[:secret_key]
  @account = Stripe::Account.create(
    managed: true,
    country: params[:country],
    email: @artist.email,
    tos_acceptance: {
      ip: request.remote_ip,
      date: Time.now.to_i
    },
    legal_entity: {
      dob: {
        day: params[:day],
        month: params[:month],
        year: params[:year]
      },
      first_name: params[:first_name],
      last_name: params[:last_name],
      type: 'individual',
    }
  )

  if @account.save
    @payment = @artist.create_artist_payment_setting(
        currency: @account.default_currency,
        country: @account.country,
        stripe_id: @account.id,
        stripe_secret_key: @account.keys.secret,
        stripe_publishable_key: @account.keys.publishable
      )
  end

  redirect_to artist_path(@artist)
end

在您的 params 中,所有属性都嵌套在一个散列中 payment

所以尝试这样访问:

params[:payment][:day] 而不是 params[:day]

params[:payment][:month] 而不是 params[:month]

params[:payment][:year] 而不是 params[:year]

...您表单的所有其他属性依此类推。