killbill-paypal-express 1.1.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/Jarfile CHANGED
@@ -1,5 +1,5 @@
1
1
  jar 'com.ning.billing:killbill-api', '0.3.0'
2
2
  jar 'com.ning.billing.plugin:killbill-plugin-api-notification', '0.2.4'
3
3
  jar 'com.ning.billing.plugin:killbill-plugin-api-payment', '0.2.4'
4
- jar 'com.ning.billing:killbill-util:tests', '0.2.6-SNAPSHOT'
4
+ jar 'com.ning.billing:killbill-util:tests', '0.3.0'
5
5
  jar 'javax.servlet:javax.servlet-api', '3.0.1'
data/NEWS CHANGED
@@ -1,2 +1,5 @@
1
+ 1.2.0
2
+ Update to killbill 1.2.0
3
+
1
4
  1.1.0
2
5
  Update to killbill 1.1.2
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.1.0
1
+ 1.2.0
@@ -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.1.2'
25
+ s.add_dependency 'killbill', '~> 1.2.0'
26
26
  s.add_dependency 'activemerchant', '~> 2.0.0'
27
27
  s.add_dependency 'activerecord', '~> 3.2.1'
28
28
  s.add_dependency 'sinatra', '~> 1.3.4'
@@ -16,7 +16,9 @@ module Killbill::PaypalExpress
16
16
  ActiveRecord::Base.connection.close
17
17
  end
18
18
 
19
- def process_payment(kb_account_id, kb_payment_id, kb_payment_method_id, amount_in_cents, currency, call_context = nil, options = {})
19
+ def process_payment(kb_account_id, kb_payment_id, kb_payment_method_id, amount, currency, call_context = nil, options = {})
20
+ amount_in_cents = (amount * 100).to_i
21
+
20
22
  # If the payment was already made, just return the status
21
23
  paypal_express_transaction = PaypalExpressTransaction.from_kb_payment_id(kb_payment_id) rescue nil
22
24
  return paypal_express_transaction.paypal_express_response.to_payment_response unless paypal_express_transaction.nil?
@@ -52,7 +54,9 @@ module Killbill::PaypalExpress
52
54
  end
53
55
  end
54
56
 
55
- def process_refund(kb_account_id, kb_payment_id, amount_in_cents, currency, call_context = nil, options = {})
57
+ def process_refund(kb_account_id, kb_payment_id, amount, currency, call_context = nil, options = {})
58
+ amount_in_cents = (amount * 100).to_i
59
+
56
60
  paypal_express_transaction = PaypalExpressTransaction.find_candidate_transaction_for_refund(kb_payment_id, amount_in_cents)
57
61
 
58
62
  options[:currency] ||= currency.to_s
@@ -147,7 +147,7 @@ module Killbill::PaypalExpress
147
147
 
148
148
  if type == :payment
149
149
  p_info_plugin = Killbill::Plugin::Model::PaymentInfoPlugin.new
150
- p_info_plugin.amount = amount_in_cents
150
+ p_info_plugin.amount = BigDecimal.new(amount_in_cents.to_s) / 100.0 if amount_in_cents
151
151
  p_info_plugin.created_date = created_date
152
152
  p_info_plugin.effective_date = effective_date
153
153
  p_info_plugin.status = (success ? :PROCESSED : :ERROR)
@@ -158,7 +158,7 @@ module Killbill::PaypalExpress
158
158
  p_info_plugin
159
159
  else
160
160
  r_info_plugin = Killbill::Plugin::Model::RefundInfoPlugin.new
161
- r_info_plugin.amount = amount_in_cents
161
+ r_info_plugin.amount = BigDecimal.new(amount_in_cents.to_s) / 100.0 if amount_in_cents
162
162
  r_info_plugin.created_date = created_date
163
163
  r_info_plugin.effective_date = effective_date
164
164
  r_info_plugin.status = (success ? :PROCESSED : :ERROR)
@@ -1,5 +1,6 @@
1
1
  require 'active_record'
2
2
  require 'activemerchant'
3
+ require 'bigdecimal'
3
4
  require 'pathname'
4
5
  require 'sinatra'
5
6
  require 'singleton'
data/pom.xml CHANGED
@@ -25,7 +25,7 @@
25
25
  <groupId>com.ning.killbill.ruby</groupId>
26
26
  <artifactId>paypal-express-plugin</artifactId>
27
27
  <packaging>pom</packaging>
28
- <version>1.1.0</version>
28
+ <version>1.2.0</version>
29
29
  <name>paypal-express-plugin</name>
30
30
  <url>http://github.com/killbill/killbill-paypal-express-plugin</url>
31
31
  <description>Plugin for accessing paypal as a payment gateway</description>
@@ -22,12 +22,12 @@ describe Killbill::PaypalExpress::PaymentPlugin do
22
22
  end
23
23
 
24
24
  it 'should be able to charge and refund' do
25
- amount_in_cents = 10000
25
+ amount = 100
26
26
  currency = 'USD'
27
27
  kb_payment_id = SecureRandom.uuid
28
28
 
29
- payment_response = @plugin.process_payment @pm.kb_account_id, kb_payment_id, @pm.kb_payment_method_id, amount_in_cents, currency
30
- payment_response.amount.should == amount_in_cents
29
+ payment_response = @plugin.process_payment @pm.kb_account_id, kb_payment_id, @pm.kb_payment_method_id, amount, currency
30
+ payment_response.amount.should == amount
31
31
  payment_response.status.should == :PROCESSED
32
32
 
33
33
  # Verify our table directly
@@ -38,14 +38,14 @@ describe Killbill::PaypalExpress::PaymentPlugin do
38
38
 
39
39
  # Check we can retrieve the payment
40
40
  payment_response = @plugin.get_payment_info @pm.kb_account_id, kb_payment_id
41
- payment_response.amount.should == amount_in_cents
41
+ payment_response.amount.should == amount
42
42
  payment_response.status.should == :PROCESSED
43
43
 
44
44
  # Check we cannot refund an amount greater than the original charge
45
- lambda { @plugin.process_refund @pm.kb_account_id, kb_payment_id, amount_in_cents + 1, currency }.should raise_error RuntimeError
45
+ lambda { @plugin.process_refund @pm.kb_account_id, kb_payment_id, amount + 1, currency }.should raise_error RuntimeError
46
46
 
47
- refund_response = @plugin.process_refund @pm.kb_account_id, kb_payment_id, amount_in_cents, currency
48
- refund_response.amount.should == amount_in_cents
47
+ refund_response = @plugin.process_refund @pm.kb_account_id, kb_payment_id, amount, currency
48
+ refund_response.amount.should == amount
49
49
  refund_response.status.should == :PROCESSED
50
50
 
51
51
  # Verify our table directly
@@ -55,19 +55,19 @@ describe Killbill::PaypalExpress::PaymentPlugin do
55
55
 
56
56
  # Check we can retrieve the refund
57
57
  refund_response = @plugin.get_refund_info @pm.kb_account_id, kb_payment_id
58
- refund_response.amount.should == (-1 * amount_in_cents)
58
+ refund_response.amount.should == (-1 * amount)
59
59
  refund_response.status.should == :PROCESSED
60
60
 
61
61
  # Try another payment to verify the BAID
62
- second_amount_in_cents = 9423
62
+ second_amount = 94.23
63
63
  second_kb_payment_id = SecureRandom.uuid
64
- payment_response = @plugin.process_payment @pm.kb_account_id, second_kb_payment_id, @pm.kb_payment_method_id, second_amount_in_cents, currency
65
- payment_response.amount.should == second_amount_in_cents
64
+ payment_response = @plugin.process_payment @pm.kb_account_id, second_kb_payment_id, @pm.kb_payment_method_id, second_amount, currency
65
+ payment_response.amount.should == second_amount
66
66
  payment_response.status.should == :PROCESSED
67
67
 
68
68
  # Check we can refund it as well
69
- refund_response = @plugin.process_refund @pm.kb_account_id, second_kb_payment_id, second_amount_in_cents, currency
70
- refund_response.amount.should == second_amount_in_cents
69
+ refund_response = @plugin.process_refund @pm.kb_account_id, second_kb_payment_id, second_amount, currency
70
+ refund_response.amount.should == second_amount
71
71
  refund_response.status.should == :PROCESSED
72
72
 
73
73
  # it "should be able to create and retrieve payment methods"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: killbill-paypal-express
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-06-21 00:00:00.000000000 Z
12
+ date: 2013-06-22 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: killbill
@@ -17,13 +17,13 @@ dependencies:
17
17
  requirements:
18
18
  - - "~>"
19
19
  - !ruby/object:Gem::Version
20
- version: 1.1.2
20
+ version: 1.2.0
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.1.2
26
+ version: 1.2.0
27
27
  none: false
28
28
  prerelease: false
29
29
  type: :runtime