Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Realex missing notification methods #130

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions lib/offsite_payments/integrations/realex.rb
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ def initialize(order, account, options = {})
# Realex does not send back CURRENCY param in response
# however it does echo any other param so we send it twice.
add_field 'X-CURRENCY', @currency
add_field 'X-TEST', @test.to_s
end

def form_fields
Expand Down Expand Up @@ -179,6 +180,18 @@ def acknowledge(authcode = nil)
verified?
end

def item_id
order_id
end

def transaction_id
pasref
end

def test?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not tested below?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

params['X-TEST']
end

def status
if result == '00'
'Completed'
Expand Down
13 changes: 13 additions & 0 deletions test/unit/integrations/realex/realex_notification_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ def test_accessors
assert @notification.verified?
assert @notification.complete?
assert @notification.acknowledge
assert !@notification.test?

assert_equal 'ORD453-11', @notification.item_id
assert_equal '13649024563820', @notification.transaction_id
assert_equal "Completed", @notification.status
assert_equal 50.0, @notification.gross
assert_equal "USD", @notification.currency
Expand All @@ -20,10 +24,19 @@ def test_compositions
assert_equal Money.new(5000, 'USD'), @notification.amount
end

def test_test_mode
@notification = Realex::Notification.new(http_raw_data_test_mode, :credential3 => 'shared-secret')
assert @notification.test?
end

private

def http_raw_data
"MERCHANT_ID=thestore&ACCOUNT=internet&ORDER_ID=ORD453-11&TIMESTAMP=20130814122239&AMOUNT=5000&X-CURRENCY=USD&SHA1HASH=dbd337bb359fa40312a7f7140ef72139cec7dace&RESULT=00&AUTHCODE=123420&MESSAGE=AUTHCODE=123420&PASREF=13649024563820&AVSPOSTCODERESULT=U&AVSADDRESSRESULT=U&CVNRESULT=M&BATCHID=870"
end

def http_raw_data_test_mode
"MERCHANT_ID=thestore&ACCOUNT=internet&ORDER_ID=ORD453-11&TIMESTAMP=20130814122239&AMOUNT=5000&X-CURRENCY=USD&SHA1HASH=dbd337bb359fa40312a7f7140ef72139cec7dace&RESULT=00&AUTHCODE=123420&MESSAGE=AUTHCODE=123420&PASREF=13649024563820&AVSPOSTCODERESULT=U&AVSADDRESSRESULT=U&CVNRESULT=M&BATCHID=870&X-TEST=true"
end

end