heavenstudio / pag_seguro

A Ruby Client to deal with PagSeguro's API
http://heavenstudio.com.br
71 stars 38 forks source link

Add convenience method to fetch status directly... #16

Closed abitdodgy closed 10 years ago

abitdodgy commented 11 years ago

Maybe not necessary, but perhaps it's useful to have a method that fetches the notification status directly? This is useful if you want to add a text representation in the database, as opposed to the status code.

We can call things like approved?, cancelled?, and so on... but the notification.status method returns an int.

This is what I do now:

  def process
    payment = Payment.new(..., status: status(@notification.status))
    payment.save!
  end

  private

    def status(status_code)
      PagSeguro::Transaction.status_for(status_code.to_i).to_s
    end
efmiglioranza commented 11 years ago

I think it's a good idea, I faced the same issue.

kurko commented 11 years ago

Mergeable?

abitdodgy commented 10 years ago

I think this was already integrated from the looks of it. I can see notification.approved? and .cancelled? etc... although not all states are documented.