/vendor/plugins/active_merchant/test/remote/gateways/remote_beanstream_interac_test.rb

https://github.com/bennett/xlsuite · Ruby · 53 lines · 46 code · 7 blank · 0 comment · 0 complexity · a1ee5e2a7ea99479c24cd4d862067bed MD5 · raw file

  1. require File.dirname(__FILE__) + '/../../test_helper'
  2. class RemoteBeanstreamInteracTest < Test::Unit::TestCase
  3. def setup
  4. @gateway = BeanstreamInteracGateway.new(fixtures(:beanstream_interac))
  5. @amount = 100
  6. @options = {
  7. :order_id => generate_unique_id,
  8. :billing_address => {
  9. :name => 'xiaobo zzz',
  10. :phone => '555-555-5555',
  11. :address1 => '1234 Levesque St.',
  12. :address2 => 'Apt B',
  13. :city => 'Montreal',
  14. :state => 'QC',
  15. :country => 'CA',
  16. :zip => 'H2C1X8'
  17. },
  18. :email => 'xiaobozzz@example.com',
  19. :subtotal => 800,
  20. :shipping => 100,
  21. :tax1 => 100,
  22. :tax2 => 100,
  23. :custom => 'reference one'
  24. }
  25. end
  26. def test_successful_purchase
  27. assert response = @gateway.purchase(@amount, @options)
  28. assert_success response
  29. assert_equal "R", response.params["responseType"]
  30. assert_false response.redirect.blank?
  31. end
  32. def test_failed_confirmation
  33. assert response = @gateway.confirm("")
  34. assert_failure response
  35. end
  36. def test_invalid_login
  37. gateway = BeanstreamInteracGateway.new(
  38. :merchant_id => '',
  39. :login => '',
  40. :password => ''
  41. )
  42. assert response = gateway.purchase(@amount, @options)
  43. assert_failure response
  44. assert_equal 'Invalid merchant id (merchant_id = 0)', response.message
  45. end
  46. end