Odyssey
v3UpdTest.i
1 <?php
2 function GetReqResponse($ipayXML) {
3  libxml_use_internal_errors(true);
4  $ipayresp = simplexml_load_string($ipayXML);
5  if ($ipayresp === false) {
6  $ipaysuccess = NULL;
7  $sessionID = NULL;
8  $respcode = NULL;
9  $respmsg = 'XML parse response failed ' . __LINE__;
10 
11  // $errors = libxml_get_errors();
12  // foreach ($errors as $error) {
13  // $respmsg .= " " . $error->message;
14  // }
15  // libxml_clear_errors();
16 
17  } else {
18  $XMLsuccess = $ipayresp->xpath("MessageRequest/Session/Response/ProcessStatus/Successful");
19  // $ipaysuccess = (is_array($XMLsuccess) ? $XMLsuccess[0] : NULL);
20  $ipaysuccess = (HCU_array_key_exists(0,$XMLsuccess) ? (string) $XMLsuccess[0] : NULL);
21 
22  $XMLsessionid = $ipayresp->xpath("MessageRequest/Session/Response/Data/SessionID");
23  // $sessionID = (is_array($XMLsessionid) ? $XMLsessionid[0] : NULL);
24  $sessionID = (HCU_array_key_exists(0,$XMLsessionid) ? (string) $XMLsessionid[0] : NULL);
25 
26  $XMLcode = $ipayresp->xpath("MessageRequest/Session/Response/ProcessStatus/Error/Code");
27  // $respcode = (is_array($XMLcode) ? $XMLcode[0] : NULL);
28  $respcode = (HCU_array_key_exists(0,$XMLcode) ? (string) $XMLcode[0] : NULL);
29 
30  $XMLmsg = $ipayresp->xpath("MessageRequest/Session/Response/ProcessStatus/Error/Message");
31  // $respmsg = (is_array($XMLmsg) ? $XMLmsg[0] : 'XML xpath null query');
32  $respmsg = (HCU_array_key_exists(0,$XMLmsg) ? (string) $XMLmsg[0] : NULL);
33  }
34  return array($ipaysuccess, $sessionID, $respcode, $respmsg);
35 }
36 
37 /**
38  * @param type $ipayXML
39  * @return type
40  */
41 function GetEnrollResponse($ipayXML) {
42  libxml_use_internal_errors(true);
43  $ipayresp = simplexml_load_string($ipayXML);
44  if ($ipayresp === false) {
45  $ipaysuccess = NULL;
46  $respcode = NULL;
47  $respmsg = 'XML parse response failed ' . __LINE__;
48 
49  // $errors = libxml_get_errors();
50  // foreach ($errors as $error) {
51  // $respmsg .= " " . $error->message;
52  // }
53  // libxml_clear_errors();
54 
55  } else {
56 
57  $XMLsuccess = $ipayresp->xpath("MessageRequest/SubscriberCreate/Response/ProcessStatus/Successful");
58  // $ipaysuccess = (is_array($XMLsuccess) ? $XMLsuccess[0] : NULL);
59  $ipaysuccess = (HCU_array_key_exists(0,$XMLsuccess) ? (string) $XMLsuccess[0] : NULL);
60 
61  $XMLcode = $ipayresp->xpath("MessageRequest/SubscriberCreate/Response/ProcessStatus/Error/Code");
62  // $respcode = (is_array($XMLcode) ? $XMLcode[0] : NULL);
63  $respcode = (HCU_array_key_exists(0,$XMLcode) ? (string) $XMLcode[0] : NULL);
64 
65  $XMLmsg = $ipayresp->xpath("MessageRequest/SubscriberCreate/Response/ProcessStatus/Error/Message");
66  // $respmsg = (is_array($XMLmsg) ? $XMLmsg[0] : 'XML xpath null query');
67  $respmsg = (HCU_array_key_exists(0,$XMLmsg) ? (string) $XMLmsg[0] : NULL);
68  }
69 
70  return array($ipaysuccess, $respcode, $respmsg);
71 }
72 ?>