File tree Expand file tree Collapse file tree 2 files changed +36
-6
lines changed
src/Omnipay/Paysafecard/Message
tests/Omnipay/Paysafecard/Message Expand file tree Collapse file tree 2 files changed +36
-6
lines changed Original file line number Diff line number Diff line change @@ -66,10 +66,6 @@ public function getData()
6666 'amount '
6767 );
6868
69- if ($ this ->getDispositionState () !== 'S ' ) {
70- throw new InvalidRequestException ('Transaction state must be "Disposed" ' );
71- }
72-
7369 $ document = new \DOMDocument ('1.0 ' , 'utf-8 ' );
7470 $ document ->formatOutput = false ;
7571 $ document ->createElement ('soapenv:Header ' );
@@ -118,7 +114,10 @@ public function getData()
118114 return $ document ->saveXML ();
119115 }
120116
121- protected function getDispositionState ()
117+ /**
118+ * {@inheritdoc}
119+ */
120+ public function sendData ($ data )
122121 {
123122 if (!$ this ->fetchTransaction ) {
124123 $ this ->fetchTransaction = new FetchTransactionRequest ($ this ->httpClient , $ this ->httpRequest );
@@ -134,7 +133,11 @@ protected function getDispositionState()
134133 'amount ' => $ this ->getAmount (),
135134 ))->send ();
136135
137- return $ response ->getDispositionState ();
136+ if ($ response ->getDispositionState () !== 'S ' ) {
137+ return $ response ;
138+ }
139+
140+ return parent ::sendData ($ data );
138141 }
139142
140143 /**
Original file line number Diff line number Diff line change @@ -103,4 +103,31 @@ public function testSendData()
103103 $ response = $ this ->request ->sendData ($ data );
104104 $ this ->assertSame ('Omnipay\Paysafecard\Message\CompletePurchaseResponse ' , get_class ($ response ));
105105 }
106+
107+ public function testSendInvalidData ()
108+ {
109+ $ httpResponse = $ this ->getMockHttpResponse ('FetchTransactionSuccess.txt ' );
110+
111+ $ mockPlugin = new \Guzzle \Plugin \Mock \MockPlugin ();
112+ $ mockPlugin ->addResponse ($ httpResponse );
113+
114+ $ httpClient = new HttpClient ();
115+ $ httpClient ->addSubscriber ($ mockPlugin );
116+
117+ $ request = new CompletePurchaseRequest ($ httpClient , new HttpRequest ());
118+ $ response = $ request ->initialize (array (
119+ 'username ' => 'SOAP_USERNAME ' ,
120+ 'password ' => 'oJ2rHLBVSbD5iGfT ' ,
121+ 'transactionId ' => 'TX9997888 ' ,
122+ 'SubId ' => 'shop1 ' ,
123+ 'amount ' => '1.00 ' ,
124+ 'currency ' => 'EUR '
125+ ))->send ();
126+
127+ $ this ->assertSame ('Omnipay\Paysafecard\Message\FetchTransactionResponse ' , get_class ($ response ));
128+ $ this ->assertTrue ($ response ->isSuccessful ());
129+ $ this ->assertSame (0 , $ response ->getCode ());
130+ $ this ->assertSame ('Consumed ' , $ response ->getMessage ());
131+ $ this ->assertSame ('9922921184073520;1.00 ' , $ response ->getSerialNumbers ());
132+ }
106133}
You can’t perform that action at this time.
0 commit comments