killbill-braintree_blue 0.0.1 → 0.1.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.
@@ -4,30 +4,31 @@ module Killbill #:nodoc:
4
4
 
5
5
  self.table_name = 'braintree_blue_payment_methods'
6
6
 
7
- def self.from_response(kb_account_id, kb_payment_method_id, kb_tenant_id, cc_or_token, response, options, extra_params = {}, model = ::Killbill::BraintreeBlue::BraintreeBluePaymentMethod)
7
+ # Note: the ActiveMerchant Braintree implementation puts the customer id in the authorization field, not the token
8
+ def self.from_response(kb_account_id, kb_payment_method_id, kb_tenant_id, b_customer_id, response, options, extra_params = {}, model = ::Killbill::BraintreeBlue::BraintreeBluePaymentMethod)
9
+ braintree_customer_id = options[:customer] || b_customer_id || self.braintree_customer_id_from_kb_account_id(kb_account_id, kb_tenant_id)
8
10
 
9
- braintree_customer_id = self.braintree_customer_id_from_kb_account_id(kb_account_id, kb_tenant_id)
11
+ primary_response = response.respond_to?(:responses) ? response.primary_response : response
10
12
 
11
- unless braintree_customer_id.blank?
12
- card_response = response.responses.first.params
13
- customer_response = response.responses.last.params
14
- else
15
- card_response = response.params['braintree_customer']['credit_cards'][0]
16
- customer_response = response.params['braintree_customer']
17
- end
13
+ # Unfortunately, the ActiveMerchant Braintree implementation will drop that information when adding a card to an existing customer
14
+ customer_response = primary_response.params['braintree_customer'] || {}
15
+
16
+ token = options[:token] || primary_response.params['credit_card_token']
17
+ card_response = (customer_response['credit_cards'] || []).first || {}
18
+ cc_exp_dates = (card_response['expiration_date'] || '').split('/')
18
19
 
19
20
  super(kb_account_id,
20
21
  kb_payment_method_id,
21
22
  kb_tenant_id,
22
- cc_or_token,
23
+ token,
23
24
  response,
24
25
  options,
25
26
  {
26
- :braintree_customer_id => customer_response['id'],
27
- :token => customer_response['id'],
27
+ :braintree_customer_id => braintree_customer_id,
28
+ :token => token,
28
29
  :cc_type => card_response['card_type'],
29
- :cc_exp_month => card_response['expiration_date'].split('/').first,
30
- :cc_exp_year => card_response['expiration_date'].split('/').last,
30
+ :cc_exp_month => cc_exp_dates.first,
31
+ :cc_exp_year => cc_exp_dates.last,
31
32
  :cc_last_4 => card_response['last_4'],
32
33
  :cc_first_name => customer_response['first_name'],
33
34
  :cc_last_name => customer_response['last_name']
@@ -49,7 +50,6 @@ module Killbill #:nodoc:
49
50
  raise "Kill Bill account #{kb_account_id} mapping to multiple Braintree customers: #{braintree_customer_ids}" if braintree_customer_ids.size > 1
50
51
  braintree_customer_ids.first
51
52
  end
52
-
53
53
  end
54
54
  end
55
55
  end
@@ -7,7 +7,6 @@ module Killbill #:nodoc:
7
7
  has_one :braintree_blue_transaction
8
8
 
9
9
  def self.from_response(api_call, kb_account_id, kb_payment_id, kb_payment_transaction_id, transaction_type, payment_processor_account_id, kb_tenant_id, response, extra_params = {}, model = ::Killbill::BraintreeBlue::BraintreeBlueResponse)
10
-
11
10
  super(api_call,
12
11
  kb_account_id,
13
12
  kb_payment_id,
@@ -31,7 +30,7 @@ module Killbill #:nodoc:
31
30
  }.merge!(extra_params),
32
31
  model)
33
32
  end
34
-
33
+
35
34
  def self.search_where_clause(t, search_key)
36
35
  where_clause = t[:params_braintree_customer_id].eq(search_key)
37
36
  .or(t[:params_braintree_customer_credit_card_token].eq(search_key))
@@ -40,8 +39,7 @@ module Killbill #:nodoc:
40
39
  where_clause = where_clause.and(t[:success].eq(true))
41
40
 
42
41
  super.or(where_clause)
43
- end
44
-
42
+ end
45
43
  end
46
44
  end
47
45
  end
@@ -22,4 +22,3 @@ require 'braintree_blue/private_api'
22
22
  require 'braintree_blue/models/payment_method'
23
23
  require 'braintree_blue/models/response'
24
24
  require 'braintree_blue/models/transaction'
25
-
data/pom.xml CHANGED
@@ -1,6 +1,6 @@
1
1
  <?xml version="1.0" encoding="UTF-8"?>
2
2
  <!--
3
- ~ Copyright 2014 The Billing Project, LLC
3
+ ~ Copyright 2014-2015 The Billing Project, LLC
4
4
  ~
5
5
  ~ The Billing Project licenses this file to you under the Apache License, version 2.0
6
6
  ~ (the "License"); you may not use this file except in compliance with the
@@ -25,7 +25,7 @@
25
25
  <groupId>org.kill-bill.billing.plugin.ruby</groupId>
26
26
  <artifactId>braintree_blue-plugin</artifactId>
27
27
  <packaging>pom</packaging>
28
- <version>0.0.1</version>
28
+ <version>0.1.0</version>
29
29
  <name>braintree_blue-plugin</name>
30
30
  <url>http://github.com/killbill/killbill-braintree_blue-plugin</url>
31
31
  <description>Plugin for accessing BraintreeBlue as a payment gateway</description>
data/release.sh CHANGED
@@ -1,5 +1,8 @@
1
1
  set -e
2
2
 
3
+ BUNDLE=${BUNDLE-"bundle exec"}
4
+ MVN=${MVN-"mvn"}
5
+
3
6
  if [ 'GNU' != "$(tar --help | grep GNU | head -1 | awk '{print $1}')" ]; then
4
7
  echo 'Unable to release: make sure to use GNU tar'
5
8
  exit 1
@@ -14,28 +17,45 @@ else
14
17
  fi
15
18
 
16
19
  VERSION=`grep -E '<version>([0-9]+\.[0-9]+\.[0-9]+)</version>' pom.xml | sed 's/[\t \n]*<version>\(.*\)<\/version>[\t \n]*/\1/'`
17
- if [ "$VERSION" != "$(cat $PWD/VERSION)" ]; then
20
+ if [[ -z "$NO_RELEASE" && "$VERSION" != "$(cat $PWD/VERSION)" ]]; then
18
21
  echo 'Unable to release: make sure the versions in pom.xml and VERSION match'
19
22
  exit 1
20
23
  fi
21
24
 
22
25
  echo 'Cleaning up'
23
- rake killbill:clean ; rake build
26
+ $BUNDLE rake killbill:clean
27
+
28
+ echo 'Building gem'
29
+ $BUNDLE rake build
24
30
 
25
- echo 'Pushing the gem to Rubygems'
26
- rake release
31
+ if [[ -z "$NO_RELEASE" ]]; then
32
+ echo 'Pushing the gem to Rubygems'
33
+ $BUNDLE rake release
34
+ fi
27
35
 
28
36
  echo 'Building artifact'
29
- rake killbill:package
37
+ $BUNDLE rake killbill:package
30
38
 
31
39
  ARTIFACT="$PWD/pkg/killbill-braintree_blue-$VERSION.tar.gz"
32
40
  echo "Pushing $ARTIFACT to Maven Central"
33
- mvn gpg:sign-and-deploy-file \
34
- -DgroupId=org.kill-bill.billing.plugin.ruby \
35
- -DartifactId=braintree_blue-plugin \
36
- -Dversion=$VERSION \
37
- -Dpackaging=tar.gz \
38
- -DrepositoryId=ossrh-releases \
39
- -Durl=https://oss.sonatype.org/service/local/staging/deploy/maven2/ \
40
- -Dfile=$ARTIFACT \
41
- -DpomFile=pom.xml
41
+
42
+ if [[ -z "$NO_RELEASE" ]]; then
43
+ GOAL=gpg:sign-and-deploy-file
44
+ REPOSITORY_ID=ossrh-releases
45
+ URL=https://oss.sonatype.org/service/local/staging/deploy/maven2/
46
+ else
47
+ GOAL=deploy:deploy-file
48
+ REPOSITORY_ID=sonatype-nexus-snapshots
49
+ URL=https://oss.sonatype.org/content/repositories/snapshots/
50
+ VERSION="$VERSION-SNAPSHOT"
51
+ fi
52
+
53
+ $MVN $GOAL \
54
+ -DgroupId=org.kill-bill.billing.plugin.ruby \
55
+ -DartifactId=braintree_blue-plugin \
56
+ -Dversion=$VERSION \
57
+ -Dpackaging=tar.gz \
58
+ -DrepositoryId=$REPOSITORY_ID \
59
+ -Durl=$URL \
60
+ -Dfile=$ARTIFACT \
61
+ -DpomFile=pom.xml
@@ -1,9 +1,12 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Killbill::BraintreeBlue::PaymentPlugin do
4
+
5
+ include ::Killbill::Plugin::ActiveMerchant::RSpec
6
+
4
7
  before(:each) do
5
8
  Dir.mktmpdir do |dir|
6
- file = File.new(File.join(dir, 'braintree_blue.yml'), "w+")
9
+ file = File.new(File.join(dir, 'braintree_blue.yml'), 'w+')
7
10
  file.write(<<-eos)
8
11
  :braintree_blue:
9
12
  :test: true
@@ -14,11 +17,7 @@ describe Killbill::BraintreeBlue::PaymentPlugin do
14
17
  eos
15
18
  file.close
16
19
 
17
- @plugin = Killbill::BraintreeBlue::PaymentPlugin.new
18
- @plugin.logger = Logger.new(STDOUT)
19
- @plugin.logger.level = Logger::INFO
20
- @plugin.conf_dir = File.dirname(file)
21
- @plugin.kb_apis = Killbill::Plugin::KillbillApi.new('braintree_blue', {})
20
+ @plugin = build_plugin(::Killbill::BraintreeBlue::PaymentPlugin, 'braintree_blue', File.dirname(file))
22
21
 
23
22
  # Start the plugin here - since the config file will be deleted
24
23
  @plugin.start_plugin
@@ -29,8 +28,8 @@ describe Killbill::BraintreeBlue::PaymentPlugin do
29
28
  @plugin.stop_plugin
30
29
  end
31
30
 
32
- it 'should generate forms correctly' do
33
31
  =begin
32
+ it 'should generate forms correctly' do
34
33
  kb_account_id = SecureRandom.uuid
35
34
  kb_tenant_id = SecureRandom.uuid
36
35
  context = @plugin.kb_apis.create_context(kb_tenant_id)
@@ -45,12 +44,9 @@ describe Killbill::BraintreeBlue::PaymentPlugin do
45
44
  form.form_url.should == 'https://braintree_blue.com'
46
45
 
47
46
  form_fields = @plugin.properties_to_hash(form.form_fields)
48
- =end
49
47
  end
50
48
 
51
49
  it 'should receive notifications correctly' do
52
- =begin
53
-
54
50
  description = 'description'
55
51
 
56
52
  kb_tenant_id = SecureRandom.uuid
@@ -59,6 +55,6 @@ describe Killbill::BraintreeBlue::PaymentPlugin do
59
55
 
60
56
  notification = ""
61
57
  gw_notification = @plugin.process_notification notification, properties, context
62
- =end
63
58
  end
59
+ =end
64
60
  end
@@ -11,22 +11,24 @@ describe Killbill::BraintreeBlue::BraintreeBluePaymentMethod do
11
11
  do_search('foo', kb_tenant_id).size.should == 0
12
12
 
13
13
  pm = Killbill::BraintreeBlue::BraintreeBluePaymentMethod.create :kb_account_id => '11-22-33-44',
14
- :kb_payment_method_id => '55-66-77-88',
15
- :kb_tenant_id => kb_tenant_id,
16
- :braintree_customer_id => '123xka',
17
- :token => '38102343',
18
- :cc_first_name => 'ccFirstName',
19
- :cc_last_name => 'ccLastName',
20
- :cc_type => 'ccType',
21
- :cc_exp_month => 10,
22
- :cc_exp_year => 11,
23
- :cc_last_4 => 1234,
24
- :address1 => 'address1',
25
- :address2 => 'address2',
26
- :city => 'city',
27
- :state => 'state',
28
- :zip => 'zip',
29
- :country => 'country'
14
+ :kb_payment_method_id => '55-66-77-88',
15
+ :kb_tenant_id => kb_tenant_id,
16
+ :braintree_customer_id => '123xka',
17
+ :token => '38102343',
18
+ :cc_first_name => 'ccFirstName',
19
+ :cc_last_name => 'ccLastName',
20
+ :cc_type => 'ccType',
21
+ :cc_exp_month => 10,
22
+ :cc_exp_year => 11,
23
+ :cc_last_4 => 1234,
24
+ :address1 => 'address1',
25
+ :address2 => 'address2',
26
+ :city => 'city',
27
+ :state => 'state',
28
+ :zip => 'zip',
29
+ :country => 'country',
30
+ :created_at => Time.now,
31
+ :updated_at => Time.now
30
32
 
31
33
  do_search('foo', kb_tenant_id).size.should == 0
32
34
  do_search(pm.token, kb_tenant_id).size.should == 1
@@ -39,22 +41,24 @@ describe Killbill::BraintreeBlue::BraintreeBluePaymentMethod do
39
41
  do_search('Name', kb_tenant_id).size.should == 1
40
42
 
41
43
  pm2 = Killbill::BraintreeBlue::BraintreeBluePaymentMethod.create :kb_account_id => '22-33-44-55',
42
- :kb_payment_method_id => '66-77-88-99',
43
- :kb_tenant_id => kb_tenant_id,
44
- :braintree_customer_id => '123xka',
45
- :token => '49384029302',
46
- :cc_first_name => 'ccFirstName',
47
- :cc_last_name => 'ccLastName',
48
- :cc_type => 'ccType',
49
- :cc_exp_month => 10,
50
- :cc_exp_year => 11,
51
- :cc_last_4 => 1234,
52
- :address1 => 'address1',
53
- :address2 => 'address2',
54
- :city => 'city',
55
- :state => 'state',
56
- :zip => 'zip',
57
- :country => 'country'
44
+ :kb_payment_method_id => '66-77-88-99',
45
+ :kb_tenant_id => kb_tenant_id,
46
+ :braintree_customer_id => '123xka',
47
+ :token => '49384029302',
48
+ :cc_first_name => 'ccFirstName',
49
+ :cc_last_name => 'ccLastName',
50
+ :cc_type => 'ccType',
51
+ :cc_exp_month => 10,
52
+ :cc_exp_year => 11,
53
+ :cc_last_4 => 1234,
54
+ :address1 => 'address1',
55
+ :address2 => 'address2',
56
+ :city => 'city',
57
+ :state => 'state',
58
+ :zip => 'zip',
59
+ :country => 'country',
60
+ :created_at => Time.now,
61
+ :updated_at => Time.now
58
62
 
59
63
  do_search('foo', kb_tenant_id).size.should == 0
60
64
  do_search(pm.token, kb_tenant_id).size.should == 1
@@ -12,22 +12,26 @@ describe Killbill::BraintreeBlue::BraintreeBlueResponse do
12
12
  do_search('foo', kb_tenant_id).size.should == 0
13
13
 
14
14
  pm = Killbill::BraintreeBlue::BraintreeBlueResponse.create :api_call => 'charge',
15
- :kb_payment_id => '11-22-33-44',
16
- :kb_account_id => kb_account_id,
17
- :kb_tenant_id => kb_tenant_id,
18
- :authorization => 'aa-bb-cc-dd',
19
- :params_braintree_customer_id => '123456',
20
- :params_braintree_customer_credit_card_token => '38102343',
21
- :success => true
15
+ :kb_payment_id => '11-22-33-44',
16
+ :kb_account_id => kb_account_id,
17
+ :kb_tenant_id => kb_tenant_id,
18
+ :authorization => 'aa-bb-cc-dd',
19
+ :params_braintree_customer_id => '123456',
20
+ :params_braintree_customer_credit_card_token => '38102343',
21
+ :success => true,
22
+ :created_at => Time.now,
23
+ :updated_at => Time.now
22
24
  # Not successful
23
25
  ignored2 = Killbill::BraintreeBlue::BraintreeBlueResponse.create :api_call => 'charge',
24
- :kb_payment_id => pm.kb_payment_id,
25
- :kb_account_id => kb_account_id,
26
- :kb_tenant_id => kb_tenant_id,
27
- :authorization => pm.authorization,
28
- :params_braintree_customer_id => pm.params_braintree_customer_id,
29
- :params_braintree_customer_credit_card_token => pm.params_braintree_customer_credit_card_token,
30
- :success => false
26
+ :kb_payment_id => pm.kb_payment_id,
27
+ :kb_account_id => kb_account_id,
28
+ :kb_tenant_id => kb_tenant_id,
29
+ :authorization => pm.authorization,
30
+ :params_braintree_customer_id => pm.params_braintree_customer_id,
31
+ :params_braintree_customer_credit_card_token => pm.params_braintree_customer_credit_card_token,
32
+ :success => false,
33
+ :created_at => Time.now,
34
+ :updated_at => Time.now
31
35
 
32
36
  do_search('foo', kb_tenant_id).size.should == 0
33
37
  do_search(pm.authorization, kb_tenant_id).size.should == 1
@@ -35,13 +39,15 @@ describe Killbill::BraintreeBlue::BraintreeBlueResponse do
35
39
  do_search(pm.params_braintree_customer_credit_card_token, kb_tenant_id).size.should == 1
36
40
 
37
41
  pm2 = Killbill::BraintreeBlue::BraintreeBlueResponse.create :api_call => 'charge',
38
- :kb_payment_id => '11-22-33-44',
39
- :kb_account_id => kb_account_id,
40
- :kb_tenant_id => kb_tenant_id,
41
- :authorization => 'AA-BB-CC-DD',
42
- :params_braintree_customer_id => '1234567',
43
- :params_braintree_customer_credit_card_token => pm.params_braintree_customer_credit_card_token,
44
- :success => true
42
+ :kb_payment_id => '11-22-33-44',
43
+ :kb_account_id => kb_account_id,
44
+ :kb_tenant_id => kb_tenant_id,
45
+ :authorization => 'AA-BB-CC-DD',
46
+ :params_braintree_customer_id => '1234567',
47
+ :params_braintree_customer_credit_card_token => pm.params_braintree_customer_credit_card_token,
48
+ :success => true,
49
+ :created_at => Time.now,
50
+ :updated_at => Time.now
45
51
 
46
52
  do_search('foo', kb_tenant_id).size.should == 0
47
53
  do_search(pm.authorization, kb_tenant_id).size.should == 1
@@ -7,30 +7,28 @@ describe Killbill::BraintreeBlue::PaymentPlugin do
7
7
  include ::Killbill::Plugin::ActiveMerchant::RSpec
8
8
 
9
9
  before(:each) do
10
- @plugin = Killbill::BraintreeBlue::PaymentPlugin.new
10
+ ::Killbill::BraintreeBlue::BraintreeBluePaymentMethod.delete_all
11
+ ::Killbill::BraintreeBlue::BraintreeBlueResponse.delete_all
12
+ ::Killbill::BraintreeBlue::BraintreeBlueTransaction.delete_all
11
13
 
12
- @account_api = ::Killbill::Plugin::ActiveMerchant::RSpec::FakeJavaUserAccountApi.new
13
- @payment_api = ::Killbill::Plugin::ActiveMerchant::RSpec::FakeJavaPaymentApi.new
14
- svcs = {:account_user_api => @account_api, :payment_api => @payment_api}
15
- @plugin.kb_apis = Killbill::Plugin::KillbillApi.new('braintree_blue', svcs)
16
-
17
- @call_context = ::Killbill::Plugin::Model::CallContext.new
18
- @call_context.tenant_id = '00000011-0022-0033-0044-000000000055'
19
- @call_context = @call_context.to_ruby(@call_context)
20
-
21
- @plugin.logger = Logger.new(STDOUT)
22
- @plugin.logger.level = Logger::INFO
23
- @plugin.conf_dir = File.expand_path(File.dirname(__FILE__) + '../../../../')
14
+ @plugin = build_plugin(::Killbill::BraintreeBlue::PaymentPlugin, 'braintree_blue')
24
15
  @plugin.start_plugin
25
16
 
17
+ @call_context = build_call_context
18
+
26
19
  @properties = []
27
- @pm = create_payment_method(::Killbill::BraintreeBlue::BraintreeBluePaymentMethod, nil, @call_context.tenant_id, @properties)
20
+ pm_overrides = {
21
+ # ActiveMerchant wants zip to be a string
22
+ :zip => '12345',
23
+ :cc_verification_value => 123
24
+ }
25
+ @pm = create_payment_method(::Killbill::BraintreeBlue::BraintreeBluePaymentMethod, nil, @call_context.tenant_id, @properties, pm_overrides)
28
26
  @amount = BigDecimal.new('100')
29
27
  @currency = 'USD'
30
28
 
31
29
  kb_payment_id = SecureRandom.uuid
32
30
  1.upto(6) do
33
- @kb_payment = @payment_api.add_payment(kb_payment_id)
31
+ @kb_payment = @plugin.kb_apis.proxied_services[:payment_api].add_payment(kb_payment_id)
34
32
  end
35
33
  end
36
34
 
@@ -38,8 +36,63 @@ describe Killbill::BraintreeBlue::PaymentPlugin do
38
36
  @plugin.stop_plugin
39
37
  end
40
38
 
39
+ # See https://github.com/killbill/killbill-braintree-blue-plugin/issues/3
40
+ it 'should be able to add multiple cards to the same customer' do
41
+ kb_account_id = SecureRandom.uuid
42
+ kb_tenant_id = @call_context.tenant_id
43
+ ::Killbill::BraintreeBlue::BraintreeBluePaymentMethod.braintree_customer_id_from_kb_account_id(kb_account_id, kb_tenant_id).should be_nil
44
+
45
+ properties = []
46
+ pm_overrides = {
47
+ :zip => '12345',
48
+ :cc_verification_value => 123
49
+ }
50
+ create_payment_method(::Killbill::BraintreeBlue::BraintreeBluePaymentMethod, kb_account_id, kb_tenant_id, properties, pm_overrides.dup)
51
+ b_customer_id = ::Killbill::BraintreeBlue::BraintreeBluePaymentMethod.braintree_customer_id_from_kb_account_id(kb_account_id, kb_tenant_id)
52
+ b_customer_id.should_not be_nil
53
+
54
+ # Add a second card on the same account (same Braintree customer)
55
+ pm_overrides[:cc_number] = '4111111111111111'
56
+ create_payment_method(::Killbill::BraintreeBlue::BraintreeBluePaymentMethod, kb_account_id, kb_tenant_id, properties, pm_overrides.dup)
57
+ ::Killbill::BraintreeBlue::BraintreeBluePaymentMethod.braintree_customer_id_from_kb_account_id(kb_account_id, kb_tenant_id).should == b_customer_id
58
+
59
+ pms = @plugin.get_payment_methods(kb_account_id, false, properties, @call_context)
60
+ pms.size.should == 2
61
+
62
+ # Verify tokens are different, and don't match the Braintree customer id
63
+ pm1 = @plugin.get_payment_method_detail(kb_account_id, pms[0].payment_method_id, properties, @call_context)
64
+ pm2 = @plugin.get_payment_method_detail(kb_account_id, pms[1].payment_method_id, properties, @call_context)
65
+ pm1.external_payment_method_id.should_not == pm2.external_payment_method_id
66
+ pm1.external_payment_method_id.should_not == b_customer_id
67
+ pm2.external_payment_method_id.should_not == b_customer_id
68
+
69
+ # Add a third card on the same account (same Braintree customer)
70
+ pm_overrides[:cc_number] = '5555555555554444'
71
+ create_payment_method(::Killbill::BraintreeBlue::BraintreeBluePaymentMethod, kb_account_id, kb_tenant_id, properties, pm_overrides.dup)
72
+ ::Killbill::BraintreeBlue::BraintreeBluePaymentMethod.braintree_customer_id_from_kb_account_id(kb_account_id, kb_tenant_id).should == b_customer_id
73
+
74
+ pms = @plugin.get_payment_methods(kb_account_id, false, properties, @call_context)
75
+ pms.size.should == 3
76
+
77
+ # Verify tokens are different, and don't match the Braintree customer id
78
+ pm1 = @plugin.get_payment_method_detail(kb_account_id, pms[0].payment_method_id, properties, @call_context)
79
+ pm2 = @plugin.get_payment_method_detail(kb_account_id, pms[1].payment_method_id, properties, @call_context)
80
+ pm3 = @plugin.get_payment_method_detail(kb_account_id, pms[2].payment_method_id, properties, @call_context)
81
+ pm1.external_payment_method_id.should_not == pm2.external_payment_method_id
82
+ pm1.external_payment_method_id.should_not == pm3.external_payment_method_id
83
+ pm2.external_payment_method_id.should_not == pm3.external_payment_method_id
84
+ pm1.external_payment_method_id.should_not == b_customer_id
85
+ pm2.external_payment_method_id.should_not == b_customer_id
86
+ pm3.external_payment_method_id.should_not == b_customer_id
87
+ end
88
+
41
89
  it 'should be able to charge a Credit Card directly' do
42
- properties = build_pm_properties
90
+ properties = build_pm_properties(nil,
91
+ {
92
+ # ActiveMerchant wants zip to be a string
93
+ :zip => '12345',
94
+ :cc_verification_value => 123
95
+ })
43
96
 
44
97
  # We created the payment method, hence the rows
45
98
  Killbill::BraintreeBlue::BraintreeBlueResponse.all.size.should == 1
@@ -53,15 +106,16 @@ describe Killbill::BraintreeBlue::PaymentPlugin do
53
106
  responses = Killbill::BraintreeBlue::BraintreeBlueResponse.all
54
107
  responses.size.should == 2
55
108
  responses[0].api_call.should == 'add_payment_method'
56
- responses[0].message.should == 'Successful transaction'
109
+ responses[0].message.should == 'OK'
57
110
  responses[1].api_call.should == 'purchase'
58
- responses[1].message.should == 'Successful transaction'
111
+ responses[1].message.should == '1000 Approved'
59
112
  transactions = Killbill::BraintreeBlue::BraintreeBlueTransaction.all
60
113
  transactions.size.should == 1
61
114
  transactions[0].api_call.should == 'purchase'
62
115
  end
63
116
 
64
- it 'should be able to charge and refund' do
117
+ # TODO Settlement?
118
+ xit 'should be able to charge and refund' do
65
119
  payment_response = @plugin.purchase_payment(@pm.kb_account_id, @kb_payment.id, @kb_payment.transactions[0].id, @pm.kb_payment_method_id, @amount, @currency, @properties, @call_context)
66
120
  payment_response.status.should eq(:PROCESSED), payment_response.gateway_error
67
121
  payment_response.amount.should == @amount
@@ -74,7 +128,8 @@ describe Killbill::BraintreeBlue::PaymentPlugin do
74
128
  refund_response.transaction_type.should == :REFUND
75
129
  end
76
130
 
77
- it 'should be able to auth, capture and refund' do
131
+ # TODO Settlement?
132
+ xit 'should be able to auth, capture and refund' do
78
133
  payment_response = @plugin.authorize_payment(@pm.kb_account_id, @kb_payment.id, @kb_payment.transactions[0].id, @pm.kb_payment_method_id, @amount, @currency, @properties, @call_context)
79
134
  payment_response.status.should eq(:PROCESSED), payment_response.gateway_error
80
135
  payment_response.amount.should == @amount