@@ -96,20 +96,21 @@ public function sendData($data)
9696 {
9797 $ merchantCode = $ this ->getMerchantCode ();
9898 $ authenticationCode = $ this ->getAuthenticationCode ();
99- $ auth = base64_encode ($ merchantCode. ": " . $ authenticationCode ); //'S61xxxxx:AuthCode123');
99+ $ auth = base64_encode ($ merchantCode . ": " . $ authenticationCode ); //'S61xxxxx:AuthCode123');
100100 unset($ data ['MerchantCode ' ], $ data ['AuthenticationCode ' ]);
101101
102102 //$postdata = $this->packageData($data);
103103 $ postdata = json_encode ($ data );
104- $ httpRequest = $ this ->httpClient ->post (
104+ $ httpResponse = $ this ->httpClient ->request (
105+ 'post ' ,
105106 $ this ->endpoint ,
106107 array (
107- 'Content-Type ' => 'application/json ' ,
108- 'Authorization ' => 'Basic ' . $ auth ,
108+ 'Content-Type ' => 'application/json ' ,
109+ 'Authorization ' => 'Basic ' . $ auth ,
109110 ),
110111 $ postdata
111112 );
112- $ httpResponse = $ httpRequest -> send ();
113+
113114 return $ this ->response = new PurchaseResponse ($ this , $ httpResponse ->getBody ());
114115 }
115116
@@ -119,18 +120,18 @@ protected function packageData($data)
119120 unset($ data ['AuthenticationCode ' ]);
120121 $ fields = "" ;
121122 foreach ($ data as $ field => $ value ) {
122- $ fields .= str_repeat (" " , 24 ). "<dco: $ field> $ value</dco: $ field> \n" ;
123+ $ fields .= str_repeat (" " , 24 ) . "<dco: $ field> $ value</dco: $ field> \n" ;
123124 }
124125 $ namespace = "http://schemas.datacontract.org/2004/07/Centricom.POLi.Services.MerchantAPI.Contracts " ;
125126 $ i_namespace = "http://www.w3.org/2001/XMLSchema-instance " ;
126127 $ dco_namespace = "http://schemas.datacontract.org/2004/07/Centricom.POLi.Services.MerchantAPI.DCO " ;
127128
128129 return '<?xml version="1.0" encoding="utf-8" ?>
129- <InitiateTransactionRequest xmlns=" '. $ namespace. '" xmlns:i=" ' . $ i_namespace. '">
130- <AuthenticationCode> ' . $ authenticationcode. '</AuthenticationCode>
131- <Transaction xmlns:dco=" '. $ dco_namespace. '"> '
132- . $ fields .
133- '</Transaction>
130+ <InitiateTransactionRequest xmlns=" ' . $ namespace . '" xmlns:i=" ' . $ i_namespace . '">
131+ <AuthenticationCode> ' . $ authenticationcode . '</AuthenticationCode>
132+ <Transaction xmlns:dco=" ' . $ dco_namespace . '"> '
133+ . $ fields .
134+ '</Transaction>
134135 </InitiateTransactionRequest> ' ;
135136 }
136137}
0 commit comments