Sha256: ac22df43a9b78c32e6e4a140aac0ba88f2b9b4f89251e8dc84190fb466da15e4

Contents?: true

Size: 1.02 KB

Versions: 10

Compression:

Stored size: 1.02 KB

Contents

# create payments based on the totals since they can't be known in YAML (quantities are random)
method = Spree::PaymentMethod.where(:name => 'Credit Card', :active => true).first

# Hack the current method so we're able to return a gateway without a RAILS_ENV
Spree::Gateway.class_eval do
  def self.current
    Spree::Gateway::Bogus.new
  end
end

creditcard = Spree::Creditcard.create({:cc_type => 'visa', :month => 12, :year => 2014, :last_digits => '1111',
                                      :first_name => 'Sean', :last_name => 'Schofield',
                                      :gateway_customer_profile_id => 'BGS-1234'}, :without_protection => true)

Spree::Order.all.each_with_index do |order,index|
  printf "\rProcessing order #{index}"
  STDOUT.flush
  order.update!
  payment = order.payments.create({:amount => order.total, :source => creditcard.clone, :payment_method => method}, :without_protection => true)
  payment.update_attributes_without_callbacks({
    :state => 'pending',
    :response_code => '12345'
  })
end
puts

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
spree_sample-1.1.6 db/sample/spree/payments.rb
spree_sample-1.1.5 db/sample/spree/payments.rb
spree_sample-1.1.4 db/sample/spree/payments.rb
spree_sample-1.1.3 db/sample/spree/payments.rb
spree_sample-1.1.2 db/sample/spree/payments.rb
spree_sample-1.1.2.rc1 db/sample/spree/payments.rb
spree_sample-1.1.1 db/sample/spree/payments.rb
spree_sample-1.1.0 db/sample/spree/payments.rb
spree_sample-1.1.0.rc2 db/sample/spree/payments.rb
spree_sample-1.1.0.rc1 db/sample/spree/payments.rb