Class: Pay::Paddle::Webhooks::SubscriptionPaymentRefunded
- Inherits:
-
Object
- Object
- Pay::Paddle::Webhooks::SubscriptionPaymentRefunded
- Defined in:
- lib/pay/paddle/webhooks/subscription_payment_refunded.rb
Instance Method Summary collapse
-
#initialize(data) ⇒ SubscriptionPaymentRefunded
constructor
A new instance of SubscriptionPaymentRefunded.
- #notify_user(billable, charge) ⇒ Object
Constructor Details
#initialize(data) ⇒ SubscriptionPaymentRefunded
Returns a new instance of SubscriptionPaymentRefunded.
5 6 7 8 9 10 11 |
# File 'lib/pay/paddle/webhooks/subscription_payment_refunded.rb', line 5 def initialize(data) charge = Pay.charge_model.find_by(processor: :paddle, processor_id: data["subscription_payment_id"]) return unless charge.present? charge.update(amount_refunded: Integer(data["gross_refund"].to_f * 100)) notify_user(charge.owner, charge) end |
Instance Method Details
#notify_user(billable, charge) ⇒ Object
13 14 15 16 17 |
# File 'lib/pay/paddle/webhooks/subscription_payment_refunded.rb', line 13 def notify_user(billable, charge) if Pay.send_emails Pay::UserMailer.with(billable: billable, charge: charge).refund.deliver_later end end |