STRIPE NameError:main:Object的未定义局部变量或方法“ request”

时间:2019-09-06 16:30:52

标签: ruby-on-rails ruby stripe-payments payment

我正在尝试更新关联的帐户,以便它可以接受服务条款并能够创建付款。但是,当我尝试在控制台中运行代码以使其更新时,它不会更新,并且会弹出有关IP地址的错误。我正在按照Stripe的文档来更新帐户。

我尝试不将ip包含在tos_acceptance中,但是ip是必需的! 我尝试使用“ ip”并在request.remote_ip

周围加上引号
"acct_id_12345", {
  tos_acceptance: {
    date: Time.now.to_i,
    ip: request.remote_ip,
  },
},
)

出现的错误是:

NameError: undefined local variable or method `request' for main:Object

2 个答案:

答案 0 :(得分:0)

您正在不存在request方法的地方运行代码,例如。在控制器外部。

答案 1 :(得分:0)

我只需要将请求变量命名为最终产品:

  account = Stripe::Account.create({
      country: "US",
      type: "custom",
      requested_capabilities: ["transfers", "card_payments"],
      email: current_user.email,
      business_type: "company",
      company: {
        name: business.name,
        address: {
          city: business.city,
          country: 'US',
          line1: business.address,
          postal_code: business.zip_code,
          state: business.state,
        },
        phone: '3128880912',
        tax_id: '000000000',
      },
      external_account: {
        country: "US",
        object: "bank_account",
        account_number: params[:account_number],
        routing_number: params[:routing_number],
      },
      settings: {
        payouts: {
          schedule: {
            interval: 'monthly',
            monthly_anchor: 1,
          },
        },
      },
      business_profile: {
        url: business.website,
        mcc: 5734,
      },
      tos_acceptance: {
        date: Time.now.to_i,
        ip: '181.48.147.209',
      },
    })