条带 - 日志和检索数据之间的差异

时间:2017-11-01 16:26:37

标签: ruby-on-rails-4 stripe-payments stripe-connect

Stripe有2个问题。

  1. 只有联系客户支持才能解决此错误吗?

    You cannot change 'legal_entity[personal_id_number]' via API if an account is verified. Please contact support@stripe.com if you need to change the legal entity information associated with this account.

  2. 仪表板上的日志和检索到的数据不同。仪表板上的最新日志如下所示,但在此之后我确实与Stripe通信,并且仪表板没有得到这个。

    {
      "id": "acct_*************",
      "object": "account",
      "business_logo": null,
      "business_name": null,
      "business_url": null,
      "charges_enabled": true,
      "country": "US",
      "debit_negative_balances": false,
      "decline_charge_on": {
        "avs_failure": false,
        "cvc_failure": false
      },
      "default_currency": "usd",
      "details_submitted": false,
      "display_name": null,
      "email": "xxxxxxx@mailinator.com",
      "external_accounts": {
        "object": "list",
        "data": [
        ],
        "has_more": false,
        "total_count": 0,
        "url": "/v1/accounts/acct_*************/external_accounts"
      },
      "keys": {
        "secret": "sk_test_*******",
        "publishable": "pk_test_*******"
      },
      "legal_entity": {
        "additional_owners": [
        ],
        "address": {
          "city": null,
          "country": "US",
          "line1": null,
          "line2": null,
          "postal_code": null,
          "state": null
        },
        "business_name": null,
        "business_tax_id_provided": false,
        "dob": {
          "day": null,
          "month": null,
          "year": null
        },
        "first_name": null,
        "last_name": null,
        "personal_address": {
          "city": null,
          "country": "US",
          "line1": null,
          "line2": null,
          "postal_code": null,
          "state": null
        },
        "personal_id_number_provided": false,
        "ssn_last_4_provided": false,
        "type": "individual",
        "verification": {
          "details": null,
          "details_code": null,
          "document": null,
          "status": "unverified"
        }
      },
      "metadata": {
      },
      "payout_schedule": {
        "delay_days": 2,
        "interval": "daily"
      },
      "payout_statement_descriptor": null,
      "payouts_enabled": false,
      "product_description": null,
      "statement_descriptor": "",
      "support_email": null,
      "support_phone": null,
      "timezone": "Etc/UTC",
      "tos_acceptance": {
        "date": 1509265479,
        "ip": "::1",
        "user_agent": null
      },
      "type": "custom",
      "verification": {
        "disabled_reason": null,
        "due_by": null,
        "fields_needed": [
          "external_account",
          "legal_entity.dob.day",
          "legal_entity.dob.month",
          "legal_entity.dob.year",
          "legal_entity.first_name",
          "legal_entity.last_name"
        ]
      }
    }
    

    并且检索到的数据的某些部分如下所示。付款未在日志中启用,但在此处启用。 fields_needed也非常不同。

    {:details_submitted=>true, :charges_enabled=>true, :payouts_enabled=>true, :fields_needed=>[\"legal_entity.personal_id_number\"], :due_by=>nil}

  3. 我的Stripe控制器是;

    class StripeManaged < Struct.new(:org_person)
      ALLOWED = ['US', 'CA', 'TW'] # public beta
      COUNTRIES = [
        {name: 'United States', code: 'US'},
        {name: 'Canada', code: 'CA'},
        {name: 'Taiwan', code: 'TW'}
        # { name: 'Australia', code: 'AU' },
        # { name: 'United Kingdom', code: 'GB' },
        # { name: 'Ireland', code: 'IE' }
      ]
    
      def create_account!(country, tos_accepted, ip)
        return nil unless tos_accepted
        return nil unless country.in?(COUNTRIES.map {|c| c[:code]})
    
        begin
          @account = Stripe::Account.create(
            type: "custom",
            country: country,
            email: org_person.email,
            tos_acceptance: {
              ip: ip,
              date: Time.now.to_i
            },
            legal_entity: {
              type: 'individual'
            }
          )
        rescue
          nil # TODO: improve
        end
    
        if @account
          org_person.update_attributes(
            stripe_currency: @account.default_currency,
            stripe_account_type: 'custom', # name has been changed from 'managed' to 'custom'
            stripe_user_id: @account.id,
            stripe_secret_key: @account.keys.secret,
            stripe_publishable_key: @account.keys.publishable,
            stripe_account_status: account_status
          )
        end
    
        @account
      end
    
      def update_account!(params: nil)
        if params
          if params[:bank_account_token]
            account.external_account = params[:bank_account_token]
            account.save
          end
    
          if params[:legal_entity]
            # clean up dob fields
            params[:legal_entity][:dob] = {
              year: params[:legal_entity].delete('dob(1i)'),
              month: params[:legal_entity].delete('dob(2i)'),
              day: params[:legal_entity].delete('dob(3i)')
            }
    
            # update legal_entity hash from the params
            params[:legal_entity].entries.each do |key, value|
              if [ :address, :dob ].include? key.to_sym
                value.entries.each do |akey, avalue|
                  next if avalue.blank?
                  # Rails.logger.error "#{akey} - #{avalue.inspect}"
                  account.legal_entity[key] ||= {}
                  account.legal_entity[key][akey] = avalue
                end
              else
                next if value.blank?
                # Rails.logger.error "#{key} - #{value.inspect}"
                account.legal_entity[key] = value
              end
            end
    
            # copy 'address' as 'personal_address'
            pa = account.legal_entity['address'].dup.to_h
            account.legal_entity['personal_address'] = pa
    
            account.save
          end
        end
    
        org_person.update_attributes(stripe_account_status: account_status)
      end
    
      def legal_entity
        account.legal_entity
      end
    
      def needs?(field)
        org_person.stripe_account_status.match(Regexp.new(/#{field}/i)).present?
      end
    
      def supported_bank_account_countries
        country_codes = case account.country
                        when 'US' then %w{US}
                        when 'CA' then %w{US CA}
                        when 'IE', 'UK' then %w{IE UK US}
                        when 'AU' then %w{AU}
                        when 'TW' then %w{TW}
                        end
        COUNTRIES.select do |country|
          country[:code].in? country_codes
        end
      end
    
      protected
    
      def account_status
        {
          details_submitted: account.details_submitted,
          charges_enabled: account.charges_enabled,
          payouts_enabled: account.payouts_enabled,
          fields_needed: account.verification.fields_needed,
          due_by: account.verification.due_by
        }
      end
    
      def account
        @account ||= Stripe::Account.retrieve(org_person.stripe_user_id)
      end
    end
    

    我从2015年的教程中获得了这些代码,并根据Stripe的变化进行了更改。很棒,如果有人可以帮助我解决这些问题。感谢。

0 个答案:

没有答案
相关问题