Class: TrustCommerce::Subscription
- Inherits:
-
Object
- Object
- TrustCommerce::Subscription
- Defined in:
- lib/trustcommerce.rb
Class Method Summary collapse
-
.charge(options) ⇒ Object
# Process one-time sale against existing subscription response = TrustCommerce::Subscription.charge( :billingid => ‘ABC123’, :amount => 1995 ).
-
.create(options) ⇒ Object
# Bill Jennifer $12.00 monthly response = TrustCommerce::Subscription.create( :cc => ‘4111111111111111’, :exp => ‘0412’, :name => ‘Jennifer Smith’, :amount => 1200, :cycle => ‘1m’ ) if response == ‘approved’ puts “Subscription created with Billing ID: #'billingid'” else puts “An error occurred: #'error'” end.
-
.credit(options) ⇒ Object
# Process one-time credit against existing transaction response = TrustCommerce::Subscription.credit( :transid => ‘001-0000111101’, :amount => 1995 ).
-
.delete(options) ⇒ Object
# Delete subscription response = TrustCommerce::Subscription.delete( :billingid => ‘ABC123’ ) if response == ‘accepted’ puts ‘Subscription removed from active use.’ else puts ‘An error occurred.’ end.
-
.query(options) ⇒ Object
# Get all sale transactions for a subscription in CSV format response = TrustCommerce::Subscription.query( :querytype => ‘transaction’, :action => ‘sale’, :billingid => ‘ABC123’ ).
-
.update(options) ⇒ Object
# Update subscription to use new credit card response = TrustCommerce::Subscription.update( :billingid => ‘ABC123’, :cc => ‘5411111111111115’, :exp => ‘0412’ ) if response == ‘accepted’ puts ‘Subscription updated.’ else puts “An error occurred: #'error'” end.
Class Method Details
.charge(options) ⇒ Object
# Process one-time sale against existing subscription
response = TrustCommerce::Subscription.charge(
:billingid => 'ABC123',
:amount => 1995
)
133 134 135 |
# File 'lib/trustcommerce.rb', line 133 def self.charge() return TrustCommerce.send_request(.merge(:action => 'sale')) end |
.create(options) ⇒ Object
# Bill Jennifer $12.00 monthly
response = TrustCommerce::Subscription.create(
:cc => '4111111111111111',
:exp => '0412',
:name => 'Jennifer Smith',
:amount => 1200,
:cycle => '1m'
)
if response['status'] == 'approved'
puts "Subscription created with Billing ID: #{response['billingid']}"
else
puts "An error occurred: #{response['error']}"
end
94 95 96 |
# File 'lib/trustcommerce.rb', line 94 def self.create() return TrustCommerce.send_request(.merge(:action => 'store')) end |
.credit(options) ⇒ Object
# Process one-time credit against existing transaction
response = TrustCommerce::Subscription.credit(
:transid => '001-0000111101',
:amount => 1995
)
142 143 144 |
# File 'lib/trustcommerce.rb', line 142 def self.credit() return TrustCommerce.send_request(.merge(:action => 'credit')) end |
.delete(options) ⇒ Object
# Delete subscription
response = TrustCommerce::Subscription.delete(
:billingid => 'ABC123'
)
if response['status'] == 'accepted'
puts 'Subscription removed from active use.'
else
puts 'An error occurred.'
end
124 125 126 |
# File 'lib/trustcommerce.rb', line 124 def self.delete() return TrustCommerce.send_request(.merge(:action => 'unstore')) end |
.query(options) ⇒ Object
# Get all sale transactions for a subscription in CSV format
response = TrustCommerce::Subscription.query(
:querytype => 'transaction',
:action => 'sale',
:billingid => 'ABC123'
)
152 153 154 |
# File 'lib/trustcommerce.rb', line 152 def self.query() return TrustCommerce.send_query() end |
.update(options) ⇒ Object
# Update subscription to use new credit card
response = TrustCommerce::Subscription.update(
:billingid => 'ABC123',
:cc => '5411111111111115',
:exp => '0412'
)
if response['status'] == 'accepted'
puts 'Subscription updated.'
else
puts "An error occurred: #{response['error']}"
end
110 111 112 |
# File 'lib/trustcommerce.rb', line 110 def self.update() return TrustCommerce.send_request(.merge(:action => 'store')) end |