killbill-litle 1.8.2 → 1.9.0

Sign up to get free protection for your applications and to get access to all the features.
data/.travis.yml CHANGED
@@ -2,16 +2,17 @@ language: ruby
2
2
 
3
3
  notifications:
4
4
  email:
5
- - killbilling-dev@googlegroups.com
5
+ - kill-bill-commits@googlegroups.com
6
6
 
7
7
  rvm:
8
8
  - jruby-19mode
9
+ - jruby-20mode
9
10
  - jruby-head
10
11
 
11
12
  jdk:
13
+ - openjdk6
12
14
  - openjdk7
13
15
  - oraclejdk7
14
- - openjdk6
15
16
 
16
17
  matrix:
17
18
  allow_failures:
data/Jarfile CHANGED
@@ -1,5 +1,5 @@
1
- jar 'com.ning.billing:killbill-api', '0.6.0'
2
- jar 'com.ning.billing.plugin:killbill-plugin-api-notification', '0.4.0'
3
- jar 'com.ning.billing.plugin:killbill-plugin-api-payment', '0.4.0'
4
- jar 'com.ning.billing:killbill-util:tests', '0.6.0'
1
+ jar 'com.ning.billing:killbill-api', '0.7.1'
2
+ jar 'com.ning.billing.plugin:killbill-plugin-api-notification', '0.5.0'
3
+ jar 'com.ning.billing.plugin:killbill-plugin-api-payment', '0.5.0'
4
+ jar 'com.ning.billing:killbill-util:tests', '0.6.17'
5
5
  jar 'javax.servlet:javax.servlet-api', '3.0.1'
data/NEWS CHANGED
@@ -1,3 +1,8 @@
1
+ 1.9.0
2
+ Update to latest killbill (1.7.1)
3
+ Add pagination support for search
4
+ Improve search algorithm
5
+
1
6
  1.8.2
2
7
  Populate customer id for payments (see killbill/killbill-litle-plugin#1)
3
8
 
data/Rakefile CHANGED
@@ -6,12 +6,25 @@ Bundler::GemHelper.install_tasks
6
6
 
7
7
  # Install test tasks
8
8
  require 'rspec/core/rake_task'
9
- desc "Run RSpec"
10
- RSpec::Core::RakeTask.new
9
+ namespace :test do
10
+ desc "Run RSpec tests"
11
+ RSpec::Core::RakeTask.new do |task|
12
+ task.name = 'spec'
13
+ task.pattern = './spec/*/*_spec.rb'
14
+ end
15
+
16
+ namespace :remote do
17
+ desc "Run RSpec remote tests"
18
+ RSpec::Core::RakeTask.new do |task|
19
+ task.name = 'spec'
20
+ task.pattern = './spec/*/remote/*_spec.rb'
21
+ end
22
+ end
23
+ end
11
24
 
12
25
  # Install tasks to package the plugin for Killbill
13
26
  require 'killbill/rake_task'
14
27
  Killbill::PluginHelper.install_tasks
15
28
 
16
29
  # Run tests by default
17
- task :default => :spec
30
+ task :default => 'test:spec'
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.8.2
1
+ 1.9.0
data/db/ddl.sql CHANGED
@@ -21,7 +21,7 @@ CREATE TABLE `litle_payment_methods` (
21
21
  PRIMARY KEY (`id`),
22
22
  KEY `index_litle_payment_methods_on_kb_account_id` (`kb_account_id`),
23
23
  KEY `index_litle_payment_methods_on_kb_payment_method_id` (`kb_payment_method_id`)
24
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
24
+ ) ENGINE=InnoDB CHARACTER SET utf8 COLLATE utf8_bin;
25
25
 
26
26
  CREATE TABLE `litle_transactions` (
27
27
  `id` int(11) NOT NULL AUTO_INCREMENT,
@@ -34,7 +34,7 @@ CREATE TABLE `litle_transactions` (
34
34
  `updated_at` datetime NOT NULL,
35
35
  PRIMARY KEY (`id`),
36
36
  KEY `index_litle_transactions_on_kb_payment_id` (`kb_payment_id`)
37
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
37
+ ) ENGINE=InnoDB CHARACTER SET utf8 COLLATE utf8_bin;
38
38
 
39
39
  CREATE TABLE `litle_responses` (
40
40
  `id` int(11) NOT NULL AUTO_INCREMENT,
@@ -67,4 +67,4 @@ CREATE TABLE `litle_responses` (
67
67
  `created_at` datetime NOT NULL,
68
68
  `updated_at` datetime NOT NULL,
69
69
  PRIMARY KEY (`id`)
70
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
70
+ ) ENGINE=InnoDB CHARACTER SET utf8 COLLATE utf8_bin;
@@ -22,7 +22,7 @@ Gem::Specification.new do |s|
22
22
 
23
23
  s.rdoc_options << '--exclude' << '.'
24
24
 
25
- s.add_dependency 'killbill', '~> 1.6.0'
25
+ s.add_dependency 'killbill', '~> 1.7.1'
26
26
  s.add_dependency 'activemerchant', '~> 1.36.0'
27
27
  s.add_dependency 'activerecord', '~> 3.2.1'
28
28
  s.add_dependency 'sinatra', '~> 1.3.4'
data/lib/litle/api.rb CHANGED
@@ -159,8 +159,8 @@ module Killbill::Litle
159
159
  end
160
160
  end
161
161
 
162
- def search_payment_methods(search_key, call_context = nil, options = {})
163
- LitlePaymentMethod.search(search_key).map(&:to_payment_method_response)
162
+ def search_payment_methods(search_key, offset = 0, limit = 100, call_context = nil, options = {})
163
+ LitlePaymentMethod.search(search_key, offset, limit)
164
164
  end
165
165
 
166
166
  private
@@ -41,28 +41,12 @@ get '/plugins/killbill-litle' do
41
41
  :merchant_txn_id => request.GET['merchant_txn_id'] || '1',
42
42
  :order_id => request.GET['order_id'] || '1',
43
43
  :report_group => request.GET['report_group'] || 'Default Report Group',
44
- :success_page => params[:successPage] || '/plugins/killbill-litle/checkout',
44
+ :success_page => params[:successPage],
45
45
  :failure_page => params[:failurePage]
46
46
  }
47
47
  erb :paypage, :views => File.expand_path(File.dirname(__FILE__) + '/../views'), :locals => locals
48
48
  end
49
49
 
50
- post '/plugins/killbill-litle/checkout' do
51
- kb_account_id = request.POST['kb_account_id']
52
- response_paypage_registration_id = request.POST['response_paypage_registration_id']
53
- # Allow currency override if needed
54
- currency = request.POST['currency'] || plugin.get_currency(kb_account_id)
55
-
56
- {
57
- :kb_account_id => kb_account_id,
58
- :currency => currency,
59
- :response_paypage_registration_id => response_paypage_registration_id
60
- }.each { |k, v| required_parameter! k, v }
61
-
62
- pm = plugin.register_token! kb_account_id, currency, response_paypage_registration_id
63
- redirect "/plugins/killbill-litle/1.0/pms/#{pm.id}"
64
- end
65
-
66
50
  # curl -v http://127.0.0.1:9292/plugins/killbill-litle/1.0/pms/1
67
51
  get '/plugins/killbill-litle/1.0/pms/:id', :provides => 'json' do
68
52
  if pm = Killbill::Litle::LitlePaymentMethod.find_by_id(params[:id].to_i)
@@ -17,6 +17,8 @@ module Killbill::Litle
17
17
  @@config.parse!
18
18
  @@test = @@config[:litle][:test]
19
19
 
20
+ @@logger.log_level = Logger::DEBUG if (@@config[:logger] || {})[:debug]
21
+
20
22
  @@gateways = Killbill::Litle::Gateway.from_config(@@config[:litle])
21
23
 
22
24
  if defined?(JRUBY_VERSION)
@@ -26,6 +28,7 @@ module Killbill::Litle
26
28
  end
27
29
 
28
30
  ActiveRecord::Base.establish_connection(@@config[:database])
31
+ ActiveRecord::Base.logger = @@logger
29
32
 
30
33
  @@initialized = true
31
34
  end
@@ -16,7 +16,35 @@ module Killbill::Litle
16
16
 
17
17
  def self.unpack_uuid(base62_uuid)
18
18
  as_hex = base62_uuid.split(//).inject(0) { |i,e| i*62 + BASE62.index(e[0]) }
19
- ("%x" % as_hex).insert(8, "-").insert(13, "-").insert(18, "-").insert(23, "-")
19
+ no_hyphens = "%x" % as_hex
20
+ no_hyphens = '0' * (32 - no_hyphens.size) + no_hyphens
21
+ no_hyphens.insert(8, "-").insert(13, "-").insert(18, "-").insert(23, "-")
22
+ end
23
+ end
24
+
25
+ # Closest from a streaming API as we can get with ActiveRecord
26
+ class StreamyResultSet
27
+ include Enumerable
28
+
29
+ def initialize(limit, batch_size = 100, &delegate)
30
+ @limit = limit
31
+ @batch = [batch_size, limit].min
32
+ @delegate = delegate
33
+ end
34
+
35
+ def each(&block)
36
+ (0..(@limit - @batch)).step(@batch) do |i|
37
+ result = @delegate.call(i, @batch)
38
+ block.call(result)
39
+ # Optimization: bail out if no more results
40
+ break if result.nil? || result.empty?
41
+ end if @batch > 0
42
+ # Make sure to return DB connections to the Pool
43
+ ActiveRecord::Base.connection.close
44
+ end
45
+
46
+ def to_a
47
+ super.to_a.flatten
20
48
  end
21
49
  end
22
50
  end
@@ -35,24 +35,57 @@ module Killbill::Litle
35
35
  payment_method.save!
36
36
  end
37
37
 
38
- def self.search(search_key)
39
- search_columns = [
40
- :litle_token,
41
- :cc_first_name,
42
- :cc_last_name,
43
- :cc_type,
44
- :cc_exp_month,
45
- :cc_exp_year,
46
- :cc_last_4,
47
- :address1,
48
- :address2,
49
- :city,
50
- :state,
51
- :zip,
52
- :country
53
- ]
54
- query = search_columns.map(&:to_s).join(' like ? or ') + ' like ?'
55
- where(query, *search_columns.map { |e| "%#{search_key}%" })
38
+ # VisibleForTesting
39
+ def self.search_query(search_key, offset = nil, limit = nil)
40
+ t = self.arel_table
41
+
42
+ # Exact match for litle_token, cc_type, cc_exp_month, cc_exp_year, cc_last_4, state and zip, partial match for the reset
43
+ where_clause = t[:litle_token].eq(search_key)
44
+ .or(t[:cc_type].eq(search_key))
45
+ .or(t[:state].eq(search_key))
46
+ .or(t[:zip].eq(search_key))
47
+ .or(t[:cc_first_name].matches("%#{search_key}%"))
48
+ .or(t[:cc_last_name].matches("%#{search_key}%"))
49
+ .or(t[:address1].matches("%#{search_key}%"))
50
+ .or(t[:address2].matches("%#{search_key}%"))
51
+ .or(t[:city].matches("%#{search_key}%"))
52
+ .or(t[:country].matches("%#{search_key}%"))
53
+
54
+ if search_key.is_a? Numeric
55
+ where_clause = where_clause.or(t[:cc_exp_month].eq(search_key))
56
+ .or(t[:cc_exp_year].eq(search_key))
57
+ .or(t[:cc_last_4].eq(search_key))
58
+ end
59
+
60
+ query = t.where(where_clause)
61
+ .order(t[:id])
62
+
63
+ if offset.blank? and limit.blank?
64
+ # true is for count distinct
65
+ query.project(t[:id].count(true))
66
+ else
67
+ query.skip(offset) unless offset.blank?
68
+ query.take(limit) unless limit.blank?
69
+ query.project(t[Arel.star])
70
+ # Not chainable
71
+ query.distinct
72
+ end
73
+ query
74
+ end
75
+
76
+ def self.search(search_key, offset = 0, limit = 100)
77
+ pagination = Killbill::Plugin::Model::Pagination.new
78
+ pagination.current_offset = offset
79
+ pagination.total_nb_records = self.count_by_sql(self.search_query(search_key))
80
+ pagination.max_nb_records = self.count
81
+ pagination.next_offset = (!pagination.total_nb_records.nil? && offset + limit >= pagination.total_nb_records) ? nil : offset + limit
82
+ # Reduce the limit if the specified value is larger than the number of records
83
+ actual_limit = [pagination.max_nb_records, limit].min
84
+ pagination.iterator = StreamyResultSet.new(actual_limit) do |offset,limit|
85
+ self.find_by_sql(self.search_query(search_key, offset, limit))
86
+ .map(&:to_payment_method_response)
87
+ end
88
+ pagination
56
89
  end
57
90
 
58
91
  def to_payment_method_response
@@ -2,18 +2,6 @@ module Killbill::Litle
2
2
  class PrivatePaymentPlugin
3
3
  include Singleton
4
4
 
5
- def register_token!(kb_account_id, currency, paypage_registration_id, options = {})
6
- litle_response = gateway(currency).store paypage_registration_id, options
7
- response = save_response litle_response, :register_token
8
-
9
- if response.success
10
- # Create the payment method (not associated to a Killbill payment method yet)
11
- LitlePaymentMethod.create! :kb_account_id => kb_account_id, :kb_payment_method_id => nil, :litle_token => response.litle_token
12
- else
13
- raise response.message
14
- end
15
- end
16
-
17
5
  def get_currency(kb_account_id)
18
6
  account = kb_apis.get_account_by_id(kb_account_id)
19
7
  account.currency
@@ -23,25 +11,6 @@ module Killbill::Litle
23
11
 
24
12
  private
25
13
 
26
- def save_response(litle_response, api_call)
27
- logger.warn "Unsuccessful #{api_call}: #{litle_response.message}" unless litle_response.success?
28
-
29
- # Save the response to our logs
30
- response = LitleResponse.from_response(api_call, nil, litle_response)
31
- response.save!
32
- response
33
- end
34
-
35
- def gateway(currency)
36
- # The gateway should have been configured when the plugin started
37
- Killbill::Litle.gateway_for_currency(currency)
38
- end
39
-
40
- def logger
41
- # The logger should have been configured when the plugin started
42
- Killbill::Litle.logger
43
- end
44
-
45
14
  def kb_apis
46
15
  # The logger should have been configured when the plugin started
47
16
  Killbill::Litle.kb_apis
data/pom.xml CHANGED
@@ -25,7 +25,7 @@
25
25
  <groupId>com.ning.killbill.ruby</groupId>
26
26
  <artifactId>litle-plugin</artifactId>
27
27
  <packaging>pom</packaging>
28
- <version>1.8.2</version>
28
+ <version>1.9.0</version>
29
29
  <name>litle-plugin</name>
30
30
  <url>http://github.com/killbill/killbill-litle-plugin</url>
31
31
  <description>Plugin for accessing Litle as a payment gateway</description>
@@ -18,6 +18,7 @@ describe Killbill::Litle::PaymentPlugin do
18
18
 
19
19
  @plugin = Killbill::Litle::PaymentPlugin.new
20
20
  @plugin.logger = Logger.new(STDOUT)
21
+ @plugin.logger.level = Logger::INFO
21
22
  @plugin.conf_dir = File.dirname(file)
22
23
 
23
24
  # Start the plugin here - since the config file will be deleted
@@ -1,8 +1,30 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Killbill::Litle::LitlePaymentMethod do
4
+ before :all do
5
+ Killbill::Litle::LitlePaymentMethod.delete_all
6
+ end
7
+
8
+ it 'should generate the right SQL query' do
9
+ # Check count query (search query numeric)
10
+ expected_query = "SELECT COUNT(DISTINCT \"litle_payment_methods\".\"id\") FROM \"litle_payment_methods\" WHERE ((((((((((((\"litle_payment_methods\".\"litle_token\" = 1234 OR \"litle_payment_methods\".\"cc_type\" = 1234) OR \"litle_payment_methods\".\"state\" = 1234) OR \"litle_payment_methods\".\"zip\" = 1234) OR \"litle_payment_methods\".\"cc_first_name\" LIKE '%1234%') OR \"litle_payment_methods\".\"cc_last_name\" LIKE '%1234%') OR \"litle_payment_methods\".\"address1\" LIKE '%1234%') OR \"litle_payment_methods\".\"address2\" LIKE '%1234%') OR \"litle_payment_methods\".\"city\" LIKE '%1234%') OR \"litle_payment_methods\".\"country\" LIKE '%1234%') OR \"litle_payment_methods\".\"cc_exp_month\" = 1234) OR \"litle_payment_methods\".\"cc_exp_year\" = 1234) OR \"litle_payment_methods\".\"cc_last_4\" = 1234) ORDER BY \"litle_payment_methods\".\"id\""
11
+ Killbill::Litle::LitlePaymentMethod.search_query(1234).to_sql.should == expected_query
12
+
13
+ # Check query with results (search query numeric)
14
+ expected_query = "SELECT DISTINCT \"litle_payment_methods\".* FROM \"litle_payment_methods\" WHERE ((((((((((((\"litle_payment_methods\".\"litle_token\" = 1234 OR \"litle_payment_methods\".\"cc_type\" = 1234) OR \"litle_payment_methods\".\"state\" = 1234) OR \"litle_payment_methods\".\"zip\" = 1234) OR \"litle_payment_methods\".\"cc_first_name\" LIKE '%1234%') OR \"litle_payment_methods\".\"cc_last_name\" LIKE '%1234%') OR \"litle_payment_methods\".\"address1\" LIKE '%1234%') OR \"litle_payment_methods\".\"address2\" LIKE '%1234%') OR \"litle_payment_methods\".\"city\" LIKE '%1234%') OR \"litle_payment_methods\".\"country\" LIKE '%1234%') OR \"litle_payment_methods\".\"cc_exp_month\" = 1234) OR \"litle_payment_methods\".\"cc_exp_year\" = 1234) OR \"litle_payment_methods\".\"cc_last_4\" = 1234) ORDER BY \"litle_payment_methods\".\"id\" LIMIT 10 OFFSET 0"
15
+ Killbill::Litle::LitlePaymentMethod.search_query(1234, 0, 10).to_sql.should == expected_query
16
+
17
+ # Check count query (search query string)
18
+ expected_query = "SELECT COUNT(DISTINCT \"litle_payment_methods\".\"id\") FROM \"litle_payment_methods\" WHERE (((((((((\"litle_payment_methods\".\"litle_token\" = 'XXX' OR \"litle_payment_methods\".\"cc_type\" = 'XXX') OR \"litle_payment_methods\".\"state\" = 'XXX') OR \"litle_payment_methods\".\"zip\" = 'XXX') OR \"litle_payment_methods\".\"cc_first_name\" LIKE '%XXX%') OR \"litle_payment_methods\".\"cc_last_name\" LIKE '%XXX%') OR \"litle_payment_methods\".\"address1\" LIKE '%XXX%') OR \"litle_payment_methods\".\"address2\" LIKE '%XXX%') OR \"litle_payment_methods\".\"city\" LIKE '%XXX%') OR \"litle_payment_methods\".\"country\" LIKE '%XXX%') ORDER BY \"litle_payment_methods\".\"id\""
19
+ Killbill::Litle::LitlePaymentMethod.search_query('XXX').to_sql.should == expected_query
20
+
21
+ # Check query with results (search query string)
22
+ expected_query = "SELECT DISTINCT \"litle_payment_methods\".* FROM \"litle_payment_methods\" WHERE (((((((((\"litle_payment_methods\".\"litle_token\" = 'XXX' OR \"litle_payment_methods\".\"cc_type\" = 'XXX') OR \"litle_payment_methods\".\"state\" = 'XXX') OR \"litle_payment_methods\".\"zip\" = 'XXX') OR \"litle_payment_methods\".\"cc_first_name\" LIKE '%XXX%') OR \"litle_payment_methods\".\"cc_last_name\" LIKE '%XXX%') OR \"litle_payment_methods\".\"address1\" LIKE '%XXX%') OR \"litle_payment_methods\".\"address2\" LIKE '%XXX%') OR \"litle_payment_methods\".\"city\" LIKE '%XXX%') OR \"litle_payment_methods\".\"country\" LIKE '%XXX%') ORDER BY \"litle_payment_methods\".\"id\" LIMIT 10 OFFSET 0"
23
+ Killbill::Litle::LitlePaymentMethod.search_query('XXX', 0, 10).to_sql.should == expected_query
24
+ end
25
+
4
26
  it 'should search all fields' do
5
- Killbill::Litle::LitlePaymentMethod.search('foo').size.should == 0
27
+ do_search('foo').size.should == 0
6
28
 
7
29
  pm = Killbill::Litle::LitlePaymentMethod.create :kb_account_id => '11-22-33-44',
8
30
  :kb_payment_method_id => '55-66-77-88',
@@ -20,13 +42,14 @@ describe Killbill::Litle::LitlePaymentMethod do
20
42
  :zip => 'zip',
21
43
  :country => 'country'
22
44
 
23
- Killbill::Litle::LitlePaymentMethod.search('foo').size.should == 0
24
- Killbill::Litle::LitlePaymentMethod.search(pm.litle_token).size.should == 1
25
- Killbill::Litle::LitlePaymentMethod.search('cc').size.should == 1
26
- Killbill::Litle::LitlePaymentMethod.search('address').size.should == 1
27
- Killbill::Litle::LitlePaymentMethod.search(2343).size.should == 1
28
- Killbill::Litle::LitlePaymentMethod.search('name').size.should == 1
29
- Killbill::Litle::LitlePaymentMethod.search('Name').size.should == 1
45
+ do_search('foo').size.should == 0
46
+ do_search(pm.litle_token).size.should == 1
47
+ do_search('ccType').size.should == 1
48
+ # Exact match on ly for cc_last_4
49
+ do_search(123).size.should == 0
50
+ # Test partial match
51
+ do_search('address').size.should == 1
52
+ do_search('Name').size.should == 1
30
53
 
31
54
  pm2 = Killbill::Litle::LitlePaymentMethod.create :kb_account_id => '22-33-44-55',
32
55
  :kb_payment_method_id => '66-77-88-99',
@@ -44,13 +67,25 @@ describe Killbill::Litle::LitlePaymentMethod do
44
67
  :zip => 'zip',
45
68
  :country => 'country'
46
69
 
47
- Killbill::Litle::LitlePaymentMethod.search('foo').size.should == 0
48
- Killbill::Litle::LitlePaymentMethod.search(pm.litle_token).size.should == 1
49
- Killbill::Litle::LitlePaymentMethod.search(pm2.litle_token).size.should == 1
50
- Killbill::Litle::LitlePaymentMethod.search('cc').size.should == 2
51
- Killbill::Litle::LitlePaymentMethod.search('address').size.should == 2
52
- Killbill::Litle::LitlePaymentMethod.search(2343).size.should == 1
53
- Killbill::Litle::LitlePaymentMethod.search('name').size.should == 2
54
- Killbill::Litle::LitlePaymentMethod.search('Name').size.should == 2
70
+ do_search('foo').size.should == 0
71
+ do_search(pm.litle_token).size.should == 1
72
+ do_search(pm2.litle_token).size.should == 1
73
+ do_search('ccType').size.should == 2
74
+ # Exact match on ly for cc_last_4
75
+ do_search(123).size.should == 0
76
+ # Test partial match
77
+ do_search('cc').size.should == 2
78
+ do_search('address').size.should == 2
79
+ do_search('Name').size.should == 2
80
+ end
81
+
82
+ private
83
+
84
+ def do_search(search_key)
85
+ pagination = Killbill::Litle::LitlePaymentMethod.search(search_key)
86
+ pagination.current_offset.should == 0
87
+ results = pagination.iterator.to_a
88
+ pagination.total_nb_records.should == results.size
89
+ results
55
90
  end
56
91
  end
@@ -27,7 +27,8 @@ describe Killbill::Litle::PaymentPlugin do
27
27
  @plugin.kb_apis = Killbill::Plugin::KillbillApi.new('litle', svcs)
28
28
 
29
29
  @plugin.logger = Logger.new(STDOUT)
30
- @plugin.conf_dir = File.expand_path(File.dirname(__FILE__) + '../../../')
30
+ @plugin.logger.level = Logger::INFO
31
+ @plugin.conf_dir = File.expand_path(File.dirname(__FILE__) + '../../../../')
31
32
  @plugin.start_plugin
32
33
  end
33
34
 
@@ -46,6 +47,7 @@ describe Killbill::Litle::PaymentPlugin do
46
47
  pm_details.external_payment_method_id.should == pm.litle_token
47
48
 
48
49
  pms_found = @plugin.search_payment_methods pm.cc_last_4
50
+ pms_found = pms_found.iterator.to_a
49
51
  pms_found.size.should == 1
50
52
  pms_found.first.external_payment_method_id.should == pm_details.external_payment_method_id
51
53
 
@@ -7,4 +7,16 @@ describe Killbill::Litle::Utils do
7
7
  unpacked = Killbill::Litle::Utils.unpack_uuid(packed)
8
8
  unpacked.should == uuid
9
9
  end
10
+
11
+ it "should respect leading 0s" do
12
+ uuid = "0ae18a4c-be57-44c3-84ba-a82962a2de03"
13
+ 0.upto(35) do |i|
14
+ # Skip hyphens
15
+ next if [8, 13, 18, 23].include?(i)
16
+ uuid[i] = '0'
17
+ packed = Killbill::Litle::Utils.compact_uuid(uuid)
18
+ unpacked = Killbill::Litle::Utils.unpack_uuid(packed)
19
+ unpacked.should == uuid
20
+ end
21
+ end
10
22
  end
data/spec/spec_helper.rb CHANGED
@@ -16,6 +16,8 @@ ActiveRecord::Base.establish_connection(
16
16
  :adapter => 'sqlite3',
17
17
  :database => 'test.db'
18
18
  )
19
+ # For debugging
20
+ #ActiveRecord::Base.logger = Logger.new(STDOUT)
19
21
  # Create the schema
20
22
  require File.expand_path(File.dirname(__FILE__) + '../../db/schema.rb')
21
23
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: killbill-litle
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.8.2
4
+ version: 1.9.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,21 +9,21 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-10-14 00:00:00.000000000 Z
12
+ date: 2013-10-26 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: killbill
16
16
  version_requirements: !ruby/object:Gem::Requirement
17
17
  requirements:
18
- - - "~>"
18
+ - - ~>
19
19
  - !ruby/object:Gem::Version
20
- version: 1.6.0
20
+ version: 1.7.1
21
21
  none: false
22
22
  requirement: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ~>
25
25
  - !ruby/object:Gem::Version
26
- version: 1.6.0
26
+ version: 1.7.1
27
27
  none: false
28
28
  prerelease: false
29
29
  type: :runtime
@@ -31,13 +31,13 @@ dependencies:
31
31
  name: activemerchant
32
32
  version_requirements: !ruby/object:Gem::Requirement
33
33
  requirements:
34
- - - "~>"
34
+ - - ~>
35
35
  - !ruby/object:Gem::Version
36
36
  version: 1.36.0
37
37
  none: false
38
38
  requirement: !ruby/object:Gem::Requirement
39
39
  requirements:
40
- - - "~>"
40
+ - - ~>
41
41
  - !ruby/object:Gem::Version
42
42
  version: 1.36.0
43
43
  none: false
@@ -47,13 +47,13 @@ dependencies:
47
47
  name: activerecord
48
48
  version_requirements: !ruby/object:Gem::Requirement
49
49
  requirements:
50
- - - "~>"
50
+ - - ~>
51
51
  - !ruby/object:Gem::Version
52
52
  version: 3.2.1
53
53
  none: false
54
54
  requirement: !ruby/object:Gem::Requirement
55
55
  requirements:
56
- - - "~>"
56
+ - - ~>
57
57
  - !ruby/object:Gem::Version
58
58
  version: 3.2.1
59
59
  none: false
@@ -63,13 +63,13 @@ dependencies:
63
63
  name: sinatra
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - "~>"
66
+ - - ~>
67
67
  - !ruby/object:Gem::Version
68
68
  version: 1.3.4
69
69
  none: false
70
70
  requirement: !ruby/object:Gem::Requirement
71
71
  requirements:
72
- - - "~>"
72
+ - - ~>
73
73
  - !ruby/object:Gem::Version
74
74
  version: 1.3.4
75
75
  none: false
@@ -79,13 +79,13 @@ dependencies:
79
79
  name: LitleOnline
80
80
  version_requirements: !ruby/object:Gem::Requirement
81
81
  requirements:
82
- - - "~>"
82
+ - - ~>
83
83
  - !ruby/object:Gem::Version
84
84
  version: 8.16.0
85
85
  none: false
86
86
  requirement: !ruby/object:Gem::Requirement
87
87
  requirements:
88
- - - "~>"
88
+ - - ~>
89
89
  - !ruby/object:Gem::Version
90
90
  version: 8.16.0
91
91
  none: false
@@ -95,13 +95,13 @@ dependencies:
95
95
  name: xml-mapping
96
96
  version_requirements: !ruby/object:Gem::Requirement
97
97
  requirements:
98
- - - "~>"
98
+ - - ~>
99
99
  - !ruby/object:Gem::Version
100
100
  version: 0.9.1
101
101
  none: false
102
102
  requirement: !ruby/object:Gem::Requirement
103
103
  requirements:
104
- - - "~>"
104
+ - - ~>
105
105
  - !ruby/object:Gem::Version
106
106
  version: 0.9.1
107
107
  none: false
@@ -111,13 +111,13 @@ dependencies:
111
111
  name: xml-object
112
112
  version_requirements: !ruby/object:Gem::Requirement
113
113
  requirements:
114
- - - "~>"
114
+ - - ~>
115
115
  - !ruby/object:Gem::Version
116
116
  version: 0.9.93
117
117
  none: false
118
118
  requirement: !ruby/object:Gem::Requirement
119
119
  requirements:
120
- - - "~>"
120
+ - - ~>
121
121
  - !ruby/object:Gem::Version
122
122
  version: 0.9.93
123
123
  none: false
@@ -127,13 +127,13 @@ dependencies:
127
127
  name: activerecord-jdbcmysql-adapter
128
128
  version_requirements: !ruby/object:Gem::Requirement
129
129
  requirements:
130
- - - "~>"
130
+ - - ~>
131
131
  - !ruby/object:Gem::Version
132
132
  version: 1.2.9
133
133
  none: false
134
134
  requirement: !ruby/object:Gem::Requirement
135
135
  requirements:
136
- - - "~>"
136
+ - - ~>
137
137
  - !ruby/object:Gem::Version
138
138
  version: 1.2.9
139
139
  none: false
@@ -143,13 +143,13 @@ dependencies:
143
143
  name: jbundler
144
144
  version_requirements: !ruby/object:Gem::Requirement
145
145
  requirements:
146
- - - "~>"
146
+ - - ~>
147
147
  - !ruby/object:Gem::Version
148
148
  version: 0.4.1
149
149
  none: false
150
150
  requirement: !ruby/object:Gem::Requirement
151
151
  requirements:
152
- - - "~>"
152
+ - - ~>
153
153
  - !ruby/object:Gem::Version
154
154
  version: 0.4.1
155
155
  none: false
@@ -159,13 +159,13 @@ dependencies:
159
159
  name: rake
160
160
  version_requirements: !ruby/object:Gem::Requirement
161
161
  requirements:
162
- - - ">="
162
+ - - '>='
163
163
  - !ruby/object:Gem::Version
164
164
  version: 10.0.0
165
165
  none: false
166
166
  requirement: !ruby/object:Gem::Requirement
167
167
  requirements:
168
- - - ">="
168
+ - - '>='
169
169
  - !ruby/object:Gem::Version
170
170
  version: 10.0.0
171
171
  none: false
@@ -175,13 +175,13 @@ dependencies:
175
175
  name: rspec
176
176
  version_requirements: !ruby/object:Gem::Requirement
177
177
  requirements:
178
- - - "~>"
178
+ - - ~>
179
179
  - !ruby/object:Gem::Version
180
180
  version: 2.12.0
181
181
  none: false
182
182
  requirement: !ruby/object:Gem::Requirement
183
183
  requirements:
184
- - - "~>"
184
+ - - ~>
185
185
  - !ruby/object:Gem::Version
186
186
  version: 2.12.0
187
187
  none: false
@@ -191,13 +191,13 @@ dependencies:
191
191
  name: activerecord-jdbcsqlite3-adapter
192
192
  version_requirements: !ruby/object:Gem::Requirement
193
193
  requirements:
194
- - - "~>"
194
+ - - ~>
195
195
  - !ruby/object:Gem::Version
196
196
  version: 1.2.6
197
197
  none: false
198
198
  requirement: !ruby/object:Gem::Requirement
199
199
  requirements:
200
- - - "~>"
200
+ - - ~>
201
201
  - !ruby/object:Gem::Version
202
202
  version: 1.2.6
203
203
  none: false
@@ -209,8 +209,8 @@ executables: []
209
209
  extensions: []
210
210
  extra_rdoc_files: []
211
211
  files:
212
- - ".gitignore"
213
- - ".travis.yml"
212
+ - .gitignore
213
+ - .travis.yml
214
214
  - Gemfile
215
215
  - Jarfile
216
216
  - NEWS
@@ -237,8 +237,8 @@ files:
237
237
  - pom.xml
238
238
  - release.sh
239
239
  - spec/litle/base_plugin_spec.rb
240
- - spec/litle/integration_spec.rb
241
240
  - spec/litle/litle_payment_method_spec.rb
241
+ - spec/litle/remote/integration_spec.rb
242
242
  - spec/litle/utils_spec.rb
243
243
  - spec/spec_helper.rb
244
244
  homepage: http://kill-bill.org
@@ -246,24 +246,23 @@ licenses:
246
246
  - Apache License (2.0)
247
247
  post_install_message:
248
248
  rdoc_options:
249
- - "--exclude"
250
- - "."
249
+ - --exclude
250
+ - .
251
251
  require_paths:
252
252
  - lib
253
253
  required_ruby_version: !ruby/object:Gem::Requirement
254
254
  requirements:
255
- - - ">="
255
+ - - '>='
256
256
  - !ruby/object:Gem::Version
257
257
  version: 1.9.3
258
258
  none: false
259
259
  required_rubygems_version: !ruby/object:Gem::Requirement
260
260
  requirements:
261
- - - ">="
261
+ - - '>='
262
262
  - !ruby/object:Gem::Version
263
263
  segments:
264
264
  - 0
265
- version: !binary |-
266
- MA==
265
+ version: '0'
267
266
  hash: 2
268
267
  none: false
269
268
  requirements: []
@@ -274,7 +273,7 @@ specification_version: 3
274
273
  summary: Plugin to use Litle & Co. as a gateway.
275
274
  test_files:
276
275
  - spec/litle/base_plugin_spec.rb
277
- - spec/litle/integration_spec.rb
278
276
  - spec/litle/litle_payment_method_spec.rb
277
+ - spec/litle/remote/integration_spec.rb
279
278
  - spec/litle/utils_spec.rb
280
279
  - spec/spec_helper.rb