servicemerchant 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.
- data/MIT-LICENSE.txt +20 -0
- data/README.txt +231 -0
- data/Rakefile +122 -0
- data/demo.rb +69 -0
- data/recurring_billing/lib/am_extensions.rb +1 -0
- data/recurring_billing/lib/am_extensions/paypal_extension.rb +170 -0
- data/recurring_billing/lib/dependencies.rb +14 -0
- data/recurring_billing/lib/gateways.rb +5 -0
- data/recurring_billing/lib/gateways/authorize_net.rb +103 -0
- data/recurring_billing/lib/gateways/paypal.rb +124 -0
- data/recurring_billing/lib/recurring_billing.rb +130 -0
- data/recurring_billing/lib/recurring_billing.rdoc +87 -0
- data/recurring_billing/lib/utils.rb +81 -0
- data/recurring_billing/test/fixtures.yml +33 -0
- data/recurring_billing/test/remote/authorize_net_test.rb +36 -0
- data/recurring_billing/test/remote/paypal_test.rb +46 -0
- data/recurring_billing/test/remote/recurring_billing_test.rb +41 -0
- data/recurring_billing/test/test_helper.rb +153 -0
- data/recurring_billing/test/unit/authorize_net_gateway_class_test.rb +42 -0
- data/recurring_billing/test/unit/paypal_gateway_class_test.rb +23 -0
- data/recurring_billing/test/unit/recurring_billing_gateway_class_test.rb +35 -0
- data/recurring_billing/test/unit/utils_test.rb +17 -0
- data/subscription_management/Rakefile +29 -0
- data/subscription_management/lib/models/subscription.rb +9 -0
- data/subscription_management/lib/models/subscription_profile.rb +4 -0
- data/subscription_management/lib/subscription_management.rb +326 -0
- data/subscription_management/samples/backpack.yml +101 -0
- data/subscription_management/samples/basecamp.yml +71 -0
- data/subscription_management/samples/brainkeeper.yml +90 -0
- data/subscription_management/samples/campfire.yml +74 -0
- data/subscription_management/samples/clickandpledge.yml +24 -0
- data/subscription_management/samples/demo.rb +19 -0
- data/subscription_management/samples/elm.yml +174 -0
- data/subscription_management/samples/freshbooks.yml +78 -0
- data/subscription_management/samples/highrise.yml +100 -0
- data/subscription_management/samples/presets.yml +10 -0
- data/subscription_management/samples/tariff.outline.yml +0 -0
- data/subscription_management/samples/taxes.yml +21 -0
- data/subscription_management/subscription_management.rb +7 -0
- data/subscription_management/tasks/schema.rb +50 -0
- data/subscription_management/test/connection.rb +10 -0
- data/subscription_management/test/remote/subscription_management_test.rb +112 -0
- data/subscription_management/test/test_helper.rb +84 -0
- data/subscription_management/test/unit/subscription_management_test.rb +40 -0
- data/tracker/README +12 -0
- data/tracker/Rakefile +40 -0
- data/tracker/db/migrations/empty-directory +0 -0
- data/tracker/demo.rb +12 -0
- data/tracker/lib/models/recurring_payment_profile.rb +134 -0
- data/tracker/lib/models/transaction.rb +19 -0
- data/tracker/lib/recurring_billing_extension.rb +103 -0
- data/tracker/lib/recurring_billing_extension.rdoc +34 -0
- data/tracker/tasks/schema.rb +66 -0
- data/tracker/test/connection.rb +10 -0
- data/tracker/test/recurring_payment_profile.rb +35 -0
- data/tracker/test/remote/authorize_net_test.rb +68 -0
- data/tracker/test/remote/paypal_test.rb +115 -0
- data/tracker/test/test_helper.rb +87 -0
- data/tracker/test/unit/recurring_payment_profile_test.rb +62 -0
- data/tracker/tracker.rb +10 -0
- data/vendor/money-1.7.1/MIT-LICENSE +20 -0
- data/vendor/money-1.7.1/README +75 -0
- data/vendor/money-1.7.1/lib/bank/no_exchange_bank.rb +9 -0
- data/vendor/money-1.7.1/lib/bank/variable_exchange_bank.rb +30 -0
- data/vendor/money-1.7.1/lib/money.rb +29 -0
- data/vendor/money-1.7.1/lib/money/core_extensions.rb +26 -0
- data/vendor/money-1.7.1/lib/money/money.rb +209 -0
- data/vendor/money-1.7.1/lib/support/cattr_accessor.rb +57 -0
- metadata +153 -0
data/MIT-LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2005 Tobias Luetke
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOa AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SaALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.txt
ADDED
@@ -0,0 +1,231 @@
|
|
1
|
+
ServiceMerchant
|
2
|
+
===============
|
3
|
+
|
4
|
+
*Ruby toolkit for recurring billing and subscription management*
|
5
|
+
|
6
|
+
ServiceMerchant is an open source library for Software-as-a-Service
|
7
|
+
applications, based on subscription payments and various service
|
8
|
+
plans. The library consists of number of well-isolated and
|
9
|
+
well-defined components, so that you may re-use portions of the
|
10
|
+
library, should you find the full functionality not required for
|
11
|
+
you. If you choose to use the library as whole, it should cover most
|
12
|
+
of your payments requirements, thus being billing module for your
|
13
|
+
application.
|
14
|
+
|
15
|
+
ServiceMerchant's main purpose is providing gateway-independent
|
16
|
+
support for recurring billing operations and powerful high-level tools
|
17
|
+
for building subscription-based billing atop of it. It is built on
|
18
|
+
top of well-known [Active Merchant](http://www.activemerchant.org/)
|
19
|
+
library.
|
20
|
+
|
21
|
+
ServiceMerchant can be used both as a Rails plug-in or standalone Ruby
|
22
|
+
library. It is also possible to integrate ServiceMerchant with
|
23
|
+
non-Ruby web applications via REST interface or common GUI.
|
24
|
+
|
25
|
+
== Supported Gateways
|
26
|
+
|
27
|
+
Currently [Authorize.Net](http://www.authorize.net/) and
|
28
|
+
[Paypal Website Payments Pro (US)](https://www.paypal.com/cgi-bin/webscr?cmd=_wp-pro-overview-outside)
|
29
|
+
are supported.
|
30
|
+
|
31
|
+
Generally, if Active Merchant supports some gateway with recurring
|
32
|
+
billing features then it is easy to add ServiceMerhant support as
|
33
|
+
well. In this case you'll only need to add a few lines of proxy code
|
34
|
+
between Active Merchant and commont recurring billing API.
|
35
|
+
|
36
|
+
== Components
|
37
|
+
|
38
|
+
ServiceMerchant consists of three relatively independent components:
|
39
|
+
|
40
|
+
=== Recurring Billing API
|
41
|
+
|
42
|
+
Recurring Billing API is aimed at providing uniform interface for
|
43
|
+
recurring billing features of payment gateways and making switching
|
44
|
+
from one to another as painless as possible.
|
45
|
+
|
46
|
+
=== Transaction Tracker
|
47
|
+
|
48
|
+
Transactions Tracker stores local and readily available snapshots of
|
49
|
+
so-called "recurring billing profiles". With Tracker you can check
|
50
|
+
account status much faster than vie gateway query (which not every
|
51
|
+
gateway API includes). Transaction Tracker hooks automatically to
|
52
|
+
Recurring Billing API and updates your local copy of data according to
|
53
|
+
all ongoing operations.
|
54
|
+
|
55
|
+
=== Subscription Manager
|
56
|
+
|
57
|
+
Subscription Manager provides high-level logic for managing
|
58
|
+
subscription services, tariff plans, payment poliies and so on. You
|
59
|
+
can even use it to automatically adjust final price with the tax of
|
60
|
+
appropriate region!
|
61
|
+
|
62
|
+
== Download
|
63
|
+
|
64
|
+
Currently this library is available from https://github.com/itteco/service_merchant
|
65
|
+
|
66
|
+
git clone git://github.com/itteco/service_merchant.git
|
67
|
+
|
68
|
+
== Installation
|
69
|
+
|
70
|
+
0. Install Ruby, Rails and dependencies:
|
71
|
+
|
72
|
+
In *nix software installation may require root privileges. Use "su"
|
73
|
+
or "sudo" in case of lack rights.
|
74
|
+
|
75
|
+
1) Install Ruby and Rails:
|
76
|
+
|
77
|
+
please, refer to section #1 and #2 at
|
78
|
+
http://wiki.rubyonrails.com/rails/pages/GettingStartedWithRails
|
79
|
+
|
80
|
+
2) Install prerequisites:
|
81
|
+
|
82
|
+
gem install activemerchant -v '1.3.2' --include-dependencies
|
83
|
+
|
84
|
+
Test suite prerequisites:
|
85
|
+
|
86
|
+
gem install mocha --include-dependencies
|
87
|
+
gem install rake
|
88
|
+
|
89
|
+
You may also need to update rubygems package manager if your
|
90
|
+
version is too old
|
91
|
+
|
92
|
+
gem install rubygems-update
|
93
|
+
|
94
|
+
3) Install SQLite3 library:
|
95
|
+
|
96
|
+
1. Install SQLite3:
|
97
|
+
|
98
|
+
In *nix try your package manager. You'll also need header
|
99
|
+
files. On Ubuntu packages names are sqlite3 and sqlite3-dev
|
100
|
+
for library and header files respectively.
|
101
|
+
|
102
|
+
Under Windows install it manually:
|
103
|
+
|
104
|
+
a) download sqlitedll-*.zip from http://sqlite.org (for
|
105
|
+
example, http://sqlite.org/sqlitedll-3_6_3.zip)
|
106
|
+
|
107
|
+
b) extract sqlite3.dll somewhere within PATH
|
108
|
+
(e.g. c:\ruby\bin, c:\windows\system32)
|
109
|
+
|
110
|
+
2. Install Ruby wrapper:
|
111
|
+
|
112
|
+
gem install sqlite3-ruby --include-dependencies
|
113
|
+
(under Windows select <mswin32> option)
|
114
|
+
|
115
|
+
In case of problems under Windows try to use older version:
|
116
|
+
|
117
|
+
gem install --version 1.2.3 sqlite3-ruby
|
118
|
+
|
119
|
+
4) [optional] Install HTMLDOC library:
|
120
|
+
|
121
|
+
To use invoice generation feature in sample Rails application
|
122
|
+
|
123
|
+
1. Install HTMLDOC:
|
124
|
+
|
125
|
+
In *nix try your package manager. Package name is *htmldoc*.
|
126
|
+
|
127
|
+
Under Windows download it from
|
128
|
+
http://www.easysw.com/htmldoc/software.php and install it
|
129
|
+
manually.
|
130
|
+
|
131
|
+
2. Intall Ruby wrapper:
|
132
|
+
|
133
|
+
gem install htmldoc
|
134
|
+
|
135
|
+
|
136
|
+
1.1. GEM installation:
|
137
|
+
|
138
|
+
#TODO#
|
139
|
+
|
140
|
+
1.2. Manual installation:
|
141
|
+
|
142
|
+
1) Download and unpack source
|
143
|
+
|
144
|
+
2) [optional] Create ServiceMerchant database (will delete current
|
145
|
+
database):
|
146
|
+
|
147
|
+
cd {unpack_dir}/trunk
|
148
|
+
rake create_all_tables
|
149
|
+
|
150
|
+
2. Configuration:
|
151
|
+
|
152
|
+
The distribution contains sample config for test usage. See
|
153
|
+
tracker/test/fixtures.yml for details. To run remote tests create
|
154
|
+
|
155
|
+
!!! WARNING !!!
|
156
|
+
|
157
|
+
Always use TEST accounts and TEST mode for your payment gateway
|
158
|
+
until you've verified everything works correctly.
|
159
|
+
|
160
|
+
|
161
|
+
3. Test suite
|
162
|
+
|
163
|
+
Run unit tests:
|
164
|
+
rake test:unit
|
165
|
+
|
166
|
+
Run remote tests (requires test accounts on gateways, see tracker/test/fixtures.yml):
|
167
|
+
rake test:remote
|
168
|
+
|
169
|
+
Other test-related tasks:
|
170
|
+
rake -T test
|
171
|
+
|
172
|
+
== Sample Usage
|
173
|
+
|
174
|
+
1) Simple command-line sample app:
|
175
|
+
|
176
|
+
cd {unpack_dir}/trunk
|
177
|
+
./demo.rb
|
178
|
+
|
179
|
+
Please, refer to its source code for details.
|
180
|
+
|
181
|
+
2) Simple web site (Ruby on Rails application):
|
182
|
+
|
183
|
+
cd {unpack_dir}/trunk/sample_app
|
184
|
+
./script/server
|
185
|
+
|
186
|
+
and open http://127.0.0.1:3000/ and http://127.0.0.1:3000/admin in
|
187
|
+
your browser. If both URLs does not work, try running
|
188
|
+
|
189
|
+
./script/server webrick
|
190
|
+
(instead of ./script/server)
|
191
|
+
|
192
|
+
Please, refer to its source code (for example, config/environment.rb
|
193
|
+
and app/controllers/*) for details.
|
194
|
+
|
195
|
+
Both of these demo applications use sample configs to work.
|
196
|
+
|
197
|
+
== Known issues
|
198
|
+
|
199
|
+
1. No expection handling is provided for sample applications.
|
200
|
+
|
201
|
+
2. Not tested in LIVE payment gateway mode.
|
202
|
+
|
203
|
+
3. Database is stored inside module, single ServiceMerchant database
|
204
|
+
for all projects.
|
205
|
+
|
206
|
+
4. sqlite3-ruby 1.0.0 generates "Table not found" error on some Linux
|
207
|
+
machines.
|
208
|
+
|
209
|
+
== Roadmap
|
210
|
+
|
211
|
+
Add "sync payments status" feature - find out what accounts has
|
212
|
+
difficulties with payments - using
|
213
|
+
|
214
|
+
1. Online sync - ask for account status directly from payment
|
215
|
+
gateway
|
216
|
+
|
217
|
+
2. Offline sync - import payment gateway report manualy
|
218
|
+
|
219
|
+
Pack source code as GEM and publish on rubyforge
|
220
|
+
|
221
|
+
== Developers
|
222
|
+
|
223
|
+
- Alexander Lebedev <me@alexlebedev.com>
|
224
|
+
- Artyom Scorecky <tonn81@gmail.com>
|
225
|
+
- Anatoly Ivanov <mail@anatoly-ivanov.com>
|
226
|
+
|
227
|
+
Sponsored by [Itteco Software](http://itteco.com)
|
228
|
+
|
229
|
+
== Contributing
|
230
|
+
|
231
|
+
#TODO#
|
data/Rakefile
ADDED
@@ -0,0 +1,122 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
require 'rake/testtask'
|
4
|
+
require 'rake/rdoctask'
|
5
|
+
require 'rake/gempackagetask'
|
6
|
+
#require 'rake/contrib/rubyforgepublisher'
|
7
|
+
|
8
|
+
PKG_VERSION = "0.1.0"
|
9
|
+
PKG_NAME = "servicemerchant"
|
10
|
+
PKG_FILE_NAME = "#{PKG_NAME}-#{PKG_VERSION}"
|
11
|
+
|
12
|
+
PKG_FILES = FileList[
|
13
|
+
"recurring_billing/**/*", "subscription_management/**/*",
|
14
|
+
"tracker/**/*", "vendor/**/*", "[a-zA-Z]*"
|
15
|
+
].exclude(/\.svn$/)
|
16
|
+
|
17
|
+
task :default => 'dobuild'
|
18
|
+
|
19
|
+
task :install => [:package] do
|
20
|
+
`gem install pkg/#{PKG_FILE_NAME}.gem`
|
21
|
+
end
|
22
|
+
|
23
|
+
#TODO: use defaults in task
|
24
|
+
task :test => ["test:default"] do
|
25
|
+
puts 'All tests run is complete.'
|
26
|
+
end
|
27
|
+
|
28
|
+
task :dobuild => [:test, :gem] do
|
29
|
+
puts 'Build complete'
|
30
|
+
end
|
31
|
+
|
32
|
+
# Genereate the RDoc documentation
|
33
|
+
Rake::RDocTask.new do |rdoc|
|
34
|
+
rdoc.rdoc_dir = 'rdoc'
|
35
|
+
rdoc.title = "ServiceMerchant library"
|
36
|
+
rdoc.options << '--line-numbers' << '--inline-source' << '--main=README' << '--include=tracker/lib/'
|
37
|
+
rdoc.rdoc_files.include('README.txt')
|
38
|
+
rdoc.rdoc_files.include('recurring_billing/lib/**/*.rb')
|
39
|
+
rdoc.rdoc_files.include('subscription_management/lib/**/*.rb')
|
40
|
+
rdoc.rdoc_files.include('tracker/lib/**/*.rb')
|
41
|
+
end
|
42
|
+
|
43
|
+
desc "Delete tar.gz / zip / rdoc"
|
44
|
+
task :cleanup => [ :clobber_package ]
|
45
|
+
|
46
|
+
spec = Gem::Specification.new do |s|
|
47
|
+
s.name = PKG_NAME
|
48
|
+
s.version = PKG_VERSION
|
49
|
+
s.summary = "Provides UI and tools to add billing feature to web application"
|
50
|
+
s.has_rdoc = true
|
51
|
+
|
52
|
+
s.files = PKG_FILES
|
53
|
+
|
54
|
+
s.add_dependency('activemerchant', '= 1.3.2')
|
55
|
+
end
|
56
|
+
|
57
|
+
Rake::GemPackageTask.new(spec) do |p|
|
58
|
+
p.gem_spec = spec
|
59
|
+
p.need_tar = true
|
60
|
+
p.need_zip = true
|
61
|
+
end
|
62
|
+
|
63
|
+
#######################################################################
|
64
|
+
|
65
|
+
require File.dirname(__FILE__)+'/tracker/tasks/schema'
|
66
|
+
require File.dirname(__FILE__)+'/subscription_management/tasks/schema'
|
67
|
+
|
68
|
+
desc "Create all tables"
|
69
|
+
task :create_all_tables => ["tracker:create_tables", "subscription:create_tables"]
|
70
|
+
|
71
|
+
desc "Drop all tables"
|
72
|
+
task :drop_all_tables => ["subscription:drop_tables", "tracker:drop_tables"]
|
73
|
+
|
74
|
+
# Run the tests
|
75
|
+
namespace :test do
|
76
|
+
Rake::TestTask.new(:unit_recurring) do |t|
|
77
|
+
t.pattern = 'recurring_billing/test/unit/**/*_test.rb'
|
78
|
+
t.ruby_opts << '-rubygems'
|
79
|
+
t.verbose = true
|
80
|
+
end
|
81
|
+
|
82
|
+
Rake::TestTask.new(:unit_tracker) do |t|
|
83
|
+
t.pattern = 'tracker/test/unit/**/*_test.rb'
|
84
|
+
t.ruby_opts << '-rubygems'
|
85
|
+
t.verbose = true
|
86
|
+
end
|
87
|
+
|
88
|
+
Rake::TestTask.new(:unit_subscription) do |t|
|
89
|
+
t.pattern = 'subscription_management/test/unit/**/*_test.rb'
|
90
|
+
t.ruby_opts << '-rubygems'
|
91
|
+
t.verbose = true
|
92
|
+
end
|
93
|
+
|
94
|
+
Rake::TestTask.new(:remote_recurring) do |t|
|
95
|
+
t.pattern = 'recurring_billing/test/remote/**/*_test.rb'
|
96
|
+
t.ruby_opts << '-rubygems'
|
97
|
+
t.verbose = true
|
98
|
+
end
|
99
|
+
|
100
|
+
Rake::TestTask.new(:remote_tracker) do |t|
|
101
|
+
t.pattern = 'tracker/test/remote/**/*_test.rb'
|
102
|
+
t.ruby_opts << '-rubygems'
|
103
|
+
t.verbose = true
|
104
|
+
end
|
105
|
+
|
106
|
+
Rake::TestTask.new(:remote_subscription) do |t|
|
107
|
+
t.pattern = 'subscription_management/test/remote/**/*_test.rb'
|
108
|
+
t.ruby_opts << '-rubygems'
|
109
|
+
t.verbose = true
|
110
|
+
end
|
111
|
+
|
112
|
+
desc "Run all unit tests"
|
113
|
+
task :unit => [:unit_recurring, :unit_tracker, :unit_subscription]
|
114
|
+
|
115
|
+
desc "Run all remote tests"
|
116
|
+
task :remote => [:remote_recurring, :remote_tracker, :remote_subscription]
|
117
|
+
|
118
|
+
desc "Run both unit and remote tests"
|
119
|
+
task :all => [:unit, :remote]
|
120
|
+
|
121
|
+
task :default => 'unit'
|
122
|
+
end
|
data/demo.rb
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
#
|
3
|
+
# Demo of subscription management
|
4
|
+
require File.dirname(__FILE__) + '/subscription_management/subscription_management'
|
5
|
+
|
6
|
+
require 'rubygems'
|
7
|
+
require 'active_merchant'
|
8
|
+
|
9
|
+
options = {
|
10
|
+
:account_id => 'Test',
|
11
|
+
:account_country => 'US',
|
12
|
+
:account_state => 'CA',
|
13
|
+
:tariff_plan => 'solo_monthly',
|
14
|
+
:start_date => (Date.today + 1),
|
15
|
+
:quantity => 1,
|
16
|
+
:end_date => DateTime.new(2010, 12, 11)
|
17
|
+
}
|
18
|
+
credit_card = ActiveMerchant::Billing::CreditCard.new({
|
19
|
+
:number => 4242424242424242,
|
20
|
+
:month => 9,
|
21
|
+
:year => Time.now.year + 1,
|
22
|
+
:first_name => 'John',
|
23
|
+
:last_name => 'Doe',
|
24
|
+
:verification_value => '123',
|
25
|
+
:type => 'visa'
|
26
|
+
})
|
27
|
+
|
28
|
+
credit_card_2 = ActiveMerchant::Billing::CreditCard.new({
|
29
|
+
:number => 4929838635250031,
|
30
|
+
:month => 9,
|
31
|
+
:year => Time.now.year + 5,
|
32
|
+
:first_name => 'John',
|
33
|
+
:last_name => 'Doe',
|
34
|
+
:verification_value => '123',
|
35
|
+
:type => 'visa'
|
36
|
+
})
|
37
|
+
|
38
|
+
credit_card_3 = ActiveMerchant::Billing::CreditCard.new({
|
39
|
+
:number => 4929273971564532,
|
40
|
+
:month => 12,
|
41
|
+
:year => Time.now.year + 3,
|
42
|
+
:first_name => 'John',
|
43
|
+
:last_name => 'Doe',
|
44
|
+
:verification_value => '123',
|
45
|
+
:type => 'visa'
|
46
|
+
})
|
47
|
+
|
48
|
+
sm = SubscriptionManagement.new(
|
49
|
+
:tariff_plans_config => 'subscription_management/samples/backpack.yml',
|
50
|
+
:taxes_config => 'subscription_management/samples/taxes.yml',
|
51
|
+
:gateways_config => 'recurring_billing/test/fixtures.yml',
|
52
|
+
:gateway => :paypal
|
53
|
+
)
|
54
|
+
|
55
|
+
subscription_id = sm.subscribe(options)
|
56
|
+
sm.pay_for_subscription(subscription_id, credit_card, {})
|
57
|
+
features = sm.get_features(subscription_id)
|
58
|
+
for feature in features
|
59
|
+
print "\n"+SubscriptionManagement.format_feature(feature)
|
60
|
+
end
|
61
|
+
|
62
|
+
options_sets = [{:card=>credit_card_2}, {:card=>credit_card_3, :start_date => Date.today + 42}]
|
63
|
+
options_sets.each do |options|
|
64
|
+
print "\nTrying to update subscription using options: #{options.inspect}"
|
65
|
+
print "\nWarning: current billing profile on gateway will be canceled and re-created" unless sm.update_possible?(subscription_id, options)
|
66
|
+
sm.update_subscription(subscription_id, options)
|
67
|
+
end
|
68
|
+
|
69
|
+
sm.unsubscribe(subscription_id)
|
@@ -0,0 +1 @@
|
|
1
|
+
Dir[File.dirname(__FILE__) + '/am_extensions/*.rb'].each{|g| require g}
|