Search code examples
ruby-on-railsrubystripe-paymentspayment

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


I am trying to update a connected account so it can accept the terms of service and be able to create a payout. however, when I try to run the code in the console so it updates it doesn't update and that error regarding the ip address pops up. I am following stripe's documentation to update accounts.

I have tried not including ip into the tos_acceptance, but the ip is neccessary! I tried 'ip' and putting quotes around request.remote_ip

"acct_id_12345", {
  tos_acceptance: {
    date: Time.now.to_i,
    ip: request.remote_ip,
  },
},
)

the error that appears is:

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


Solution

  • I just needed to name the request variable this is the final product:

      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',
          },
        })