@@ -12,6 +12,7 @@ class Intermex
1212 protected $ url ;
1313 protected $ log ;
1414 protected $ service_id ;
15+ protected $ database ;
1516 protected $ operationMap = array (
1617 'create ' => 'altaEnvioT ' ,
1718 'modify ' => 'processUpdate ' ,
@@ -22,9 +23,12 @@ class Intermex
2223 public function __construct (ContainerInterface $ container )
2324 {
2425 $ this ->container = $ container ;
25- $ this ->url ='http://187.157.136.71/SIINetAg/SIINetAg.asmx?wsdl ' ;
26- $ this ->service_id =$ this ->container ->get ('connection ' )->getServiceId ('intermex ' );
2726 $ this ->log =$ this ->container ->get ('log ' );
27+ $ connection =$ this ->container ->get ('connection ' );
28+ $ result =$ connection ->getCred ('intermex ' );
29+ $ this ->database = json_decode (base64_decode ($ result [0 ]['credentials ' ]));
30+ $ this ->url =$ this ->database ->url ;
31+ $ this ->service_id =$ result [0 ]['id ' ];
2832 }
2933
3034 /**
@@ -42,7 +46,7 @@ public function conectar()
4246 'exceptions ' => 1 ,
4347 'cache_wsdl ' => WSDL_CACHE_NONE ,)
4448 );
45- $ cred =array ('vUsuario ' =>' 308901 ' , 'vPassword ' =>' ixrue308901p ' );
49+ $ cred =array ('vUsuario ' =>$ this -> database -> username , 'vPassword ' =>$ this -> database -> password );
4650 $ actual = $ soap_client ->Conectar ($ cred );
4751 if ($ actual ->ConectarResult ) {
4852 $ this ->log ->addInfo ($ this ->service_id [0 ], 'Conectar ' , $ cred , $ actual ->ConectarResult );
@@ -123,9 +127,9 @@ public function altaEnvioT($txn=null)
123127 if ($ xmlFinal ->NewDataSet ->ENVIO ->tiExito == '1 ' ) {
124128 $ return = array ('code ' => '200 ' ,
125129 'operation ' =>'create ' ,
126- 'message ' => 'Transaction Successful. ' ,
130+ 'message ' => 'Transaction Create Successful. ' ,
127131 'notify_source ' =>$ data ['source ' ],
128- 'status ' => 'complete ' ,
132+ 'status ' => 'complete ' ,
129133 'confirmation_number ' =>
130134 $ data ['transaction ' ]->transaction_code
131135 );
@@ -248,12 +252,22 @@ public function cambiaBeneficiario($vReferencia=null,$vNuevoBeneficiario=null,$v
248252 $ extractedData [1 ],
249253 'SimpleXMLElement ' , LIBXML_NOCDATA | LIBXML_PARSEHUGE
250254 );
251- $ response = json_decode (json_encode ((array ) $ xmlFinal ), true );
255+ $ response = json_decode (json_encode ((array ) $ xmlFinal ), true );
252256 if (isset ($ response ['DocumentElement ' ]['RESP ' ])) {
253257 $ output =(object ) $ response ['DocumentElement ' ]['RESP ' ];
254258 $ arr =array ('tiExito ' =>$ output ->tiExito ,'error_msg ' =>$ output ->vMensajeError );
259+
255260 if ($ output ->tiExito =='1 ' ) {
256- $ this ->log ->addInfo ($ this ->service_id [0 ], 'cambiaBeneficiario ' , $ param , $ response_main );
261+ $ return = array ('code ' => '200 ' ,
262+ 'operation ' =>'modify ' ,
263+ 'message ' => 'Receiver Name Change Successful. ' ,
264+ 'notify_source ' =>'tb ' ,
265+ 'status ' => 'complete ' ,
266+ 'data ' => array ('receiver_first_name ' =>$ vNuevoBeneficiario ) ,
267+ 'confirmation_number ' => $ vReferencia ,
268+ );
269+ $ this ->log ->addInfo ($ this ->service_id [0 ], 'cambiaBeneficiario ' , $ param , $ response_main );
270+ return $ return ;
257271 } else {
258272 $ this ->log ->addError ($ this ->service_id [0 ], 'cambiaBeneficiario ' , $ param , $ response_main );
259273 }
@@ -262,7 +276,16 @@ public function cambiaBeneficiario($vReferencia=null,$vNuevoBeneficiario=null,$v
262276 $ arr =array ('code ' =>400 ,'msg ' =>'confirming paid remittance failed ' );
263277 $ this ->log ->addError ($ this ->service_id [0 ], 'cambiaBeneficiario ' , $ param , $ response_main );
264278 }
279+ $ return = array ('code ' => '400 ' ,
280+ 'operation ' =>'modify ' ,
281+ 'message ' => 'Receiver Name Change Failed. ' ,
282+ 'notify_source ' =>'tb ' ,
283+ 'status ' => 'failed ' ,
284+ 'data ' => '' ,
285+ 'confirmation_number ' => $ vReferencia ,
286+ );
265287
288+ return $ return ;
266289 }
267290
268291 /**
@@ -299,14 +322,33 @@ public function cambiaRemitente($vReferencia=null,$vNuevoRemitente=null,$vMotivo
299322 $ output =(object ) $ response ['DocumentElement ' ]['RESP ' ];
300323 $ arr =array ('tiExito ' =>$ output ->tiExito ,'error_msg ' =>$ output ->vMensajeError );
301324 if ($ output ->tiExito =='1 ' ) {
325+ $ return = array ('code ' => '200 ' ,
326+ 'operation ' =>'modify ' ,
327+ 'message ' => 'Sender Name Change Successful. ' ,
328+ 'notify_source ' =>'tb ' ,
329+ 'status ' => 'complete ' ,
330+ 'data ' => array ('sender_first_name ' =>$ vNuevoRemitente ) ,
331+ 'confirmation_number ' => $ vReferencia ,
332+ );
302333 $ this ->log ->addInfo ($ this ->service_id [0 ], 'cambiaRemitente ' , $ param , $ response_main );
334+ return $ return ;
303335 } else {
304336 $ this ->log ->addError ($ this ->service_id [0 ], 'cambiaRemitente ' , $ param , $ response_main );
305337 }
306338 } else {
307339 $ arr =array ('code ' =>400 ,'msg ' =>'confirming paid remittance failed ' );
308340 $ this ->log ->addError ($ this ->service_id [0 ], 'cambiaRemitente ' , $ param , $ response_main );
309341 }
342+ $ return = array ('code ' => '400 ' ,
343+ 'operation ' =>'modify ' ,
344+ 'message ' => 'Sender Name Change Failed. ' ,
345+ 'notify_source ' =>'tb ' ,
346+ 'status ' => 'failed ' ,
347+ 'data ' => '' ,
348+ 'confirmation_number ' => $ vReferencia ,
349+ );
350+
351+ return $ return ;
310352 }
311353
312354 /**
@@ -343,14 +385,33 @@ public function cambiaTelBeneficiario($vReferencia=null,$vNuevoTelefon=null,$vMo
343385 $ output =(object ) $ response ['DocumentElement ' ]['RESP ' ];
344386 $ arr =array ('tiExito ' =>$ output ->tiExito ,'error_msg ' =>$ output ->vMensajeError );
345387 if ($ output ->tiExito =='1 ' ) {
346- $ this ->log ->addInfo ($ this ->service_id [0 ], 'cambiaTelBeneficiario ' , $ param , $ response_main );
388+ $ return = array ('code ' => '200 ' ,
389+ 'operation ' =>'modify ' ,
390+ 'message ' => 'Receiver Phone Number Change Successful. ' ,
391+ 'notify_source ' =>'tb ' ,
392+ 'status ' => 'complete ' ,
393+ 'data ' => array ('receiver_phone_mobile ' =>$ vNuevoTelefon ) ,
394+ 'confirmation_number ' => $ vReferencia ,
395+ );
396+ $ this ->log ->addInfo ($ this ->service_id [0 ], 'cambiaTelBeneficiario ' , $ param , $ response_main );
397+ return $ return ;
347398 } else {
348399 $ this ->log ->addError ($ this ->service_id [0 ], 'cambiaTelBeneficiario ' , $ param , $ response_main );
349400 }
350401 } else {
351402 $ arr =array ('code ' =>400 ,'msg ' =>'confirming paid remittance failed ' );
352403 $ this ->log ->addError ($ this ->service_id [0 ], 'cambiaTelBeneficiario ' , $ param , $ response_main );
353404 }
405+ $ return = array ('code ' => '400 ' ,
406+ 'operation ' =>'modify ' ,
407+ 'message ' => 'Receiver Phone Number Change Failed. ' ,
408+ 'notify_source ' =>'tb ' ,
409+ 'status ' => 'failed ' ,
410+ 'data ' => '' ,
411+ 'confirmation_number ' => $ vReferencia ,
412+ );
413+
414+ return $ return ;
354415 }
355416
356417 /**
@@ -359,8 +420,10 @@ public function cambiaTelBeneficiario($vReferencia=null,$vNuevoTelefon=null,$vMo
359420 * @param string $vMotivoCancelacion [Reason for changing]
360421 * @return void
361422 */
362- public function anulaEnvio ($ vReferencia = null , $ vMotivoCancelacion =null )
423+ public function anulaEnvio ($ txn =null )
363424 {
425+ $ vReferencia =$ txn ['confirmation_number ' ];
426+ $ vMotivoCancelacion =$ txn ['reason ' ];
364427 $ iIdAgencia =$ this ->conectar ();
365428 $ param =array (
366429 'iIdAgencia ' =>$ iIdAgencia ,
@@ -384,7 +447,16 @@ public function anulaEnvio($vReferencia=null,$vMotivoCancelacion=null)
384447 if (isset ($ response ['DocumentElement ' ]['RESP ' ])) {
385448 $ output =(object ) $ response ['DocumentElement ' ]['RESP ' ];
386449 if ($ output ->tiExito =='1 ' ) {
450+ $ return = array ('code ' => '200 ' ,
451+ 'operation ' =>'modify ' ,
452+ 'message ' => 'Transaction Successfully Cancelled. ' ,
453+ 'notify_source ' =>'tb ' ,
454+ 'status ' => 'complete ' ,
455+ 'data ' => array ('status ' =>'canceled ' ) ,
456+ 'confirmation_number ' => $ vReferencia ,
457+ );
387458 $ this ->log ->addInfo ($ this ->service_id [0 ], 'anulaEnvio ' , $ param , $ response_main );
459+ return $ return ;
388460 } else {
389461 $ this ->log ->addError ($ this ->service_id [0 ], 'anulaEnvio ' , $ param , $ response_main );
390462 }
@@ -393,6 +465,16 @@ public function anulaEnvio($vReferencia=null,$vMotivoCancelacion=null)
393465 $ arr =array ('code ' =>400 ,'msg ' =>'Cancellation Failed ' );
394466 $ this ->log ->addError ($ this ->service_id [0 ], 'anulaEnvio ' , $ param , $ response_main );
395467 }
468+ $ return = array ('code ' => '400 ' ,
469+ 'operation ' =>'modify ' ,
470+ 'message ' => 'Transaction Cancel Failed. ' ,
471+ 'notify_source ' =>'tb ' ,
472+ 'status ' => 'failed ' ,
473+ 'data ' => '' ,
474+ 'confirmation_number ' => $ vReferencia ,
475+ );
476+
477+ return $ return ;
396478
397479 }
398480
@@ -483,23 +565,26 @@ public function process($operation, $args)
483565 * modified data
484566 *
485567 * @param Array $txn [fields must be('refNo','newData','reason for change')]
568+ *
486569 * @return void
487570 */
488571 public function processUpdate ($ txn =null )
489572 {
490573 if (isset ($ txn ['receiver_first_name ' ]))
491574 {
492- $ this ->cambiaBeneficiario ($ txn ['confirmation_number ' ],$ txn ['receiver_first_name ' ],$ txn ['reason ' ]);
575+ $ data = $ this ->cambiaBeneficiario ($ txn ['confirmation_number ' ],$ txn ['receiver_first_name ' ],$ txn ['reason ' ]);
576+ return $ data ;
493577 }
494578 if (isset ($ txn ['sender_first_name ' ]))
495579 {
496- $ this ->cambiaRemitente ($ txn ['confirmation_number ' ],$ txn ['sender_first_name ' ],$ txn ['reason ' ]);
580+ $ data = $ this ->cambiaRemitente ($ txn ['confirmation_number ' ],$ txn ['sender_first_name ' ],$ txn ['reason ' ]);
581+ return $ data ;
497582 }
498- if (isset ($ txn ['sender_phone_mobile ' ]))
583+ if (isset ($ txn ['receiver_phone_mobile ' ]))
499584 {
500- $ this ->cambiaTelBeneficiario ($ txn ['confirmation_number ' ],$ txn ['sender_phone_mobile ' ],$ txn ['reason ' ]);
585+ $ data = $ this ->cambiaTelBeneficiario ($ txn ['confirmation_number ' ],$ txn ['receiver_phone_mobile ' ],$ txn ['reason ' ]);
586+ return $ data ;
501587 }
502-
503588 }
504589
505590}
0 commit comments