killbill-litle 4.0.0 → 4.0.1

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.
@@ -1,125 +0,0 @@
1
- require 'spec_helper'
2
-
3
- ActiveMerchant::Billing::Base.mode = :test
4
-
5
- describe Killbill::Litle::PaymentPlugin do
6
-
7
- include ::Killbill::Plugin::ActiveMerchant::RSpec
8
-
9
- before(:each) do
10
- ::Killbill::Litle::LitlePaymentMethod.delete_all
11
- ::Killbill::Litle::LitleResponse.delete_all
12
- ::Killbill::Litle::LitleTransaction.delete_all
13
-
14
- @plugin = build_plugin(::Killbill::Litle::PaymentPlugin, 'litle')
15
- @plugin.start_plugin
16
-
17
- @call_context = build_call_context
18
-
19
- @properties = []
20
- @pm = create_payment_method(::Killbill::Litle::LitlePaymentMethod, nil, @call_context.tenant_id, @properties)
21
- @amount = BigDecimal.new('100')
22
- @currency = 'USD'
23
-
24
- kb_payment_id = SecureRandom.uuid
25
- 1.upto(6) do
26
- @kb_payment = @plugin.kb_apis.proxied_services[:payment_api].add_payment(kb_payment_id)
27
- end
28
- end
29
-
30
- after(:each) do
31
- @plugin.stop_plugin
32
- end
33
-
34
- it 'should be able to charge a Credit Card directly' do
35
- properties = build_pm_properties
36
-
37
- # We created the payment method, hence the rows
38
- Killbill::Litle::LitleResponse.all.size.should == 1
39
- Killbill::Litle::LitleTransaction.all.size.should == 0
40
-
41
- 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)
42
- payment_response.status.should eq(:PROCESSED), payment_response.gateway_error
43
- payment_response.amount.should == @amount
44
- payment_response.transaction_type.should == :PURCHASE
45
-
46
- responses = Killbill::Litle::LitleResponse.all
47
- responses.size.should == 2
48
- responses[0].api_call.should == 'add_payment_method'
49
- responses[0].message.should == 'Approved'
50
- responses[1].api_call.should == 'purchase'
51
- responses[1].message.should == 'Approved'
52
- transactions = Killbill::Litle::LitleTransaction.all
53
- transactions.size.should == 1
54
- transactions[0].api_call.should == 'purchase'
55
- end
56
-
57
- it 'should be able to charge and refund' do
58
- 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)
59
- payment_response.status.should eq(:PROCESSED), payment_response.gateway_error
60
- payment_response.amount.should == @amount
61
- payment_response.transaction_type.should == :PURCHASE
62
-
63
- # Try a full refund
64
- refund_response = @plugin.refund_payment(@pm.kb_account_id, @kb_payment.id, @kb_payment.transactions[1].id, @pm.kb_payment_method_id, @amount, @currency, @properties, @call_context)
65
- refund_response.status.should eq(:PROCESSED), refund_response.gateway_error
66
- refund_response.amount.should == @amount
67
- refund_response.transaction_type.should == :REFUND
68
- end
69
-
70
- it 'should be able to auth, capture and refund' do
71
- 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)
72
- payment_response.status.should eq(:PROCESSED), payment_response.gateway_error
73
- payment_response.amount.should == @amount
74
- payment_response.transaction_type.should == :AUTHORIZE
75
-
76
- # Try multiple partial captures
77
- partial_capture_amount = BigDecimal.new('10')
78
- 1.upto(3) do |i|
79
- payment_response = @plugin.capture_payment(@pm.kb_account_id, @kb_payment.id, @kb_payment.transactions[i].id, @pm.kb_payment_method_id, partial_capture_amount, @currency, @properties, @call_context)
80
- payment_response.status.should eq(:PROCESSED), payment_response.gateway_error
81
- payment_response.amount.should == partial_capture_amount
82
- payment_response.transaction_type.should == :CAPTURE
83
- end
84
-
85
- # Try a partial refund
86
- refund_response = @plugin.refund_payment(@pm.kb_account_id, @kb_payment.id, @kb_payment.transactions[4].id, @pm.kb_payment_method_id, partial_capture_amount, @currency, @properties, @call_context)
87
- refund_response.status.should eq(:PROCESSED), refund_response.gateway_error
88
- refund_response.amount.should == partial_capture_amount
89
- refund_response.transaction_type.should == :REFUND
90
-
91
- # Try to capture again
92
- payment_response = @plugin.capture_payment(@pm.kb_account_id, @kb_payment.id, @kb_payment.transactions[5].id, @pm.kb_payment_method_id, partial_capture_amount, @currency, @properties, @call_context)
93
- payment_response.status.should eq(:PROCESSED), payment_response.gateway_error
94
- payment_response.amount.should == partial_capture_amount
95
- payment_response.transaction_type.should == :CAPTURE
96
- end
97
-
98
- it 'should be able to auth and void' do
99
- 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)
100
- payment_response.status.should eq(:PROCESSED), payment_response.gateway_error
101
- payment_response.amount.should == @amount
102
- payment_response.transaction_type.should == :AUTHORIZE
103
-
104
- payment_response = @plugin.void_payment(@pm.kb_account_id, @kb_payment.id, @kb_payment.transactions[1].id, @pm.kb_payment_method_id, @properties, @call_context)
105
- payment_response.status.should eq(:PROCESSED), payment_response.gateway_error
106
- payment_response.transaction_type.should == :VOID
107
- end
108
-
109
- it 'should be able to auth, partial capture and void' do
110
- 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)
111
- payment_response.status.should eq(:PROCESSED), payment_response.gateway_error
112
- payment_response.amount.should == @amount
113
- payment_response.transaction_type.should == :AUTHORIZE
114
-
115
- partial_capture_amount = BigDecimal.new('10')
116
- payment_response = @plugin.capture_payment(@pm.kb_account_id, @kb_payment.id, @kb_payment.transactions[1].id, @pm.kb_payment_method_id, partial_capture_amount, @currency, @properties, @call_context)
117
- payment_response.status.should eq(:PROCESSED), payment_response.gateway_error
118
- payment_response.amount.should == partial_capture_amount
119
- payment_response.transaction_type.should == :CAPTURE
120
-
121
- payment_response = @plugin.void_payment(@pm.kb_account_id, @kb_payment.id, @kb_payment.transactions[2].id, @pm.kb_payment_method_id, @properties, @call_context)
122
- payment_response.status.should eq(:PROCESSED), payment_response.gateway_error
123
- payment_response.transaction_type.should == :VOID
124
- end
125
- end
data/spec/spec_helper.rb DELETED
@@ -1,24 +0,0 @@
1
- require 'bundler'
2
- require 'litle'
3
- require 'killbill/helpers/active_merchant/killbill_spec_helper'
4
-
5
- require 'logger'
6
-
7
- require 'rspec'
8
-
9
- RSpec.configure do |config|
10
- config.color_enabled = true
11
- config.tty = true
12
- config.formatter = 'documentation'
13
- end
14
-
15
- require 'active_record'
16
- ActiveRecord::Base.establish_connection(
17
- :adapter => 'sqlite3',
18
- :database => 'test.db'
19
- )
20
- # For debugging
21
- #ActiveRecord::Base.logger = Logger.new(STDOUT)
22
- # Create the schema
23
- require File.expand_path(File.dirname(__FILE__) + '../../db/schema.rb')
24
-