chargify_api_ares 0.2.2 → 0.2.3
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/Rakefile +1 -1
- data/VERSION +1 -1
- data/chargify_api_ares.gemspec +4 -4
- data/lib/chargify_api_ares.rb +7 -0
- data/samples/subscriptions.rb +5 -0
- data/spec/factories.rb +4 -0
- data/spec/subscription_spec.rb +14 -0
- metadata +13 -5
data/Rakefile
CHANGED
@@ -6,7 +6,7 @@ begin
|
|
6
6
|
gemspec.description = ""
|
7
7
|
gemspec.email = "mklett@grasshopper.com"
|
8
8
|
gemspec.homepage = "http://github.com/grasshopperlabs/chargify_api_ares"
|
9
|
-
gemspec.authors = ["Michael Klett", "The Lab Rats @ Phase Two Labs"]
|
9
|
+
gemspec.authors = ["Michael Klett", "The Lab Rats @ Phase Two Labs", "Brian Rose"]
|
10
10
|
Jeweler::GemcutterTasks.new
|
11
11
|
end
|
12
12
|
rescue LoadError
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.3
|
data/chargify_api_ares.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{chargify_api_ares}
|
8
|
-
s.version = "0.2.
|
8
|
+
s.version = "0.2.3"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
-
s.authors = ["Michael Klett", "The Lab Rats @ Phase Two Labs"]
|
12
|
-
s.date = %q{2010-
|
11
|
+
s.authors = ["Michael Klett", "The Lab Rats @ Phase Two Labs", "Brian Rose"]
|
12
|
+
s.date = %q{2010-02-26}
|
13
13
|
s.description = %q{}
|
14
14
|
s.email = %q{mklett@grasshopper.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -38,7 +38,7 @@ Gem::Specification.new do |s|
|
|
38
38
|
s.homepage = %q{http://github.com/grasshopperlabs/chargify_api_ares}
|
39
39
|
s.rdoc_options = ["--charset=UTF-8"]
|
40
40
|
s.require_paths = ["lib"]
|
41
|
-
s.rubygems_version = %q{1.3.
|
41
|
+
s.rubygems_version = %q{1.3.6}
|
42
42
|
s.summary = %q{A Chargify API wrapper for Ruby using ActiveResource}
|
43
43
|
s.test_files = [
|
44
44
|
"spec/base_spec.rb",
|
data/lib/chargify_api_ares.rb
CHANGED
@@ -92,6 +92,13 @@ module Chargify
|
|
92
92
|
def cancel
|
93
93
|
destroy
|
94
94
|
end
|
95
|
+
|
96
|
+
# Perform a one-time charge on an existing subscription.
|
97
|
+
# For more information, please see the one-time charge API docs available
|
98
|
+
# at: http://support.chargify.com/faqs/api/api-charges
|
99
|
+
def charge(attrs = {})
|
100
|
+
post :charges, :charge => attrs
|
101
|
+
end
|
95
102
|
end
|
96
103
|
|
97
104
|
class Product < Base
|
data/samples/subscriptions.rb
CHANGED
@@ -37,6 +37,11 @@ subscription.save
|
|
37
37
|
# => #<Chargify::Subscription:0x1020ed4b0 @prefix_options={}, @attributes={"cancellation_message"=>nil, "activated_at"=>Tue Nov 17 16:00:17 UTC 2009, "expires_at"=>nil, "updated_at"=>Tue Nov 17 16:00:17 UTC 2009, "credit_card"=>#<Chargify::Subscription::CreditCard:0x1023ba878 @prefix_options={}, @attributes={"card_type"=>"bogus", "expiration_year"=>2015, "masked_card_number"=>"XXXX-XXXX-XXXX-2", "first_name"=>"Michael", "expiration_month"=>1, "last_name"=>"Klett"}>, "product"=>#<Chargify::Product:0x1023baa80 @prefix_options={}, @attributes={"price_in_cents"=>0, "name"=>"Chargify API Ares Test", "handle"=>"chargify-api-ares-test", "product_family"=>#<Chargify::Product::ProductFamily:0x1023c04d0 @prefix_options={}, @attributes={"name"=>"Chargify API ARes Test", "handle"=>"chargify-api-ares-test", "id"=>79, "accounting_code"=>nil}>, "id"=>153, "accounting_code"=>nil, "interval_unit"=>"month", "interval"=>1}>, "credit_card_attributes"=>{:full_number=>"2", :expiration_year=>"2015"}, "trial_ended_at"=>nil, "id"=>331, "current_period_ends_at"=>Thu Dec 17 16:00:17 UTC 2009, "product_handle"=>"chargify-api-ares-test", "customer"=>#<Chargify::Customer:0x1023bae40 @prefix_options={}, @attributes={"reference"=>"moklett", "updated_at"=>Tue Nov 17 15:51:02 UTC 2009, "id"=>331, "first_name"=>"Michael", "organization"=>"Chargify", "last_name"=>"Klett", "email"=>"moklett@example.com", "created_at"=>Tue Nov 17 15:51:02 UTC 2009}>, "trial_started_at"=>nil, "balance_in_cents"=>0, "current_period_started_at"=>Tue Nov 17 16:00:17 UTC 2009, "state"=>"active", "created_at"=>Tue Nov 17 16:00:17 UTC 2009, "customer_reference"=>"moklett"}>
|
38
38
|
|
39
39
|
|
40
|
+
# Perform a one-time charge against an existing subscription
|
41
|
+
subscription.charge(:amount => 10.00, :memo => 'Extra service')
|
42
|
+
# => #<Net::HTTPCreated>
|
43
|
+
|
44
|
+
|
40
45
|
# Cancel a subscription
|
41
46
|
subscription.cancel
|
42
47
|
subscription.reload
|
data/spec/factories.rb
CHANGED
@@ -28,6 +28,10 @@ Factory.define :product, :class => Chargify::Product do |p|
|
|
28
28
|
p.name { Factory.next(:product_name) }
|
29
29
|
end
|
30
30
|
|
31
|
+
Factory.sequence :subscription_id do |n|
|
32
|
+
n
|
33
|
+
end
|
34
|
+
|
31
35
|
Factory.define :subscription, :class => Chargify::Subscription do |s|
|
32
36
|
s.balance_in_cents 500
|
33
37
|
s.current_period_ends_at 3.days.from_now
|
data/spec/subscription_spec.rb
CHANGED
@@ -32,6 +32,20 @@ describe Chargify::Subscription do
|
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
35
|
+
describe 'one-time charges' do
|
36
|
+
it 'creates a one-time charge' do
|
37
|
+
id = Factory.next(:subscription_id)
|
38
|
+
subscription = Factory(:subscription, :id => id)
|
39
|
+
expected_response = {:charge => {:amount_in_cents => 1000, :memo => "one-time charge", :success => true}}.to_xml
|
40
|
+
FakeWeb.register_uri(:post, "#{test_domain}/subscriptions/#{id}/charges.xml?charge%5Bamount%5D=10.00&charge%5Bmemo%5D=one-time+charge", :status => 201, :body => expected_response)
|
41
|
+
|
42
|
+
response = subscription.charge(:amount => "10.00", "memo" => "one-time charge")
|
43
|
+
|
44
|
+
response.body.should == expected_response
|
45
|
+
response.should be_a(Net::HTTPCreated)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
35
49
|
it 'cancels the subscription' do
|
36
50
|
@subscription = Factory(:subscription, :id => 1)
|
37
51
|
find_subscription = lambda { Chargify::Subscription.find(1) }
|
metadata
CHANGED
@@ -1,16 +1,22 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chargify_api_ares
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 2
|
8
|
+
- 3
|
9
|
+
version: 0.2.3
|
5
10
|
platform: ruby
|
6
11
|
authors:
|
7
12
|
- Michael Klett
|
8
13
|
- The Lab Rats @ Phase Two Labs
|
14
|
+
- Brian Rose
|
9
15
|
autorequire:
|
10
16
|
bindir: bin
|
11
17
|
cert_chain: []
|
12
18
|
|
13
|
-
date: 2010-
|
19
|
+
date: 2010-02-26 00:00:00 -07:00
|
14
20
|
default_executable:
|
15
21
|
dependencies: []
|
16
22
|
|
@@ -54,18 +60,20 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
54
60
|
requirements:
|
55
61
|
- - ">="
|
56
62
|
- !ruby/object:Gem::Version
|
63
|
+
segments:
|
64
|
+
- 0
|
57
65
|
version: "0"
|
58
|
-
version:
|
59
66
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
60
67
|
requirements:
|
61
68
|
- - ">="
|
62
69
|
- !ruby/object:Gem::Version
|
70
|
+
segments:
|
71
|
+
- 0
|
63
72
|
version: "0"
|
64
|
-
version:
|
65
73
|
requirements: []
|
66
74
|
|
67
75
|
rubyforge_project:
|
68
|
-
rubygems_version: 1.3.
|
76
|
+
rubygems_version: 1.3.6
|
69
77
|
signing_key:
|
70
78
|
specification_version: 3
|
71
79
|
summary: A Chargify API wrapper for Ruby using ActiveResource
|