realex 0.1.3 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/Rakefile CHANGED
@@ -25,7 +25,7 @@ begin
25
25
  gemspec.email = "paul@rslw.com"
26
26
  gemspec.homepage = "http://github.com/paulca/realex"
27
27
  gemspec.authors = ["Paul Campbell"]
28
- gemspec.version = "0.1.3"
28
+ gemspec.version = "0.2.0"
29
29
  gemspec.add_dependency 'hpricot'
30
30
  gemspec.add_dependency 'rio'
31
31
  end
@@ -4,10 +4,15 @@ module RealEx
4
4
  attributes :street, :city, :county
5
5
  attributes :post_code, :country, :country_code, :phone_numbers, :email
6
6
 
7
+ def initialize(*args)
8
+ super
9
+ @phone_numbers ||= {}
10
+ end
11
+
7
12
  [1,2,3].each do |line|
8
13
  class_eval do
9
14
  define_method("line#{line}") do
10
- street.split("\n")[line - 1]
15
+ street.to_s.split("\n")[line - 1]
11
16
  end
12
17
  end
13
18
  end
@@ -29,13 +29,15 @@ module RealEx
29
29
  add.city address.city
30
30
  add.county address.county
31
31
  add.postcode address.post_code
32
- add.country(address.country, :country_code => address.country_code)
32
+ add.country(address.country, :country_code => address.country_code)
33
33
  end
34
- payer.phonenumbers do |numbers|
35
- numbers.home address.phone_numbers[:home]
36
- numbers.work address.phone_numbers[:work]
37
- numbers.fax address.phone_numbers[:fax]
38
- numbers.mobile address.phone_numbers[:mobile]
34
+ if address.phone_numbers.kind_of?(Hash)
35
+ payer.phonenumbers do |numbers|
36
+ numbers.home address.phone_numbers[:home]
37
+ numbers.work address.phone_numbers[:work]
38
+ numbers.fax address.phone_numbers[:fax]
39
+ numbers.mobile address.phone_numbers[:mobile]
40
+ end
39
41
  end
40
42
  payer.email address.email
41
43
  if !comments.empty?
data/realex.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{realex}
8
- s.version = "0.1.3"
8
+ s.version = "0.2.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Paul Campbell"]
12
- s.date = %q{2010-02-26}
12
+ s.date = %q{2010-03-01}
13
13
  s.description = %q{A Ruby library to make use of the payments API at http://realexpayments.com}
14
14
  s.email = %q{paul@rslw.com}
15
15
  s.extra_rdoc_files = [
data/spec/address_spec.rb CHANGED
@@ -9,6 +9,13 @@ describe "RealEx::Address" do
9
9
  )
10
10
  end
11
11
 
12
+ it "should cope with an empty street" do
13
+ @address.street = nil
14
+ lambda {
15
+ @address.line1
16
+ }.should_not raise_error
17
+ end
18
+
12
19
  it "should just save the attributes" do
13
20
  @address.post_code.should == '1234'
14
21
  end
@@ -49,4 +49,27 @@ describe "RealEx::Recurring" do
49
49
  it "should create tasty XML for the authorization" do
50
50
  @transaction.to_xml.should == "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<request type=\"receipt-in\" timestamp=\"20090326160218\">\n <merchantid>paul</merchantid>\n <orderid>1234</orderid>\n <account>internet</account>\n <amount currency=\"EUR\">500</amount>\n <payerref>boom</payerref>\n <paymentmethod></paymentmethod>\n <sha1hash>ec3afd1714b4473210c2b1eda0c6675bd13c411b</sha1hash>\n</request>\n"
51
51
  end
52
+ end
53
+
54
+ describe "RealEx::Recurring without a full address" do
55
+ before do
56
+ RealEx::Config.merchant_id = 'paul'
57
+ RealEx::Config.shared_secret = "He's not dead, he's just asleep!"
58
+ RealEx::Config.account = 'internet'
59
+
60
+ @card = RealEx::Card.new(
61
+ :number => '4111111111111111',
62
+ :cvv => '509',
63
+ :expiry_date => '0802',
64
+ :cardholder_name => 'Paul Campbell',
65
+ :type => 'VISA',
66
+ :issue_number => nil
67
+ )
68
+ @payer = RealEx::Recurring::Payer.new(:type => 'Business', :reference => 'boom', :title => 'Mr.', :firstname => 'Paul', :lastname => 'Campbell', :company => 'Contrast')
69
+ @payer.address = RealEx::Address.new(:country => 'Ireland', :country_code => 'IE')
70
+ end
71
+
72
+ it "should convert the payer" do
73
+ @payer.to_xml.should match(/IE/)
74
+ end
52
75
  end
data/spec/spec_helper.rb CHANGED
@@ -5,13 +5,12 @@ rescue LoadError
5
5
  gem 'rspec'
6
6
  require 'spec'
7
7
  end
8
-
8
+
9
9
  dir = File.dirname(__FILE__)
10
-
10
+
11
11
  $:.unshift(File.join(dir, '/../lib/'))
12
- require dir + '/../lib/real_ex'
13
-
14
-
12
+ require dir + '/../lib/realex'
13
+
15
14
  def stdout_for(&block)
16
15
  # Inspired by http://www.ruby-forum.com/topic/58647
17
16
  old_stdout = $stdout
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
- - 1
8
- - 3
9
- version: 0.1.3
7
+ - 2
8
+ - 0
9
+ version: 0.2.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - Paul Campbell
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-02-26 00:00:00 +00:00
17
+ date: 2010-03-01 00:00:00 +00:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency