Sha256: f8746cef08c76b30b5b06048d818a5cbe059eb466333175bc831dacf30aa92eb

Contents?: true

Size: 996 Bytes

Versions: 6

Compression:

Stored size: 996 Bytes

Contents

module Pay
  module Receipts
    def filename
      "receipt-#{created_at.strftime('%Y-%m-%d')}.pdf"
    end

    # Must return a file object
    def receipt
      receipt_pdf.render
    end

    def receipt_pdf
      Receipts::Receipt.new(
        id: id,
        product: Pay.config.application_name,
        company: {
          name:    Pay.config.business_name,
          address: Pay.config.business_address,
          email:   Pay.config.support_email,
        },
        line_items: line_items
      )
    end

    def line_items
      line_items = [
        ["Date",           created_at.to_s],
        ["Account Billed", "#{owner.name} (#{owner.email})"],
        ["Product",        Pay.config.application_name],
        ["Amount",         ActionController::Base.helpers.number_to_currency(amount / 100.0)],
        ["Charged to",     charged_to],
      ]
      line_items << ["Additional Info", owner.extra_billing_info] if owner.extra_billing_info?
      line_items
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
pay-1.0.0.rc2 lib/pay/receipts.rb
pay-1.0.0.rc1 lib/pay/receipts.rb
pay-1.0.0.beta5 lib/pay/receipts.rb
pay-1.0.0.beta4 lib/pay/receipts.rb
pay-1.0.0.beta3 lib/pay/receipts.rb
pay-1.0.0.beta2 lib/pay/receipts.rb