Permalink
Browse files

Fixed remote test to work with new psp polska api

  • Loading branch information...
PiotrMisiurek committed Mar 14, 2012
1 parent 024d2d6 commit 6f03977c2b34635d8483ebc29546219013ce375c
View
@@ -1,7 +1,7 @@
request_uri: "https://sandbox.psp-polska.pl/api/receiver.xml"
-key_request: "TestRequest1"
-app_id: "999999991"
-password: "TestService1"
-key_response: "TestResponse1"
+key_request: "ILbspO7YxpYz"
+app_id: "914353790"
+password: "Testpass12"
+key_response: "lWY3las8syIz"
ip: "109.205.48.206"
domain: "sandbox.psp-polska.pl"
@@ -2,6 +2,45 @@
class ActiveSupport::TestCase
+
+ def psp_polska_test_data
+ output_hash = {
+ :sale => {
+ :session_id => sale_session_id = SecureRandom.hex(10),
+ :request => {
+ :action => 'sale',
+ :amount => 100,
+ :currency => 'EUR',
+ :title => "Title #{sale_session_id}",
+ :session_id => sale_session_id,
+ :email => 'email@example.com',
+ :first_name => 'John',
+ :last_name => 'Smith',
+ :client_ip => '127.0.0.1'
+ }
+ }
+ }
+ output_hash.merge!(
+ :recurring_start => {
+ :session_id => recurring_session_id = SecureRandom.hex(10),
+ :request => output_hash[:sale][:request].merge(
+ :action => 'recurring_start',
+ :cycle => '1m',
+ :max_amount => 100,
+ :session_id => recurring_session_id
+ )
+ },
+ :preauth => {
+ :session_id => preauth_session_id = SecureRandom.hex(10),
+ :request=> output_hash[:sale][:request].merge(
+ :action => 'preauth',
+ :session_id => preauth_session_id
+ )
+ }
+ )
+ end
+
+
VALID_SALE_RESPONSE = "<?xml version='1.0' encoding='UTF-8'?>
<response>
<action>sale</action>
@@ -95,7 +134,7 @@ class ActiveSupport::TestCase
<currency>PLN</currency>
<title>Recurring 706631045</title>
<session-id>ses45011</session-id>
- </response> "
+ </response>"
VALID_CAPTURE_RESPONSE = "<?xml version='1.0' encoding='UTF-8'?>
<response>
@@ -170,7 +209,7 @@ class ActiveSupport::TestCase
VALID_STATUS_REQUEST_PARAMS = {:action => "get_status", :transaction_id => "666"}
- VALID_RECURRING_START_REQUEST_PARAMS = VALID_SALE_REQUEST_PARAMS.merge(:action => "recurring_start", :cycle => "1m")
+ VALID_RECURRING_START_REQUEST_PARAMS = VALID_SALE_REQUEST_PARAMS.merge(:action => "recurring_start", :cycle => "1m", :max_amount => 100)
VALID_RECURRING_STOP_REQUEST_PARAMS = {:action => "recurring_stop", :recurring_id => 777}
@@ -9,7 +9,7 @@ def test_sale
assert @return.valid?
assert_equal @return.action, "sale"
assert_equal @return.status, "accepted"
- assert_equal @return.redirect_url, "https://sandbox.psp-polska.pl/en/transaction/credit_card/sale/#{@return.transaction_id}"
+ assert_equal @return.redirect_url, "https://sandbox.psp-polska.pl/en/transactions/#{@return.transaction_id}"
end
def test_get_status
@@ -26,7 +26,7 @@ def test_recurring_start
assert @return.valid?
assert_equal @return.action, "recurring_start"
assert_equal @return.status, "new"
- assert_equal @return.redirect_url, "https://sandbox.psp-polska.pl/en/transaction/credit_card/recurring/#{@return.transaction_id}"
+ assert_equal @return.redirect_url, "https://sandbox.psp-polska.pl/en/recurring/#{@return.recurring_id}"
assert @return.success?
end
@@ -44,23 +44,23 @@ def test_preauth
assert @return.valid?
assert_equal @return.action, "preauth"
assert_equal @return.status, "accepted"
- assert_equal @return.redirect_url, "https://sandbox.psp-polska.pl/en/transaction/credit_card/preauth/#{@return.transaction_id}"
+ assert_equal @return.redirect_url, "https://sandbox.psp-polska.pl/en/transactions/#{@return.transaction_id}"
end
private
def sale_setup
- @request = PspPolskaRequest.new(VALID_SALE_REQUEST_PARAMS)
+ @request = PspPolskaRequest.new(psp_polska_test_data[:sale][:request])
basic_setup
end
def preauth_setup
- @request = PspPolskaRequest.new(VALID_PREAUTH_REQUEST_PARAMS)
+ @request = PspPolskaRequest.new(psp_polska_test_data[:preauth][:request])
basic_setup
end
def recurring_setup
- @request = PspPolskaRequest.new(VALID_RECURRING_START_REQUEST_PARAMS)
+ @request = PspPolskaRequest.new(psp_polska_test_data[:recurring_start][:request])
basic_setup
end

0 comments on commit 6f03977

Please sign in to comment.