Module: Adyen::API::PaymentService::TestHelpers
- Included in:
- Adyen::API::PaymentService
- Defined in:
- lib/adyen/api/test_helpers.rb
Overview
A collection of test helpers that create and assign stubbed response instances for a subsequent remote call.
This module extends the Adyen::API::PaymentService class and thus these methods are callable on it.
Constant Summary collapse
- AUTHORISE_RESPONSE =
SimpleSOAPClient::ENVELOPE % <<-EOXML <ns1:authoriseResponse xmlns:ns1="http://payment.services.adyen.com"> <ns1:paymentResult> <additionalData xmlns="http://payment.services.adyen.com" xsi:nil="true"/> <authCode xmlns="http://payment.services.adyen.com">1234</authCode> <dccAmount xmlns="http://payment.services.adyen.com" xsi:nil="true"/> <dccSignature xmlns="http://payment.services.adyen.com" xsi:nil="true"/> <fraudResult xmlns="http://payment.services.adyen.com" xsi:nil="true"/> <issuerUrl xmlns="http://payment.services.adyen.com" xsi:nil="true"/> <md xmlns="http://payment.services.adyen.com" xsi:nil="true"/> <paRequest xmlns="http://payment.services.adyen.com" xsi:nil="true"/> <pspReference xmlns="http://payment.services.adyen.com">9876543210987654</pspReference> <refusalReason xmlns="http://payment.services.adyen.com" xsi:nil="true"/> <resultCode xmlns="http://payment.services.adyen.com">Authorised</resultCode> </ns1:paymentResult> </ns1:authoriseResponse> EOXML
- AUTHORISATION_REFUSED_RESPONSE =
SimpleSOAPClient::ENVELOPE % <<-EOXML <ns1:authoriseResponse xmlns:ns1="http://payment.services.adyen.com"> <ns1:paymentResult> <additionalData xmlns="http://payment.services.adyen.com" xsi:nil="true"/> <authCode xmlns="http://payment.services.adyen.com">1234</authCode> <dccAmount xmlns="http://payment.services.adyen.com" xsi:nil="true"/> <dccSignature xmlns="http://payment.services.adyen.com" xsi:nil="true"/> <fraudResult xmlns="http://payment.services.adyen.com" xsi:nil="true"/> <issuerUrl xmlns="http://payment.services.adyen.com" xsi:nil="true"/> <md xmlns="http://payment.services.adyen.com" xsi:nil="true"/> <paRequest xmlns="http://payment.services.adyen.com" xsi:nil="true"/> <pspReference xmlns="http://payment.services.adyen.com">9876543210987654</pspReference> <refusalReason xmlns="http://payment.services.adyen.com">You need to actually own money.</refusalReason> <resultCode xmlns="http://payment.services.adyen.com">Refused</resultCode> </ns1:paymentResult> </ns1:authoriseResponse> EOXML
- AUTHORISATION_REQUEST_INVALID_RESPONSE =
SimpleSOAPClient::ENVELOPE % <<-EOXML <soap:Fault> <faultcode>soap:Server</faultcode> <faultstring>validation 101 Invalid card number</faultstring> </soap:Fault> EOXML
Instance Method Summary collapse
-
#invalid_stub ⇒ AuthorisationResponse
An ‘invalid request’ response instance.
-
#refused_stub ⇒ AuthorisationResponse
An authorisation refused response instance.
-
#stub_invalid! ⇒ AuthorisationResponse
Assigns a #invalid_stub, meaning the subsequent authoristaion request will be refused, because the request was invalid.
-
#stub_refused! ⇒ AuthorisationResponse
Assigns a #refused_stub, meaning the subsequent authoristaion request will be refused.
-
#stub_success! ⇒ AuthorisationResponse
Assigns a #success_stub, meaning the subsequent authoristaion request will be authorised.
-
#success_stub ⇒ AuthorisationResponse
A authorisation succeeded response instance.
Instance Method Details
#invalid_stub ⇒ AuthorisationResponse
Returns An ‘invalid request’ response instance.
69 70 71 72 73 |
# File 'lib/adyen/api/test_helpers.rb', line 69 def invalid_stub http_response = Net::HTTPOK.new('1.1', '200', 'OK') def http_response.body; AUTHORISATION_REQUEST_INVALID_RESPONSE; end PaymentService::AuthorisationResponse.new(http_response) end |
#refused_stub ⇒ AuthorisationResponse
Returns An authorisation refused response instance.
62 63 64 65 66 |
# File 'lib/adyen/api/test_helpers.rb', line 62 def refused_stub http_response = Net::HTTPOK.new('1.1', '200', 'OK') def http_response.body; AUTHORISATION_REFUSED_RESPONSE; end PaymentService::AuthorisationResponse.new(http_response) end |
#stub_invalid! ⇒ AuthorisationResponse
Assigns a #invalid_stub, meaning the subsequent authoristaion request will be refused, because the request was invalid.
93 94 95 |
# File 'lib/adyen/api/test_helpers.rb', line 93 def stub_invalid! @stubbed_response = invalid_stub end |
#stub_refused! ⇒ AuthorisationResponse
Assigns a #refused_stub, meaning the subsequent authoristaion request will be refused.
85 86 87 |
# File 'lib/adyen/api/test_helpers.rb', line 85 def stub_refused! @stubbed_response = refused_stub end |
#stub_success! ⇒ AuthorisationResponse
Assigns a #success_stub, meaning the subsequent authoristaion request will be authorised.
78 79 80 |
# File 'lib/adyen/api/test_helpers.rb', line 78 def stub_success! @stubbed_response = success_stub end |
#success_stub ⇒ AuthorisationResponse
Returns A authorisation succeeded response instance.
55 56 57 58 59 |
# File 'lib/adyen/api/test_helpers.rb', line 55 def success_stub http_response = Net::HTTPOK.new('1.1', '200', 'OK') def http_response.body; AUTHORISE_RESPONSE; end PaymentService::AuthorisationResponse.new(http_response) end |