Sha256: b29ebbd56cb4e152c5df5402e35f56c9ac850d80c36b6fa1c0bba51dea26132f

Contents?: true

Size: 1.26 KB

Versions: 42

Compression:

Stored size: 1.26 KB

Contents

module Paypal
  module Payment
    class Recurring::Billing < Base
      attr_optional :period, :frequency, :paid, :currency_code, :total_cycles
      attr_accessor :amount, :trial

      def initialize(attributes = {})
        @amount = if attributes[:amount].is_a?(Common::Amount)
          attributes[:amount]
        else
          Common::Amount.new(
            :total => attributes[:amount],
            :tax => attributes[:tax_amount],
            :shipping => attributes[:shipping_amount]
          )
        end
        @trial = Recurring::Billing.new(attributes[:trial]) if attributes[:trial].present?
        super
      end

      def to_params
        trial_params = (trial.try(:to_params) || {}).inject({}) do |trial_params, (key, value)|
          trial_params.merge(
            :"TRIAL#{key}" => value
          )
        end
        trial_params.merge(
          :BILLINGPERIOD => self.period,
          :BILLINGFREQUENCY => self.frequency,
          :TOTALBILLINGCYCLES => self.total_cycles,
          :AMT => Util.formatted_amount(self.amount.total),
          :CURRENCYCODE => self.currency_code,
          :SHIPPINGAMT => Util.formatted_amount(self.amount.shipping),
          :TAXAMT => Util.formatted_amount(self.amount.tax)
        )
      end
    end
  end
end

Version data entries

42 entries across 42 versions & 4 rubygems

Version Path
ianfleeton-paypal-express-1.1.0 lib/paypal/payment/recurring/billing.rb
ianfleeton-paypal-express-1.0.0 lib/paypal/payment/recurring/billing.rb
ianfleeton-paypal-express-0.8.7 lib/paypal/payment/recurring/billing.rb
ianfleeton-paypal-express-0.8.6 lib/paypal/payment/recurring/billing.rb
ianfleeton-paypal-express-0.8.5 lib/paypal/payment/recurring/billing.rb
ianfleeton-paypal-express-0.8.4 lib/paypal/payment/recurring/billing.rb
creative-paypal-express-1.4.1 lib/paypal/payment/recurring/billing.rb
creative-paypal-express-1.4.0 lib/paypal/payment/recurring/billing.rb
creative-paypal-express-1.3.0 lib/paypal/payment/recurring/billing.rb
ianfleeton-paypal-express-0.8.3 lib/paypal/payment/recurring/billing.rb
ianfleeton-paypal-express-0.8.2 lib/paypal/payment/recurring/billing.rb
creative-paypal-express-1.2.1 lib/paypal/payment/recurring/billing.rb
creative-paypal-express-1.2.0 lib/paypal/payment/recurring/billing.rb
creative-paypal-express-1.1.0 lib/paypal/payment/recurring/billing.rb
dfg-paypal-0.8.2 lib/paypal/payment/recurring/billing.rb
creative-paypal-express-1.0.1.dev2 lib/paypal/payment/recurring/billing.rb
creative-paypal-express-1.0.1.dev1 lib/paypal/payment/recurring/billing.rb
creative-paypal-express-1.0.0 lib/paypal/payment/recurring/billing.rb
creative-paypal-express-0.8.2.4 lib/paypal/payment/recurring/billing.rb
creative-paypal-express-0.8.2.3 lib/paypal/payment/recurring/billing.rb