Class: PayPal::Recurring::Base
- Inherits:
-
Object
- Object
- PayPal::Recurring::Base
- Defined in:
- lib/paypal/recurring/base.rb
Instance Attribute Summary collapse
-
#amount ⇒ Object
Returns the value of attribute amount.
-
#cancel_url ⇒ Object
Returns the value of attribute cancel_url.
-
#currency ⇒ Object
Returns the value of attribute currency.
-
#description ⇒ Object
Returns the value of attribute description.
-
#email ⇒ Object
Returns the value of attribute email.
-
#failed ⇒ Object
Returns the value of attribute failed.
-
#frequency ⇒ Object
Returns the value of attribute frequency.
-
#initial_amount ⇒ Object
Returns the value of attribute initial_amount.
-
#initial_amount_action ⇒ Object
Returns the value of attribute initial_amount_action.
-
#ipn_url ⇒ Object
Returns the value of attribute ipn_url.
-
#item_amount ⇒ Object
Returns the value of attribute item_amount.
-
#item_category ⇒ Object
Returns the value of attribute item_category.
-
#item_name ⇒ Object
Returns the value of attribute item_name.
-
#item_quantity ⇒ Object
Returns the value of attribute item_quantity.
-
#locale ⇒ Object
Returns the value of attribute locale.
-
#note ⇒ Object
Returns the value of attribute note.
-
#outstanding ⇒ Object
Returns the value of attribute outstanding.
-
#payer_id ⇒ Object
Returns the value of attribute payer_id.
-
#period ⇒ Object
Returns the value of attribute period.
-
#profile_id ⇒ Object
Returns the value of attribute profile_id.
-
#reference ⇒ Object
Returns the value of attribute reference.
-
#refund_type ⇒ Object
Returns the value of attribute refund_type.
-
#return_url ⇒ Object
Returns the value of attribute return_url.
-
#start_at ⇒ Object
Returns the value of attribute start_at.
-
#token ⇒ Object
Returns the value of attribute token.
-
#transaction_id ⇒ Object
Returns the value of attribute transaction_id.
-
#trial_amount ⇒ Object
Returns the value of attribute trial_amount.
-
#trial_frequency ⇒ Object
Returns the value of attribute trial_frequency.
-
#trial_length ⇒ Object
Returns the value of attribute trial_length.
-
#trial_period ⇒ Object
Returns the value of attribute trial_period.
Instance Method Summary collapse
-
#cancel ⇒ Object
Cancel a recurring profile.
-
#checkout ⇒ Object
Request a checkout token.
-
#checkout_details ⇒ Object
Return checkout details.
-
#create_recurring_profile ⇒ Object
Create a recurring billing profile.
-
#initialize(options = {}) ⇒ Base
constructor
A new instance of Base.
-
#profile ⇒ Object
Retrieve information about existing recurring profile.
-
#reactivate ⇒ Object
Reactivate a suspended recurring profile.
-
#refund ⇒ Object
Request a refund.
-
#request ⇒ Object
Just a shortcut convenience.
-
#request_payment ⇒ Object
Request payment.
-
#suspend ⇒ Object
Suspend a recurring profile.
-
#update_recurring_profile ⇒ Object
Update a recurring billing profile.
Constructor Details
#initialize(options = {}) ⇒ Base
Returns a new instance of Base.
35 36 37 |
# File 'lib/paypal/recurring/base.rb', line 35 def initialize( = {}) .each {|name, value| send("#{name}=", value)} end |
Instance Attribute Details
#amount ⇒ Object
Returns the value of attribute amount.
4 5 6 |
# File 'lib/paypal/recurring/base.rb', line 4 def amount @amount end |
#cancel_url ⇒ Object
Returns the value of attribute cancel_url.
5 6 7 |
# File 'lib/paypal/recurring/base.rb', line 5 def cancel_url @cancel_url end |
#currency ⇒ Object
Returns the value of attribute currency.
6 7 8 |
# File 'lib/paypal/recurring/base.rb', line 6 def currency @currency end |
#description ⇒ Object
Returns the value of attribute description.
7 8 9 |
# File 'lib/paypal/recurring/base.rb', line 7 def description @description end |
#email ⇒ Object
Returns the value of attribute email.
9 10 11 |
# File 'lib/paypal/recurring/base.rb', line 9 def email @email end |
#failed ⇒ Object
Returns the value of attribute failed.
10 11 12 |
# File 'lib/paypal/recurring/base.rb', line 10 def failed @failed end |
#frequency ⇒ Object
Returns the value of attribute frequency.
11 12 13 |
# File 'lib/paypal/recurring/base.rb', line 11 def frequency @frequency end |
#initial_amount ⇒ Object
Returns the value of attribute initial_amount.
12 13 14 |
# File 'lib/paypal/recurring/base.rb', line 12 def initial_amount @initial_amount end |
#initial_amount_action ⇒ Object
Returns the value of attribute initial_amount_action.
13 14 15 |
# File 'lib/paypal/recurring/base.rb', line 13 def initial_amount_action @initial_amount_action end |
#ipn_url ⇒ Object
Returns the value of attribute ipn_url.
14 15 16 |
# File 'lib/paypal/recurring/base.rb', line 14 def ipn_url @ipn_url end |
#item_amount ⇒ Object
Returns the value of attribute item_amount.
28 29 30 |
# File 'lib/paypal/recurring/base.rb', line 28 def item_amount @item_amount end |
#item_category ⇒ Object
Returns the value of attribute item_category.
26 27 28 |
# File 'lib/paypal/recurring/base.rb', line 26 def item_category @item_category end |
#item_name ⇒ Object
Returns the value of attribute item_name.
27 28 29 |
# File 'lib/paypal/recurring/base.rb', line 27 def item_name @item_name end |
#item_quantity ⇒ Object
Returns the value of attribute item_quantity.
29 30 31 |
# File 'lib/paypal/recurring/base.rb', line 29 def item_quantity @item_quantity end |
#locale ⇒ Object
Returns the value of attribute locale.
15 16 17 |
# File 'lib/paypal/recurring/base.rb', line 15 def locale @locale end |
#note ⇒ Object
Returns the value of attribute note.
8 9 10 |
# File 'lib/paypal/recurring/base.rb', line 8 def note @note end |
#outstanding ⇒ Object
Returns the value of attribute outstanding.
16 17 18 |
# File 'lib/paypal/recurring/base.rb', line 16 def outstanding @outstanding end |
#payer_id ⇒ Object
Returns the value of attribute payer_id.
17 18 19 |
# File 'lib/paypal/recurring/base.rb', line 17 def payer_id @payer_id end |
#period ⇒ Object
Returns the value of attribute period.
18 19 20 |
# File 'lib/paypal/recurring/base.rb', line 18 def period @period end |
#profile_id ⇒ Object
Returns the value of attribute profile_id.
19 20 21 |
# File 'lib/paypal/recurring/base.rb', line 19 def profile_id @profile_id end |
#reference ⇒ Object
Returns the value of attribute reference.
20 21 22 |
# File 'lib/paypal/recurring/base.rb', line 20 def reference @reference end |
#refund_type ⇒ Object
Returns the value of attribute refund_type.
21 22 23 |
# File 'lib/paypal/recurring/base.rb', line 21 def refund_type @refund_type end |
#return_url ⇒ Object
Returns the value of attribute return_url.
22 23 24 |
# File 'lib/paypal/recurring/base.rb', line 22 def return_url @return_url end |
#start_at ⇒ Object
Returns the value of attribute start_at.
23 24 25 |
# File 'lib/paypal/recurring/base.rb', line 23 def start_at @start_at end |
#token ⇒ Object
Returns the value of attribute token.
24 25 26 |
# File 'lib/paypal/recurring/base.rb', line 24 def token @token end |
#transaction_id ⇒ Object
Returns the value of attribute transaction_id.
25 26 27 |
# File 'lib/paypal/recurring/base.rb', line 25 def transaction_id @transaction_id end |
#trial_amount ⇒ Object
Returns the value of attribute trial_amount.
33 34 35 |
# File 'lib/paypal/recurring/base.rb', line 33 def trial_amount @trial_amount end |
#trial_frequency ⇒ Object
Returns the value of attribute trial_frequency.
30 31 32 |
# File 'lib/paypal/recurring/base.rb', line 30 def trial_frequency @trial_frequency end |
#trial_length ⇒ Object
Returns the value of attribute trial_length.
31 32 33 |
# File 'lib/paypal/recurring/base.rb', line 31 def trial_length @trial_length end |
#trial_period ⇒ Object
Returns the value of attribute trial_period.
32 33 34 |
# File 'lib/paypal/recurring/base.rb', line 32 def trial_period @trial_period end |
Instance Method Details
#cancel ⇒ Object
106 107 108 |
# File 'lib/paypal/recurring/base.rb', line 106 def cancel request.run(:manage_profile, :action => :cancel, :profile_id => profile_id) end |
#checkout ⇒ Object
Request a checkout token.
ppr = PayPal::Recurring.new({
:return_url => "http://example.com/checkout/thank_you",
:cancel_url => "http://example.com/checkout/canceled",
:ipn_url => "http://example.com/paypal/ipn",
:description => "Awesome - Monthly Subscription",
:amount => "9.00",
:currency => "USD"
})
response = ppr.request_token
response.checkout_url
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/paypal/recurring/base.rb', line 59 def checkout params = collect( :locale, :amount, :return_url, :cancel_url, :currency, :description, :ipn_url, :item_category, :item_name, :item_amount, :item_quantity ).merge( :payment_action => "Authorization", :no_shipping => 1, :L_BILLINGTYPE0 => "RecurringPayments" ) request.run(:checkout, params) end |
#checkout_details ⇒ Object
115 116 117 |
# File 'lib/paypal/recurring/base.rb', line 115 def checkout_details request.run(:details, :token => token) end |
#create_recurring_profile ⇒ Object
Create a recurring billing profile.
ppr = PayPal::Recurring.new({
:amount => "9.00",
:initial_amount => "9.00",
:initial_amount_action => :cancel,
:currency => "USD",
:description => "Awesome - Monthly Subscription",
:ipn_url => "http://example.com/paypal/ipn",
:frequency => 1,
:token => "EC-05C46042TU8306821",
:period => :monthly,
:reference => "1234",
:payer_id => "WTTS5KC2T46YU",
:start_at => Time.now,
:failed => 1,
:outstanding => :next_billing,
:trial_period => :monthly,
:trial_length => 1,
:trial_frequency => 1,
:trial_amount => 0.00
})
response = ppr.create_recurring_profile
175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 |
# File 'lib/paypal/recurring/base.rb', line 175 def create_recurring_profile params = collect( :amount, :initial_amount, :initial_amount_action, :currency, :description, :payer_id, :token, :reference, :start_at, :failed, :outstanding, :ipn_url, :frequency, :period, :email, :trial_length, :trial_period, :trial_frequency, :trial_amount, :item_category, :item_name, :item_amount, :item_quantity ) request.run(:create_profile, params) end |
#profile ⇒ Object
242 243 244 |
# File 'lib/paypal/recurring/base.rb', line 242 def profile request.run(:profile, :profile_id => profile_id) end |
#reactivate ⇒ Object
96 97 98 |
# File 'lib/paypal/recurring/base.rb', line 96 def reactivate request.run(:manage_profile, :action => :reactivate, :profile_id => profile_id) end |
#refund ⇒ Object
257 258 259 260 261 262 263 264 265 266 267 268 |
# File 'lib/paypal/recurring/base.rb', line 257 def refund params = collect( :transaction_id, :reference, :refund_type, :amount, :currency, :note ) request.run(:refund, params) end |
#request ⇒ Object
Just a shortcut convenience.
41 42 43 |
# File 'lib/paypal/recurring/base.rb', line 41 def request # :nodoc: @request ||= Request.new end |
#request_payment ⇒ Object
Request payment.
# ppr = PayPal::Recurring.new({
:token => "EC-6LX60229XS426623E",
:payer_id => "WTTS5KC2T46YU",
:amount => "9.00",
:description => "Awesome - Monthly Subscription"
})
response = ppr.request_payment
response.completed? && response.approved?
130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 |
# File 'lib/paypal/recurring/base.rb', line 130 def request_payment params = collect( :amount, :return_url, :cancel_url, :ipn_url, :currency, :description, :payer_id, :token, :reference, :item_category, :item_name, :item_amount, :item_quantity ).merge(:payment_action => "Sale") request.run(:payment, params) end |
#suspend ⇒ Object
87 88 89 |
# File 'lib/paypal/recurring/base.rb', line 87 def suspend request.run(:manage_profile, :action => :suspend, :profile_id => profile_id) end |
#update_recurring_profile ⇒ Object
Update a recurring billing profile.
ppr = PayPal::Recurring.new({
:amount => "99.00",
:currency => "USD",
:description => "Awesome - Monthly Subscription",
:note => "Changed plan to Gold",
:ipn_url => "http://example.com/paypal/ipn",
:reference => "1234",
:profile_id => "I-VCEL6TRG35CU",
:start_at => Time.now,
:outstanding => :next_billing
})
response = ppr.update_recurring_profile
220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 |
# File 'lib/paypal/recurring/base.rb', line 220 def update_recurring_profile params = collect( :amount, :currency, :description, :note, :profile_id, :reference, :start_at, :outstanding, :ipn_url, :email ) request.run(:update_profile, params) end |