Module: SubscriptionFu::Paypal

Defined in:
lib/subscription_fu/paypal.rb

Constant Summary collapse

UTC_TZ =
ActiveSupport::TimeZone.new("UTC")
CANCELED_STATE =
"Cancelled"
ACTIVE_STATE =
"Active"

Class Method Summary collapse

Class Method Details

.express_requestObject



9
10
11
12
13
14
15
# File 'lib/subscription_fu/paypal.rb', line 9

def self.express_request
  config = SubscriptionFu.config
  ::Paypal::Express::Request.new(
    :username   => config.paypal_api_user_id,
    :password   => config.paypal_api_pwd,
    :signature  => config.paypal_api_sig)
end

.recurring_details(profile_id) ⇒ Object



17
18
19
20
21
22
# File 'lib/subscription_fu/paypal.rb', line 17

def self.recurring_details(profile_id)
  res = SubscriptionFu::Paypal.express_request.subscription(profile_id)
  { :status => res.recurring.status,
    :next_billing_date => UTC_TZ.parse(res.recurring.summary.next_billing_date.to_s),
    :last_payment_date => UTC_TZ.parse(res.recurring.summary.last_payment_date.to_s) }
end