class StripeOrder

Public Class Methods

stripe_class() click to toggle source
# File lib/stripe_model_callbacks/models/stripe_order.rb, line 10
def self.stripe_class
  Stripe::Order
end

Public Instance Methods

assign_from_stripe(object) click to toggle source
# File lib/stripe_model_callbacks/models/stripe_order.rb, line 14
def assign_from_stripe(object)
  assign_attributes(
    stripe_charge_id: object.charge,
    created: Time.zone.at(object.created),
    currency: object.currency,
    stripe_customer_id: object.customer,
    email: object.email,
    livemode: object.livemode,
    metadata: JSON.generate(object.metadata),
    selected_shipping_method: object.selected_shipping_method,
    status: object.status,
    updated: Time.zone.at(object.updated)
  )

  assign_amounts_from_stripe(object)
  assign_shipping_address_from_stripe(object)
  assign_shipping_from_stripe(object)
end

Private Instance Methods

assign_amounts_from_stripe(object) click to toggle source
# File lib/stripe_model_callbacks/models/stripe_order.rb, line 35
def assign_amounts_from_stripe(object)
  assign_attributes(
    amount: Money.new(object.amount, object.currency),
    application: object.application ? Money.new(object.application, object.currency) : nil,
    application_fee: object.application_fee
  )
end
assign_shipping_address_from_stripe(object) click to toggle source
# File lib/stripe_model_callbacks/models/stripe_order.rb, line 43
def assign_shipping_address_from_stripe(object)
  assign_attributes(
    shipping_address_city: object.shipping.address.city,
    shipping_address_country: object.shipping.address.country,
    shipping_address_line1: object.shipping.address.line1,
    shipping_address_line2: object.shipping.address.line2,
    shipping_address_postal_code: object.shipping.address.postal_code,
    shipping_address_state: object.shipping.address.state
  )
end
assign_shipping_from_stripe(object) click to toggle source
# File lib/stripe_model_callbacks/models/stripe_order.rb, line 54
def assign_shipping_from_stripe(object)
  assign_attributes(
    shipping_carrier: object.shipping.carrier,
    shipping_name: object.shipping.name,
    shipping_phone: object.shipping.phone,
    shipping_tracking_number: object.shipping.tracking_number,
    shipping_methods: object.shipping_methods
  )
end