Module: Payola::StatusBehavior

Extended by:
ActiveSupport::Concern
Included in:
SubscriptionsController, TransactionsController
Defined in:
app/controllers/concerns/payola/status_behavior.rb

Instance Method Summary collapse

Instance Method Details

#render_payola_status(object) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
# File 'app/controllers/concerns/payola/status_behavior.rb', line 5

def render_payola_status(object)
  head :not_found and return unless object

  errors = ([object.error.presence] + object.errors.full_messages).compact.to_sentence

  render json: {
    guid:   object.guid,
    status: object.state,
    error:  errors.presence
  }, status: errors.blank? ? 200 : 400
end