Sha256: 6be93811c3e5eb4ff1c15a0dd0e053c8084d60df2fc836efa349366cf05bc293

Contents?: true

Size: 829 Bytes

Versions: 3

Compression:

Stored size: 829 Bytes

Contents

class StripePayout < StripeModelCallbacks::ApplicationRecord
  monetize :amount_cents, allow_nil: true

  def self.stripe_class
    Stripe::Subscription
  end

  def assign_from_stripe(object)
    assign_attributes(
      amount: Money.new(object.amount, object.currency),
      arrival_date: Time.zone.at(object.arrival_date),
      created: Time.zone.at(object.created),
      metadata: JSON.generate(object.metadata),
      stripe_method: object.method,
      stripe_type: object.type
    )

    StripeModelCallbacks::AttributesAssignerService.execute!(
      model: self, stripe_model: object,
      attributes: %w[
        automatic balance_transaction currency description destination failure_balance_transaction
        failure_code failure_message livemode source_type statement_descriptor status
      ]
    )
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
stripe_model_callbacks-0.1.2 lib/stripe_model_callbacks/models/stripe_payout.rb
stripe_model_callbacks-0.1.1 lib/stripe_model_callbacks/models/stripe_payout.rb
stripe_model_callbacks-0.1.0 lib/stripe_model_callbacks/models/stripe_payout.rb