Module: Platformx::StripeHelpers
- Defined in:
- lib/platformx/stripe.rb
Overview
Stripe helpers module
Instance Method Summary collapse
-
#x_stripe_customer(customer_id: "") ⇒ Stripe::Customer
Get stripe customer.
-
#x_stripe_customer_card(customer_id: "", card_id: "") ⇒ Stripe::Card
Retrieve stripe card for a customer.
-
#x_stripe_customer_card_delete(customer_id: "", card_id: "") ⇒ Stripe::Card
Delete a stripe card for a customer.
-
#x_stripe_invoice(invoice: "") ⇒ Stripe::Invoice
Get specific stripe invoice.
-
#x_stripe_invoices(customer_id: "") ⇒ Array<Stripe::Invoice>
Provide all stripe invoices.
-
#x_stripe_total(amount: "", tax_percentage: "") ⇒ String
Stripe total including tax.
Instance Method Details
#x_stripe_customer(customer_id: "") ⇒ Stripe::Customer
Get stripe customer
26 27 28 29 |
# File 'lib/platformx/stripe.rb', line 26 def x_stripe_customer(customer_id: "") customer = Stripe::Customer.retrieve(customer_id) return customer end |
#x_stripe_customer_card(customer_id: "", card_id: "") ⇒ Stripe::Card
Retrieve stripe card for a customer
35 36 37 38 39 |
# File 'lib/platformx/stripe.rb', line 35 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: "") ⇒ Stripe::Card
Delete a stripe card for a customer
45 46 47 48 49 |
# File 'lib/platformx/stripe.rb', line 45 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: "") ⇒ Stripe::Invoice
Get specific stripe invoice
18 19 20 21 |
# File 'lib/platformx/stripe.rb', line 18 def x_stripe_invoice(invoice: "") invoice = Stripe::Invoice.retrieve(invoice) return invoice end |
#x_stripe_invoices(customer_id: "") ⇒ Array<Stripe::Invoice>
Provide all stripe invoices
10 11 12 13 |
# File 'lib/platformx/stripe.rb', line 10 def x_stripe_invoices(customer_id: "") invoices = Stripe::Invoice.all return invoices end |
#x_stripe_total(amount: "", tax_percentage: "") ⇒ String
Stripe total including tax
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/platformx/stripe.rb', line 55 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 |