pepijn / omni_kassa

Easier Rabobank OmniKassa payments
MIT License
9 stars 7 forks source link

added status codes for pending, renamed other status codes #2

Closed koenpunt closed 11 years ago

koenpunt commented 11 years ago

Pending is self explanatory. Renamed other status codes (:user_cancellation => :cancelled, :request_timeout => :expired) to match what is in Rabobank's PHP lib:

// Translate transaction status code
protected function getTransactionStatus($sTransactionCode)
{
    if(in_array($sTransactionCode, array('00'))) // SUCCESS
    {
        return 'SUCCESS';
    }
    elseif(in_array($sTransactionCode, array('60', '90'))) // PENDING
    {
        return 'PENDING';
    }
    elseif(in_array($sTransactionCode, array('97'))) // EXPIRED
    {
        return 'EXPIRED';
    }
    elseif(in_array($sTransactionCode, array('17'))) // CANCELLED
    {
        return 'CANCELLED';
    }

    return 'FAILED';
}
pepijn commented 11 years ago

Thanks! What do you think about changing Response#successful? to also return true on :pending? I remember having some reports of people being confused of the error message while the transaction turned out successful in the end.

koenpunt commented 11 years ago

Not sure, pending isn't per definition successful.. What about a method pending? and then use it like:

if response.pending? or response.successful?
   # Do something
end
koenpunt commented 11 years ago

And also, I think there should be a different processing for pending transactions than for successful transactions. For pending transactions you'd probably want to show a message with; "your payment is being processed, you'll receive an email when the status of your transaction changes" and for successful transactions you can show a message like "your payment was successful"

pepijn commented 11 years ago

Yeah sounds sensible, I'll add another public method so the responsibility is given to the implementer. #successful? will return false on pending.

pepijn commented 11 years ago

3