Module: Pay
- Defined in:
- lib/pay/braintree/webhooks/subscription_expired.rb,
lib/pay.rb,
lib/pay/env.rb,
lib/pay/engine.rb,
lib/pay/errors.rb,
lib/pay/stripe.rb,
lib/pay/adapter.rb,
lib/pay/nano_id.rb,
lib/pay/payment.rb,
lib/pay/version.rb,
lib/pay/currency.rb,
lib/pay/receipts.rb,
lib/pay/webhooks.rb,
lib/pay/braintree.rb,
lib/pay/attributes.rb,
app/models/pay/charge.rb,
lib/pay/lemon_squeezy.rb,
app/models/pay/webhook.rb,
lib/pay/fake_processor.rb,
lib/pay/paddle_billing.rb,
lib/pay/paddle_classic.rb,
app/models/pay/customer.rb,
app/models/pay/merchant.rb,
lib/pay/webhooks/delegator.rb,
app/mailers/pay/user_mailer.rb,
app/models/pay/subscription.rb,
app/jobs/pay/application_job.rb,
app/models/pay/stripe/charge.rb,
lib/pay/webhooks/process_job.rb,
app/models/pay/payment_method.rb,
app/jobs/pay/customer_sync_job.rb,
app/models/pay/stripe/customer.rb,
app/models/pay/stripe/merchant.rb,
lib/pay/billable/sync_customer.rb,
app/helpers/pay/currency_helper.rb,
app/models/concerns/pay/routing.rb,
app/models/pay/braintree/charge.rb,
app/models/pay/application_record.rb,
app/models/pay/braintree/customer.rb,
app/mailers/pay/application_mailer.rb,
app/models/pay/stripe/subscription.rb,
lib/generators/pay/views_generator.rb,
app/models/pay/lemon_squeezy/charge.rb,
app/models/pay/fake_processor/charge.rb,
app/models/pay/paddle_billing/charge.rb,
app/models/pay/paddle_classic/charge.rb,
app/models/pay/stripe/payment_method.rb,
lib/pay/lemon_squeezy/webhooks/order.rb,
app/models/pay/braintree/subscription.rb,
app/models/pay/lemon_squeezy/customer.rb,
app/models/pay/fake_processor/customer.rb,
app/models/pay/fake_processor/merchant.rb,
app/models/pay/paddle_billing/customer.rb,
app/models/pay/paddle_classic/customer.rb,
lib/pay/stripe/webhooks/payment_failed.rb,
app/controllers/pay/payments_controller.rb,
app/models/pay/braintree/payment_method.rb,
lib/pay/stripe/webhooks/account_updated.rb,
lib/pay/stripe/webhooks/charge_refunded.rb,
lib/generators/pay/email_views_generator.rb,
lib/pay/stripe/webhooks/charge_succeeded.rb,
lib/pay/stripe/webhooks/customer_deleted.rb,
lib/pay/stripe/webhooks/customer_updated.rb,
app/models/pay/lemon_squeezy/subscription.rb,
app/controllers/pay/application_controller.rb,
app/models/pay/fake_processor/subscription.rb,
app/models/pay/paddle_billing/subscription.rb,
app/models/pay/paddle_classic/subscription.rb,
app/models/pay/lemon_squeezy/payment_method.rb,
lib/pay/lemon_squeezy/webhooks/subscription.rb,
app/models/pay/fake_processor/payment_method.rb,
app/models/pay/paddle_billing/payment_method.rb,
app/models/pay/paddle_classic/payment_method.rb,
lib/pay/paddle_billing/webhooks/subscription.rb,
lib/pay/stripe/webhooks/subscription_created.rb,
lib/pay/stripe/webhooks/subscription_deleted.rb,
lib/pay/stripe/webhooks/subscription_updated.rb,
lib/pay/stripe/webhooks/subscription_renewing.rb,
app/controllers/pay/webhooks/stripe_controller.rb,
lib/pay/stripe/webhooks/payment_method_updated.rb,
lib/pay/stripe/webhooks/payment_action_required.rb,
lib/pay/stripe/webhooks/payment_method_attached.rb,
lib/pay/stripe/webhooks/payment_method_detached.rb,
lib/pay/braintree/webhooks/subscription_canceled.rb,
lib/pay/stripe/webhooks/payment_intent_succeeded.rb,
app/controllers/pay/webhooks/braintree_controller.rb,
lib/pay/paddle_classic/webhooks/signature_verifier.rb,
lib/pay/stripe/webhooks/checkout_session_completed.rb,
lib/pay/braintree/webhooks/subscription_trial_ended.rb,
lib/pay/braintree/webhooks/subscription_went_active.rb,
lib/pay/lemon_squeezy/webhooks/subscription_payment.rb,
lib/pay/stripe/webhooks/subscription_trial_will_end.rb,
lib/pay/paddle_classic/webhooks/subscription_created.rb,
lib/pay/paddle_classic/webhooks/subscription_updated.rb,
app/controllers/pay/webhooks/lemon_squeezy_controller.rb,
lib/pay/braintree/webhooks/subscription_went_past_due.rb,
lib/pay/paddle_billing/webhooks/transaction_completed.rb,
app/controllers/pay/webhooks/paddle_billing_controller.rb,
app/controllers/pay/webhooks/paddle_classic_controller.rb,
lib/pay/paddle_classic/webhooks/subscription_cancelled.rb,
lib/pay/braintree/webhooks/subscription_charged_successfully.rb,
lib/pay/paddle_classic/webhooks/subscription_payment_refunded.rb,
lib/pay/braintree/webhooks/subscription_charged_unsuccessfully.rb,
lib/pay/paddle_classic/webhooks/subscription_payment_succeeded.rb,
lib/pay/stripe/webhooks/checkout_session_async_payment_succeeded.rb
Overview
A subscription successfully moves to the next billing cycle. This will also occur when either a new transaction is created mid-cycle due to proration on an upgrade or a billing cycle is skipped due to the presence of a negative balance that covers the cost of the subscription.
Defined Under Namespace
Modules: Adapter, Attributes, Billable, Braintree, CurrencyHelper, Env, FakeProcessor, Generators, LemonSqueezy, NanoId, PaddleBilling, PaddleClassic, Receipts, Routing, Stripe, Webhooks
Classes: ActionRequired, ApplicationController, ApplicationJob, ApplicationMailer, ApplicationRecord, Charge, Currency, Customer, CustomerSyncJob, Engine, Error, InvalidPaymentMethod, Merchant, Payment, PaymentError, PaymentMethod, PaymentsController, Subscription, UserMailer, Webhook
Constant Summary
collapse
- VERSION =
"8.2.0"
- @@model_parent_class =
"ApplicationRecord"
- @@automount_routes =
true
- @@default_product_name =
"default"
- @@default_plan_name =
"default"
- @@routes_path =
"/pay"
- @@enabled_processors =
[:stripe, :braintree, :paddle_billing, :paddle_classic, :lemon_squeezy]
- @@send_emails =
true
- @@emails =
ActiveSupport::OrderedOptions.new
- @@mailer =
"Pay::UserMailer"
- @@parent_mailer =
"Pay::ApplicationMailer"
- @@mail_arguments =
-> {
{
to: instance_exec(&Pay.mail_to),
subject: default_i18n_subject(application: Pay.application_name)
}
}
- @@mail_to =
-> {
if ::ActionMailer::Base.respond_to?(:email_address_with_name)
::ActionMailer::Base.email_address_with_name(params[:pay_customer].email, params[:pay_customer].customer_name)
else
::Mail::Address.new.tap do |builder|
builder.address = params[:pay_customer].email
builder.display_name = params[:pay_customer].customer_name.presence
end.to_s
end
}
Class Method Summary
collapse
Class Method Details
.mailer ⇒ Object
85
86
87
|
# File 'lib/pay.rb', line 85
def self.mailer
@@mailer_ref ||= @@mailer&.constantize
end
|
.mailer=(value) ⇒ Object
80
81
82
83
|
# File 'lib/pay.rb', line 80
def self.mailer=(value)
@@mailer = value
@@mailer_ref = nil
end
|
.resolve_option(option, *remaining_args) ⇒ Object
127
128
129
130
131
132
133
|
# File 'lib/pay.rb', line 127
def self.resolve_option(option, *remaining_args)
if option.respond_to?(:call)
option.call(*remaining_args)
else
option
end
end
|
.send_email?(email_option, *remaining_args) ⇒ Boolean
118
119
120
121
122
123
124
125
|
# File 'lib/pay.rb', line 118
def self.send_email?(email_option, *remaining_args)
if resolve_option(send_emails, *remaining_args)
email_config_option_enabled = emails.send(email_option)
resolve_option(email_config_option_enabled, *remaining_args)
else
false
end
end
|
.setup {|_self| ... } ⇒ Object
114
115
116
|
# File 'lib/pay.rb', line 114
def self.setup
yield self
end
|
.support_email=(value) ⇒ Object
43
44
45
|
# File 'lib/pay.rb', line 43
def self.support_email=(value)
@@support_email = value.is_a?(::Mail::Address) ? value : ::Mail::Address.new(value)
end
|
.sync(params) ⇒ Object
135
136
137
138
139
140
141
142
143
|
# File 'lib/pay.rb', line 135
def self.sync(params)
if (session_id = params[:stripe_checkout_session_id] || params[:session_id])
Pay::Stripe.sync_checkout_session(session_id)
elsif (transaction_id = params[:paddle_billing_transaction_id] || params[:transaction_id])
Pay::PaddleBilling.sync_transaction(transaction_id)
elsif (order_id = params[:lemon_squeezy_order_id])
Pay::LemonSqueezy.sync_order(order_id)
end
end
|