app/models/subscription_fu/subscription.rb in subscription_fu-0.1.0 vs app/models/subscription_fu/subscription.rb in subscription_fu-0.2.0
- old
+ new
@@ -53,20 +53,20 @@
end
# billing time data about the subscription
def next_billing_date
- paypal_recurring_details[:next_billing_date]
+ paypal_recurring_details[:next_billing_date] if paypal?
end
def estimated_next_billing_date
p = last_billing_date
p.next_month unless p.nil?
end
def last_billing_date
- paypal_recurring_details[:last_payment_date]
+ paypal_recurring_details[:last_payment_date] if paypal?
end
def successor_start_date(new_plan_name)
new_plan = SubscriptionFu.config.available_plans[new_plan_name]
if new_plan > self.plan
@@ -101,11 +101,17 @@
transactions.create_cancellation(admin, activation_transaction, self)
end
private
+ def paypal?
+ ! paypal_profile_id.blank?
+ end
+
def paypal_recurring_details
- @paypal_recurring_details ||= (paypal_profile_id.blank? ? {} : SubscriptionFu::Paypal.paypal.recurring_details(paypal_profile_id))
+ @paypal_recurring_details ||= begin
+ SubscriptionFu::Paypal.recurring_details(paypal_profile_id)
+ end
end
def convert_paypal_status(paypal_status)
case paypal_status
when "ActiveProfile" then "complete"