Module: StripeWrapper
- Defined in:
- lib/stripe_wrapper.rb,
lib/stripe_wrapper/engine.rb,
lib/stripe_wrapper/version.rb,
app/models/stripe_wrapper/charge.rb,
app/models/stripe_wrapper/customer.rb,
app/jobs/stripe_wrapper/application_job.rb,
app/helpers/stripe_wrapper/customers_helper.rb,
lib/stripe_wrapper/main_app_route_delegator.rb,
app/models/stripe_wrapper/application_record.rb,
app/mailers/stripe_wrapper/application_mailer.rb,
app/helpers/stripe_wrapper/stripe_wrapper_helper.rb,
app/controllers/stripe_wrapper/charges_controller.rb,
app/controllers/stripe_wrapper/customers_controller.rb,
app/controllers/stripe_wrapper/application_controller.rb,
lib/generators/stripe_wrapper/install/install_generator.rb
Defined Under Namespace
Modules: CustomersHelper, MainAppRouteDelegator, StripeWrapperHelper
Classes: ApplicationController, ApplicationJob, ApplicationMailer, ApplicationRecord, Charge, ChargesController, Customer, CustomersController, Engine, InstallGenerator
Constant Summary
collapse
- VERSION =
'0.1.4'
Class Method Summary
collapse
Class Method Details
.create_charge(customer = nil, source = nil, amount = 0, currency = 'clp', metadata = {}, description = '') ⇒ Object
Source is either a customer or a token
8
9
10
11
12
13
14
15
16
17
18
19
20
|
# File 'lib/stripe_wrapper.rb', line 8
def self.create_charge(customer=nil,source=nil,amount=0,currency='clp',metadata={},description='')
Stripe::Charge.create({
amount: amount,
currency: currency,
customer: customer,
source: source, description: description,
metadata: metadata
}
)
end
|
.create_customer(token, user, description = '') ⇒ Object
22
23
24
25
26
27
28
|
# File 'lib/stripe_wrapper.rb', line 22
def self.create_customer(token,user,description='')
Stripe::Customer.create(
:description => description,
:email => user.email,
:source => token )
end
|
.get_customer(user) ⇒ Object
30
31
32
33
|
# File 'lib/stripe_wrapper.rb', line 30
def self.get_customer(user)
customer = StripeCustomer.find_by_user_id(user.id)
customer = Customer.parse(Stripe::Customer.retrieve(customer.stripe_id)) rescue nil end
|
.update_customer(user, customer_params) ⇒ Object
34
35
36
37
38
39
40
41
42
|
# File 'lib/stripe_wrapper.rb', line 34
def self.update_customer(user,customer_params)
customer = StripeCustomer.find_by_user_id(user.id)
stripe_customer = Stripe::Customer.retrieve(customer.stripe_id)
customer_params.each do |param|
stripe_customer.send("#{param[0]}=",param[1])
end
stripe_customer.save
end
|