Sha256: c7243881457deda6545b0537ed810ee931eecccd358d33c88148891bc36ce4d6

Contents?: true

Size: 771 Bytes

Versions: 3

Compression:

Stored size: 771 Bytes

Contents

class StripeTransfer < StripeModelCallbacks::ApplicationRecord
  monetize :amount_cents
  monetize :amount_reversed_cents

  def self.stripe_class
    Stripe::Transfer
  end

  def assign_from_stripe(object)
    assign_attributes(
      amount: Money.new(object.amount, object.currency),
      amount_reversed: Money.new(object.amount_reversed, object.currency),
      created: Time.zone.at(object.created),
      metadata: JSON.generate(object.metadata)
    )

    StripeModelCallbacks::AttributesAssignerService.execute!(
      model: self, stripe_model: object,
      attributes: %w[
        balance_transaction currency description destination destination_payment livemode reversed
        source_transaction source_type transfer_group 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_transfer.rb
stripe_model_callbacks-0.1.1 lib/stripe_model_callbacks/models/stripe_transfer.rb
stripe_model_callbacks-0.1.0 lib/stripe_model_callbacks/models/stripe_transfer.rb