Sha256: dad2ac5472aa8b853b4017065bb11463b923cde6bcc0d0e8b2855d5c095be5b9

Contents?: true

Size: 735 Bytes

Versions: 3

Compression:

Stored size: 735 Bytes

Contents

require "paypal"

module SubscriptionFu::Paypal
  UTC_TZ = ActiveSupport::TimeZone.new("UTC")

  CANCELED_STATE = "Cancelled"
  ACTIVE_STATE = "Active"

  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

  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
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
subscription_fu-0.4.0 lib/subscription_fu/paypal.rb
subscription_fu-0.3.1 lib/subscription_fu/paypal.rb
subscription_fu-0.3.0 lib/subscription_fu/paypal.rb