Skip to content

Commit

Permalink
DIRECTebanking: Make sure Notification implements #status and #test? …
Browse files Browse the repository at this point in the history
…correctly
  • Loading branch information
Soleone committed May 5, 2011
1 parent 6c7cf3d commit e5b90e4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,34 +12,37 @@ def initialize(data, options)
end

def complete?
true
status == 'Completed'
end

def item_id
params[:user_variable_0.to_s]
params['user_variable_0']
end

def transaction_id
params[:transaction.to_s]
params['transaction']
end

# When was this payment received by the client.
def received_at
Time.parse(params[:created.to_s])
Time.parse(params['created']) if params['created']
end

# the money amount we received in X.2 decimal.
def gross
"%.2f" % params[:amount.to_s].to_f
"%.2f" % params['amount'].to_f
end

def status
# Notifications: Please pay attention that you are only notified about successful transactions.
true # so it is always true
'Completed'
end

def currency
params[:currency_id.to_s]
params['currency_id']
end

def test?
params['sender_bank_name'] == 'Testbank'
end

# for verifying the signature of the URL parameters
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@ def setup

def test_accessors
assert @deb.complete?
assert_equal true, @deb.status
assert_equal 'Completed', @deb.status
assert_equal "19488-100576-4D6A7F5F-7FC4", @deb.transaction_id
assert_equal "123456789", @deb.item_id
assert_equal "1.00", @deb.gross
assert_equal "EUR", @deb.currency
assert_equal Time.parse("2011-02-27 17:45:23"), @deb.received_at
assert @deb.test?
end

def test_compositions
Expand Down

0 comments on commit e5b90e4

Please sign in to comment.