diff --git a/lib/bank_audi.rb b/lib/bank_audi.rb index 3f5ab4d..1d22f9e 100644 --- a/lib/bank_audi.rb +++ b/lib/bank_audi.rb @@ -96,7 +96,7 @@ def valid_vpc_secure_hash? end def valid_vpc_txn_response_code? - !(vpc_txn_response_code == '7' || vpc_txn_response_code.blank?) + vpc_txn_response_code == '0' end def sort_keys(attributes) diff --git a/lib/bank_audi/version.rb b/lib/bank_audi/version.rb index 8c9ab2e..9f5fdfb 100644 --- a/lib/bank_audi/version.rb +++ b/lib/bank_audi/version.rb @@ -1,3 +1,3 @@ module BankAudi - VERSION = "0.2.3" + VERSION = "0.2.4" end diff --git a/spec/bank_audi_spec.rb b/spec/bank_audi_spec.rb index bdc22b3..8b5dc02 100644 --- a/spec/bank_audi_spec.rb +++ b/spec/bank_audi_spec.rb @@ -83,6 +83,13 @@ def valid(request) @response = BankAudi::Response.new end + def valid(response) + response.attributes = { :access_code => 'XXXXXX', :amount => 100, :merchant_txn_ref => 'merchant-txn-ref', + :merchant => 'XXXXXX', :order_info => 'order-info', :return_url => 'http://www.google.com', + :vpc_secure_hash => 'B2384E5659611034CFFC95842C66A4BA', :vpc_txn_response_code => '0' } + response + end + it 'should initialize with default attributes' do [:secret_code].each do |attribute| @response.send(attribute).should_not be_blank @@ -96,14 +103,19 @@ def valid(request) end it 'should be valid' do - @response.attributes = { :access_code => 'XXXXXX', :amount => 100, :merchant_txn_ref => 'merchant-txn-ref', - :merchant => 'XXXXXX', :order_info => 'order-info', :return_url => 'http://www.google.com', - :vpc_secure_hash => '82688C2F8F74B120E20C05CE7E4DC4F7', :vpc_txn_response_code => 'M' } - @response.should be_valid + valid(@response).should be_valid end it 'should be invalid' do @response.should_not be_valid + + response = valid(@response) + response.attributes[:vpc_txn_response_code] = 'M' + response.should_not be_valid + + response = valid(@response) + response.attributes[:amount] = 200 + response.should_not be_valid end end