Sha256: f0da6d8e55c960194b18f48f54630d2b48d68658e82fe21cecc49c28c35604d4

Contents?: true

Size: 1006 Bytes

Versions: 8

Compression:

Stored size: 1006 Bytes

Contents

# 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.

module Pay
  module Braintree
    module Webhooks
      class SubscriptionChargedUnsuccessfully
        def call(event)
          subscription = event.subscription
          return if subscription.nil?

          pay_subscription = Pay::Subscription.find_by_processor_and_id(:braintree, subscription.id)
          return unless pay_subscription.present?

          # pay_customer = pay_subscription.customer
          # pay_charge = Pay::Braintree::Billable.new(pay_customer).save_transaction(subscription.transactions.first)

          # if Pay.send_emails
          #  Pay::UserMailer.with(pay_customer: pay_charge.customer, charge: pay_charge).receipt.deliver_later
          # end
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
pay-4.0.0 lib/pay/braintree/webhooks/subscription_charged_unsuccessfully.rb
pay-3.0.24 lib/pay/braintree/webhooks/subscription_charged_unsuccessfully.rb
pay-3.0.23 lib/pay/braintree/webhooks/subscription_charged_unsuccessfully.rb
pay-3.0.22 lib/pay/braintree/webhooks/subscription_charged_unsuccessfully.rb
pay-3.0.21 lib/pay/braintree/webhooks/subscription_charged_unsuccessfully.rb
pay-3.0.20 lib/pay/braintree/webhooks/subscription_charged_unsuccessfully.rb
pay-3.0.19 lib/pay/braintree/webhooks/subscription_charged_unsuccessfully.rb
pay-3.0.18 lib/pay/braintree/webhooks/subscription_charged_unsuccessfully.rb