Module: Platformx::StripeHelpers

Defined in:
lib/platformx/stripe.rb

Instance Method Summary collapse

Instance Method Details

#x_stripe_customer(customer_id: "") ⇒ Object



19
20
21
22
# File 'lib/platformx/stripe.rb', line 19

def x_stripe_customer(customer_id: "")
  customer = Stripe::Customer.retrieve(customer_id)
  return customer
end

#x_stripe_customer_card(customer_id: "", card_id: "") ⇒ Object



24
25
26
27
28
# File 'lib/platformx/stripe.rb', line 24

def x_stripe_customer_card(customer_id: "", card_id: "")
  customer = Stripe::Customer.retrieve(customer_id)
  card = customer.sources.retrieve(card_id)
  return card
end

#x_stripe_customer_card_delete(customer_id: "", card_id: "") ⇒ Object



30
31
32
33
34
# File 'lib/platformx/stripe.rb', line 30

def x_stripe_customer_card_delete(customer_id: "", card_id: "")
  customer = Stripe::Customer.retrieve(customer_id)
  card = customer.sources.retrieve(card_id).delete()
  return card
end

#x_stripe_invoice(invoice: "") ⇒ Object



14
15
16
17
# File 'lib/platformx/stripe.rb', line 14

def x_stripe_invoice(invoice: "")
  invoice = Stripe::Invoice.retrieve(invoice)
  return invoice
end

#x_stripe_invoices(customer_id: "") ⇒ Object



9
10
11
12
# File 'lib/platformx/stripe.rb', line 9

def x_stripe_invoices(customer_id: "")
  invoices = Stripe::Invoice.all
  return invoices
end

#x_stripe_total(amount: "", tax_percentage: "") ⇒ Object

Common functions for Stripe



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/platformx/stripe.rb', line 41

def x_stripe_total(amount: "", tax_percentage: "")
    num = 0

    if amount.is_a?(Numeric)
      num = (amount.to_f/100) 
    end

    if tax_percentage != "" && tax_percentage.is_a?(Numeric)
     num = num * (1+(tax_percentage.to_f/100))
    end
    
    #num = '%.02f' % num

    return  num.to_s(:currency)

end