Sha256: 7f4640ac8b292abfaebce50cbdd5ba6a943f738d755bded173a64facd5563147

Contents?: true

Size: 1.99 KB

Versions: 5

Compression:

Stored size: 1.99 KB

Contents

require 'test_helper'

module RubyPsigate
  class RemoteAccountTest < Test::Unit::TestCase
    
    def setup
      @gateway = RubyPsigate::Gateway.new(:cid => 1000001, :user_id => "teststore", :password => "testpass")
    end
    
    should "create a new billing account" do
      @account = RubyPsigate::Account.new
      @account.action = { :account => :register }
      
      @credit_card = RubyPsigate::CreditCard.new(
        :number => "4111111111111111",
        :month  => "12",
        :year   => "2011",
        :verification_value => "123",
        :name   => "Bob John"
      )
      
      @account.email = "bob@gmail.com"
      @account.cc = @credit_card
      @account.address = valid_address
      
      @gateway.account = @account
      
      response = @gateway.commit!
      assert response.success?
    end
    
    should "register a new charge on billing account" do
      @response = setup_remote_account
      
      @account = RubyPsigate::Account.new
      @account.action = { :charges => :immediate }
      @account.account_id = @response.accountid
      @account.serial_no = @response.serialno

      @recurring_charge = RecurringCharge.new(:rbname => "Immediate Payment", :storeid => "teststore")
      @recurring_charge << valid_recurring_item
      
      @account.rbcharge = @recurring_charge
      
      @gateway.account = @account
      response = @gateway.commit!
      assert response.success?
    end
    
    private
    
    def setup_remote_account
      @account = RubyPsigate::Account.new
      @account.action = { :account => :register }
      
      @credit_card = RubyPsigate::CreditCard.new(
        :number => "4111111111111111",
        :month  => "12",
        :year   => "2011",
        :verification_value => "123",
        :name   => "Bob John"
      )
      
      @account.email = "bob@gmail.com"
      @account.cc = @credit_card
      @account.address = valid_address
      
      @gateway.account = @account
      
      @response = @gateway.commit!
    end
    
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
ruby_psigate-0.7.8 test/remote/remote_account_test.rb
ruby_psigate-0.7.7 test/remote/remote_account_test.rb
ruby_psigate-0.7.6 test/remote/remote_account_test.rb
ruby_psigate-0.7.5 test/remote/remote_account_test.rb
ruby_psigate-0.7.4 test/remote/remote_account_test.rb