Angelleye_PayPal_Adaptive

Angell EYE PayPal Adaptive Payments Class An open source PHP library written to easily work with PayPal's API's.

Defined (1)

The class is defined in the following location(s).

/classes/lib/angelleye/paypal-php-library/includes/paypal.adaptive.class.php  
  1. class Angelleye_PayPal_Adaptive extends Angelleye_PayPal 
  2. var $DeveloperAccountEmail = ''; 
  3. var $XMLNamespace = ''; 
  4. var $ApplicationID = ''; 
  5. var $DeviceID = ''; 
  6. var $IPAddress = ''; 
  7. var $DetailLevel = ''; 
  8. var $ErrorLanguage = ''; 
  9.  
  10. /** 
  11. * Constructor 
  12. * @access public 
  13. * @param array config preferences 
  14. * @return void 
  15. */ 
  16. function __construct($DataArray) 
  17. $DataArray = apply_filters( 'angelleye_paypal_adaptive_construct_params', $DataArray ); 
  18.  
  19. parent::__construct($DataArray); 
  20.  
  21. $this->XMLNamespace = 'http://svcs.paypal.com/types/ap'; 
  22. $this->DeviceID = isset($DataArray['DeviceID']) ? $DataArray['DeviceID'] : ''; 
  23. $this->IPAddress = isset($DataArray['IPAddress']) ? $DataArray['IPAddress'] : $_SERVER['REMOTE_ADDR']; 
  24. $this->DetailLevel = isset($DataArray['DetailLevel']) ? $DataArray['DetailLevel'] : 'ReturnAll'; 
  25. $this->ErrorLanguage = isset($DataArray['ErrorLanguage']) ? $DataArray['ErrorLanguage'] : 'en_US'; 
  26. $this->APISubject = isset($DataArray['APISubject']) ? $DataArray['APISubject'] : ''; 
  27. $this->DeveloperAccountEmail = isset($DataArray['DeveloperAccountEmail']) ? $DataArray['DeveloperAccountEmail'] : ''; 
  28.  
  29. if($this -> Sandbox) 
  30. {  
  31. // Sandbox Credentials 
  32. $this -> ApplicationID = isset($DataArray['ApplicationID']) ? $DataArray['ApplicationID'] : ''; 
  33. $this -> APIUsername = isset($DataArray['APIUsername']) && $DataArray['APIUsername'] != '' ? $DataArray['APIUsername'] : ''; 
  34. $this -> APIPassword = isset($DataArray['APIPassword']) && $DataArray['APIPassword'] != '' ? $DataArray['APIPassword'] : ''; 
  35. $this -> APISignature = isset($DataArray['APISignature']) && $DataArray['APISignature'] != '' ? $DataArray['APISignature'] : ''; 
  36. $this -> EndPointURL = isset($DataArray['EndPointURL']) && $DataArray['EndPointURL'] != '' ? $DataArray['EndPointURL'] : 'https://svcs.sandbox.paypal.com/'; 
  37. elseif($this -> BetaSandbox) 
  38. // Beta Sandbox Credentials 
  39. $this -> ApplicationID = isset($DataArray['ApplicationID']) ? $DataArray['ApplicationID'] : ''; 
  40. $this -> APIUsername = isset($DataArray['APIUsername']) && $DataArray['APIUsername'] != '' ? $DataArray['APIUsername'] : ''; 
  41. $this -> APIPassword = isset($DataArray['APIPassword']) && $DataArray['APIPassword'] != '' ? $DataArray['APIPassword'] : ''; 
  42. $this -> APISignature = isset($DataArray['APISignature']) && $DataArray['APISignature'] != '' ? $DataArray['APISignature'] : ''; 
  43. $this -> EndPointURL = isset($DataArray['EndPointURL']) && $DataArray['EndPointURL'] != '' ? $DataArray['EndPointURL'] : 'https://svcs.beta-sandbox.paypal.com/'; 
  44. else 
  45. // Live Credentials 
  46. $this -> ApplicationID = isset($DataArray['ApplicationID']) ? $DataArray['ApplicationID'] : ''; 
  47. $this -> APIUsername = isset($DataArray['APIUsername']) && $DataArray['APIUsername'] != '' ? $DataArray['APIUsername'] : ''; 
  48. $this -> APIPassword = isset($DataArray['APIPassword']) && $DataArray['APIPassword'] != '' ? $DataArray['APIPassword'] : ''; 
  49. $this -> APISignature = isset($DataArray['APISignature']) && $DataArray['APISignature'] != '' ? $DataArray['APISignature'] : ''; 
  50. $this -> EndPointURL = isset($DataArray['EndPointURL']) && $DataArray['EndPointURL'] != '' ? $DataArray['EndPointURL'] : 'https://svcs.paypal.com/'; 
  51.  
  52. /** 
  53. * Build all HTTP headers required for the API call. 
  54. * @access public 
  55. * @param boolean $PrintHeaders - Whether to print headers on screen or not (true/false) 
  56. * @return array $headers 
  57. */ 
  58. function BuildHeaders($PrintHeaders) 
  59. $headers = array( 
  60. 'X-PAYPAL-SECURITY-USERID: ' . $this -> APIUsername,  
  61. 'X-PAYPAL-SECURITY-PASSWORD: ' . $this -> APIPassword,  
  62. 'X-PAYPAL-SECURITY-SIGNATURE: ' . $this -> APISignature,  
  63. 'X-PAYPAL-SECURITY-SUBJECT: ' . $this -> APISubject,  
  64. 'X-PAYPAL-SECURITY-VERSION: ' . $this -> APIVersion,  
  65. 'X-PAYPAL-REQUEST-DATA-FORMAT: XML',  
  66. 'X-PAYPAL-RESPONSE-DATA-FORMAT: XML',  
  67. 'X-PAYPAL-APPLICATION-ID: ' . $this -> ApplicationID,  
  68. 'X-PAYPAL-DEVICE-ID: ' . $this -> DeviceID,  
  69. 'X-PAYPAL-DEVICE-IPADDRESS: ' . $this -> IPAddress 
  70. ); 
  71.  
  72. if($this -> Sandbox) 
  73. array_push($headers, 'X-PAYPAL-SANDBOX-EMAIL-ADDRESS: '.$this->DeveloperAccountEmail); 
  74.  
  75. if($PrintHeaders) 
  76. echo '<pre />'; 
  77. print_r($headers); 
  78.  
  79. return $headers; 
  80.  
  81. /** 
  82. * Send the API request to PayPal using CURL 
  83. * @access public 
  84. * @param string $Request 
  85. * @param string $APIName 
  86. * @param string $APIOperation 
  87. * @return string 
  88. */ 
  89. function CURLRequest($Request = "", $APIName = "", $APIOperation = "") 
  90. $curl = curl_init(); 
  91. curl_setopt($curl, CURLOPT_VERBOSE, 1); 
  92. curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE); 
  93. curl_setopt($curl, CURLOPT_TIMEOUT, 30); 
  94. curl_setopt($curl, CURLOPT_URL, $this -> EndPointURL . $APIName . '/' . $APIOperation); 
  95. curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); 
  96. curl_setopt($curl, CURLOPT_POSTFIELDS, $Request); 
  97. curl_setopt($curl, CURLOPT_HTTPHEADER, $this -> BuildHeaders(false)); 
  98.  
  99. if($this -> APIMode == 'Certificate') 
  100. curl_setopt($curl, CURLOPT_SSLCERT, $this -> PathToCertKeyPEM); 
  101.  
  102. $Response = curl_exec($curl);  
  103. curl_close($curl); 
  104. return $Response; 
  105.  
  106. /** 
  107. * Get all errors returned from PayPal 
  108. * @access public 
  109. * @param string XML response from PayPal 
  110. * @return array 
  111. */ 
  112. function GetErrors($XML) 
  113. $DOM = new DOMDocument(); 
  114. $DOM -> loadXML($XML); 
  115.  
  116. $Errors = $DOM -> getElementsByTagName('error') -> length > 0 ? $DOM -> getElementsByTagName('error') : array(); 
  117. $ErrorsArray = array(); 
  118. foreach($Errors as $Error) 
  119. $Receiver = $Error -> getElementsByTagName('receiver') -> length > 0 ? $Error -> getElementsByTagName('receiver') -> item(0) -> nodeValue : ''; 
  120. $Category = $Error -> getElementsByTagName('category') -> length > 0 ? $Error -> getElementsByTagName('category') -> item(0) -> nodeValue : ''; 
  121. $Domain = $Error -> getElementsByTagName('domain') -> length > 0 ? $Error -> getElementsByTagName('domain') -> item(0) -> nodeValue : ''; 
  122. $ErrorID = $Error -> getElementsByTagName('errorId') -> length > 0 ? $Error -> getElementsByTagName('errorId') -> item(0) -> nodeValue : ''; 
  123. $ExceptionID = $Error -> getElementsByTagName('exceptionId') -> length > 0 ? $Error -> getElementsByTagName('exceptionId') -> item(0) -> nodeValue : ''; 
  124. $Message = $Error -> getElementsByTagName('message') -> length > 0 ? $Error -> getElementsByTagName('message') -> item(0) -> nodeValue : ''; 
  125. $Parameter = $Error -> getElementsByTagName('parameter') -> length > 0 ? $Error -> getElementsByTagName('parameter') -> item(0) -> nodeValue : ''; 
  126. $Severity = $Error -> getElementsByTagName('severity') -> length > 0 ? $Error -> getElementsByTagName('severity') -> item(0) -> nodeValue : ''; 
  127. $Subdomain = $Error -> getElementsByTagName('subdomain') -> length > 0 ? $Error -> getElementsByTagName('subdomain') -> item(0) -> nodeValue : ''; 
  128.  
  129. $CurrentError = array( 
  130. 'Receiver' => $Receiver,  
  131. 'Category' => $Category,  
  132. 'Domain' => $Domain,  
  133. 'ErrorID' => $ErrorID,  
  134. 'ExceptionID' => $ExceptionID,  
  135. 'Message' => $Message,  
  136. 'Parameter' => $Parameter,  
  137. 'Severity' => $Severity,  
  138. 'Subdomain' => $Subdomain 
  139. ); 
  140. array_push($ErrorsArray, $CurrentError); 
  141. return $ErrorsArray; 
  142.  
  143. /** 
  144. * Get the request envelope from the XML string 
  145. * @access public 
  146. * @return string XML request envelope 
  147. */ 
  148. function GetXMLRequestEnvelope() 
  149. $XML = '<requestEnvelope xmlns="">'; 
  150. $XML .= '<detailLevel>' . $this -> DetailLevel . '</detailLevel>'; 
  151. $XML .= '<errorLanguage>' . $this -> ErrorLanguage . '</errorLanguage>'; 
  152. $XML .= '</requestEnvelope>'; 
  153.  
  154. return $XML; 
  155. }  
  156.  
  157. /** 
  158. * Log result to a location on the disk. 
  159. * @access public 
  160. * @param string $filename  
  161. * @param string $string_data 
  162. * @return array 
  163. */ 
  164. function Logger($filename, $string_data) 
  165. {  
  166. $timestamp = strtotime('now'); 
  167. $timestamp = date('mdY_giA_', $timestamp); 
  168. $file = $_SERVER['DOCUMENT_ROOT']."/paypal/logs/".$timestamp.$filename.".xml"; 
  169. $fh = fopen($file, 'w'); 
  170. fwrite($fh, $string_data); 
  171. fclose($fh);  
  172.  
  173.  
  174. /** 
  175. * Submit Pay() API request to PayPal 
  176. * @access public 
  177. * @param array call config data 
  178. * @return array 
  179. */ 
  180. function Pay($DataArray) 
  181. {  
  182. // PayRequest Fields 
  183. $PayRequestFields = isset($DataArray['PayRequestFields']) ? $DataArray['PayRequestFields'] : array(); 
  184. $ActionType = isset($PayRequestFields['ActionType']) ? $PayRequestFields['ActionType'] : ''; 
  185. $CancelURL = isset($PayRequestFields['CancelURL']) ? $PayRequestFields['CancelURL'] : ''; 
  186. $CurrencyCode = isset($PayRequestFields['CurrencyCode']) ? $PayRequestFields['CurrencyCode'] : ''; 
  187. $FeesPayer = isset($PayRequestFields['FeesPayer']) ? $PayRequestFields['FeesPayer'] : ''; 
  188. $IPNNotificationURL = isset($PayRequestFields['IPNNotificationURL']) ? $PayRequestFields['IPNNotificationURL'] : ''; 
  189. $Memo = isset($PayRequestFields['Memo']) ? $PayRequestFields['Memo'] : ''; 
  190. $Pin = isset($PayRequestFields['Pin']) ? $PayRequestFields['Pin'] : ''; 
  191. $PreapprovalKey = isset($PayRequestFields['PreapprovalKey']) ? $PayRequestFields['PreapprovalKey'] : ''; 
  192. $ReturnURL = isset($PayRequestFields['ReturnURL']) ? $PayRequestFields['ReturnURL'] : ''; 
  193. $ReverseAllParallelPaymentsOnError = isset($PayRequestFields['ReverseAllParallelPaymentsOnError']) ? $PayRequestFields['ReverseAllParallelPaymentsOnError'] : ''; 
  194. $SenderEmail = isset($PayRequestFields['SenderEmail']) ? $PayRequestFields['SenderEmail'] : ''; 
  195. $TrackingID = isset($PayRequestFields['TrackingID']) ? $PayRequestFields['TrackingID'] : ''; 
  196.  
  197. // ClientDetails Fields 
  198. $ClientDetailsFields = isset($DataArray['ClientDetailsFields']) ? $DataArray['ClientDetailsFields'] : array(); 
  199. $CustomerID = isset($ClientDetailsFields['CustomerID']) ? $ClientDetailsFields['CustomerID'] : ''; 
  200. $CustomerType = isset($ClientDetailsFields['CustomerType']) ? $ClientDetailsFields['CustomerType'] : ''; 
  201. $GeoLocation = isset($ClientDetailsFields['GeoLocation']) ? $ClientDetailsFields['GeoLocation'] : ''; 
  202. $Model = isset($ClientDetailsFields['Model']) ? $ClientDetailsFields['Model'] : ''; 
  203. $PartnerName = isset($ClientDetailsFields['PartnerName']) ? $ClientDetailsFields['PartnerName'] : ''; 
  204.  
  205. // FundingConstraint Fields 
  206. $FundingTypes = isset($DataArray['FundingTypes']) ? $DataArray['FundingTypes'] : array(); 
  207.  
  208. // Receivers Fields 
  209. $Receivers = isset($DataArray['Receivers']) ? $DataArray['Receivers'] : array(); 
  210. $Amount = isset($Receivers['Amount']) ? $Receivers['Amount'] : ''; 
  211. $Email = isset($Receivers['Email']) ? $Receivers['Email'] : ''; 
  212. $InvoiceID = isset($Receivers['InvoiceID']) ? $Receivers['InvoiceID'] : ''; 
  213. $PaymentType = isset($Receivers['PaymentType']) ? $Receivers['PaymentType'] : ''; 
  214. $PaymentSubType = isset($Receivers['PaymentSubType']) ? $Receivers['PaymentSubType'] : ''; 
  215. $Phone = isset($Receivers['Phone']) ? $Receivers['Phone'] : ''; 
  216. $Primary = isset($Receivers['Primary']) ? strtolower($Receivers['Primary']) : ''; 
  217.  
  218. // SenderIdentifier Fields 
  219. $SenderIdentifierFields = isset($DataArray['SenderIdentifierFields']) ? $DataArray['SenderIdentifierFields'] : array(); 
  220. $UseCredentials = isset($SenderIdentifierFields['UseCredentials']) ? $SenderIdentifierFields['UseCredentials'] : ''; 
  221.  
  222. // AccountIdentifierFields Fields 
  223. $AccountIdentifierFields = isset($DataArray['AccountIdentifierFields']) ? $DataArray['AccountIdentifierFields'] : array(); 
  224. $AccountEmail = isset($AccountIdentifierFields['Email']) ? $AccountIdentifierFields['Email'] : ''; 
  225. $AccountPhone = isset($AccountIdentifierFields['Phone']) ? $AccountIdentifierFields['Phone'] : ''; 
  226.  
  227. // Generate XML Request 
  228. $XMLRequest = '<?xml version="1.0" encoding="utf-8"?>'; 
  229. $XMLRequest .= '<PayRequest xmlns="' . $this -> XMLNamespace . '">'; 
  230. $XMLRequest .= $this -> GetXMLRequestEnvelope(); 
  231. $XMLRequest .= $ActionType != '' ? '<actionType xmlns="">' . $ActionType . '</actionType>' : ''; 
  232. $XMLRequest .= $CancelURL != '' ? '<cancelUrl xmlns="">' . $CancelURL . '</cancelUrl>' : ''; 
  233.  
  234. if(count($ClientDetailsFields) > 0) 
  235. $XMLRequest .= '<clientDetails xmlns="">'; 
  236. $XMLRequest .= $this -> ApplicationID != '' ? '<applicationId xmlns="">' . $this -> ApplicationID . '</applicationId>' : ''; 
  237. $XMLRequest .= $CustomerID != '' ? '<customerId xmlns="">' . $CustomerID . '</customerId>' : ''; 
  238. $XMLRequest .= $CustomerType != '' ? '<customerType xmlns="">' . $CustomerType . '</customerType>' : ''; 
  239. $XMLRequest .= $this -> DeviceID != '' ? '<deviceId xmlns="">' . $this -> DeviceID . '</deviceId>' : ''; 
  240. $XMLRequest .= $GeoLocation != '' ? '<geoLocation xmlns="">' . $GeoLocation . '</geoLocation>' : ''; 
  241. $XMLRequest .= $this -> IPAddress != '' ? '<ipAddress xmlns="">' . $this -> IPAddress . '</ipAddress>' : ''; 
  242. $XMLRequest .= $Model != '' ? '<model xmlns="">' . $Model . '</model>' : ''; 
  243. $XMLRequest .= $PartnerName != '' ? '<partnerName xmlns="">' . $PartnerName . '</partnerName>' : ''; 
  244. $XMLRequest .= '</clientDetails>';  
  245.  
  246. $XMLRequest .= $CurrencyCode != '' ? '<currencyCode xmlns="">' . $CurrencyCode . '</currencyCode>' : ''; 
  247. $XMLRequest .= $FeesPayer != '' ? '<feesPayer xmlns="">' . $FeesPayer . '</feesPayer>' : ''; 
  248.  
  249. if(count($FundingTypes) > 0) 
  250. {  
  251. $XMLRequest .= '<fundingConstraint xmlns="">'; 
  252. $XMLRequest .= '<allowedFundingType xmlns="">'; 
  253.  
  254. foreach($FundingTypes as $FundingType) 
  255. $XMLRequest .= '<fundingTypeInfo xmlns="">'; 
  256. $XMLRequest .= '<fundingType xmlns="">' . $FundingType . '</fundingType>'; 
  257. $XMLRequest .= '</fundingTypeInfo>'; 
  258.  
  259. $XMLRequest .= '</allowedFundingType>'; 
  260. $XMLRequest .= '</fundingConstraint>'; 
  261.  
  262. $XMLRequest .= $IPNNotificationURL != '' ? '<ipnNotificationUrl xmlns="">' . $IPNNotificationURL . '</ipnNotificationUrl>' : ''; 
  263. $XMLRequest .= $Memo != '' ? '<memo xmlns="">' . $Memo . '</memo>' : ''; 
  264. $XMLRequest .= $Pin != '' ? '<pin xmlns="">' . $Pin . '</pin>' : ''; 
  265. $XMLRequest .= $PreapprovalKey != '' ? '<preapprovalKey xmlns="">' . $PreapprovalKey . '</preapprovalKey>' : ''; 
  266.  
  267. $XMLRequest .= '<receiverList xmlns="">'; 
  268.  
  269. $IsDigitalGoods = FALSE; 
  270. foreach($Receivers as $Receiver) 
  271. $IsDigitalGoods = strtoupper($Receiver['PaymentType']) == 'DIGITALGOODS' ? TRUE : FALSE; 
  272.  
  273. $XMLRequest .= '<receiver xmlns="">'; 
  274. $XMLRequest .= $Receiver['Amount'] != '' ? '<amount xmlns="">' . $Receiver['Amount'] . '</amount>' : ''; 
  275. $XMLRequest .= $Receiver['Email'] != '' ? '<email xmlns="">' . $Receiver['Email'] . '</email>' : ''; 
  276. $XMLRequest .= $Receiver['InvoiceID'] != '' ? '<invoiceId xmlns="">' . $Receiver['InvoiceID'] . '</invoiceId>' : ''; 
  277. $XMLRequest .= $Receiver['PaymentType'] != '' ? '<paymentType xmlns="">' . $Receiver['PaymentType'] . '</paymentType>' : ''; 
  278. $XMLRequest .= $Receiver['PaymentSubType'] != '' ? '<paymentSubType xmlns="">' . $Receiver['PaymentSubType'] . '</paymentSubType>' : ''; 
  279.  
  280. if($Receiver['Phone']['CountryCode'] != '') 
  281. $XMLRequest .= '<phone xmlns="">'; 
  282. $XMLRequest .= $Receiver['Phone']['CountryCode'] != '' ? '<countryCode xmlns="">' . $Receiver['Phone']['CountryCode'] . '</countryCode>' : ''; 
  283. $XMLRequest .= $Receiver['Phone']['PhoneNumber'] != '' ? '<phoneNumber xmlns="">' . $Receiver['Phone']['PhoneNumber'] . '</phoneNumber>' : ''; 
  284. $XMLRequest .= $Receiver['Phone']['Extension'] != '' ? '<extension xmlns="">' . $Receiver['Phone']['Extension'] . '</extension>' : ''; 
  285. $XMLRequest .= '</phone>'; 
  286.  
  287. $XMLRequest .= $Receiver['Primary'] != '' ? '<primary xmlns="">' . strtolower($Receiver['Primary']) . '</primary>' : ''; 
  288. $XMLRequest .= '</receiver>'; 
  289. $XMLRequest .= '</receiverList>'; 
  290.  
  291. if(count($SenderIdentifierFields) > 0) 
  292. $XMLRequest .= '<sender>'; 
  293. $XMLRequest .= '<useCredentials xmlns="">' . $SenderIdentifierFields['UseCredentials'] . '</useCredentials>'; 
  294. $XMLRequest .= '</sender>';  
  295.  
  296. if(count($AccountIdentifierFields) > 0) 
  297. $XMLRequest .= '<account xmlns="">'; 
  298. $XMLRequest .= $AccountEmail != '' ? '<email xmlns="">' . $AccountEmail . '</email>' : ''; 
  299.  
  300. if($AccountPhone != '') 
  301. $XMLRequest .= '<phone xmlns="">'; 
  302. $XMLRequest .= $AccountPhone['CountryCode'] != '' ? '<countryCode xmlns="">' . $AccountPhone['CountryCode'] . '</countryCode>' : ''; 
  303. $XMLRequest .= $AccountPhone['PhoneNumber'] != '' ? '<phoneNumber xmlns="">' . $AccountPhone['PhoneNumber'] . '</phoneNumber>' : ''; 
  304. $XMLRequest .= $AccountPhone['Extension'] != '' ? '<extension xmlns="">' . $AccountPhone['Extension'] . '</extension>' : ''; 
  305. $XMLRequest .= '</phone>'; 
  306.  
  307. $XMLRequest .= '</account>'; 
  308.  
  309. $XMLRequest .= $ReturnURL != '' ? '<returnUrl xmlns="">' . $ReturnURL . '</returnUrl>' : ''; 
  310. $XMLRequest .= $ReverseAllParallelPaymentsOnError != '' ? '<reverseAllParallelPaymentsOnError xmlns="">' . $ReverseAllParallelPaymentsOnError . '</reverseAllParallelPaymentsOnError>' : ''; 
  311. $XMLRequest .= $SenderEmail != '' ? '<senderEmail xmlns="">' . $SenderEmail . '</senderEmail>' : ''; 
  312. $XMLRequest .= $TrackingID != '' ? '<trackingId xmlns="">' . $TrackingID . '</trackingId>' : ''; 
  313. $XMLRequest .= '</PayRequest>'; 
  314.  
  315. // Call the API and load XML response into DOM 
  316. $XMLResponse = $this -> CURLRequest($XMLRequest, 'AdaptivePayments', 'Pay'); 
  317. $DOM = new DOMDocument(); 
  318. $DOM -> loadXML($XMLResponse); 
  319.  
  320. // Parse XML values 
  321. $Fault = $DOM -> getElementsByTagName('FaultMessage') -> length > 0 ? true : false; 
  322. $Errors = $this -> GetErrors($XMLResponse); 
  323. $Ack = $DOM -> getElementsByTagName('ack') -> length > 0 ? $DOM -> getElementsByTagName('ack') -> item(0) -> nodeValue : ''; 
  324. $Build = $DOM -> getElementsByTagName('build') -> length > 0 ? $DOM -> getElementsByTagName('build') -> item(0) -> nodeValue : ''; 
  325. $CorrelationID = $DOM -> getElementsByTagName('correlationId') -> length > 0 ? $DOM -> getElementsByTagName('correlationId') -> item(0) -> nodeValue : ''; 
  326. $Timestamp = $DOM -> getElementsByTagName('timestamp') -> length > 0 ? $DOM -> getElementsByTagName('timestamp') -> item(0) -> nodeValue : ''; 
  327.  
  328. $PayKey = $DOM -> getElementsByTagName('payKey') -> length > 0 ? $DOM -> getElementsByTagName('payKey') -> item(0) -> nodeValue : ''; 
  329. $PaymentExecStatus = $DOM -> getElementsByTagName('paymentExecStatus') -> length > 0 ? $DOM -> getElementsByTagName('paymentExecStatus') -> item(0) -> nodeValue : ''; 
  330.  
  331. if($this -> Sandbox) 
  332. if($IsDigitalGoods) 
  333. $RedirectURL = 'https://www.sandbox.paypal.com/webapps/adaptivepayment/flow/pay?paykey='.$PayKey; 
  334. else 
  335. $RedirectURL = 'https://www.sandbox.paypal.com/webscr?cmd=_ap-payment&paykey=' . $PayKey; 
  336. elseif($this -> BetaSandbox) 
  337. if($IsDigitalGoods) 
  338. $RedirectURL = 'https://www.beta-sandbox.paypal.com/webapps/adaptivepayment/flow/pay?paykey='.$PayKey;  
  339. else 
  340. $RedirectURL = 'https://www.beta-sandbox.paypal.com/webscr?cmd=_ap-payment&paykey=' . $PayKey; 
  341. else 
  342. if($IsDigitalGoods) 
  343. $RedirectURL = 'https://www.paypal.com/webapps/adaptivepayment/flow/pay?paykey='.$PayKey; 
  344. else 
  345. $RedirectURL = 'https://www.paypal.com/webscr?cmd=_ap-payment&paykey=' . $PayKey; 
  346.  
  347. $ResponseDataArray = array( 
  348. 'Errors' => $Errors,  
  349. 'Ack' => $Ack,  
  350. 'Build' => $Build,  
  351. 'CorrelationID' => $CorrelationID,  
  352. 'Timestamp' => $Timestamp,  
  353. 'PayKey' => $PayKey,  
  354. 'PaymentExecStatus' => $PaymentExecStatus,  
  355. 'RedirectURL' => $PayKey != '' ? $RedirectURL : '',  
  356. 'XMLRequest' => $XMLRequest,  
  357. 'XMLResponse' => $XMLResponse 
  358. ); 
  359.  
  360. return $ResponseDataArray; 
  361.  
  362. /** 
  363. * Submit PayWithOptions() API request to PayPal 
  364. * @access public 
  365. * @param array call config data 
  366. * @return array 
  367. */ 
  368. function PayWithOptions($DataArray) 
  369. // PayRequest Fields 
  370. $PayRequestFields = isset($DataArray['PayRequestFields']) ? $DataArray['PayRequestFields'] : array(); 
  371. $ActionType = 'CREATE'; 
  372. $CancelURL = isset($PayRequestFields['CancelURL']) ? $PayRequestFields['CancelURL'] : ''; 
  373. $CurrencyCode = isset($PayRequestFields['CurrencyCode']) ? $PayRequestFields['CurrencyCode'] : ''; 
  374. $FeesPayer = isset($PayRequestFields['FeesPayer']) ? $PayRequestFields['FeesPayer'] : ''; 
  375. $IPNNotificationURL = isset($PayRequestFields['IPNNotificationURL']) ? $PayRequestFields['IPNNotificationURL'] : ''; 
  376. $Memo = isset($PayRequestFields['Memo']) ? $PayRequestFields['Memo'] : ''; 
  377. $Pin = isset($PayRequestFields['Pin']) ? $PayRequestFields['Pin'] : ''; 
  378. $PreapprovalKey = isset($PayRequestFields['PreapprovalKey']) ? $PayRequestFields['PreapprovalKey'] : ''; 
  379. $ReturnURL = isset($PayRequestFields['ReturnURL']) ? $PayRequestFields['ReturnURL'] : ''; 
  380. $ReverseAllParallelPaymentsOnError = isset($PayRequestFields['ReverseAllParallelPaymentsOnError']) ? $PayRequestFields['ReverseAllParallelPaymentsOnError'] : ''; 
  381. $SenderEmail = isset($PayRequestFields['SenderEmail']) ? $PayRequestFields['SenderEmail'] : ''; 
  382. $TrackingID = isset($PayRequestFields['TrackingID']) ? $PayRequestFields['TrackingID'] : ''; 
  383.  
  384. // ClientDetails Fields 
  385. $ClientDetailsFields = isset($DataArray['ClientDetailsFields']) ? $DataArray['ClientDetailsFields'] : array(); 
  386. $CustomerID = isset($ClientDetailsFields['CustomerID']) ? $ClientDetailsFields['CustomerID'] : ''; 
  387. $CustomerType = isset($ClientDetailsFields['CustomerType']) ? $ClientDetailsFields['CustomerType'] : ''; 
  388. $GeoLocation = isset($ClientDetailsFields['GeoLocation']) ? $ClientDetailsFields['GeoLocation'] : ''; 
  389. $Model = isset($ClientDetailsFields['Model']) ? $ClientDetailsFields['Model'] : ''; 
  390. $PartnerName = isset($ClientDetailsFields['PartnerName']) ? $ClientDetailsFields['PartnerName'] : ''; 
  391.  
  392. // FundingConstraint Fields 
  393. $FundingTypes = isset($DataArray['FundingTypes']) ? $DataArray['FundingTypes'] : array(); 
  394.  
  395. // Receivers Fields 
  396. $Receivers = isset($DataArray['Receivers']) ? $DataArray['Receivers'] : array(); 
  397. $Amount = isset($Receivers['Amount']) ? $Receivers['Amount'] : ''; 
  398. $Email = isset($Receivers['Email']) ? $Receivers['Email'] : ''; 
  399. $InvoiceID = isset($Receivers['InvoiceID']) ? $Receivers['InvoiceID'] : ''; 
  400. $PaymentType = isset($Receivers['PaymentType']) ? $Receivers['PaymentType'] : ''; 
  401. $PaymentSubType = isset($Receivers['PaymentSubType']) ? $Receivers['PaymentSubType'] : ''; 
  402. $Phone = isset($Receivers['Phone']) ? $Receivers['Phone'] : ''; 
  403. $Primary = isset($Receivers['Primary']) ? strtolower($Receivers['Primary']) : ''; 
  404.  
  405. // SenderIdentifier Fields 
  406. $SenderIdentifierFields = isset($DataArray['SenderIdentifierFields']) ? $DataArray['SenderIdentifierFields'] : array(); 
  407. $UseCredentials = isset($SenderIdentifierFields['UseCredentials']) ? $SenderIdentifierFields['UseCredentials'] : ''; 
  408.  
  409. // AccountIdentifierFields Fields 
  410. $AccountIdentifierFields = isset($DataArray['AccountIdentifierFields']) ? $DataArray['AccountIdentifierFields'] : array(); 
  411. $AccountEmail = isset($AccountIdentifierFields['Email']) ? $AccountIdentifierFields['Email'] : ''; 
  412. $AccountPhone = isset($AccountIdentifierFields['Phone']) ? $AccountIdentifierFields['Phone'] : ''; 
  413.  
  414. // Generate XML Request 
  415. $XMLRequest = '<?xml version="1.0" encoding="utf-8"?>'; 
  416. $XMLRequest .= '<PayRequest xmlns="' . $this -> XMLNamespace . '">'; 
  417. $XMLRequest .= $this -> GetXMLRequestEnvelope(); 
  418. $XMLRequest .= $ActionType != '' ? '<actionType xmlns="">' . $ActionType . '</actionType>' : ''; 
  419. $XMLRequest .= $CancelURL != '' ? '<cancelUrl xmlns="">' . $CancelURL . '</cancelUrl>' : ''; 
  420.  
  421. if(count($ClientDetailsFields) > 0) 
  422. $XMLRequest .= '<clientDetails xmlns="">'; 
  423. $XMLRequest .= $this -> ApplicationID != '' ? '<applicationId xmlns="">' . $this -> ApplicationID . '</applicationId>' : ''; 
  424. $XMLRequest .= $CustomerID != '' ? '<customerId xmlns="">' . $CustomerID . '</customerId>' : ''; 
  425. $XMLRequest .= $CustomerType != '' ? '<customerType xmlns="">' . $CustomerType . '</customerType>' : ''; 
  426. $XMLRequest .= $this -> DeviceID != '' ? '<deviceId xmlns="">' . $this -> DeviceID . '</deviceId>' : ''; 
  427. $XMLRequest .= $GeoLocation != '' ? '<geoLocation xmlns="">' . $GeoLocation . '</geoLocation>' : ''; 
  428. $XMLRequest .= $this -> IPAddress != '' ? '<ipAddress xmlns="">' . $this -> IPAddress . '</ipAddress>' : ''; 
  429. $XMLRequest .= $Model != '' ? '<model xmlns="">' . $Model . '</model>' : ''; 
  430. $XMLRequest .= $PartnerName != '' ? '<partnerName xmlns="">' . $PartnerName . '</partnerName>' : ''; 
  431. $XMLRequest .= '</clientDetails>'; 
  432.  
  433. $XMLRequest .= $CurrencyCode != '' ? '<currencyCode xmlns="">' . $CurrencyCode . '</currencyCode>' : ''; 
  434. $XMLRequest .= $FeesPayer != '' ? '<feesPayer xmlns="">' . $FeesPayer . '</feesPayer>' : ''; 
  435.  
  436. if(count($FundingTypes) > 0) 
  437. $XMLRequest .= '<fundingConstraint xmlns="">'; 
  438. $XMLRequest .= '<allowedFundingType xmlns="">'; 
  439.  
  440. foreach($FundingTypes as $FundingType) 
  441. $XMLRequest .= '<fundingTypeInfo xmlns="">'; 
  442. $XMLRequest .= '<fundingType xmlns="">' . $FundingType . '</fundingType>'; 
  443. $XMLRequest .= '</fundingTypeInfo>'; 
  444.  
  445. $XMLRequest .= '</allowedFundingType>'; 
  446. $XMLRequest .= '</fundingConstraint>'; 
  447.  
  448. $XMLRequest .= $IPNNotificationURL != '' ? '<ipnNotificationUrl xmlns="">' . $IPNNotificationURL . '</ipnNotificationUrl>' : ''; 
  449. $XMLRequest .= $Memo != '' ? '<memo xmlns="">' . $Memo . '</memo>' : ''; 
  450. $XMLRequest .= $Pin != '' ? '<pin xmlns="">' . $Pin . '</pin>' : ''; 
  451. $XMLRequest .= $PreapprovalKey != '' ? '<preapprovalKey xmlns="">' . $PreapprovalKey . '</preapprovalKey>' : ''; 
  452.  
  453. $XMLRequest .= '<receiverList xmlns="">'; 
  454.  
  455. $IsDigitalGoods = FALSE; 
  456. foreach($Receivers as $Receiver) 
  457. $IsDigitalGoods = strtoupper($Receiver['PaymentType']) == 'DIGITALGOODS' ? TRUE : FALSE; 
  458.  
  459. $XMLRequest .= '<receiver xmlns="">'; 
  460. $XMLRequest .= $Receiver['Amount'] != '' ? '<amount xmlns="">' . $Receiver['Amount'] . '</amount>' : ''; 
  461. $XMLRequest .= $Receiver['Email'] != '' ? '<email xmlns="">' . $Receiver['Email'] . '</email>' : ''; 
  462. $XMLRequest .= $Receiver['InvoiceID'] != '' ? '<invoiceId xmlns="">' . $Receiver['InvoiceID'] . '</invoiceId>' : ''; 
  463. $XMLRequest .= $Receiver['PaymentType'] != '' ? '<paymentType xmlns="">' . $Receiver['PaymentType'] . '</paymentType>' : ''; 
  464. $XMLRequest .= $Receiver['PaymentSubType'] != '' ? '<paymentSubType xmlns="">' . $Receiver['PaymentSubType'] . '</paymentSubType>' : ''; 
  465.  
  466. if($Receiver['Phone']['CountryCode'] != '') 
  467. $XMLRequest .= '<phone xmlns="">'; 
  468. $XMLRequest .= $Receiver['Phone']['CountryCode'] != '' ? '<countryCode xmlns="">' . $Receiver['Phone']['CountryCode'] . '</countryCode>' : ''; 
  469. $XMLRequest .= $Receiver['Phone']['PhoneNumber'] != '' ? '<phoneNumber xmlns="">' . $Receiver['Phone']['PhoneNumber'] . '</phoneNumber>' : ''; 
  470. $XMLRequest .= $Receiver['Phone']['Extension'] != '' ? '<extension xmlns="">' . $Receiver['Phone']['Extension'] . '</extension>' : ''; 
  471. $XMLRequest .= '</phone>'; 
  472.  
  473. $XMLRequest .= $Receiver['Primary'] != '' ? '<primary xmlns="">' . strtolower($Receiver['Primary']) . '</primary>' : ''; 
  474. $XMLRequest .= '</receiver>'; 
  475. $XMLRequest .= '</receiverList>'; 
  476.  
  477. if(count($SenderIdentifierFields) > 0) 
  478. $XMLRequest .= '<sender>'; 
  479. $XMLRequest .= '<useCredentials xmlns="">' . $SenderIdentifierFields['UseCredentials'] . '</useCredentials>'; 
  480. $XMLRequest .= '</sender>'; 
  481.  
  482. if(count($AccountIdentifierFields) > 0) 
  483. $XMLRequest .= '<account xmlns="">'; 
  484. $XMLRequest .= $AccountEmail != '' ? '<email xmlns="">' . $AccountEmail . '</email>' : ''; 
  485.  
  486. if($AccountPhone != '') 
  487. $XMLRequest .= '<phone xmlns="">'; 
  488. $XMLRequest .= $AccountPhone['CountryCode'] != '' ? '<countryCode xmlns="">' . $AccountPhone['CountryCode'] . '</countryCode>' : ''; 
  489. $XMLRequest .= $AccountPhone['PhoneNumber'] != '' ? '<phoneNumber xmlns="">' . $AccountPhone['PhoneNumber'] . '</phoneNumber>' : ''; 
  490. $XMLRequest .= $AccountPhone['Extension'] != '' ? '<extension xmlns="">' . $AccountPhone['Extension'] . '</extension>' : ''; 
  491. $XMLRequest .= '</phone>'; 
  492.  
  493. $XMLRequest .= '</account>'; 
  494.  
  495. $XMLRequest .= $ReturnURL != '' ? '<returnUrl xmlns="">' . $ReturnURL . '</returnUrl>' : ''; 
  496. $XMLRequest .= $ReverseAllParallelPaymentsOnError != '' ? '<reverseAllParallelPaymentsOnError xmlns="">' . $ReverseAllParallelPaymentsOnError . '</reverseAllParallelPaymentsOnError>' : ''; 
  497. $XMLRequest .= $SenderEmail != '' ? '<senderEmail xmlns="">' . $SenderEmail . '</senderEmail>' : ''; 
  498. $XMLRequest .= $TrackingID != '' ? '<trackingId xmlns="">' . $TrackingID . '</trackingId>' : ''; 
  499. $XMLRequest .= '</PayRequest>'; 
  500.  
  501. $PayXMLRequest = $XMLRequest; 
  502.  
  503. // Call the API and load XML response into DOM 
  504. $XMLResponse = $this -> CURLRequest($XMLRequest, 'AdaptivePayments', 'Pay'); 
  505. $PayXMLResponse = $XMLResponse; 
  506.  
  507. $DOM = new DOMDocument(); 
  508. $DOM -> loadXML($XMLResponse); 
  509.  
  510. // Parse XML values 
  511. $Fault = $DOM -> getElementsByTagName('FaultMessage') -> length > 0 ? true : false; 
  512. $Errors = $this -> GetErrors($XMLResponse); 
  513. $Ack = $DOM -> getElementsByTagName('ack') -> length > 0 ? $DOM -> getElementsByTagName('ack') -> item(0) -> nodeValue : ''; 
  514. $Build = $DOM -> getElementsByTagName('build') -> length > 0 ? $DOM -> getElementsByTagName('build') -> item(0) -> nodeValue : ''; 
  515. $CorrelationID = $DOM -> getElementsByTagName('correlationId') -> length > 0 ? $DOM -> getElementsByTagName('correlationId') -> item(0) -> nodeValue : ''; 
  516. $Timestamp = $DOM -> getElementsByTagName('timestamp') -> length > 0 ? $DOM -> getElementsByTagName('timestamp') -> item(0) -> nodeValue : ''; 
  517.  
  518. $PayKey = $DOM -> getElementsByTagName('payKey') -> length > 0 ? $DOM -> getElementsByTagName('payKey') -> item(0) -> nodeValue : ''; 
  519. $PaymentExecStatus = $DOM -> getElementsByTagName('paymentExecStatus') -> length > 0 ? $DOM -> getElementsByTagName('paymentExecStatus') -> item(0) -> nodeValue : ''; 
  520.  
  521. if($this -> Sandbox) 
  522. if($IsDigitalGoods) 
  523. $RedirectURL = 'https://www.sandbox.paypal.com/webapps/adaptivepayment/flow/pay?paykey='.$PayKey; 
  524. else 
  525. $RedirectURL = 'https://www.sandbox.paypal.com/webscr?cmd=_ap-payment&paykey=' . $PayKey; 
  526. elseif($this -> BetaSandbox) 
  527. if($IsDigitalGoods) 
  528. $RedirectURL = 'https://www.beta-sandbox.paypal.com/webapps/adaptivepayment/flow/pay?paykey='.$PayKey; 
  529. else 
  530. $RedirectURL = 'https://www.beta-sandbox.paypal.com/webscr?cmd=_ap-payment&paykey=' . $PayKey; 
  531. else 
  532. if($IsDigitalGoods) 
  533. $RedirectURL = 'https://www.paypal.com/webapps/adaptivepayment/flow/pay?paykey='.$PayKey; 
  534. else 
  535. $RedirectURL = 'https://www.paypal.com/webscr?cmd=_ap-payment&paykey=' . $PayKey; 
  536.  
  537. if(!$this->APICallSuccessful($Ack)) 
  538. $ResponseDataArray = array( 
  539. 'Errors' => $Errors,  
  540. 'Ack' => $Ack,  
  541. 'Build' => $Build,  
  542. 'CorrelationID' => $CorrelationID,  
  543. 'Timestamp' => $Timestamp,  
  544. 'PayKey' => $PayKey,  
  545. 'PaymentExecStatus' => $PaymentExecStatus,  
  546. 'PayXMLRequest' => $PayXMLRequest,  
  547. 'PayXMLResponse' => $PayXMLResponse 
  548. ); 
  549.  
  550. return $ResponseDataArray; 
  551. exit(); 
  552.  
  553. // SetPaymentOptions Basic Fields 
  554. $SPOFields = isset($DataArray['SPOFields']) ? $DataArray['SPOFields'] : array(); 
  555. $ShippingAddressID = isset($SPOFields['ShippingAddressID']) ? $SPOFields['ShippingAddressID'] : ''; 
  556.  
  557. // DisplayOptions Fields 
  558. $DisplayOptions = isset($DataArray['DisplayOptions']) ? $DataArray['DisplayOptions'] : array(); 
  559. $EmailHeaderImageURL = isset($DisplayOptions['EmailHeaderImageURL']) ? $DisplayOptions['EmailHeaderImageURL'] : ''; 
  560. $EmailMarketingImageURL = isset($DisplayOptions['EmailMarketingImageURL']) ? $DisplayOptions['EmailMarketingImageURL'] : ''; 
  561. $HeaderImageURL = isset($DisplayOptions['HeaderImageURL']) ? $DisplayOptions['HeaderImageURL'] : ''; 
  562. $BusinessName = isset($DisplayOptions['BusinessName']) ? $DisplayOptions['BusinessName'] : ''; 
  563.  
  564. // InstitutionCustomer Fields 
  565. $InstitutionCustomer = isset($DataArray['InstitutionCustomer']) ? $DataArray['InstitutionCustomer'] : array(); 
  566. $CountryCode = isset($InstitutionCustomer['CountryCode']) ? $InstitutionCustomer['CountryCode'] : ''; 
  567. $DisplayName = isset($InstitutionCustomer['DisplayName']) ? $InstitutionCustomer['DisplayName'] : ''; 
  568. $InstitutionCustomerEmail = isset($InstitutionCustomer['Email']) ? $InstitutionCustomer['Email'] : ''; 
  569. $FirstName = isset($InstitutionCustomer['FirstName']) ? $InstitutionCustomer['FirstName'] : ''; 
  570. $LastName = isset($InstitutionCustomer['LastName']) ? $InstitutionCustomer['LastName'] : ''; 
  571. $InstitutionCustomerID = isset($InstitutionCustomer['InstitutionCustomerID']) ? $InstitutionCustomer['InstitutionCustomerID'] : ''; 
  572. $InstitutionID = isset($InstitutionCustomer['InstitutionID']) ? $InstitutionCustomer['InstitutionID'] : ''; 
  573.  
  574. // SenderOptions Fields 
  575. $SenderOptions = isset($DataArray['SenderOptions']) ? $DataArray['SenderOptions'] : array(); 
  576. $RequireShippingAddressSelection = isset($SenderOptions['RequireShippingAddressSelection']) ? $SenderOptions['RequireShippingAddressSelection'] : ''; 
  577. $ReferrerCode = $this->APIButtonSource; 
  578.  
  579. // ReceiverOptions Fields 
  580. $ReceiverOptionsXML = ''; 
  581. $ReceiverOptions = isset($DataArray['ReceiverOptions']) ? $DataArray['ReceiverOptions'] : array(); 
  582. foreach($ReceiverOptions as $ReceiverOption) 
  583. $Description = isset($ReceiverOption['Description']) ? $ReceiverOption['Description'] : ''; 
  584. $CustomID = isset($ReceiverOption['CustomID']) ? $ReceiverOption['CustomID'] : ''; 
  585.  
  586. // Invoice Data 
  587. $InvoiceData = isset($ReceiverOption['InvoiceData']) ? $ReceiverOption['InvoiceData'] : array(); 
  588. $TotalTax = isset($InvoiceData['TotalTax']) ? $InvoiceData['TotalTax'] : ''; 
  589. $TotalShipping = isset($InvoiceData['TotalShipping']) ? $InvoiceData['TotalShipping'] : ''; 
  590.  
  591. // InvoiceItem Fields 
  592. $InvoiceItems = isset($ReceiverOption['InvoiceItems']) ? $ReceiverOption['InvoiceItems'] : array(); 
  593.  
  594. // ReceiverIdentifer Fields 
  595. $ReceiverIdentifier = isset($ReceiverOption['ReceiverIdentifier']) ? $ReceiverOption['ReceiverIdentifier'] : array(); 
  596. $ReceiverIdentifierEmail = isset($ReceiverIdentifier['Email']) ? $ReceiverIdentifier['Email'] : ''; 
  597. $PhoneCountryCode = isset($ReceiverIdentifier['PhoneCountryCode']) ? $ReceiverIdentifier['PhoneCountryCode'] : ''; 
  598. $PhoneNumber = isset($ReceiverIdentifier['PhoneNumber']) ? $ReceiverIdentifier['PhoneNumber'] : ''; 
  599. $PhoneExtension = isset($ReceiverIdentifier['PhoneExtension']) ? $ReceiverIdentifier['PhoneExtension'] : ''; 
  600.  
  601.  
  602. $ReceiverOptionsXML .= '<receiverOptions xmlns="">'; 
  603. $ReceiverOptionsXML .= $Description != '' ? '<description xmlns="">'.$Description.'</description>' : ''; 
  604. $ReceiverOptionsXML .= $CustomID != '' ? '<customId xmlns="">'.$CustomID.'</customId>' : ''; 
  605.  
  606. if(!empty($InvoiceData)) 
  607. $ReceiverOptionsXML .= '<invoiceData xmlns="">'; 
  608. $ReceiverOptionsXML .= $TotalTax != '' ? '<totalTax xmlns="">'.$TotalTax.'</totalTax>' : ''; 
  609. $ReceiverOptionsXML .= $TotalShipping != '' ? '<totalShipping xmlns="">'.$TotalShipping.'</totalShipping>' : ''; 
  610.  
  611.  
  612. foreach($InvoiceItems as $InvoiceItem) 
  613. $ReceiverOptionsXML .= '<item xmlns="">'; 
  614. $ReceiverOptionsXML .= $InvoiceItem['Name'] != '' ? '<name xmlns="">'.$InvoiceItem['Name'].'</name>' : ''; 
  615. $ReceiverOptionsXML .= $InvoiceItem['Identifier'] != '' ? '<identifier xmlns="">'.$InvoiceItem['Identifier'].'</identifier>' : ''; 
  616. $ReceiverOptionsXML .= $InvoiceItem['Price'] != '' ? '<price xmlns="">'.$InvoiceItem['Price'].'</price>' : ''; 
  617. $ReceiverOptionsXML .= $InvoiceItem['ItemPrice'] != '' ? '<itemPrice xmlns="">'.$InvoiceItem['ItemPrice'].'</itemPrice>' : ''; 
  618. $ReceiverOptionsXML .= $InvoiceItem['ItemCount'] != '' ? '<itemCount xmlns="">'.$InvoiceItem['ItemCount'].'</itemCount>' : ''; 
  619. $ReceiverOptionsXML .= '</item>'; 
  620.  
  621. $ReceiverOptionsXML .= '</invoiceData>'; 
  622.  
  623. if(count($ReceiverIdentifier) > 0) 
  624. $ReceiverOptionsXML .= '<receiver xmlns="">'; 
  625. $ReceiverOptionsXML .= $ReceiverIdentifierEmail != '' ? '<email xmlns="">'.$ReceiverIdentifierEmail.'</email>' : ''; 
  626.  
  627. if($PhoneNumber != '') 
  628. $ReceiverOptionsXML .= '<phone xmlns="">'; 
  629. $ReceiverOptionsXML .= $PhoneCountryCode != '' ? '<countryCode xmlns="">'.$PhoneCountryCode.'</countryCode>' : ''; 
  630. $ReceiverOptionsXML .= $PhoneNumber != '' ? '<phoneNumber xmlns="">'.$PhoneNumber.'</phoneNumber>' : ''; 
  631. $ReceiverOptionsXML .= $PhoneExtension != '' ? '<extension xmlns="">'.$PhoneExtension.'</extension>' : ''; 
  632. $ReceiverOptionsXML .= '</phone>'; 
  633.  
  634. $ReceiverOptionsXML .= '</receiver>'; 
  635.  
  636. $ReceiverOptionsXML .= '</receiverOptions>'; 
  637.  
  638. // Generate XML Request 
  639. $XMLRequest = '<?xml version="1.0" encoding="utf-8"?>'; 
  640. $XMLRequest .= '<SetPaymentOptionsRequest xmlns="' . $this -> XMLNamespace . '">'; 
  641. $XMLRequest .= $this -> GetXMLRequestEnvelope(); 
  642. $XMLRequest .= $PayKey != '' ? '<payKey xmlns="">'.$PayKey.'</payKey>' : ''; 
  643. $XMLRequest .= $ShippingAddressID != '' ? '<shippingAddressId xmlns="">'.$ShippingAddressID.'</shippingAddressId>' : ''; 
  644.  
  645. if(count($InstitutionCustomer) > 0) 
  646. $XMLRequest .= '<initiatingEntity xmlns="">'; 
  647. $XMLRequest .= '<institutionCustomer xmlns="">'; 
  648. $XMLRequest .= $InstitutionID != '' ? '<institutionId xmlns="">'.$InstitutionID.'</institutionId>' : ''; 
  649. $XMLRequest .= $FirstName != '' ? '<firstName xmlns="">'.$FirstName.'</firstName>' : ''; 
  650. $XMLRequest .= $LastName != '' ? '<lastName xmlns="">'.$LastName.'</lastName>' : ''; 
  651. $XMLRequest .= $DisplayName != '' ? '<displayName xmlns="">'.$DisplayName.'</displayName>' : ''; 
  652. $XMLRequest .= $InstitutionCustomerID != '' ? '<institutionCustomerId xmlns="">'.$InstitutionCustomerID.'</institutionCustomerId>' : ''; 
  653. $XMLRequest .= $CountryCode != '' ? '<countryCode xmlns="">'.$CountryCode.'</countryCode>' : ''; 
  654. $XMLRequest .= $InstitutionCustomerEmail != '' ? '<email xmlns="">'.$InstitutionCustomerEmail.'</email>' : ''; 
  655. $XMLRequest .= '</institutionCustomer>'; 
  656. $XMLRequest .= '</initiatingEntity>';  
  657.  
  658. if(count($DisplayOptions) > 0) 
  659. $XMLRequest .= '<displayOptions xmlns="">'; 
  660. $XMLRequest .= $EmailHeaderImageURL != '' ? '<emailHeaderImageUrl xmlns="">'.$EmailHeaderImageURL.'</emailHeaderImageUrl>' : ''; 
  661. $XMLRequest .= $EmailMarketingImageURL != '' ? '<emailMarketingImageUrl xmlns="">'.$EmailMarketingImageURL.'</emailMarketingImageUrl>' : ''; 
  662. $XMLRequest .= $HeaderImageURL != '' ? '<headerImageUrl xmlns="">'.$HeaderImageURL.'</headerImageUrl>' : ''; 
  663. $XMLRequest .= $BusinessName != '' ? '<businessName xmlns="">'.$BusinessName.'</businessName>' : ''; 
  664. $XMLRequest .= '</displayOptions>';  
  665.  
  666. if(count($SenderOptions) > 0) 
  667. $XMLRequest .= '<senderOptions xmlns="">'; 
  668. $XMLRequest .= $RequireShippingAddressSelection != '' ? '<requireShippingAddressSelection xmlns="">'.$RequireShippingAddressSelection.'</requireShippingAddressSelection>' : ''; 
  669. $XMLRequest .= $ReferrerCode != '' ? '<referrerCode xmlns="">'.$ReferrerCode.'</referrerCode>' : ''; 
  670. $XMLRequest .= '</senderOptions>';  
  671.  
  672. $XMLRequest .= $ReceiverOptionsXML; 
  673. $XMLRequest .= '</SetPaymentOptionsRequest>'; 
  674. $SetPaymentOptionsXMLRequest = $XMLRequest; 
  675.  
  676. // Call the API and load XML response into DOM 
  677. $XMLResponse = $this -> CURLRequest($XMLRequest, 'AdaptivePayments', 'SetPaymentOptions'); 
  678. $SetPaymentOptionsXMLResponse = $XMLResponse; 
  679.  
  680. $DOM = new DOMDocument(); 
  681. $DOM -> loadXML($XMLResponse); 
  682.  
  683. // Parse XML values 
  684. $Fault = $DOM -> getElementsByTagName('FaultMessage') -> length > 0 ? true : false; 
  685. $Errors = $this -> GetErrors($XMLResponse); 
  686. $Ack = $DOM -> getElementsByTagName('ack') -> length > 0 ? $DOM -> getElementsByTagName('ack') -> item(0) -> nodeValue : ''; 
  687.  
  688. $ResponseDataArray = array( 
  689. 'Errors' => $Errors,  
  690. 'Ack' => $Ack,  
  691. 'Build' => $Build,  
  692. 'CorrelationID' => $CorrelationID,  
  693. 'Timestamp' => $Timestamp,  
  694. 'PayKey' => $PayKey,  
  695. 'PaymentExecStatus' => $PaymentExecStatus,  
  696. 'RedirectURL' => $PayKey != '' ? $RedirectURL : '',  
  697. 'PayXMLRequest' => $PayXMLRequest,  
  698. 'PayXMLResponse' => $PayXMLResponse,  
  699. 'SetPaymentOptionsXMLRequest' => $SetPaymentOptionsXMLRequest,  
  700. 'SetPaymentOptionsXMLResponse' => $SetPaymentOptionsXMLResponse 
  701. ); 
  702.  
  703. return $ResponseDataArray; 
  704.  
  705. /** 
  706. * Submit PaymentDetails API request to PayPal. 
  707. * @access public 
  708. * @param array call config data 
  709. * @return array 
  710. */ 
  711. function PaymentDetails($DataArray) 
  712. // PaymentDetails Fields 
  713. $PaymentDetailsFields = isset($DataArray['PaymentDetailsFields']) ? $DataArray['PaymentDetailsFields'] : array(); 
  714. $PayKey = isset($PaymentDetailsFields['PayKey']) ? $PaymentDetailsFields['PayKey'] : ''; 
  715. $TransactionID = isset($PaymentDetailsFields['TransactionID']) ? $PaymentDetailsFields['TransactionID'] : ''; 
  716. $TrackingID = isset($PaymentDetailsFields['TrackingID']) ? $PaymentDetailsFields['TrackingID'] : ''; 
  717.  
  718. // Generate XML Request 
  719. $XMLRequest = '<?xml version="1.0" encoding="utf-8"?>'; 
  720. $XMLRequest .= '<PaymentDetailsRequest xmlns="' . $this -> XMLNamespace . '">'; 
  721. $XMLRequest .= $this -> GetXMLRequestEnvelope(); 
  722. $XMLRequest .= $PayKey != '' ? '<payKey xmlns="">' . $PayKey . '</payKey>' : ''; 
  723. $XMLRequest .= $TransactionID != '' ? '<transactionId xmlns="">' . $TransactionID . '</transactionId>' : ''; 
  724. $XMLRequest .= $TrackingID != '' ? '<trackingId xmlns="">' . $TrackingID . '</trackingId>' : ''; 
  725. $XMLRequest .= '</PaymentDetailsRequest>'; 
  726.  
  727. // Call the API and load XML response into DOM 
  728. $XMLResponse = $this -> CURLRequest($XMLRequest, 'AdaptivePayments', 'PaymentDetails'); 
  729. $DOM = new DOMDocument(); 
  730. $DOM -> loadXML($XMLResponse); 
  731.  
  732. // Parse XML values 
  733. $Fault = $DOM -> getElementsByTagName('FaultMessage') -> length > 0 ? true : false; 
  734. $Errors = $this -> GetErrors($XMLResponse); 
  735. $Ack = $DOM -> getElementsByTagName('ack') -> length > 0 ? $DOM -> getElementsByTagName('ack') -> item(0) -> nodeValue : ''; 
  736. $Build = $DOM -> getElementsByTagName('build') -> length > 0 ? $DOM -> getElementsByTagName('build') -> item(0) -> nodeValue : ''; 
  737. $CorrelationID = $DOM -> getElementsByTagName('correlationId') -> length > 0 ? $DOM -> getElementsByTagName('correlationId') -> item(0) -> nodeValue : ''; 
  738. $Timestamp = $DOM -> getElementsByTagName('timestamp') -> length > 0 ? $DOM -> getElementsByTagName('timestamp') -> item(0) -> nodeValue : ''; 
  739.  
  740. $ActionType = $DOM -> getElementsByTagName('actionType') -> length > 0 ? $DOM -> getElementsByTagName('actionType') -> item(0) -> nodeValue : ''; 
  741. $CancelURL = $DOM -> getElementsByTagName('cancelUrl') -> length > 0 ? $DOM -> getElementsByTagName('cancelUrl') -> item(0) -> nodeValue : ''; 
  742. $CurrencyCode = $DOM -> getElementsByTagName('currencyCode') -> length > 0 ? $DOM -> getElementsByTagName('currencyCode') -> item(0) -> nodeValue : ''; 
  743. $FeesPayer = $DOM -> getElementsByTagName('feesPayer') -> length > 0 ? $DOM -> getElementsByTagName('feesPayer') -> item(0) -> nodeValue : ''; 
  744.  
  745. $FundingTypesDOM = $DOM -> getElementsByTagName('fundingType') -> length > 0 ? $DOM -> getElementsByTagName('fundingType') : array(); 
  746. $FundingTypes = array(); 
  747. foreach($FundingTypesDOM as $FundingType) 
  748. array_push($FundingTypes, $FundingType); 
  749.  
  750. $IPNNotificationURL = $DOM -> getElementsByTagName('ipnNotificationUrl') -> length > 0 ? $DOM -> getElementsByTagName('ipnNotificationUrl') -> item(0) -> nodeValue : ''; 
  751. $Memo = $DOM -> getElementsByTagName('memo') -> length > 0 ? $DOM -> getElementsByTagName('memo') -> item(0) -> nodeValue : ''; 
  752. $PayKey = $DOM -> getElementsByTagName('payKey') -> length > 0 ? $DOM -> getElementsByTagName('payKey') -> item(0) -> nodeValue : ''; 
  753.  
  754. $PendingRefund = $DOM -> getElementsByTagName('pendingRefund') -> length > 0 ? $DOM -> getElementsByTagName('pendingRefund') -> item(0) -> nodeValue : 'false'; 
  755. $RefundedAmount = $DOM -> getElementsByTagName('refundedAmount') -> length > 0 ? $DOM -> getElementsByTagName('refundedAmount') -> item(0) -> nodeValue : ''; 
  756. $SenderTransactionID = $DOM -> getElementsByTagName('senderTransactionID') -> length > 0 ? $DOM -> getElementsByTagName('senderTransactionID') -> item(0) -> nodeValue : ''; 
  757.  
  758. $SenderTransactionStatus = $DOM -> getElementsByTagName('senderTransactionStatus') -> length > 0 ? $DOM -> getElementsByTagName('senderTransactionStatus') -> item(0) -> nodeValue : ''; 
  759. $TransactionID = $DOM -> getElementsByTagName('transactionId') -> length > 0 ? $DOM -> getElementsByTagName('transactionId') -> item(0) -> nodeValue : ''; 
  760. $TransactionStatus = $DOM -> getElementsByTagName('transactionStatus') -> length > 0 ? $DOM -> getElementsByTagName('transactionStatus') -> item(0) -> nodeValue : ''; 
  761. $PaymentInfo = array( 
  762. 'PendingRefund' => $PendingRefund,  
  763. 'RefundAmount' => $RefundedAmount,  
  764. 'SenderTransactionID' => $SenderTransactionID,  
  765. 'SenderTransactionStatus' => $SenderTransactionStatus,  
  766. 'TransactionID' => $TransactionID,  
  767. 'TransactionStatus' => $TransactionStatus 
  768. ); 
  769.  
  770. $PreapprovalKey = $DOM -> getElementsByTagName('preapprovalKey') -> length > 0 ? $DOM -> getElementsByTagName('preapprovalKey') -> item(0) -> nodeValue : ''; 
  771. $ReturnURL = $DOM -> getElementsByTagName('returnUrl') -> length > 0 ? $DOM -> getElementsByTagName('returnUrl') -> item(0) -> nodeValue : ''; 
  772. $ReverseAllParallelPaymentsOnError = $DOM -> getElementsByTagName('reverseAllParallelPaymentsOnError') -> length > 0 ? $DOM -> getElementsByTagName('reverseAllParallelPaymentsOnError') -> item(0) -> nodeValue : ''; 
  773. $SenderEmail = $DOM -> getElementsByTagName('senderEmail') -> length > 0 ? $DOM -> getElementsByTagName('senderEmail') -> item(0) -> nodeValue : ''; 
  774. $Status = $DOM -> getElementsByTagName('status') -> length > 0 ? $DOM -> getElementsByTagName('status') -> item(0) -> nodeValue : ''; 
  775. $TrackingID = $DOM -> getElementsByTagName('trackingId') -> length > 0 ? $DOM -> getElementsByTagName('trackingId') -> item(0) -> nodeValue : ''; 
  776.  
  777. $Amount = $DOM -> getElementsByTagName('amount') -> length > 0 ? $DOM -> getElementsByTagName('amount') -> item(0) -> nodeValue : ''; 
  778. $Email = $DOM -> getElementsByTagName('email') -> length > 0 ? $DOM -> getElementsByTagName('email') -> item(0) -> nodeValue : ''; 
  779. $InvoiceID = $DOM -> getElementsByTagName('invoiceId') -> length > 0 ? $DOM -> getElementsByTagName('invoiceId') -> item(0) -> nodeValue : ''; 
  780. $PaymentType = $DOM -> getElementsByTagName('paymentType') -> length > 0 ? $DOM -> getElementsByTagName('paymentType') -> item(0) -> nodeValue : ''; 
  781. $Primary = $DOM -> getElementsByTagName('primary') -> length > 0 ? $DOM -> getElementsByTagName('primary') -> item(0) -> nodeValue : 'false'; 
  782. $Receiver = array( 
  783. 'Amount' => $Amount,  
  784. 'Email' => $Email,  
  785. 'InvoiceID' => $InvoiceID,  
  786. 'PaymentType' => $PaymentType,  
  787. 'Primary' => $Primary 
  788. ); 
  789.  
  790. $ResponseDataArray = array( 
  791. 'Errors' => $Errors,  
  792. 'Ack' => $Ack,  
  793. 'Build' => $Build,  
  794. 'CorrelationID' => $CorrelationID,  
  795. 'Timestamp' => $Timestamp,  
  796. 'ActionType' => $ActionType,  
  797. 'CancelURL' => $CancelURL,  
  798. 'CurrencyCode' => $CurrencyCode,  
  799. 'FeesPayer' => $FeesPayer,  
  800. 'FundingTypes' => $FundingTypes,  
  801. 'IPNNotificationURL' => $IPNNotificationURL,  
  802. 'Memo' => $Memo,  
  803. 'PayKey' => $PayKey,  
  804. 'PaymentInfo' => $PaymentInfo,  
  805. 'PreapprovalKey' => $PreapprovalKey,  
  806. 'ReturnURL' => $ReturnURL,  
  807. 'ReverseAllParallelPaymentsOnError' => $ReverseAllParallelPaymentsOnError,  
  808. 'SenderEmail' => $SenderEmail,  
  809. 'Status' => $Status,  
  810. 'TrackingID' => $TrackingID,  
  811. 'Receiver' => $Receiver,  
  812. 'XMLRequest' => $XMLRequest,  
  813. 'XMLResponse' => $XMLResponse 
  814. ); 
  815.  
  816. return $ResponseDataArray; 
  817.  
  818.  
  819. /** 
  820. * Submit ExecutePayment API request to PayPal. 
  821. * @access public 
  822. * @param array call config data 
  823. * @return array 
  824. */ 
  825. function ExecutePayment($DataArray) 
  826. // ExecutePaymentFields Fields 
  827. $ExecutePaymentFields = isset($DataArray['ExecutePaymentFields']) ? $DataArray['ExecutePaymentFields'] : array(); 
  828.  
  829. // Generate XML Request 
  830. $XMLRequest = '<?xml version="1.0" encoding="utf-8"?>'; 
  831. $XMLRequest .= '<ExecutePaymentRequest xmlns="' . $this -> XMLNamespace . '">'; 
  832. $XMLRequest .= $this -> GetXMLRequestEnvelope(); 
  833. $XMLRequest .= isset($ExecutePaymentFields['PayKey']) && $ExecutePaymentFields['PayKey'] != '' ? '<payKey xmlns="">' . $ExecutePaymentFields['PayKey'] . '</payKey>' : ''; 
  834. $XMLRequest .= isset($ExecutePaymentFields['FundingPlanID']) && $ExecutePaymentFields['FundingPlanID'] != '' ? '<fundingPlanId xmlns="">' . $ExecutePaymentFields['FundingPlanID'] . '</fundingPlanId>' : ''; 
  835. $XMLRequest .= '</ExecutePaymentRequest>'; 
  836.  
  837. // Call the API and load XML response into DOM 
  838. $XMLResponse = $this -> CURLRequest($XMLRequest, 'AdaptivePayments', 'ExecutePayment'); 
  839. $DOM = new DOMDocument(); 
  840. $DOM -> loadXML($XMLResponse); 
  841.  
  842. // Parse XML values 
  843. $Fault = $DOM -> getElementsByTagName('FaultMessage') -> length > 0 ? true : false; 
  844. $Errors = $this -> GetErrors($XMLResponse); 
  845. $Ack = $DOM -> getElementsByTagName('ack') -> length > 0 ? $DOM -> getElementsByTagName('ack') -> item(0) -> nodeValue : ''; 
  846. $Build = $DOM -> getElementsByTagName('build') -> length > 0 ? $DOM -> getElementsByTagName('build') -> item(0) -> nodeValue : ''; 
  847. $CorrelationID = $DOM -> getElementsByTagName('correlationId') -> length > 0 ? $DOM -> getElementsByTagName('correlationId') -> item(0) -> nodeValue : ''; 
  848. $Timestamp = $DOM -> getElementsByTagName('timestamp') -> length > 0 ? $DOM -> getElementsByTagName('timestamp') -> item(0) -> nodeValue : ''; 
  849. $PaymentExecStatus = $DOM -> getElementsByTagName('paymentExecStatus') -> length > 0 ? $DOM -> getElementsByTagName('paymentExecStatus') -> item(0) -> nodeValue : ''; 
  850.  
  851. $ResponseDataArray = array( 
  852. 'Errors' => $Errors,  
  853. 'Ack' => $Ack,  
  854. 'Build' => $Build,  
  855. 'CorrelationID' => $CorrelationID,  
  856. 'Timestamp' => $Timestamp,  
  857. 'PaymentExecStatus' => $PaymentExecStatus,  
  858. 'XMLRequest' => $XMLRequest,  
  859. 'XMLResponse' => $XMLResponse 
  860. ); 
  861.  
  862. return $ResponseDataArray; 
  863.  
  864.  
  865. /** 
  866. * Submit GetPaymentOptions API request to PayPal. 
  867. * @access public 
  868. * @param array call config data 
  869. * @return array 
  870. */ 
  871. function GetPaymentOptions($PayKey) 
  872. // Generate XML Request 
  873. $XMLRequest = '<?xml version="1.0" encoding="utf-8"?>'; 
  874. $XMLRequest .= '<GetPaymentOptionsRequest xmlns="' . $this -> XMLNamespace . '">'; 
  875. $XMLRequest .= $this -> GetXMLRequestEnvelope(); 
  876. $XMLRequest .= $PayKey != '' ? '<payKey xmlns="">' . $PayKey. '</payKey>' : ''; 
  877. $XMLRequest .= '</GetPaymentOptionsRequest>'; 
  878.  
  879. // Call the API and load XML response into DOM 
  880. $XMLResponse = $this -> CURLRequest($XMLRequest, 'AdaptivePayments', 'GetPaymentOptions'); 
  881. $DOM = new DOMDocument(); 
  882. $DOM -> loadXML($XMLResponse); 
  883.  
  884. // Parse XML values 
  885. $Fault = $DOM -> getElementsByTagName('FaultMessage') -> length > 0 ? true : false; 
  886. $Errors = $this -> GetErrors($XMLResponse); 
  887. $Ack = $DOM -> getElementsByTagName('ack') -> length > 0 ? $DOM -> getElementsByTagName('ack') -> item(0) -> nodeValue : ''; 
  888. $Build = $DOM -> getElementsByTagName('build') -> length > 0 ? $DOM -> getElementsByTagName('build') -> item(0) -> nodeValue : ''; 
  889. $CorrelationID = $DOM -> getElementsByTagName('correlationId') -> length > 0 ? $DOM -> getElementsByTagName('correlationId') -> item(0) -> nodeValue : ''; 
  890. $Timestamp = $DOM -> getElementsByTagName('timestamp') -> length > 0 ? $DOM -> getElementsByTagName('timestamp') -> item(0) -> nodeValue : ''; 
  891.  
  892. // GetPaymentOptionsResponse Fields 
  893. $PayKey = $DOM -> getElementsByTagName('payKey') -> length > 0 ? $DOM -> getElementsByTagName('payKey') -> item(0) -> nodeValue : ''; 
  894. $ShippingAddressID = $DOM -> getElementsByTagName('shippingAddressId') -> length > 0 ? $DOM -> getElementsByTagName('shippingAddressId') -> item(0) -> nodeValue : ''; 
  895.  
  896. // InitiatingEntity Fields 
  897. $InstitutionCustomer = $DOM -> getElementsByTagName('institutionCustomer') -> length > 0 ? $DOM -> getElementsByTagName('institutionCustomer') -> item(0) -> nodeValue : ''; 
  898. $CountryCode = $InstitutionCustomer != '' && $InstitutionCustomer -> getElementsByTagName('countryCode') -> length > 0 ? $InstitutionCustomer -> getElementsByTagName('countryCode') -> item(0) -> nodeValue : ''; 
  899. $DisplayName = $InstitutionCustomer != '' && $InstitutionCustomer -> getElementsByTagName('displayName') -> length > 0 ? $InstitutionCustomer -> getElementsByTagName('displayName') -> item(0) -> nodeValue : ''; 
  900. $Email = $InstitutionCustomer != '' && $InstitutionCustomer -> getElementsByTagName('email') -> length > 0 ? $InstitutionCustomer -> getElementsByTagName('email') -> item(0) -> nodeValue : ''; 
  901. $FirstName = $InstitutionCustomer != '' && $InstitutionCustomer -> getElementsByTagName('firstName') -> length > 0 ? $InstitutionCustomer -> getElementsByTagName('firstName') -> item(0) -> nodeValue : ''; 
  902. $InstitutionCustomerID = $InstitutionCustomer != '' && $InstitutionCustomer -> getElementsByTagName('institutionCustomerId') -> length > 0 ? $InstitutionCustomer -> getElementsByTagName('institutionCustomerId') -> item(0) -> nodeValue : ''; 
  903. $InstitutionID = $InstitutionCustomer != '' && $InstitutionCustomer -> getElementsByTagName('institutionId') -> length > 0 ? $InstitutionCustomer -> getElementsByTagName('institutionId') -> item(0) -> nodeValue : ''; 
  904. $LastName = $InstitutionCustomer != '' && $InstitutionCustomer -> getElementsByTagName('lastName') -> length > 0 ? $InstitutionCustomer -> getElementsByTagName('lastName') -> item(0) -> nodeValue : ''; 
  905. $InitiatingEntity = array( 
  906. 'CountryCode' => $CountryCode,  
  907. 'DisplayName' => $DisplayName,  
  908. 'Email' => $Email,  
  909. 'FirstName' => $FirstName,  
  910. 'InstitutionCustomerID' => $InstitutionCustomerID,  
  911. 'InstitutionID' => $InstitutionID,  
  912. 'LastName' => $LastName 
  913. );  
  914.  
  915.  
  916. // DisplayOptions Fields 
  917. $EmailHeaderImageURL = $DOM -> getElementsByTagName('emailHeaderImageUrl') -> length > 0 ? $DOM -> getElementsByTagName('emailHeaderImageUrl') -> item(0) -> nodeValue : ''; 
  918. $EmailMarketingImageURL = $DOM -> getElementsByTagName('emailMarketingImageUrl') -> length > 0 ? $DOM -> getElementsByTagName('emailMarketingImageUrl') -> item(0) -> nodeValue : ''; 
  919. $BusinessName = $DOM -> getElementsByTagName('businessName') -> length > 0 ? $DOM -> getElementsByTagName('businessName') -> item(0) -> nodeValue : ''; 
  920. $DisplayOptions = array( 
  921. 'EmailHeaderImageURL' => $EmailHeaderImageURL,  
  922. 'EmailMarketingImageURL' => $EmailMarketingImageURL,  
  923. 'BusinessName' => $BusinessName 
  924. ); 
  925.  
  926. // Sender Options 
  927. $RequireShippingAddressSelection = $DOM -> getElementsByTagName('requireShippingAddressSelection') -> length > 0 ? $DOM -> getElementsByTagName('requireShippingAddressSelection') -> item(0) -> nodeValue : ''; 
  928.  
  929. // ReceiverOptions Fields 
  930. $ReceiverOptions = $DOM -> getElementsByTagName('receiverOptions') -> length > 0 ? $DOM -> getElementsByTagName('receiverOptions') -> item(0) -> nodeValue : ''; 
  931. $Description = $ReceiverOptions != '' && $ReceiverOptions -> getElementsByTagName('description') -> length > 0 ? $ReceiverOptions -> getElementsByTagName('description') -> item(0) -> nodeValue : ''; 
  932. $CustomID = $ReceiverOptions != '' && $ReceiverOptions -> getElementsByTagName('customId') -> length > 0 ? $ReceiverOptions -> getElementsByTagName('customId') -> item(0) -> nodeValue : ''; 
  933. $Email = $ReceiverOptions != '' && $ReceiverOptions -> getElementsByTagName('email') -> length > 0 ? $ReceiverOptions -> getElementsByTagName('email') -> item(0) -> nodeValue : ''; 
  934. $PhoneCountryCode = $ReceiverOptions != '' && $ReceiverOptions -> getElementsByTagName('countryCode') -> length > 0 ? $ReceiverOptions -> getElementsByTagName('countryCode') -> item(0) -> nodeValue : ''; 
  935. $PhoneNumber = $ReceiverOptions != '' && $ReceiverOptions -> getElementsByTagName('phoneNumber') -> length > 0 ? $ReceiverOptions -> getElementsByTagName('phoneNumber') -> item(0) -> nodeValue : ''; 
  936. $PhoneExtension = $ReceiverOptions != '' && $ReceiverOptions -> getElementsByTagName('extension') -> length > 0 ? $ReceiverOptions -> getElementsByTagName('extension') -> item(0) -> nodeValue : ''; 
  937.  
  938. // InvoiceDataFields 
  939. $InvoiceItems = $ReceiverOptions != '' && $ReceiverOptions -> getElementsByTagName('item') -> length > 0 ? $ReceiverOptions -> getElementsByTagName('item') : array(); 
  940. $TotalTax = $ReceiverOptions != '' && $ReceiverOptions -> getElementsByTagName('totalTax') -> length > 0 ? $ReceiverOptions -> getElementsByTagName('totalTax') -> item(0) -> nodeValue : ''; 
  941. $TotalShipping = $ReceiverOptions != '' && $ReceiverOptions -> getElementsByTagName('totalShipping') -> length > 0 ? $ReceiverOptions -> getElementsByTagName('totalShipping') -> item(0) -> nodeValue : ''; 
  942.  
  943. $InvoiceItemsArray = array(); 
  944. foreach($InvoiceItems as $InvoiceItem) 
  945. $ItemName = $InvoiceItem -> getElementsByTagName('name') -> length > 0 ? $InvoiceItem -> getElementsByTagName('name') -> item(0) -> nodeValue : ''; 
  946. $ItemIdentifier = $InvoiceItem -> getElementsByTagName('identifier') -> length > 0 ? $InvoiceItem -> getElementsByTagName('identifier') -> item(0) -> nodeValue : ''; 
  947. $ItemSubtotal = $InvoiceItem -> getElementsByTagName('price') -> length > 0 ? $InvoiceItem -> getElementsByTagName('price') -> item(0) -> nodeValue : ''; 
  948. $ItemPrice = $InvoiceItem -> getElementsByTagName('itemPrice') -> length > 0 ? $InvoiceItem -> getElementsByTagName('itemPrice') -> item(0) -> nodeValue : ''; 
  949. $ItemCount = $InvoiceItem -> getElementsByTagName('itemCount') -> length > 0 ? $InvoiceItem -> getElementsByTagName('itemCount') -> item(0) -> nodeValue : ''; 
  950.  
  951. $CurrentItem = array( 
  952. 'Name' => $ItemName,  
  953. 'Identifier' => $ItemIdentifier,  
  954. 'Subtotal' => $ItemSubtotal,  
  955. 'Price' => $ItemPrice,  
  956. 'ItemCount' => $ItemCount 
  957. ); 
  958. array_push($InvoiceItemsArray, $CurrentItem);  
  959.  
  960. $InvoiceData = array('TotalTax' => $TotalTax, 'TotalShipping' => $TotalShipping, 'InvoiceItems' => $InvoiceItemsArray); 
  961.  
  962. $ReceiverOptionsFields = array( 
  963. 'Description' => $Description,  
  964. 'CustomID' => $CustomID,  
  965. 'Email' => $Email,  
  966. 'PhoneCountryCode' => $PhoneCountryCode,  
  967. 'PhoneNumber' => $PhoneNumber,  
  968. 'PhoneExtension' => $PhoneExtension,  
  969. 'InvoiceData' => $InvoiceData 
  970. ); 
  971.  
  972. $ResponseDataArray = array( 
  973. 'Errors' => $Errors,  
  974. 'Ack' => $Ack,  
  975. 'Build' => $Build,  
  976. 'CorrelationID' => $CorrelationID,  
  977. 'Timestamp' => $Timestamp,  
  978. 'PayKey' => $PayKey,  
  979. 'ShippingAddressID' => $ShippingAddressID,  
  980. 'InitiatingEntity' => $InitiatingEntity,  
  981. 'DisplayOptions' => $DisplayOptions,  
  982. 'RequireShippingAddressSelection' => $RequireShippingAddressSelection,  
  983. 'ReceiverOptions' => $ReceiverOptionsFields,  
  984. 'XMLRequest' => $XMLRequest,  
  985. 'XMLResponse' => $XMLResponse 
  986. ); 
  987.  
  988. return $ResponseDataArray; 
  989.  
  990.  
  991. /** 
  992. * Submit SetPaymentOptions API request to PayPal. 
  993. * @access public 
  994. * @param array call config data 
  995. * @return array 
  996. */ 
  997. function SetPaymentOptions($DataArray) 
  998. // SetPaymentOptions Basic Fields 
  999. $SPOFields = isset($DataArray['SPOFields']) ? $DataArray['SPOFields'] : array(); 
  1000. $PayKey = isset($SPOFields['PayKey']) ? $SPOFields['PayKey'] : ''; 
  1001. $ShippingAddressID = isset($SPOFields['ShippingAddressID']) ? $SPOFields['ShippingAddressID'] : ''; 
  1002.  
  1003. // DisplayOptions Fields 
  1004. $DisplayOptions = isset($DataArray['DisplayOptions']) ? $DataArray['DisplayOptions'] : array(); 
  1005. $EmailHeaderImageURL = isset($DisplayOptions['EmailHeaderImageURL']) ? $DisplayOptions['EmailHeaderImageURL'] : ''; 
  1006. $EmailMarketingImageURL = isset($DisplayOptions['EmailMarketingImageURL']) ? $DisplayOptions['EmailMarketingImageURL'] : ''; 
  1007. $HeaderImageURL = isset($DisplayOptions['HeaderImageURL']) ? $DisplayOptions['HeaderImageURL'] : ''; 
  1008. $BusinessName = isset($DisplayOptions['BusinessName']) ? $DisplayOptions['BusinessName'] : ''; 
  1009.  
  1010. // InstitutionCustomer Fields 
  1011. $InstitutionCustomer = isset($DataArray['InstitutionCustomer']) ? $DataArray['InstitutionCustomer'] : array(); 
  1012. $CountryCode = isset($InstitutionCustomer['CountryCode']) ? $InstitutionCustomer['CountryCode'] : ''; 
  1013. $DisplayName = isset($InstitutionCustomer['DisplayName']) ? $InstitutionCustomer['DisplayName'] : ''; 
  1014. $InstitutionCustomerEmail = isset($InstitutionCustomer['Email']) ? $InstitutionCustomer['Email'] : ''; 
  1015. $FirstName = isset($InstitutionCustomer['FirstName']) ? $InstitutionCustomer['FirstName'] : ''; 
  1016. $LastName = isset($InstitutionCustomer['LastName']) ? $InstitutionCustomer['LastName'] : ''; 
  1017. $InstitutionCustomerID = isset($InstitutionCustomer['InstitutionCustomerID']) ? $InstitutionCustomer['InstitutionCustomerID'] : ''; 
  1018. $InstitutionID = isset($InstitutionCustomer['InstitutionID']) ? $InstitutionCustomer['InstitutionID'] : ''; 
  1019.  
  1020. // SenderOptions Fields 
  1021. $SenderOptions = isset($DataArray['SenderOptions']) ? $DataArray['SenderOptions'] : array(); 
  1022. $RequireShippingAddressSelection = isset($SenderOptions['RequireShippingAddressSelection']) ? $SenderOptions['RequireShippingAddressSelection'] : ''; 
  1023. $ReferrerCode = $this->APIButtonSource; 
  1024.  
  1025. // ReceiverOptions Fields 
  1026. $ReceiverOptionsXML = ''; 
  1027. $ReceiverOptions = isset($DataArray['ReceiverOptions']) ? $DataArray['ReceiverOptions'] : array(); 
  1028. foreach($ReceiverOptions as $ReceiverOption) 
  1029. $Description = isset($ReceiverOption['Description']) ? $ReceiverOption['Description'] : ''; 
  1030. $CustomID = isset($ReceiverOption['CustomID']) ? $ReceiverOption['CustomID'] : ''; 
  1031.  
  1032. // Invoice Data 
  1033. $InvoiceData = isset($ReceiverOption['InvoiceData']) ? $ReceiverOption['InvoiceData'] : array(); 
  1034. $TotalTax = isset($InvoiceData['TotalTax']) ? $InvoiceData['TotalTax'] : ''; 
  1035. $TotalShipping = isset($InvoiceData['TotalShipping']) ? $InvoiceData['TotalShipping'] : ''; 
  1036.  
  1037. // InvoiceItem Fields 
  1038. $InvoiceItems = isset($ReceiverOption['InvoiceItems']) ? $ReceiverOption['InvoiceItems'] : array(); 
  1039.  
  1040. // ReceiverIdentifer Fields 
  1041. $ReceiverIdentifier = isset($ReceiverOption['ReceiverIdentifier']) ? $ReceiverOption['ReceiverIdentifier'] : array(); 
  1042. $ReceiverIdentifierEmail = isset($ReceiverIdentifier['Email']) ? $ReceiverIdentifier['Email'] : ''; 
  1043. $PhoneCountryCode = isset($ReceiverIdentifier['PhoneCountryCode']) ? $ReceiverIdentifier['PhoneCountryCode'] : ''; 
  1044. $PhoneNumber = isset($ReceiverIdentifier['PhoneNumber']) ? $ReceiverIdentifier['PhoneNumber'] : ''; 
  1045. $PhoneExtension = isset($ReceiverIdentifier['PhoneExtension']) ? $ReceiverIdentifier['PhoneExtension'] : ''; 
  1046.  
  1047.  
  1048. $ReceiverOptionsXML .= '<receiverOptions xmlns="">'; 
  1049. $ReceiverOptionsXML .= $Description != '' ? '<description xmlns="">'.$Description.'</description>' : ''; 
  1050. $ReceiverOptionsXML .= $CustomID != '' ? '<customId xmlns="">'.$CustomID.'</customId>' : ''; 
  1051.  
  1052. if(!empty($InvoiceData)) 
  1053. $ReceiverOptionsXML .= '<invoiceData xmlns="">'; 
  1054. $ReceiverOptionsXML .= $TotalTax != '' ? '<totalTax xmlns="">'.$TotalTax.'</totalTax>' : ''; 
  1055. $ReceiverOptionsXML .= $TotalShipping != '' ? '<totalShipping xmlns="">'.$TotalShipping.'</totalShipping>' : ''; 
  1056.  
  1057.  
  1058. foreach($InvoiceItems as $InvoiceItem) 
  1059. $ReceiverOptionsXML .= '<item xmlns="">'; 
  1060. $ReceiverOptionsXML .= $InvoiceItem['Name'] != '' ? '<name xmlns="">'.$InvoiceItem['Name'].'</name>' : ''; 
  1061. $ReceiverOptionsXML .= $InvoiceItem['Identifier'] != '' ? '<identifier xmlns="">'.$InvoiceItem['Identifier'].'</identifier>' : ''; 
  1062. $ReceiverOptionsXML .= $InvoiceItem['Price'] != '' ? '<price xmlns="">'.$InvoiceItem['Price'].'</price>' : ''; 
  1063. $ReceiverOptionsXML .= $InvoiceItem['ItemPrice'] != '' ? '<itemPrice xmlns="">'.$InvoiceItem['ItemPrice'].'</itemPrice>' : ''; 
  1064. $ReceiverOptionsXML .= $InvoiceItem['ItemCount'] != '' ? '<itemCount xmlns="">'.$InvoiceItem['ItemCount'].'</itemCount>' : ''; 
  1065. $ReceiverOptionsXML .= '</item>'; 
  1066.  
  1067. $ReceiverOptionsXML .= '</invoiceData>'; 
  1068.  
  1069. if(count($ReceiverIdentifier) > 0) 
  1070. $ReceiverOptionsXML .= '<receiver xmlns="">'; 
  1071. $ReceiverOptionsXML .= $ReceiverIdentifierEmail != '' ? '<email xmlns="">'.$ReceiverIdentifierEmail.'</email>' : ''; 
  1072.  
  1073. if($PhoneNumber != '') 
  1074. $ReceiverOptionsXML .= '<phone xmlns="">'; 
  1075. $ReceiverOptionsXML .= $PhoneCountryCode != '' ? '<countryCode xmlns="">'.$PhoneCountryCode.'</countryCode>' : ''; 
  1076. $ReceiverOptionsXML .= $PhoneNumber != '' ? '<phoneNumber xmlns="">'.$PhoneNumber.'</phoneNumber>' : ''; 
  1077. $ReceiverOptionsXML .= $PhoneExtension != '' ? '<extension xmlns="">'.$PhoneExtension.'</extension>' : ''; 
  1078. $ReceiverOptionsXML .= '</phone>'; 
  1079.  
  1080. $ReceiverOptionsXML .= '</receiver>'; 
  1081.  
  1082. $ReceiverOptionsXML .= '</receiverOptions>'; 
  1083.  
  1084. // Generate XML Request 
  1085. $XMLRequest = '<?xml version="1.0" encoding="utf-8"?>'; 
  1086. $XMLRequest .= '<SetPaymentOptionsRequest xmlns="' . $this -> XMLNamespace . '">'; 
  1087. $XMLRequest .= $this -> GetXMLRequestEnvelope(); 
  1088. $XMLRequest .= $PayKey != '' ? '<payKey xmlns="">'.$PayKey.'</payKey>' : ''; 
  1089. $XMLRequest .= $ShippingAddressID != '' ? '<shippingAddressId xmlns="">'.$ShippingAddressID.'</shippingAddressId>' : ''; 
  1090.  
  1091. if(count($InstitutionCustomer) > 0) 
  1092. $XMLRequest .= '<initiatingEntity xmlns="">'; 
  1093. $XMLRequest .= '<institutionCustomer xmlns="">'; 
  1094. $XMLRequest .= $InstitutionID != '' ? '<institutionId xmlns="">'.$InstitutionID.'</institutionId>' : ''; 
  1095. $XMLRequest .= $FirstName != '' ? '<firstName xmlns="">'.$FirstName.'</firstName>' : ''; 
  1096. $XMLRequest .= $LastName != '' ? '<lastName xmlns="">'.$LastName.'</lastName>' : ''; 
  1097. $XMLRequest .= $DisplayName != '' ? '<displayName xmlns="">'.$DisplayName.'</displayName>' : ''; 
  1098. $XMLRequest .= $InstitutionCustomerID != '' ? '<institutionCustomerId xmlns="">'.$InstitutionCustomerID.'</institutionCustomerId>' : ''; 
  1099. $XMLRequest .= $CountryCode != '' ? '<countryCode xmlns="">'.$CountryCode.'</countryCode>' : ''; 
  1100. $XMLRequest .= $InstitutionCustomerEmail != '' ? '<email xmlns="">'.$InstitutionCustomerEmail.'</email>' : ''; 
  1101. $XMLRequest .= '</institutionCustomer>'; 
  1102. $XMLRequest .= '</initiatingEntity>';  
  1103.  
  1104. if(count($DisplayOptions) > 0) 
  1105. $XMLRequest .= '<displayOptions xmlns="">'; 
  1106. $XMLRequest .= $EmailHeaderImageURL != '' ? '<emailHeaderImageUrl xmlns="">'.$EmailHeaderImageURL.'</emailHeaderImageUrl>' : ''; 
  1107. $XMLRequest .= $EmailMarketingImageURL != '' ? '<emailMarketingImageUrl xmlns="">'.$EmailMarketingImageURL.'</emailMarketingImageUrl>' : ''; 
  1108. $XMLRequest .= $HeaderImageURL != '' ? '<headerImageUrl xmlns="">'.$HeaderImageURL.'</headerImageUrl>' : ''; 
  1109. $XMLRequest .= $BusinessName != '' ? '<businessName xmlns="">'.$BusinessName.'</businessName>' : ''; 
  1110. $XMLRequest .= '</displayOptions>';  
  1111.  
  1112. if(count($SenderOptions) > 0) 
  1113. $XMLRequest .= '<senderOptions xmlns="">'; 
  1114. $XMLRequest .= $RequireShippingAddressSelection != '' ? '<requireShippingAddressSelection xmlns="">'.$RequireShippingAddressSelection.'</requireShippingAddressSelection>' : ''; 
  1115. $XMLRequest .= $ReferrerCode != '' ? '<referrerCode xmlns="">'.$ReferrerCode.'</referrerCode>' : ''; 
  1116. $XMLRequest .= '</senderOptions>';  
  1117.  
  1118. $XMLRequest .= $ReceiverOptionsXML; 
  1119. $XMLRequest .= '</SetPaymentOptionsRequest>'; 
  1120.  
  1121. // Call the API and load XML response into DOM 
  1122. $XMLResponse = $this -> CURLRequest($XMLRequest, 'AdaptivePayments', 'SetPaymentOptions'); 
  1123. $DOM = new DOMDocument(); 
  1124. $DOM -> loadXML($XMLResponse); 
  1125.  
  1126. // Parse XML values 
  1127. $Fault = $DOM -> getElementsByTagName('FaultMessage') -> length > 0 ? true : false; 
  1128. $Errors = $this -> GetErrors($XMLResponse); 
  1129. $Ack = $DOM -> getElementsByTagName('ack') -> length > 0 ? $DOM -> getElementsByTagName('ack') -> item(0) -> nodeValue : ''; 
  1130. $Build = $DOM -> getElementsByTagName('build') -> length > 0 ? $DOM -> getElementsByTagName('build') -> item(0) -> nodeValue : ''; 
  1131. $CorrelationID = $DOM -> getElementsByTagName('correlationId') -> length > 0 ? $DOM -> getElementsByTagName('correlationId') -> item(0) -> nodeValue : ''; 
  1132. $Timestamp = $DOM -> getElementsByTagName('timestamp') -> length > 0 ? $DOM -> getElementsByTagName('timestamp') -> item(0) -> nodeValue : ''; 
  1133.  
  1134. $ResponseDataArray = array( 
  1135. 'Errors' => $Errors,  
  1136. 'Ack' => $Ack,  
  1137. 'Build' => $Build,  
  1138. 'CorrelationID' => $CorrelationID,  
  1139. 'Timestamp' => $Timestamp,  
  1140. 'XMLRequest' => $XMLRequest,  
  1141. 'XMLResponse' => $XMLResponse 
  1142. ); 
  1143.  
  1144. return $ResponseDataArray; 
  1145.  
  1146. /** 
  1147. * Submit Preapproval API request to PayPal. 
  1148. * @access public 
  1149. * @param array call config data 
  1150. * @return array 
  1151. */ 
  1152. function Preapproval($DataArray) 
  1153. {  
  1154. $PreapprovalFields = isset($DataArray['PreapprovalFields']) ? $DataArray['PreapprovalFields'] : array(); 
  1155. $CancelURL = isset($PreapprovalFields['CancelURL']) ? $PreapprovalFields['CancelURL'] : ''; 
  1156. $CurrencyCode = isset($PreapprovalFields['CurrencyCode']) ? $PreapprovalFields['CurrencyCode'] : ''; 
  1157. $DateOfMonth = isset($PreapprovalFields['DateOfMonth']) ? $PreapprovalFields['DateOfMonth'] : ''; 
  1158. $DayOfWeek = isset($PreapprovalFields['DayOfWeek']) ? $PreapprovalFields['DayOfWeek'] : ''; 
  1159. $EndingDate = isset($PreapprovalFields['EndingDate']) ? $PreapprovalFields['EndingDate'] : ''; 
  1160. $IPNNotificationURL = isset($PreapprovalFields['IPNNotificationURL']) ? $PreapprovalFields['IPNNotificationURL'] : ''; 
  1161. $MaxAmountPerPayment = isset($PreapprovalFields['MaxAmountPerPayment']) ? $PreapprovalFields['MaxAmountPerPayment'] : ''; 
  1162. $MaxNumberOfPayments = isset($PreapprovalFields['MaxNumberOfPayments']) ? $PreapprovalFields['MaxNumberOfPayments'] : ''; 
  1163. $MaxNumberOfPaymentsPerPeriod = isset($PreapprovalFields['MaxNumberOfPaymentsPerPeriod']) ? $PreapprovalFields['MaxNumberOfPaymentsPerPeriod'] : ''; 
  1164. $MaxTotalAmountOfAllPayments = isset($PreapprovalFields['MaxTotalAmountOfAllPayments']) ? $PreapprovalFields['MaxTotalAmountOfAllPayments'] : ''; 
  1165. $Memo = isset($PreapprovalFields['Memo']) ? $PreapprovalFields['Memo'] : ''; 
  1166. $PaymentPeriod = isset($PreapprovalFields['PaymentPeriod']) ? $PreapprovalFields['PaymentPeriod'] : ''; 
  1167. $PinType = isset($PreapprovalFields['PinType']) ? $PreapprovalFields['PinType'] : ''; 
  1168. $ReturnURL = isset($PreapprovalFields['ReturnURL']) ? $PreapprovalFields['ReturnURL'] : ''; 
  1169. $SenderEmail = isset($PreapprovalFields['SenderEmail']) ? $PreapprovalFields['SenderEmail'] : ''; 
  1170. $StartingDate = isset($PreapprovalFields['StartingDate']) ? $PreapprovalFields['StartingDate'] : ''; 
  1171. $FeesPayer = isset($PreapprovalFields['FeesPayer']) ? $PreapprovalFields['FeesPayer'] : ''; 
  1172. $DisplayMaxTotalAmount = isset($PreapprovalFields['DisplayMaxTotalAmount']) ? $PreapprovalFields['DisplayMaxTotalAmount'] : ''; 
  1173.  
  1174. $ClientDetailsFields = isset($DataArray['ClientDetailsFields']) ? $DataArray['ClientDetailsFields'] : array(); 
  1175. $CustomerID = isset($ClientDetailsFields['CustomerID']) ? $ClientDetailsFields['CustomerID'] : ''; 
  1176. $CustomerType = isset($ClientDetailsFields['CustomerType']) ? $ClientDetailsFields['CustomerType'] : ''; 
  1177. $GeoLocation = isset($ClientDetailsFields['GeoLocation']) ? $ClientDetailsFields['GeoLocation'] : ''; 
  1178. $Model = isset($ClientDetailsFields['Model']) ? $ClientDetailsFields['Model'] : ''; 
  1179. $PartnerName = isset($ClientDetailsFields['PartnerName']) ? $ClientDetailsFields['PartnerName'] : ''; 
  1180.  
  1181. // Generate XML Request 
  1182. $XMLRequest = '<?xml version="1.0" encoding="utf-8"?>'; 
  1183. $XMLRequest .= '<PreapprovalRequest xmlns="' . $this -> XMLNamespace . '">'; 
  1184. $XMLRequest .= $this -> GetXMLRequestEnvelope(); 
  1185. $XMLRequest .= '<cancelUrl xmlns="">' . $CancelURL . '</cancelUrl>'; 
  1186.  
  1187. $XMLRequest .= '<clientDetails xmlns="">'; 
  1188. $XMLRequest .= $this -> ApplicationID != '' ? '<applicationId xmlns="">' . $this -> ApplicationID . '</applicationId>' : ''; 
  1189. $XMLRequest .= $CustomerID != '' ? '<customerId xmlns="">' . $CustomerID . '</customerId>' : ''; 
  1190. $XMLRequest .= $CustomerType != '' ? '<customerType xmlns="">' . $CustomerType . '</customerType>' : ''; 
  1191. $XMLRequest .= $this -> DeviceID != '' ? '<deviceId xmlns="">' . $this -> DeviceID . '</deviceId>' : ''; 
  1192. $XMLRequest .= $GeoLocation != '' ? '<geoLocation xmlns="">' . $GeoLocation . '</geoLocation>' : ''; 
  1193. $XMLRequest .= $this -> IPAddress != '' ? '<ipAddress xmlns="">' . $this -> IPAddress . '</ipAddress>' : ''; 
  1194. $XMLRequest .= $Model != '' ? '<model xmlns="">' . $Model . '</model>' : ''; 
  1195. $XMLRequest .= $PartnerName != '' ? '<partnerName xmlns="">' . $PartnerName . '</partnerName>' : ''; 
  1196. $XMLRequest .= '</clientDetails>'; 
  1197.  
  1198. $XMLRequest .= '<currencyCode xmlns="">' . $CurrencyCode . '</currencyCode>'; 
  1199. $XMLRequest .= $DateOfMonth != '' ? '<dateOfMonth xmlns="">' . $DateOfMonth . '</dateOfMonth>' : ''; 
  1200. $XMLRequest .= $DayOfWeek != '' ? '<dayOfWeek xmlns="">' . $DayOfWeek . '</dayOfWeek>' : ''; 
  1201. $XMLRequest .= $EndingDate != '' ? '<endingDate xmlns="">' . $EndingDate . '</endingDate>' : ''; 
  1202. $XMLRequest .= $IPNNotificationURL != '' ? '<ipnNotificationUrl xmlns="">' . $IPNNotificationURL . '</ipnNotificationUrl>' : ''; 
  1203. $XMLRequest .= $MaxAmountPerPayment != '' ? '<maxAmountPerPayment xmlns="">' . $MaxAmountPerPayment . '</maxAmountPerPayment>' : ''; 
  1204. $XMLRequest .= $MaxNumberOfPayments != '' ? '<maxNumberOfPayments xmlns="">' . $MaxNumberOfPayments . '</maxNumberOfPayments>' : ''; 
  1205. $XMLRequest .= $MaxNumberOfPaymentsPerPeriod != '' ? '<maxNumberOfPaymentsPerPeriod xmlns="">' . $MaxNumberOfPaymentsPerPeriod . '</maxNumberOfPaymentsPerPeriod>' : ''; 
  1206. $XMLRequest .= $MaxTotalAmountOfAllPayments != '' ? '<maxTotalAmountOfAllPayments xmlns="">' . $MaxTotalAmountOfAllPayments . '</maxTotalAmountOfAllPayments>' : ''; 
  1207. $XMLRequest .= $Memo != '' ? '<memo xmlns="">' . $Memo . '</memo>' : ''; 
  1208. $XMLRequest .= $PaymentPeriod != '' ? '<paymentPeriod xmlns="">' . $PaymentPeriod . '</paymentPeriod>' : ''; 
  1209. $XMLRequest .= $PinType != '' ? '<pinType xmlns="">' . $PinType . '</pinType>' : ''; 
  1210. $XMLRequest .= $FeesPayer != '' ? '<feesPayer xmlns="">' . $FeesPayer . '</feesPayer>' : ''; 
  1211. $XMLRequest .= $DisplayMaxTotalAmount != '' ? '<displayMaxTotalAmount xmlns="">' . $DisplayMaxTotalAmount . '</displayMaxTotalAmount>' : ''; 
  1212. $XMLRequest .= $ReturnURL != '' ? '<returnUrl xmlns="">' . $ReturnURL . '</returnUrl>' : ''; 
  1213. $XMLRequest .= $SenderEmail != '' ? '<senderEmail xmlns="">' . $SenderEmail . '</senderEmail>' : ''; 
  1214. $XMLRequest .= $StartingDate != '' ? '<startingDate xmlns="">' . $StartingDate . '</startingDate>' : ''; 
  1215. $XMLRequest .= '</PreapprovalRequest>'; 
  1216.  
  1217. // Call the API and load XML response into DOM 
  1218. $XMLResponse = $this -> CURLRequest($XMLRequest, 'AdaptivePayments', 'Preapproval'); 
  1219. $DOM = new DOMDocument(); 
  1220. $DOM -> loadXML($XMLResponse); 
  1221.  
  1222. // Parse XML values 
  1223. $Fault = $DOM -> getElementsByTagName('FaultMessage') -> length > 0 ? true : false; 
  1224. $Errors = $this -> GetErrors($XMLResponse); 
  1225. $Ack = $DOM -> getElementsByTagName('ack') -> length > 0 ? $DOM -> getElementsByTagName('ack') -> item(0) -> nodeValue : ''; 
  1226. $Build = $DOM -> getElementsByTagName('build') -> length > 0 ? $DOM -> getElementsByTagName('build') -> item(0) -> nodeValue : ''; 
  1227. $CorrelationID = $DOM -> getElementsByTagName('correlationId') -> length > 0 ? $DOM -> getElementsByTagName('correlationId') -> item(0) -> nodeValue : ''; 
  1228. $Timestamp = $DOM -> getElementsByTagName('timestamp') -> length > 0 ? $DOM -> getElementsByTagName('timestamp') -> item(0) -> nodeValue : ''; 
  1229. $PreapprovalKey = $DOM -> getElementsByTagName('preapprovalKey') -> length > 0 ? $DOM -> getElementsByTagName('preapprovalKey') -> item(0) -> nodeValue: ''; 
  1230.  
  1231. if($this -> Sandbox) 
  1232. $RedirectURL = 'https://www.sandbox.paypal.com/webscr?cmd=_ap-preapproval&preapprovalkey=' . $PreapprovalKey; 
  1233. elseif($this -> BetaSandbox) 
  1234. $RedirectURL = 'https://www.beta-sandbox.paypal.com/webscr?cmd=_ap-preapproval&preapprovalkey=' . $PreapprovalKey; 
  1235. else 
  1236. $RedirectURL = 'https://www.paypal.com/webscr?cmd=_ap-preapproval&preapprovalkey=' . $PreapprovalKey; 
  1237.  
  1238. $ResponseDataArray = array( 
  1239. 'Errors' => $Errors,  
  1240. 'Ack' => $Ack,  
  1241. 'Build' => $Build,  
  1242. 'CorrelationID' => $CorrelationID,  
  1243. 'Timestamp' => $Timestamp,  
  1244. 'PreapprovalKey' => $PreapprovalKey,  
  1245. 'RedirectURL' => $PreapprovalKey != '' ? $RedirectURL : '',  
  1246. 'XMLRequest' => $XMLRequest,  
  1247. 'XMLResponse' => $XMLResponse 
  1248. ); 
  1249.  
  1250. return $ResponseDataArray; 
  1251.  
  1252. /** 
  1253. * Submit PreapprovalDetails API request to PayPal. 
  1254. * @access public 
  1255. * @param array call config data 
  1256. * @return array 
  1257. */ 
  1258. function PreapprovalDetails($DataArray) 
  1259. $PreapprovalDetailsFields = isset($DataArray['PreapprovalDetailsFields']) ? $DataArray['PreapprovalDetailsFields'] : array(); 
  1260. $GetBillingAddress = isset($PreapprovalDetailsFields['GetBillingAddress']) ? $PreapprovalDetailsFields['GetBillingAddress'] : ''; 
  1261. $PreapprovalKey = isset($PreapprovalDetailsFields['PreapprovalKey']) ? $PreapprovalDetailsFields['PreapprovalKey'] : ''; 
  1262.  
  1263. // Generate XML Request 
  1264. $XMLRequest = '<?xml version="1.0" encoding="utf-8"?>'; 
  1265. $XMLRequest .= '<PreapprovalDetailsRequest xmlns="' . $this -> XMLNamespace . '">'; 
  1266. $XMLRequest .= $this -> GetXMLRequestEnvelope(); 
  1267. $XMLRequest .= $GetBillingAddress != '' ? '<getBillingAddress xmlns="">' . $GetBillingAddress . '</getBillingAddress>' : ''; 
  1268. $XMLRequest .= $PreapprovalKey != '' ? '<preapprovalKey xmlns="">' . $PreapprovalKey . '</preapprovalKey>' : ''; 
  1269. $XMLRequest .= '</PreapprovalDetailsRequest>'; 
  1270.  
  1271. // Call the API and load XML response into DOM 
  1272. $XMLResponse = $this -> CURLRequest($XMLRequest, 'AdaptivePayments', 'PreapprovalDetails'); 
  1273. $DOM = new DOMDocument(); 
  1274. $DOM -> loadXML($XMLResponse); 
  1275.  
  1276. // Parse XML values 
  1277. $Fault = $DOM -> getElementsByTagName('FaultMessage') -> length > 0 ? true : false; 
  1278. $Errors = $this -> GetErrors($XMLResponse); 
  1279. $Ack = $DOM -> getElementsByTagName('ack') -> length > 0 ? $DOM -> getElementsByTagName('ack') -> item(0) -> nodeValue : ''; 
  1280. $Build = $DOM -> getElementsByTagName('build') -> length > 0 ? $DOM -> getElementsByTagName('build') -> item(0) -> nodeValue : ''; 
  1281. $CorrelationID = $DOM -> getElementsByTagName('correlationId') -> length > 0 ? $DOM -> getElementsByTagName('correlationId') -> item(0) -> nodeValue : ''; 
  1282. $Timestamp = $DOM -> getElementsByTagName('timestamp') -> length > 0 ? $DOM -> getElementsByTagName('timestamp') -> item(0) -> nodeValue : ''; 
  1283.  
  1284. $Approved = $DOM -> getElementsByTagName('approved') -> length > 0 ? $DOM -> getElementsByTagName('approved') -> item(0) -> nodeValue : ''; 
  1285. $CancelURL = $DOM -> getElementsByTagName('cancelUrl') -> length > 0 ? $DOM -> getElementsByTagName('cancelUrl') -> item(0) -> nodeValue : ''; 
  1286. $CurPayments = $DOM -> getElementsByTagName('curPayments') -> length > 0 ? $DOM -> getElementsByTagName('curPayments') -> item(0) -> nodeValue : ''; 
  1287. $CurPaymentsAmount = $DOM -> getElementsByTagName('curPaymentsAmount') -> length > 0 ? $DOM -> getElementsByTagName('curPaymentsAmount') -> item(0) -> nodeValue : ''; 
  1288. $CurPeriodAttempts = $DOM -> getElementsByTagName('curPeriodAttempts') -> length > 0 ? $DOM -> getElementsByTagName('curPeriodAttempts') -> item(0) -> nodeValue : ''; 
  1289. $CurPeriodEndingDate = $DOM -> getElementsByTagName('curPeriodEndingDate') -> length > 0 ? $DOM -> getElementsByTagName('curPeriodEndingDate') -> item(0) -> nodeValue : ''; 
  1290. $CurrencyCode = $DOM -> getElementsByTagName('currencyCode') -> length > 0 ? $DOM -> getElementsByTagName('currencyCode') -> item(0) -> nodeValue : ''; 
  1291. $DateOfMonth = $DOM -> getElementsByTagName('dateOfMonth') -> length > 0 ? $DOM -> getElementsByTagName('dateOfMonth') -> item(0) -> nodeValue : ''; 
  1292. $DayOfWeek = $DOM -> getElementsByTagName('dayOfWeek') -> length > 0 ? $DOM -> getElementsByTagName('dayOfWeek') -> item(0) -> nodeValue : ''; 
  1293. $EndingDate = $DOM -> getElementsByTagName('endingDate') -> length > 0 ? $DOM -> getElementsByTagName('endingDate') -> item(0) -> nodeValue : ''; 
  1294. $IPNNotificationURL = $DOM -> getElementsByTagName('ipnNotificationUrl') -> length > 0 ? $DOM -> getElementsByTagName('ipnNotificationUrl') -> item(0) -> nodeValue : ''; 
  1295. $MaxAmountPerPayment = $DOM -> getElementsByTagName('maxAmountPerPayment') -> length > 0 ? $DOM -> getElementsByTagName('maxAmountPerPayment') -> item(0) -> nodeValue : ''; 
  1296. $MaxNumberOfPayments = $DOM -> getElementsByTagName('maxNumberOfPayments') -> length > 0 ? $DOM -> getElementsByTagName('maxNumberOfPayments') -> item(0) -> nodeValue : ''; 
  1297. $MaxNumberOfPaymentsPerPeriod = $DOM -> getElementsByTagName('maxNumberOfPaymentsPerPeriod') -> length > 0 ? $DOM -> getElementsByTagName('maxNumberOfPaymentsPerPeriod') -> item(0) -> nodeValue : ''; 
  1298. $MaxTotalAmountOfAllPayments = $DOM -> getElementsByTagName('maxTotalAmountOfAllPayments') -> length > 0 ? $DOM -> getElementsByTagName('maxTotalAmountOfAllPayments') -> item(0) -> nodeValue : ''; 
  1299. $Memo = $DOM -> getElementsByTagName('memo') -> length > 0 ? $DOM -> getElementsByTagName('memo') -> item(0) -> nodeValue : ''; 
  1300. $PaymentPeriod = $DOM -> getElementsByTagName('paymentPeriod') -> length > 0 ? $DOM -> getElementsByTagName('paymentPeriod') -> item(0) -> nodeValue : ''; 
  1301. $PinType = $DOM -> getElementsByTagName('pinType') -> length > 0 ? $DOM -> getElementsByTagName('pinType') -> item(0) -> nodeValue : ''; 
  1302. $ReturnUrl = $DOM -> getElementsByTagName('returnUrl') -> length > 0 ? $DOM -> getElementsByTagName('returnUrl') -> item(0) -> nodeValue : ''; 
  1303. $SenderEmail = $DOM -> getElementsByTagName('senderEmail') -> length > 0 ? $DOM -> getElementsByTagName('senderEmail') -> item(0) -> nodeValue : ''; 
  1304. $StartingDate = $DOM -> getElementsByTagName('startingDate') -> length > 0 ? $DOM -> getElementsByTagName('startingDate') -> item(0) -> nodeValue : ''; 
  1305. $Status = $DOM -> getElementsByTagName('status') -> length > 0 ? $DOM -> getElementsByTagName('status') -> item(0) -> nodeValue : ''; 
  1306.  
  1307. $ResponseDataArray = array( 
  1308. 'Errors' => $Errors,  
  1309. 'Ack' => $Ack,  
  1310. 'Build' => $Build,  
  1311. 'CorrelationID' => $CorrelationID,  
  1312. 'Timestamp' => $Timestamp,  
  1313. 'Approved' => $Approved,  
  1314. 'CancelURL' => $CancelURL,  
  1315. 'CurPayments' => $CurPayments,  
  1316. 'CurPaymentsAmount' => $CurPaymentsAmount,  
  1317. 'CurPeriodAttempts' => $CurPeriodAttempts,  
  1318. 'CurPeriodEndingDate' => $CurPeriodEndingDate,  
  1319. 'CurrencyCode' => $CurrencyCode,  
  1320. 'DateOfMonth' => $DateOfMonth,  
  1321. 'DayOfWeek' => $DayOfWeek,  
  1322. 'EndingDate' => $EndingDate,  
  1323. 'IPNNotificationURL' => $IPNNotificationURL,  
  1324. 'MaxAmountPerPayment' => $MaxAmountPerPayment,  
  1325. 'MaxNumberOfPayments' => $MaxNumberOfPayments,  
  1326. 'MaxNumberOfPaymentsPerPeriod' => $MaxNumberOfPaymentsPerPeriod,  
  1327. 'MaxTotalAmountOfAllPayments' => $MaxTotalAmountOfAllPayments,  
  1328. 'Memo' => $Memo,  
  1329. 'PaymentPeriod' => $PaymentPeriod,  
  1330. 'PinType' => $PinType,  
  1331. 'ReturnUrl' => $ReturnUrl,  
  1332. 'SenderEmail' => $SenderEmail,  
  1333. 'StartingDate' => $StartingDate,  
  1334. 'Status' => $Status,  
  1335. 'XMLRequest' => $XMLRequest,  
  1336. 'XMLResponse' => $XMLResponse 
  1337. ); 
  1338.  
  1339. return $ResponseDataArray; 
  1340.  
  1341. /** 
  1342. * Submit CancelPreapproval API request to PayPal. 
  1343. * @access public 
  1344. * @param array call config data 
  1345. * @return array 
  1346. */ 
  1347. function CancelPreapproval($DataArray) 
  1348. $CancelPreapprovalFields = isset($DataArray['CancelPreapprovalFields']) ? $DataArray['CancelPreapprovalFields'] : array(); 
  1349. $PreapprovalKey = isset($CancelPreapprovalFields['PreapprovalKey']) ? $CancelPreapprovalFields['PreapprovalKey'] : ''; 
  1350.  
  1351. // Generate XML Request 
  1352. $XMLRequest = '<?xml version="1.0" encoding="utf-8"?>'; 
  1353. $XMLRequest .= '<CancelPreapprovalRequest xmlns="' . $this -> XMLNamespace . '">'; 
  1354. $XMLRequest .= $this -> GetXMLRequestEnvelope(); 
  1355. $XMLRequest .= $PreapprovalKey != '' ? '<preapprovalKey xmlns="">' . $PreapprovalKey . '</preapprovalKey>' : ''; 
  1356. $XMLRequest .= '</CancelPreapprovalRequest>'; 
  1357.  
  1358. // Call the API and load XML response into DOM 
  1359. $XMLResponse = $this -> CURLRequest($XMLRequest, 'AdaptivePayments', 'CancelPreapproval'); 
  1360. $DOM = new DOMDocument(); 
  1361. $DOM -> loadXML($XMLResponse); 
  1362.  
  1363. // Parse XML values 
  1364. $Fault = $DOM -> getElementsByTagName('FaultMessage') -> length > 0 ? true : false; 
  1365. $Errors = $this -> GetErrors($XMLResponse); 
  1366. $Ack = $DOM -> getElementsByTagName('ack') -> length > 0 ? $DOM -> getElementsByTagName('ack') -> item(0) -> nodeValue : ''; 
  1367. $Build = $DOM -> getElementsByTagName('build') -> length > 0 ? $DOM -> getElementsByTagName('build') -> item(0) -> nodeValue : ''; 
  1368. $CorrelationID = $DOM -> getElementsByTagName('correlationId') -> length > 0 ? $DOM -> getElementsByTagName('correlationId') -> item(0) -> nodeValue : ''; 
  1369. $Timestamp = $DOM -> getElementsByTagName('timestamp') -> length > 0 ? $DOM -> getElementsByTagName('timestamp') -> item(0) -> nodeValue : ''; 
  1370.  
  1371. $ResponseDataArray = array( 
  1372. 'Errors' => $Errors,  
  1373. 'Ack' => $Ack,  
  1374. 'Build' => $Build,  
  1375. 'CorrelationID' => $CorrelationID,  
  1376. 'Timestamp' => $Timestamp,  
  1377. 'XMLRequest' => $XMLRequest,  
  1378. 'XMLResponse' => $XMLResponse 
  1379. ); 
  1380.  
  1381. return $ResponseDataArray; 
  1382.  
  1383. /** 
  1384. * Submit Refund API request to PayPal. 
  1385. * @access public 
  1386. * @param array call config data 
  1387. * @return array 
  1388. */ 
  1389. function Refund($DataArray) 
  1390. $RefundFields = isset($DataArray['RefundFields']) ? $DataArray['RefundFields'] : array(); 
  1391. $CurrencyCode = isset($RefundFields['CurrencyCode']) ? $RefundFields['CurrencyCode'] : ''; 
  1392. $PayKey = isset($RefundFields['PayKey']) ? $RefundFields['PayKey'] : ''; 
  1393. $TransactionID = isset($RefundFields['TransactionID']) ? $RefundFields['TransactionID'] : ''; 
  1394. $TrackingID = isset($RefundFields['TrackingID']) ? $RefundFields['TrackingID'] : ''; 
  1395.  
  1396. $Receivers = isset($DataArray['Receivers']) ? $DataArray['Receivers'] : array(); 
  1397. $Amount = isset($Receivers['Amount']) ? $Receivers['Amount'] : ''; 
  1398. $Email = isset($Receivers['Email']) ? $Receivers['Email'] : ''; 
  1399. $InvoiceID = isset($Receivers['InvoiceID']) ? $Receivers['InvoiceID'] : ''; 
  1400. $Primary = isset($Receivers['Primary']) ? $Receivers['Primary'] : ''; 
  1401. $PaymentType = isset($Receivers['PaymentType']) ? $Receivers['PaymentType'] : ''; 
  1402.  
  1403. // Generate XML Request 
  1404. $XMLRequest = '<?xml version="1.0" encoding="utf-8"?>'; 
  1405. $XMLRequest .= '<RefundRequest xmlns="' . $this -> XMLNamespace . '">'; 
  1406. $XMLRequest .= $this -> GetXMLRequestEnvelope(); 
  1407. $XMLRequest .= $CurrencyCode != '' ? '<currencyCode xmlns="">' . $CurrencyCode . '</currencyCode>' : ''; 
  1408. $XMLRequest .= $PayKey != '' ? '<payKey xmlns="">' . $PayKey . '</payKey>' : ''; 
  1409.  
  1410. if(!empty($Receivers)) 
  1411. $XMLRequest .= '<receiverList xmlns="">'; 
  1412. foreach($Receivers as $Receiver) 
  1413. $XMLRequest .= '<receiver xmlns="">'; 
  1414. $XMLRequest .= $Receiver['Amount'] != '' ? '<amount xmlns="">' . $Receiver['Amount'] . '</amount>' : ''; 
  1415. $XMLRequest .= $Receiver['Email'] != '' ? '<email xmlns="">' . $Receiver['Email'] . '</email>' : ''; 
  1416. $XMLRequest .= $Receiver['InvoiceID'] != '' ? '<invoiceId xmlns="">' . $Receiver['InvoiceID'] . '</invoiceId>' : ''; 
  1417. $XMLRequest .= $Receiver['PaymentType'] != '' ? '<paymentType xmlns="">' . $Receiver['PaymentType'] . '</paymentType>' : ''; 
  1418. $XMLRequest .= '</receiver>'; 
  1419. $XMLRequest .= '</receiverList>'; 
  1420.  
  1421. $XMLRequest .= $TransactionID != '' ? '<transactionId xmlns="">' . $TransactionID . '</transactionId>' : ''; 
  1422. $XMLRequest .= $TrackingID != '' ? '<trackingId xmlns="">' . $TrackingID . '</trackingId>' : ''; 
  1423. $XMLRequest .= '</RefundRequest>'; 
  1424.  
  1425. // Call the API and load XML response into DOM 
  1426. $XMLResponse = $this -> CURLRequest($XMLRequest, 'AdaptivePayments', 'Refund'); 
  1427. $DOM = new DOMDocument(); 
  1428. $DOM -> loadXML($XMLResponse); 
  1429.  
  1430. // Parse XML values 
  1431. $Fault = $DOM -> getElementsByTagName('FaultMessage') -> length > 0 ? true : false; 
  1432. $Errors = $this -> GetErrors($XMLResponse); 
  1433. $Ack = $DOM -> getElementsByTagName('ack') -> length > 0 ? $DOM -> getElementsByTagName('ack') -> item(0) -> nodeValue : ''; 
  1434. $Build = $DOM -> getElementsByTagName('build') -> length > 0 ? $DOM -> getElementsByTagName('build') -> item(0) -> nodeValue : ''; 
  1435. $CorrelationID = $DOM -> getElementsByTagName('correlationId') -> length > 0 ? $DOM -> getElementsByTagName('correlationId') -> item(0) -> nodeValue : ''; 
  1436. $Timestamp = $DOM -> getElementsByTagName('timestamp') -> length > 0 ? $DOM -> getElementsByTagName('timestamp') -> item(0) -> nodeValue : ''; 
  1437.  
  1438. $EncryptedTransactionID = $DOM -> getElementsByTagName('encryptedRefundTransactionId') -> length > 0 ? $DOM -> getElementsByTagName('encryptedRefundTransactionId') -> item(0) -> nodeValue : ''; 
  1439. $RefundFeeAmount = $DOM -> getElementsByTagName('refundFeeAmount') -> length > 0 ? $DOM -> getElementsByTagName('refundFeeAmount') -> item(0) -> nodeValue : ''; 
  1440. $RefundGrossAmount = $DOM -> getElementsByTagName('refundGrossAmount') -> length > 0 ? $DOM -> getElementsByTagName('refundGrossAmount') -> item(0) -> nodeValue : ''; 
  1441. $RefundHasBecomeFull = $DOM -> getElementsByTagName('refundHasBecomeFull') -> length > 0 ? $DOM -> getElementsByTagName('refundHasBecomeFull') -> item(0) -> nodeValue : ''; 
  1442. $RefundNetAmount = $DOM -> getElementsByTagName('refundNetAmount') -> length > 0 ? $DOM -> getElementsByTagName('refundNetAmount') -> item(0) -> nodeValue : ''; 
  1443. $RefundStatus = $DOM -> getElementsByTagName('refundStatus') -> length > 0 ? $DOM -> getElementsByTagName('refundStatus') -> item(0) -> nodeValue : ''; 
  1444. $RefundTransactionStatus = $DOM -> getElementsByTagName('refundTransactionStatus') -> length > 0 ? $DOM -> getElementsByTagName('refundTransactionStatus') -> item(0) -> nodeValue : ''; 
  1445. $TotalOfAllRefunds = $DOM -> getElementsByTagName('totalOfAllRefunds') -> length > 0 ? $DOM -> getElementsByTagName('totalOfAllRefunds') -> item(0) -> nodeValue : ''; 
  1446.  
  1447. $Amount = $DOM -> getElementsByTagName('amount') -> length > 0 ? $DOM -> getElementsByTagName('amount') -> item(0) -> nodeValue : ''; 
  1448. $Email = $DOM -> getElementsByTagName('email') -> length > 0 ? $DOM -> getElementsByTagName('email') -> item(0) -> nodeValue : ''; 
  1449. $InvoiceID = $DOM -> getElementsByTagName('invoiceId') -> length > 0 ? $DOM -> getElementsByTagName('invoiceId') -> item(0) -> nodeValue : ''; 
  1450. $PaymentType = $DOM -> getElementsByTagName('paymentType') -> length > 0 ? $DOM -> getElementsByTagName('paymentType') -> item(0) -> nodeValue : ''; 
  1451. $Primary = $DOM -> getElementsByTagName('primary') -> length > 0 ? $DOM -> getElementsByTagName('primary') -> item(0) -> nodeValue : ''; 
  1452. $Receiver = array( 
  1453. 'Amount' => $Amount,  
  1454. 'Email' => $Email,  
  1455. 'InvoiceID' => $InvoiceID,  
  1456. 'PaymentType' => $PaymentType,  
  1457. 'Primary' => $Primary 
  1458. ); 
  1459.  
  1460. $ResponseDataArray = array( 
  1461. 'Errors' => $Errors,  
  1462. 'Ack' => $Ack,  
  1463. 'Build' => $Build,  
  1464. 'CorrelationID' => $CorrelationID,  
  1465. 'Timestamp' => $Timestamp,  
  1466. 'EncryptedTransactionID' => $EncryptedTransactionID,  
  1467. 'RefundFeeAmount' => $RefundFeeAmount,  
  1468. 'RefundGrossAmount' => $RefundGrossAmount,  
  1469. 'RefundHasBecomeFull' => $RefundHasBecomeFull,  
  1470. 'RefundNetAmount' => $RefundNetAmount,  
  1471. 'RefundStatus' => $RefundStatus,  
  1472. 'RefundTransactionStatus' => $RefundTransactionStatus,  
  1473. 'TotalOfAllRefunds' => $TotalOfAllRefunds,  
  1474. 'Receiver' => $Receiver,  
  1475. 'RawRequest' => $XMLRequest,  
  1476. 'RawResponse' => $XMLResponse 
  1477. ); 
  1478.  
  1479. return $ResponseDataArray; 
  1480.  
  1481. /** 
  1482. * Submit ConvertCurrency API request to PayPal. 
  1483. * @access public 
  1484. * @param array call config data 
  1485. * @return array 
  1486. */ 
  1487. function ConvertCurrency($DataArray) 
  1488. $BaseAmountList = isset($DataArray['BaseAmountList']) ? $DataArray['BaseAmountList'] : array(); 
  1489. $ConvertToCurrencyList = isset($DataArray['ConvertToCurrencyList']) ? $DataArray['ConvertToCurrencyList'] : array(); 
  1490.  
  1491. // Generate XML Request 
  1492. $XMLRequest = '<?xml version="1.0" encoding="utf-8"?>'; 
  1493. $XMLRequest .= '<ConvertCurrencyRequest xmlns="' . $this -> XMLNamespace . '">'; 
  1494. $XMLRequest .= $this -> GetXMLRequestEnvelope(); 
  1495. $XMLRequest .= '<baseAmountList xmlns="">'; 
  1496. foreach($BaseAmountList as $BaseAmount) 
  1497. $XMLRequest .= '<currency xmlns="">'; 
  1498. $XMLRequest .= '<code xmlns="">' . $BaseAmount['Code'] . '</code>'; 
  1499. $XMLRequest .= '<amount xmlns="">' . $BaseAmount['Amount'] . '</amount>'; 
  1500. $XMLRequest .= '</currency>'; 
  1501. $XMLRequest .= '</baseAmountList>'; 
  1502. $XMLRequest .= '<convertToCurrencyList xmlns="">'; 
  1503.  
  1504. foreach($ConvertToCurrencyList as $CurrencyCode) 
  1505. $XMLRequest .= '<currencyCode xmlns="">' . $CurrencyCode . '</currencyCode>'; 
  1506.  
  1507. $XMLRequest .= '</convertToCurrencyList>'; 
  1508. $XMLRequest .= '</ConvertCurrencyRequest>'; 
  1509.  
  1510. // Call the API and load XML response into DOM 
  1511. $XMLResponse = $this -> CURLRequest($XMLRequest, 'AdaptivePayments', 'ConvertCurrency'); 
  1512. $DOM = new DOMDocument(); 
  1513. $DOM -> loadXML($XMLResponse); 
  1514.  
  1515. // Parse XML values 
  1516. $Fault = $DOM -> getElementsByTagName('FaultMessage') -> length > 0 ? true : false; 
  1517. $Errors = $this -> GetErrors($XMLResponse); 
  1518. $Ack = $DOM -> getElementsByTagName('ack') -> length > 0 ? $DOM -> getElementsByTagName('ack') -> item(0) -> nodeValue : ''; 
  1519. $Build = $DOM -> getElementsByTagName('build') -> length > 0 ? $DOM -> getElementsByTagName('build') -> item(0) -> nodeValue : ''; 
  1520. $CorrelationID = $DOM -> getElementsByTagName('correlationId') -> length > 0 ? $DOM -> getElementsByTagName('correlationId') -> item(0) -> nodeValue : ''; 
  1521. $Timestamp = $DOM -> getElementsByTagName('timestamp') -> length > 0 ? $DOM -> getElementsByTagName('timestamp') -> item(0) -> nodeValue : ''; 
  1522.  
  1523. $CurrencyConversionListArray = array(); 
  1524. $CurrencyConversionListDOM = $DOM -> getElementsByTagName('currencyConversionList') -> length > 0 ? $DOM -> getElementsByTagName('currencyConversionList') : array(); 
  1525.  
  1526. foreach($CurrencyConversionListDOM as $CurrencyConversionList) 
  1527. $BaseAmountDOM = $CurrencyConversionList -> getElementsByTagName('baseAmount') -> length > 0 ? $CurrencyConversionList -> getElementsByTagName('baseAmount') : array();  
  1528. foreach($BaseAmountDOM as $BaseAmount) 
  1529. $BaseAmountCurrencyCode = $BaseAmount -> getElementsByTagName('code') -> length > 0 ? $BaseAmount -> getElementsByTagName('code') -> item(0) -> nodeValue : ''; 
  1530. $BaseAmountValue = $BaseAmount -> getElementsByTagName('amount') -> length > 0 ? $BaseAmount -> getElementsByTagName('amount') -> item(0) -> nodeValue : ''; 
  1531. $BaseAmountArray = array( 
  1532. 'Code' => $BaseAmountCurrencyCode,  
  1533. 'Amount' => $BaseAmountValue 
  1534. ); 
  1535.  
  1536. $CurrencyListArray = array(); 
  1537. $CurrencyListDOM = $CurrencyConversionList -> getElementsByTagName('currency') -> length > 0 ? $CurrencyConversionList -> getElementsByTagName('currency') : array(); 
  1538. foreach($CurrencyListDOM as $CurrencyList) 
  1539. $ListCurrencyCode = $CurrencyList -> getElementsByTagName('code') -> length > 0 ? $CurrencyList -> getElementsByTagName('code') -> item(0) -> nodeValue : ''; 
  1540. $ListCurrencyAmount = $CurrencyList -> getElementsByTagName('amount') -> length > 0 ? $CurrencyList -> getElementsByTagName('amount') -> item(0) -> nodeValue : ''; 
  1541. $ListCurrencyCurrent = array( 
  1542. 'Code' => $ListCurrencyCode,  
  1543. 'Amount' => $ListCurrencyAmount 
  1544. ); 
  1545. array_push($CurrencyListArray, $ListCurrencyCurrent); 
  1546.  
  1547. $CurrencyConversionListCurrent = array( 
  1548. 'BaseAmount' => $BaseAmountArray,  
  1549. 'CurrencyList' => $CurrencyListArray 
  1550. ); 
  1551.  
  1552. array_push($CurrencyConversionListArray, $CurrencyConversionListCurrent); 
  1553.  
  1554. $ResponseDataArray = array( 
  1555. 'Errors' => $Errors,  
  1556. 'Ack' => $Ack,  
  1557. 'Build' => $Build,  
  1558. 'CorrelationID' => $CorrelationID,  
  1559. 'Timestamp' => $Timestamp,  
  1560. 'CurrencyConversionList' => $CurrencyConversionListArray,  
  1561. 'XMLRequest' => $XMLRequest,  
  1562. 'XMLResponse' => $XMLResponse 
  1563. ); 
  1564.  
  1565. return $ResponseDataArray; 
  1566.  
  1567. /** 
  1568. * Submit CreateAccount API request to PayPal. 
  1569. * @access public 
  1570. * @param array call config data 
  1571. * @return array 
  1572. */ 
  1573. function CreateAccount($DataArray) 
  1574. $CreateAccountFields = isset($DataArray['CreateAccountFields']) ? $DataArray['CreateAccountFields'] : array(); 
  1575. $AccountType = isset($CreateAccountFields['AccountType']) ? $CreateAccountFields['AccountType'] : ''; 
  1576. $CitizenshipCountryCode = isset($CreateAccountFields['CitizenshipCountryCode']) ? $CreateAccountFields['CitizenshipCountryCode'] : ''; 
  1577. $ContactPhoneNumber = isset($CreateAccountFields['ContactPhoneNumber']) ? $CreateAccountFields['ContactPhoneNumber'] : ''; 
  1578. $HomePhoneNumber = isset($CreateAccountFields['HomePhoneNumber']) ? $CreateAccountFields['HomePhoneNumber'] : ''; 
  1579. $MobilePhoneNumber = isset($CreateAccountFields['MobilePhoneNumber']) ? $CreateAccountFields['MobilePhoneNumber'] : ''; 
  1580. $CurrencyCode = isset($CreateAccountFields['CurrencyCode']) ? $CreateAccountFields['CurrencyCode'] : ''; 
  1581. $DateOfBirth = isset($CreateAccountFields['DateOfBirth']) ? $CreateAccountFields['DateOfBirth'] : ''; 
  1582. $EmailAddress = isset($CreateAccountFields['EmailAddress']) ? $CreateAccountFields['EmailAddress'] : ''; 
  1583. $Salutation = isset($CreateAccountFields['Salutation']) ? $CreateAccountFields['Salutation'] : ''; 
  1584. $FirstName = isset($CreateAccountFields['FirstName']) ? $CreateAccountFields['FirstName'] : ''; 
  1585. $MiddleName = isset($CreateAccountFields['MiddleName']) ? $CreateAccountFields['MiddleName'] : ''; 
  1586. $LastName = isset($CreateAccountFields['LastName']) ? $CreateAccountFields['LastName'] : ''; 
  1587. $Suffix = isset($CreateAccountFields['Suffix']) ? $CreateAccountFields['Suffix'] : ''; 
  1588. $NotificationURL = isset($CreateAccountFields['NotificationURL']) ? $CreateAccountFields['NotificationURL'] : ''; 
  1589. $PerformExtraVettingOnThisAccount = isset($CreateAccountFields['PerformExtraVettingOnThisAccount']) ? $CreateAccountFields['PerformExtraVettingOnThisAccount'] : '';  
  1590. $PreferredLanguageCode = isset($CreateAccountFields['PreferredLanguageCode']) && $CreateAccountFields['PreferredLanguageCode'] != '' ? $CreateAccountFields['PreferredLanguageCode'] : 'en_US'; 
  1591. $RegistrationType = isset($CreateAccountFields['RegistrationType']) ? $CreateAccountFields['RegistrationType'] : 'Web'; 
  1592. $SuppressWelcomeEmail = isset($CreateAccountFields['SuppressWelcomeEmail']) ? $CreateAccountFields['SuppressWelcomeEmail'] : ''; 
  1593. $TaxID = isset($CreateAccountFields['TaxID']) ? $CreateAccountFields['TaxID'] : ''; 
  1594.  
  1595. $ReturnURL = isset($CreateAccountFields['ReturnURL']) ? $CreateAccountFields['ReturnURL'] : ''; 
  1596. $ShowAddCreditCard = isset($CreateAccountFields['ShowAddCreditCard']) ? $CreateAccountFields['ShowAddCreditCard'] : ''; 
  1597. $ShowMobileConfirm = isset($CreateAccountFields['ShowMobileConfirm']) ? $CreateAccountFields['ShowMobileConfirm'] : ''; 
  1598. $ReturnURLDescription = isset($CreateAccountFields['ReturnURLDescription']) ? $CreateAccountFields['ReturnURLDescription'] : ''; 
  1599. $UseMiniBrowser = isset($CreateAccountFields['UseMiniBrowser']) ? $CreateAccountFields['UseMiniBrowser'] : ''; 
  1600.  
  1601. $Address = isset($DataArray['Address']) ? $DataArray['Address'] : array(); 
  1602. $Line1 = isset($Address['Line1']) ? $Address['Line1'] : ''; 
  1603. $Line2 = isset($Address['Line2']) ? $Address['Line2'] : ''; 
  1604. $City = isset($Address['City']) ? $Address['City'] : ''; 
  1605. $State = isset($Address['State']) ? $Address['State'] : ''; 
  1606. $PostalCode = isset($Address['PostalCode']) ? $Address['PostalCode'] : ''; 
  1607. $CountryCode = isset($Address['CountryCode']) ? $Address['CountryCode'] : ''; 
  1608.  
  1609. $BusinessInfo = isset($DataArray['BusinessInfo']) ? $DataArray['BusinessInfo'] : array(); 
  1610. $AveragePrice = isset($BusinessInfo['AveragePrice']) ? $BusinessInfo['AveragePrice'] : ''; 
  1611. $AverageMonthlyVolume = isset($BusinessInfo['AverageMonthlyVolume']) ? $BusinessInfo['AverageMonthlyVolume'] : ''; 
  1612. $BusinessName = isset($BusinessInfo['BusinessName']) ? $BusinessInfo['BusinessName'] : ''; 
  1613. $BusinessType = isset($BusinessInfo['BusinessType']) ? $BusinessInfo['BusinessType'] : ''; 
  1614. $BusinessSubType = isset($BusinessInfo['BusinessSubType']) ? $BusinessInfo['BusinessSubType'] : ''; 
  1615. $Category = isset($BusinessInfo['Category']) ? $BusinessInfo['Category'] : ''; 
  1616. $CommercialRegistrationLocation = isset($BusinessInfo['CommercialRegistrationLocation']) ? $BusinessInfo['CommercialRegistrationLocation'] : ''; 
  1617. $CompanyID = isset($BusinessInfo['CompanyID']) ? $BusinessInfo['CompanyID'] : ''; 
  1618. $CustomerServiceEmail = isset($BusinessInfo['CustomerServiceEmail']) ? $BusinessInfo['CustomerServiceEmail'] : ''; 
  1619. $CustomerServicePhone = isset($BusinessInfo['CustomerServicePhone']) ? $BusinessInfo['CustomerServicePhone'] : ''; 
  1620. $DateOfEstablishment = isset($BusinessInfo['DateOfEstablishment']) ? $BusinessInfo['DateOfEstablishment'] : ''; 
  1621. $DisputeEmail = isset($BusinessInfo['DisputeEmail']) ? $BusinessInfo['DisputeEmail'] : ''; 
  1622. $DoingBusinessAs = isset($BusinessInfo['DoingBusinessAs']) ? $BusinessInfo['DoingBusinessAs'] : ''; 
  1623. $EstablishmentCountryCode = isset($BusinessInfo['EstablishmentCountryCode']) ? $BusinessInfo['EstablishmentCountryCode'] : ''; 
  1624. $EstablishmentState = isset($BusinessInfo['EstablishmentState']) ? $BusinessInfo['EstablishmentState'] : ''; 
  1625. $IncorporationID = isset($BusinessInfo['IncorporationID']) ? $BusinessInfo['IncorporationID'] : ''; 
  1626. $MerchantCategoryCode = isset($BusinessInfo['MerchantCategoryCode']) ? $BusinessInfo['MerchantCategoryCode'] : ''; 
  1627. $PercentageRevenueFromOnline = isset($BusinessInfo['PercentageRevenueFromOnline']) ? $BusinessInfo['PercentageRevenueFromOnline'] : ''; 
  1628. $SalesVenu = isset($BusinessInfo['SalesVenu']) ? $BusinessInfo['SalesVenu'] : ''; 
  1629. $SalesVenuDesc = isset($BusinessInfo['SalesVenuDesc']) ? $BusinessInfo['SalesVenuDesc'] : ''; 
  1630. $SubCategory = isset($BusinessInfo['SubCategory']) ? $BusinessInfo['SubCategory'] : ''; 
  1631. $VatCountryCode = isset($BusinessInfo['VatCountryCode']) ? $BusinessInfo['VatCountryCode'] : ''; 
  1632. $VatID = isset($BusinessInfo['VatID']) ? $BusinessInfo['VatID'] : ''; 
  1633. $WebSite = isset($BusinessInfo['WebSite']) ? $BusinessInfo['WebSite'] : ''; 
  1634. $WorkPhone = isset($BusinessInfo['WorkPhone']) ? $BusinessInfo['WorkPhone'] : ''; 
  1635.  
  1636. $BusinessAddress = isset($DataArray['BusinessAddress']) ? $DataArray['BusinessAddress'] : array(); 
  1637. $BusinessAddressLine1 = isset($BusinessAddress['Line1']) ? $BusinessAddress['Line1'] : ''; 
  1638. $BusinessAddressLine2 = isset($BusinessAddress['Line2']) ? $BusinessAddress['Line2'] : ''; 
  1639. $BusinessAddressCity = isset($BusinessAddress['City']) ? $BusinessAddress['City'] : ''; 
  1640. $BusinessAddressState = isset($BusinessAddress['State']) ? $BusinessAddress['State'] : ''; 
  1641. $BusinessAddressPostalCode = isset($BusinessAddress['PostalCode']) ? $BusinessAddress['PostalCode'] : ''; 
  1642. $BusinessAddressCountryCode = isset($BusinessAddress['CountryCode']) ? $BusinessAddress['CountryCode'] : ''; 
  1643.  
  1644. $PrinciplePlaceOfBusinessAddress = isset($DataArray['PrinciplePlaceOfBusinessAddress']) ? $DataArray['PrinciplePlaceOfBusinessAddress'] : array(); 
  1645. $PrinciplePlaceOfBusinessAddressLine1 = isset($PrinciplePlaceOfBusinessAddress['Line1']) ? $PrinciplePlaceOfBusinessAddress['Line1'] : ''; 
  1646. $PrinciplePlaceOfBusinessAddressLine2 = isset($PrinciplePlaceOfBusinessAddress['Line2']) ? $PrinciplePlaceOfBusinessAddress['Line2'] : ''; 
  1647. $PrinciplePlaceOfBusinessAddressCity = isset($PrinciplePlaceOfBusinessAddress['City']) ? $PrinciplePlaceOfBusinessAddress['City'] : ''; 
  1648. $PrinciplePlaceOfBusinessAddressState = isset($PrinciplePlaceOfBusinessAddress['State']) ? $PrinciplePlaceOfBusinessAddress['State'] : ''; 
  1649. $PrinciplePlaceOfBusinessAddressPostalCode = isset($PrinciplePlaceOfBusinessAddress['PostalCode']) ? $PrinciplePlaceOfBusinessAddress['PostalCode'] : ''; 
  1650. $PrinciplePlaceOfBusinessAddressCountryCode = isset($PrinciplePlaceOfBusinessAddress['CountryCode']) ? $PrinciplePlaceOfBusinessAddress['CountryCode'] : ''; 
  1651.  
  1652. $RegisteredOfficeAddress = isset($DataArray['RegisteredOfficeAddress']) ? $DataArray['RegisteredOfficeAddress'] : array(); 
  1653. $RegisteredOfficeAddressLine1 = isset($RegisteredOfficeAddress['Line1']) ? $RegisteredOfficeAddress['Line1'] : ''; 
  1654. $RegisteredOfficeAddressLine2 = isset($RegisteredOfficeAddress['Line2']) ? $RegisteredOfficeAddress['Line2'] : ''; 
  1655. $RegisteredOfficeAddressCity = isset($RegisteredOfficeAddress['City']) ? $RegisteredOfficeAddress['City'] : ''; 
  1656. $RegisteredOfficeAddressState = isset($RegisteredOfficeAddress['State']) ? $RegisteredOfficeAddress['State'] : ''; 
  1657. $RegisteredOfficeAddressPostalCode = isset($RegisteredOfficeAddress['PostalCode']) ? $RegisteredOfficeAddress['PostalCode'] : ''; 
  1658. $RegisteredOfficeAddressCountryCode = isset($RegisteredOfficeAddress['CountryCode']) ? $RegisteredOfficeAddress['CountryCode'] : ''; 
  1659.  
  1660. $BusinessStakeHolder = isset($DataArray['BusinessStakeHolder']) ? $DataArray['BusinessStakeHolder'] : array(); 
  1661. $BusinessStakeHolderDateOfBirth = isset($BusinessStakeHolder['DateOfBirth']) ? $BusinessStakeHolder['DateOfBirth'] : ''; 
  1662. $BusinessStakeHolderFullLegalName = isset($BusinessStakeHolder['FullLegalName']) ? $BusinessStakeHolder['FullLegalName'] : ''; 
  1663. $BusinessStakeHolderSalutation = isset($BusinessStakeHolder['Salutation']) ? $BusinessStakeHolder['Salutation'] : ''; 
  1664. $BusinessStakeHolderFirstName = isset($BusinessStakeHolder['FirstName']) ? $BusinessStakeHolder['FirstName'] : ''; 
  1665. $BusinessStakeHolderMiddleName = isset($BusinessStakeHolder['MiddleName']) ? $BusinessStakeHolder['MiddleName'] : ''; 
  1666. $BusinessStakeHolderLastName = isset($BusinessStakeHolder['LastName']) ? $BusinessStakeHolder['LastName'] : ''; 
  1667. $BusinessStakeHolderSuffix = isset($BusinessStakeHolder['Suffix']) ? $BusinessStakeHolder['Suffix'] : ''; 
  1668. $BusinessStakeHolderRole = isset($BusinessStakeHolder['Role']) ? $BusinessStakeHolder['Role'] : ''; 
  1669. $BusinessStakeHolderCountryCode = isset($BusinessStakeHolder['CountryCode']) ? $BusinessStakeHolder['CountryCode'] : ''; 
  1670.  
  1671. $BusinessStakeHolderAddress = isset($DataArray['BusinessStakeHolderAddress']) ? $DataArray['BusinessStakeHolderAddress'] : array(); 
  1672. $BusinessStakeHolderAddressLine1 = isset($BusinessStakeHolderAddress['Line1']) ? $BusinessStakeHolderAddress['Line1'] : ''; 
  1673. $BusinessStakeHolderAddressLine2 = isset($BusinessStakeHolderAddress['Line2']) ? $BusinessStakeHolderAddress['Line2'] : ''; 
  1674. $BusinessStakeHolderAddressCity = isset($BusinessStakeHolderAddress['City']) ? $BusinessStakeHolderAddress['City'] : ''; 
  1675. $BusinessStakeHolderAddressState = isset($BusinessStakeHolderAddress['State']) ? $BusinessStakeHolderAddress['State'] : ''; 
  1676. $BusinessStakeHolderAddressPostalCode = isset($BusinessStakeHolderAddress['PostalCode']) ? $BusinessStakeHolderAddress['PostalCode'] : ''; 
  1677. $BusinessStakeHolderAddressCountryCode = isset($BusinessStakeHolderAddress['CountryCode']) ? $BusinessStakeHolderAddress['CountryCode'] : ''; 
  1678.  
  1679. $PartnerFields = isset($DataArray['PartnerFields']) ? $DataArray['PartnerFields'] : array(); 
  1680. $PartnerField1 = isset($PartnerFields['Field1']) ? $PartnerFields['Field1'] : ''; 
  1681. $PartnerField2 = isset($PartnerFields['Field2']) ? $PartnerFields['Field2'] : ''; 
  1682. $PartnerField3 = isset($PartnerFields['Field3']) ? $PartnerFields['Field3'] : ''; 
  1683. $PartnerField4 = isset($PartnerFields['Field4']) ? $PartnerFields['Field4'] : ''; 
  1684. $PartnerField5 = isset($PartnerFields['Field5']) ? $PartnerFields['Field5'] : ''; 
  1685.  
  1686. // Generate XML Request 
  1687. $XMLRequest = '<?xml version="1.0" encoding="utf-8"?>'; 
  1688. $XMLRequest .= '<CreateAccountRequest xmlns="' . $this -> XMLNamespace . '">'; 
  1689. $XMLRequest .= $this -> GetXMLRequestEnvelope(); 
  1690. $XMLRequest .= $AccountType != '' ? '<accountType xmlns="">' . $AccountType . '</accountType>' : ''; 
  1691. $XMLRequest .= $EmailAddress != '' ? '<emailAddress xmlns="">' . $EmailAddress . '</emailAddress>' : ''; 
  1692.  
  1693. if($Salutation != '' || $FirstName != '' || $MiddleName != '' || $LastName != '' || $Suffix != '') 
  1694. $XMLRequest .= '<name xmlns="">'; 
  1695. $XMLRequest .= $Salutation != '' ? '<salutation xmlns="">' . $Salutation . '</salutation>' : ''; 
  1696. $XMLRequest .= $FirstName != '' ? '<firstName xmlns="">' . $FirstName . '</firstName>' : ''; 
  1697. $XMLRequest .= $MiddleName != '' ? '<middleName xmlns="">' . $MiddleName . '</middleName>' : ''; 
  1698. $XMLRequest .= $LastName != '' ? '<lastName xmlns="">' . $LastName . '</lastName>' : ''; 
  1699. $XMLRequest .= $Suffix != '' ? '<suffix xmlns="">' . $Suffix . '</suffix>' : ''; 
  1700. $XMLRequest .= '</name>'; 
  1701.  
  1702. $XMLRequest .= $DateOfBirth != '' ? '<dateOfBirth xmlns="">' . $DateOfBirth . '</dateOfBirth>' : ''; 
  1703.  
  1704. if(!empty($Address)) 
  1705. $XMLRequest .= '<address xmlns="">'; 
  1706. $XMLRequest .= $Line1 != '' ? '<line1 xmlns="">' . $Line1 . '</line1>' : ''; 
  1707. $XMLRequest .= $Line2 != '' ? '<line2 xmlns="">' . $Line2 . '</line2>' : ''; 
  1708. $XMLRequest .= $City != '' ? '<city xmlns="">' . $City . '</city>' : ''; 
  1709. $XMLRequest .= $State != '' ? '<state xmlns="">' . $State . '</state>' : ''; 
  1710. $XMLRequest .= $PostalCode != '' ? '<postalCode xmlns="">' . $PostalCode . '</postalCode>' : ''; 
  1711. $XMLRequest .= $CountryCode != '' ? '<countryCode xmlns="">' . $CountryCode . '</countryCode>' : ''; 
  1712. $XMLRequest .= '</address>'; 
  1713.  
  1714. $XMLRequest .= $ContactPhoneNumber != '' ? '<contactPhoneNumber xmlns="">' . $ContactPhoneNumber . '</contactPhoneNumber>' : ''; 
  1715. $XMLRequest .= $HomePhoneNumber != '' ? '<homePhoneNumber xmlns="">' . $HomePhoneNumber . '</homePhoneNumber>' : ''; 
  1716. $XMLRequest .= $MobilePhoneNumber != '' ? '<mobilePhoneNumber xmlns="">' . $MobilePhoneNumber . '</mobilePhoneNumber>' : ''; 
  1717. $XMLRequest .= $CurrencyCode != '' ? '<currencyCode xmlns="">' . $CurrencyCode . '</currencyCode>' : ''; 
  1718. $XMLRequest .= $CitizenshipCountryCode != '' ? '<citizenshipCountryCode xmlns="">' . $CitizenshipCountryCode . '</citizenshipCountryCode>' : ''; 
  1719. $XMLRequest .= $PreferredLanguageCode != '' ? '<preferredLanguageCode xmlns="">' . $PreferredLanguageCode . '</preferredLanguageCode>' : ''; 
  1720. $XMLRequest .= $NotificationURL != '' ? '<notificationURL xmlns="">' . $NotificationURL . '</notificationURL>' : ''; 
  1721. $XMLRequest .= $PartnerField1 != '' ? '<partnerField1 xmlns="">' . $PartnerField1 . '</partnerField1>' : ''; 
  1722. $XMLRequest .= $PartnerField2 != '' ? '<partnerField2 xmlns="">' . $PartnerField2 . '</partnerField2>' : ''; 
  1723. $XMLRequest .= $PartnerField3 != '' ? '<partnerField3 xmlns="">' . $PartnerField3 . '</partnerField3>' : ''; 
  1724. $XMLRequest .= $PartnerField4 != '' ? '<partnerField4 xmlns="">' . $PartnerField4 . '</partnerField4>' : ''; 
  1725. $XMLRequest .= $PartnerField5 != '' ? '<partnerField5 xmlns="">' . $PartnerField5 . '</partnerField5>' : ''; 
  1726. $XMLRequest .= $RegistrationType != '' ? '<registrationType xmlns="">' . $RegistrationType . '</registrationType>' : ''; 
  1727. $XMLRequest .= $SuppressWelcomeEmail != '' ? '<suppressWelcomeEmail xmlns="">' . $SuppressWelcomeEmail . '</suppressWelcomeEmail>' : ''; 
  1728. $XMLRequest .= $PerformExtraVettingOnThisAccount != '' ? '<performExtraVettingOnthisAccount xmlns="">' . $PerformExtraVettingOnThisAccount . '</performExtraVettingOnthisAccount>' : ''; 
  1729. $XMLRequest .= $TaxID != '' ? '<taxId xmlns="">' . $TaxID . '</taxId>' : ''; 
  1730.  
  1731. if($ReturnURL != '' || $ReturnURLDescription != '' || $ShowAddCreditCard != '' || $ShowMobileConfirm != '' || $UseMiniBrowser != '') 
  1732. $XMLRequest .= '<createAccountWebOptions xmlns="">'; 
  1733. $XMLRequest .= $ReturnURL != '' ? '<returnUrl xmlns="">' . $ReturnURL . '</returnUrl>' : ''; 
  1734. $XMLRequest .= $ReturnURLDescription != '' ? '<returnUrlDescription xmlns="">' . $ReturnURLDescription . '</returnUrlDescription>' : ''; 
  1735. $XMLRequest .= $ShowAddCreditCard != '' ? '<showAddCreditCard xmlns="">' . $ShowAddCreditCard . '</showAddCreditCard>' : ''; 
  1736. $XMLRequest .= $ShowMobileConfirm != '' ? '<showMobileConfirm xmlns="">' . $ShowMobileConfirm . '</showMobileConfirm>' : ''; 
  1737. $XMLRequest .= $UseMiniBrowser != '' ? '<useMiniBrowser xmlns="">' . $UseMiniBrowser . '</useMiniBrowser>' : ''; 
  1738. $XMLRequest .= '</createAccountWebOptions>'; 
  1739.  
  1740. if(!empty($BusinessInfo)) 
  1741. $XMLRequest .= '<businessInfo xmlns="">'; 
  1742. $XMLRequest .= $BusinessName != '' ? '<businessName xmlns="">'. $BusinessName . '</businessName>' : ''; 
  1743.  
  1744. if(!empty($BusinessAddress)) 
  1745. $XMLRequest .= '<businessAddress xmlns="">'; 
  1746. $XMLRequest .= $BusinessAddressLine1 != '' ? '<line1 xmlns="">' . $BusinessAddressLine1 . '</line1>' : ''; 
  1747. $XMLRequest .= $BusinessAddressLine2 != '' ? '<line2 xmlns="">' . $BusinessAddressLine2 . '</line2>' : ''; 
  1748. $XMLRequest .= $BusinessAddressCity != '' ? '<city xmlns="">' . $BusinessAddressCity . '</city>' : ''; 
  1749. $XMLRequest .= $BusinessAddressState != '' ? '<state xmlns="">' . $BusinessAddressState . '</state>' : ''; 
  1750. $XMLRequest .= $BusinessAddressPostalCode != '' ? '<postalCode xmlns="">' . $BusinessAddressPostalCode . '</postalCode>' : ''; 
  1751. $XMLRequest .= $BusinessAddressCountryCode != '' ? '<countryCode xmlns="">' . $BusinessAddressCountryCode . '</countryCode>' : ''; 
  1752. $XMLRequest .= '</businessAddress>'; 
  1753.  
  1754. $XMLRequest .= $WorkPhone != '' ? '<workPhone xmlns="">'. $WorkPhone . '</workPhone>' : ''; 
  1755. $XMLRequest .= $Category != '' ? '<category xmlns="">' . $Category . '</category>' : ''; 
  1756. $XMLRequest .= $SubCategory != '' ? '<subCategory xmlns="">'. $SubCategory . '</subCategory>' : ''; 
  1757. $XMLRequest .= $MerchantCategoryCode != '' ? '<merchantCategoryCode xmlns="">' . $MerchantCategoryCode . '</merchantCategoryCode>' : ''; 
  1758. $XMLRequest .= $DoingBusinessAs != '' ? '<doingBusinessAs xmlns="">' . $DoingBusinessAs . '</doingBusinessAs>' : ''; 
  1759. $XMLRequest .= $CustomerServicePhone != '' ? '<customerServicePhone xmlns="">' . $CustomerServicePhone . '</customerServicePhone>' : ''; 
  1760. $XMLRequest .= $CustomerServiceEmail != '' ? '<customerServiceEmail xmlns="">' . $CustomerServiceEmail . '</customerServiceEmail>' : ''; 
  1761. $XMLRequest .= $DisputeEmail != '' ? '<disputeEmail xmlns="">'. $DisputeEmail . '</disputeEmail>' : ''; 
  1762. $XMLRequest .= $WebSite != '' ? '<webSite xmlns="">' . $WebSite . '</webSite>' : ''; 
  1763. $XMLRequest .= $CompanyID != '' ? '<companyId xmlns="">' . $CompanyID . '</companyId>' : ''; 
  1764. $XMLRequest .= $DateOfEstablishment != '' ? '<dateOfEstablishment xmlns="">' . $DateOfEstablishment . '</dateOfEstablishment>' : ''; 
  1765. $XMLRequest .= $BusinessType != '' ? '<businessType xmlns="">' . $BusinessType . '</businessType>' : ''; 
  1766. $XMLRequest .= $BusinessSubType != '' ? '<businessSubType xmlns="">' . $BusinessSubType . '</businessSubType>' : ''; 
  1767. $XMLRequest .= $IncorporationID != '' ? '<incorporationId xmlns="">' . $IncorporationID . '</incorporationId>' : ''; 
  1768. $XMLRequest .= $AveragePrice != '' ? '<averagePrice xmlns="">' . $AveragePrice . '</averagePrice>' : ''; 
  1769. $XMLRequest .= $AverageMonthlyVolume != '' ? '<averageMonthlyVolume xmlns="">' . $AverageMonthlyVolume . '</averageMonthlyVolume>' : ''; 
  1770. $XMLRequest .= $PercentageRevenueFromOnline != '' ? '<percentageRevenueFromOnline xmlns="">' . $PercentageRevenueFromOnline . '</percentageRevenueFromOnline>' : ''; 
  1771. $XMLRequest .= $SalesVenu != '' ? '<salesVenue xmlns="">' . $SalesVenu . '</salesVenue>' : ''; 
  1772. $XMLRequest .= $SalesVenuDesc != '' ? '<salesVenueDesc xmlns="">' . $SalesVenuDesc . '</salesVenueDesc>' : ''; 
  1773. $XMLRequest .= $VatID != '' ? '<vatId xmlns="">' . $VatID . '</vatId>' : ''; 
  1774. $XMLRequest .= $VatCountryCode != '' ? '<vatCountryCode xmlns="">' . $VatCountryCode . '</vatCountryCode>' : ''; 
  1775. $XMLRequest .= $CommercialRegistrationLocation != '' ? '<commercialRegistrationLocation xmlns="">' . $CommercialRegistrationLocation . '</commercialRegistrationLocation>' : ''; 
  1776.  
  1777. if(!empty($PrinciplePlaceOfBusinessAddress)) 
  1778. $XMLRequest .= '<principlePlaceOfBusinessAddress xmlns="">'; 
  1779. $XMLRequest .= $PrinciplePlaceOfBusinessAddressLine1 != '' ? '<line1 xmlns="">' . $PrinciplePlaceOfBusinessAddressLine1 . '</line1>' : ''; 
  1780. $XMLRequest .= $PrinciplePlaceOfBusinessAddressLine2 != '' ? '<line2 xmlns="">' . $PrinciplePlaceOfBusinessAddressLine2 . '</line2>' : ''; 
  1781. $XMLRequest .= $PrinciplePlaceOfBusinessAddressCity != '' ? '<city xmlns="">' . $PrinciplePlaceOfBusinessAddressCity . '</city>' : ''; 
  1782. $XMLRequest .= $PrinciplePlaceOfBusinessAddressState != '' ? '<state xmlns="">' . $PrinciplePlaceOfBusinessAddressState . '</state>' : ''; 
  1783. $XMLRequest .= $PrinciplePlaceOfBusinessAddressPostalCode != '' ? '<postalCode xmlns="">' . $PrinciplePlaceOfBusinessAddressPostalCode . '</postalCode>' : ''; 
  1784. $XMLRequest .= $PrinciplePlaceOfBusinessAddressCountryCode != '' ? '<countryCode xmlns="">' . $PrinciplePlaceOfBusinessAddressCountryCode . '</countryCode>' : ''; 
  1785. $XMLRequest .= '</principlePlaceOfBusinessAddress>'; 
  1786.  
  1787. if(!empty($RegisteredOfficeAddress)) 
  1788. $XMLRequest .= '<registeredOfficeAddress xmlns="">'; 
  1789. $XMLRequest .= $RegisteredOfficeAddressLine1 != '' ? '<line1 xmlns="">' . $RegisteredOfficeAddressLine1 . '</line1>' : ''; 
  1790. $XMLRequest .= $RegisteredOfficeAddressLine2 != '' ? '<line2 xmlns="">' . $RegisteredOfficeAddressLine2 . '</line2>' : ''; 
  1791. $XMLRequest .= $RegisteredOfficeAddressCity != '' ? '<city xmlns="">' . $RegisteredOfficeAddressCity . '</city>' : ''; 
  1792. $XMLRequest .= $RegisteredOfficeAddressState != '' ? '<state xmlns="">' . $RegisteredOfficeAddressState . '</state>' : ''; 
  1793. $XMLRequest .= $RegisteredOfficeAddressPostalCode != '' ? '<postalCode xmlns="">' . $RegisteredOfficeAddressPostalCode . '</postalCode>' : ''; 
  1794. $XMLRequest .= $RegisteredOfficeAddressCountryCode != '' ? '<countryCode xmlns="">' . $RegisteredOfficeAddressCountryCode . '</countryCode>' : '';  
  1795. $XMLRequest .= '</registeredOfficeAddress>'; 
  1796.  
  1797. $XMLRequest .= $EstablishmentCountryCode != '' ? '<establishmentCountryCode xmlns="">' . $EstablishmentCountryCode . '</establishmentCountryCode>' : ''; 
  1798. $XMLRequest .= $EstablishmentState != '' ? '<establishmentState xmlns="">' . $EstablishmentState . '</establishmentState>' : ''; 
  1799.  
  1800. if(!empty($BusinessStakeHolder)) 
  1801. $XMLRequest .= '<businessStakeHolder xmlns="">'; 
  1802. $XMLRequest .= $BusinessStakeHolderRole != '' ? '<role xmlns="">' . $BusinessStakeHolderRole . '</role>' : ''; 
  1803.  
  1804. if($BusinessStakeHolderSalutation != '' || $BusinessStakeHolderFirstName != '' || $BusinessStakeHolderMiddleName != '' || $BusinessStakeHolderLastName != '' || $BusinessStakeHolderSuffix != '') 
  1805. $XMLRequest .= '<name xmlns="">'; 
  1806. $XMLRequest .= $BusinessStakeHolderSalutation != '' ? '<salutation xmlns="">' . $BusinessStakeHolderSalutation . '</salutation>' : ''; 
  1807. $XMLRequest .= $BusinessStakeHolderFirstName != '' ? '<firstName xmlns="">' . $BusinessStakeHolderFirstName . '</firstName>' : ''; 
  1808. $XMLRequest .= $BusinessStakeHolderMiddleName != '' ? '<middleName xmlns="">' . $BusinessStakeHolderMiddleName . '</middleName>' : ''; 
  1809. $XMLRequest .= $BusinessStakeHolderLastName != '' ? '<lastName xmlns="">' . $BusinessStakeHolderLastName . '</lastName>' : ''; 
  1810. $XMLRequest .= $BusinessStakeHolderSuffix != '' ? '<suffix xmlns="">' . $BusinessStakeHolderSuffix . '</suffix>' : '';  
  1811. $XMLRequest .= '</name>'; 
  1812.  
  1813. $XMLRequest .= $BusinessStakeHolderFullLegalName != '' ? '<fullLegalName xmlns="">' . $BusinessStakeHolderFullLegalName . '</fullLegalName>' : ''; 
  1814.  
  1815. if(!empty($BusinessStakeHolderAddress)) 
  1816. $XMLRequest .= '<address xmlns="">'; 
  1817. $XMLRequest .= $BusinessStakeHolderAddressLine1 != '' ? '<line1 xmlns="">' . $BusinessStakeHolderAddressLine1 . '</line1>' : ''; 
  1818. $XMLRequest .= $BusinessStakeHolderAddressLine2 != '' ? '<line2 xmlns="">' . $BusinessStakeHolderAddressLine2 . '</line2>' : ''; 
  1819. $XMLRequest .= $BusinessStakeHolderAddressCity != '' ? '<city xmlns="">' . $BusinessStakeHolderAddressCity . '</city>' : ''; 
  1820. $XMLRequest .= $BusinessStakeHolderAddressState != '' ? '<state xmlns="">' . $BusinessStakeHolderAddressState . '</state>' : ''; 
  1821. $XMLRequest .= $BusinessStakeHolderAddressPostalCode != '' ? '<postalCode xmlns="">' . $BusinessStakeHolderAddressPostalCode . '</postalCode>' : ''; 
  1822. $XMLRequest .= $BusinessStakeHolderAddressCountryCode != '' ? '<countryCode xmlns="">' . $BusinessStakeHolderAddressCountryCode . '</countryCode>' : '';  
  1823. $XMLRequest .= '</address>'; 
  1824.  
  1825. $XMLRequest .= $BusinessStakeHolderDateOfBirth != '' ? '<dateOfBirth xmlns="">' . $BusinessStakeHolderDateOfBirth . '</dateOfBirth>' : ''; 
  1826. $XMLRequest .= '</businessStakeHolder>'; 
  1827.  
  1828. $XMLRequest .= '</businessInfo>'; 
  1829.  
  1830. $XMLRequest .= '</CreateAccountRequest>'; 
  1831.  
  1832. // Call the API and load XML response into DOM 
  1833. $XMLResponse = $this -> CURLRequest($XMLRequest, 'AdaptiveAccounts', 'CreateAccount'); 
  1834. $DOM = new DOMDocument(); 
  1835. $DOM -> loadXML($XMLResponse); 
  1836.  
  1837. // Parse XML values 
  1838. $Fault = $DOM -> getElementsByTagName('FaultMessage') -> length > 0 ? true : false; 
  1839. $Errors = $this -> GetErrors($XMLResponse); 
  1840. $Ack = $DOM -> getElementsByTagName('ack') -> length > 0 ? $DOM -> getElementsByTagName('ack') -> item(0) -> nodeValue : ''; 
  1841. $Build = $DOM -> getElementsByTagName('build') -> length > 0 ? $DOM -> getElementsByTagName('build') -> item(0) -> nodeValue : ''; 
  1842. $CorrelationID = $DOM -> getElementsByTagName('correlationId') -> length > 0 ? $DOM -> getElementsByTagName('correlationId') -> item(0) -> nodeValue : ''; 
  1843. $Timestamp = $DOM -> getElementsByTagName('timestamp') -> length > 0 ? $DOM -> getElementsByTagName('timestamp') -> item(0) -> nodeValue : ''; 
  1844.  
  1845. $AccountID = $DOM -> getElementsByTagName('accountId') -> length > 0 ? $DOM -> getElementsByTagName('accountId') -> item(0) -> nodeValue : ''; 
  1846. $CreateAccountKey = $DOM -> getElementsByTagName('createAccountKey') -> length > 0 ? $DOM -> getElementsByTagName('createAccountKey') -> item(0) -> nodeValue : ''; 
  1847. $ExecStatus = $DOM -> getElementsByTagName('execStatus') -> length > 0 ? $DOM -> getElementsByTagName('execStatus') -> item(0) -> nodeValue : ''; 
  1848. $RedirectURL = $DOM -> getElementsByTagName('redirectURL') -> length > 0 ? $DOM -> getElementsByTagName('redirectURL') -> item(0) -> nodeValue : ''; 
  1849.  
  1850. $ResponseDataArray = array( 
  1851. 'Errors' => $Errors,  
  1852. 'Ack' => $Ack,  
  1853. 'Build' => $Build,  
  1854. 'CorrelationID' => $CorrelationID,  
  1855. 'Timestamp' => $Timestamp,  
  1856. 'AccountID' => $AccountID,  
  1857. 'CreateAccountKey' => $CreateAccountKey,  
  1858. 'ExecStatus' => $ExecStatus,  
  1859. 'RedirectURL' => $RedirectURL,  
  1860. 'XMLRequest' => $XMLRequest,  
  1861. 'XMLResponse' => $XMLResponse 
  1862. ); 
  1863.  
  1864. return $ResponseDataArray; 
  1865.  
  1866. /** 
  1867. * Submit AddBankAccount API request to PayPal. 
  1868. * @access public 
  1869. * @param array call config data 
  1870. * @return array 
  1871. */ 
  1872. function AddBankAccount($DataArray) 
  1873. $AddBankAccountFields = isset($DataArray['AddBankAccountFields']) ? $DataArray['AddBankAccountFields'] : array(); 
  1874. $EmailAddress = isset($AddBankAccountFields['EmailAddress']) ? $AddBankAccountFields['EmailAddress'] : ''; 
  1875. $AccountID = isset($AddBankAccountFields['AccountID']) ? $AddBankAccountFields['AccountID'] : ''; 
  1876. $CreateAccountKey = isset($AddBankAccountFields['CreateAccountKey']) ? $AddBankAccountFields['CreateAccountKey'] : ''; 
  1877. $BankCountryCode = isset($AddBankAccountFields['BankCountryCode']) ? $AddBankAccountFields['BankCountryCode'] : ''; 
  1878. $BankName = isset($AddBankAccountFields['BankName']) ? $AddBankAccountFields['BankName'] : ''; 
  1879. $RoutingNumber = isset($AddBankAccountFields['RoutingNumber']) ? $AddBankAccountFields['RoutingNumber'] : ''; 
  1880. $BankAccountType = isset($AddBankAccountFields['BankAccountType']) ? $AddBankAccountFields['BankAccountType'] : ''; 
  1881. $BankAccountNumber = isset($AddBankAccountFields['BankAccountNumber']) ? $AddBankAccountFields['BankAccountNumber'] : ''; 
  1882. $IBAN = isset($AddBankAccountFields['IBAN']) ? $AddBankAccountFields['IBAN'] : ''; 
  1883. $CLABE = isset($AddBankAccountFields['CLABE']) ? $AddBankAccountFields['CLABE'] : ''; 
  1884. $BSBNumber = isset($AddBankAccountFields['BSBNumber']) ? $AddBankAccountFields['BSBNumber'] : ''; 
  1885. $BranchLocation = isset($AddBankAccountFields['BranchLocation']) ? $AddBankAccountFields['BranchLocation'] : ''; 
  1886. $SortCode = isset($AddBankAccountFields['SortCode']) ? $AddBankAccountFields['SortCode'] : ''; 
  1887. $BankTransitNumber = isset($AddBankAccountFields['BankTransitNumber']) ? $AddBankAccountFields['BankTransitNumber'] : ''; 
  1888. $InstitutionNumber = isset($AddBankAccountFields['InstitutionNumber']) ? $AddBankAccountFields['InstitutionNumber'] : ''; 
  1889. $BranchCode = isset($AddBankAccountFields['BranchCode']) ? $AddBankAccountFields['BranchCode'] : ''; 
  1890. $AgencyNumber = isset($AddBankAccountFields['AgencyNumber']) ? $AddBankAccountFields['AgencyNumber'] : ''; 
  1891. $BankCode = isset($AddBankAccountFields['BankCode']) ? $AddBankAccountFields['BankCode'] : ''; 
  1892. $RibKey = isset($AddBankAccountFields['RibKey']) ? $AddBankAccountFields['RibKey'] : ''; 
  1893. $ControlDigit = isset($AddBankAccountFields['ControlDigit']) ? $AddBankAccountFields['ControlDigit'] : ''; 
  1894. $TaxIDType = isset($AddBankAccountFields['TaxIDType']) ? $AddBankAccountFields['TaxIDType'] : ''; 
  1895. $TaxIDNumber = isset($AddBankAccountFields['TaxIDNumber']) ? $AddBankAccountFields['TaxIDNumber'] : ''; 
  1896. $AccountHolderDateOfBirth = isset($AddBankAccountFields['AccountHolderDateOfBirth']) ? $AddBankAccountFields['AccountHolderDateOfBirth'] : ''; 
  1897. $ConfirmationType = isset($AddBankAccountFields['ConfirmationType']) ? $AddBankAccountFields['ConfirmationType'] : ''; 
  1898.  
  1899. $WebOptions = isset($DataArray['WebOptions']) ? $DataArray['WebOptions'] : array(); 
  1900. $ReturnURL = isset($WebOptions['ReturnURL']) ? $WebOptions['ReturnURL'] : ''; 
  1901. $CancelURL = isset($WebOptions['CancelURL']) ? $WebOptions['CancelURL'] : ''; 
  1902. $ReturnURLDescription = isset($WebOptions['ReturnURLDescription']) ? $WebOptions['ReturnURLDescription'] : ''; 
  1903. $CancelURLDescription = isset($WebOptions['CancelURLDescription']) ? $WebOptions['CancelURLDescription'] : ''; 
  1904.  
  1905. // Generate XML Request 
  1906. $XMLRequest = '<?xml version="1.0" encoding="utf-8"?>'; 
  1907. $XMLRequest .= '<AddBankAccountRequest xmlns="' . $this -> XMLNamespace . '">'; 
  1908. $XMLRequest .= $this -> GetXMLRequestEnvelope(); 
  1909. $XMLRequest .= $EmailAddress != '' ? '<emailAddress xmlns="">' . $EmailAddress . '</emailAddress>' : ''; 
  1910. $XMLRequest .= $AccountID != '' ? '<accountId xmlns="">' . $AccountID . '</accountId>' : ''; 
  1911. $XMLRequest .= $CreateAccountKey != '' ? '<createAccountKey xmlns="">' . $CreateAccountKey . '</createAccountKey>' : ''; 
  1912. $XMLRequest .= $BankCountryCode != '' ? '<bankCountryCode xmlns="">' . $BankCountryCode . '</bankCountryCode>' : ''; 
  1913. $XMLRequest .= $BankName != '' ? '<bankName xmlns="">' . $BankName . '</bankName>' : ''; 
  1914. $XMLRequest .= $RoutingNumber != '' ? '<routingNumber xmlns="">' . $RoutingNumber . '</routingNumber>' : ''; 
  1915. $XMLRequest .= $BankAccountType != '' ? '<bankAccountType xmlns="">' . $BankAccountType . '</bankAccountType>' : ''; 
  1916. $XMLRequest .= $BankAccountNumber != '' ? '<bankAccountNumber xmlns="">' . $BankAccountNumber . '</bankAccountNumber>' : ''; 
  1917. $XMLRequest .= $IBAN != '' ? '<iban xmlns="">' . $IBAN . '</iban>' : ''; 
  1918. $XMLRequest .= $CLABE != '' ? '<clabe xmlns="">' . $CLABE . '</clabe>' : ''; 
  1919. $XMLRequest .= $BSBNumber != '' ? '<bsbNumber xmlns="">' . $BSBNumber . '</bsbNumber>' : ''; 
  1920. $XMLRequest .= $BranchLocation != '' ? '<branchLocation xmlns="">' . $BranchLocation . '</branchLocation>' : ''; 
  1921. $XMLRequest .= $SortCode != '' ? '<sortCode xmlns="">' . $SortCode . '</sortCode>' : ''; 
  1922. $XMLRequest .= $BankTransitNumber != '' ? '<bankTransitNumber xmlns="">' . $BankTransitNumber . '</bankTransitNumber>' : ''; 
  1923. $XMLRequest .= $InstitutionNumber != '' ? '<institutionNumber xmlns="">' . $InstitutionNumber . '</institutionNumber>' : ''; 
  1924. $XMLRequest .= $BranchCode != '' ? '<branchCode xmlns="">' . $BranchCode . '</branchCode>' : ''; 
  1925. $XMLRequest .= $AgencyNumber != '' ? '<agencyNumber xmlns="">' . $AgencyNumber . '</agencyNumber>' : ''; 
  1926. $XMLRequest .= $BankCode != '' ? '<bankCode xmlns="">' . $BankCode . '</bankCode>' : ''; 
  1927. $XMLRequest .= $RibKey != '' ? '<ribKey xmlns="">' . $RibKey . '</ribKey>' : ''; 
  1928. $XMLRequest .= $ControlDigit != '' ? '<controlDigit xmlns="">' . $ControlDigit . '</controlDigit>' : ''; 
  1929. $XMLRequest .= $TaxIDType != '' ? '<taxIdType xmlns="">' . $TaxIDType . '</taxIdType>' : ''; 
  1930. $XMLRequest .= $TaxIDNumber != '' ? '<taxIdNumber xmlns="">' . $TaxIDNumber . '</taxIdNumber>' : ''; 
  1931. $XMLRequest .= $AccountHolderDateOfBirth != '' ? '<accountHolderDateOfBirth xmlns="">' . $AccountHolderDateOfBirth . '</accountHolderDateOfBirth>' : ''; 
  1932. $XMLRequest .= $ConfirmationType != '' ? '<confirmationType xmlns="">' . $ConfirmationType . '</confirmationType>' : ''; 
  1933.  
  1934. if(!empty($WebOptions)) 
  1935. $XMLRequest .= '<webOptions xmlns="">'; 
  1936. $XMLRequest .= $ReturnURL != '' ? '<returnUrl xmlns="">' . $ReturnURL . '</returnUrl>' : ''; 
  1937. $XMLRequest .= $CancelURL != '' ? '<cancelUrl xmlns="">' . $CancelURL . '</cancelUrl>' : ''; 
  1938. $XMLRequest .= $ReturnURLDescription != '' ? '<returnUrlDescription xmlns="">' . $ReturnURLDescription . '</returnUrlDescription>' : ''; 
  1939. $XMLRequest .= $CancelURLDescription != '' ? '<cancelUrlDescription xmlns="">' . $CancelURLDescription . '</cancelUrlDescription>' : '';  
  1940. $XMLRequest .= '</webOptions>'; 
  1941.  
  1942. $XMLRequest .= '</AddBankAccountRequest>'; 
  1943.  
  1944. // Call the API and load XML response into DOM 
  1945. $XMLResponse = $this -> CURLRequest($XMLRequest, 'AdaptiveAccounts', 'AddBankAccount'); 
  1946. $DOM = new DOMDocument(); 
  1947. $DOM -> loadXML($XMLResponse); 
  1948.  
  1949. // Parse XML values 
  1950. $Fault = $DOM -> getElementsByTagName('FaultMessage') -> length > 0 ? true : false; 
  1951. $Errors = $this -> GetErrors($XMLResponse); 
  1952. $Ack = $DOM -> getElementsByTagName('ack') -> length > 0 ? $DOM -> getElementsByTagName('ack') -> item(0) -> nodeValue : ''; 
  1953. $Build = $DOM -> getElementsByTagName('build') -> length > 0 ? $DOM -> getElementsByTagName('build') -> item(0) -> nodeValue : ''; 
  1954. $CorrelationID = $DOM -> getElementsByTagName('correlationId') -> length > 0 ? $DOM -> getElementsByTagName('correlationId') -> item(0) -> nodeValue : ''; 
  1955. $Timestamp = $DOM -> getElementsByTagName('timestamp') -> length > 0 ? $DOM -> getElementsByTagName('timestamp') -> item(0) -> nodeValue : ''; 
  1956.  
  1957. $ExecStatus = $DOM -> getElementsByTagName('execStatus') -> length > 0 ? $DOM -> getElementsByTagName('execStatus') -> item(0) -> nodeValue : ''; 
  1958. $FundingSourceKey = $DOM -> getElementsByTagName('fundingSourceKey') -> length > 0 ? $DOM -> getElementsByTagName('fundingSourceKey') -> item(0) -> nodeValue : ''; 
  1959. $RedirectURL = $DOM -> getElementsByTagName('redirectURL') -> length > 0 ? $DOM -> getElementsByTagName('redirectURL') -> item(0) -> nodeValue : ''; 
  1960.  
  1961. $ResponseDataArray = array( 
  1962. 'Errors' => $Errors,  
  1963. 'Ack' => $Ack,  
  1964. 'Build' => $Build,  
  1965. 'CorrelationID' => $CorrelationID,  
  1966. 'Timestamp' => $Timestamp,  
  1967. 'ExecStatus' => $ExecStatus,  
  1968. 'FundingSourceKey' => $FundingSourceKey,  
  1969. 'RedirectURL' => $RedirectURL,  
  1970. 'XMLRequest' => $XMLRequest,  
  1971. 'XMLResponse' => $XMLResponse 
  1972. ); 
  1973.  
  1974. return $ResponseDataArray; 
  1975.  
  1976. /** 
  1977. * Submit AddPaymentCard API request to PayPal. 
  1978. * @access public 
  1979. * @param array call config data 
  1980. * @return array 
  1981. */ 
  1982. function AddPaymentCard($DataArray) 
  1983. $AddPaymentCardFields = isset($DataArray['AddPaymentCardFields']) ? $DataArray['AddPaymentCardFields'] : array(); 
  1984. $EmailAddress = isset($AddPaymentCardFields['EmailAddress']) ? $AddPaymentCardFields['EmailAddress'] : ''; 
  1985. $AccountID = isset($AddPaymentCardFields['AccountID']) ? $AddPaymentCardFields['AccountID'] : ''; 
  1986. $CreateAccountKey = isset($AddPaymentCardFields['CreateAccountKey']) ? $AddPaymentCardFields['CreateAccountKey'] : ''; 
  1987. $CardOwnerDateOfBirth = isset($AddPaymentCardFields['CardOwnerDateOfBirth']) ? $AddPaymentCardFields['CardOwnerDateOfBirth'] : ''; 
  1988. $CardNumber = isset($AddPaymentCardFields['CardNumber']) ? $AddPaymentCardFields['CardNumber'] : ''; 
  1989. $CardType = isset($AddPaymentCardFields['CardType']) ? $AddPaymentCardFields['CardType'] : ''; 
  1990. $CardVerificationNumber = isset($AddPaymentCardFields['CardVerificationNumber']) ? $AddPaymentCardFields['CardVerificationNumber'] : ''; 
  1991. $StartDate = isset($AddPaymentCardFields['StartDate']) ? $AddPaymentCardFields['StartDate'] : ''; 
  1992. $IssueNumber = isset($AddPaymentCardFields['IssueNumber']) ? $AddPaymentCardFields['IssueNumber'] : ''; 
  1993. $ConfirmationType = isset($AddPaymentCardFields['ConfirmationType']) ? $AddPaymentCardFields['ConfirmationType'] : ''; 
  1994.  
  1995. $NameOnCard = isset($DataArray['NameOnCard']) ? $DataArray['NameOnCard'] : array(); 
  1996. $Salutation = isset($NameOnCard['Salutation']) ? $NameOnCard['Salutation'] : ''; 
  1997. $FirstName = isset($NameOnCard['FirstName']) ? $NameOnCard['FirstName'] : ''; 
  1998. $MiddleName = isset($NameOnCard['MiddleName']) ? $NameOnCard['MiddleName'] : ''; 
  1999. $LastName = isset($NameOnCard['LastName']) ? $NameOnCard['LastName'] : ''; 
  2000. $Suffix = isset($NameOnCard['Suffix']) ? $NameOnCard['Suffix'] : ''; 
  2001.  
  2002. $BillingAddress = isset($DataArray['BillingAddress']) ? $DataArray['BillingAddress'] : array(); 
  2003. $Line1 = isset($BillingAddress['Line1']) ? $BillingAddress['Line1'] : ''; 
  2004. $Line2 = isset($BillingAddress['Line2']) ? $BillingAddress['Line2'] : ''; 
  2005. $City = isset($BillingAddress['City']) ? $BillingAddress['City'] : ''; 
  2006. $State = isset($BillingAddress['State']) ? $BillingAddress['State'] : ''; 
  2007. $PostalCode = isset($BillingAddress['PostalCode']) ? $BillingAddress['PostalCode'] : ''; 
  2008. $CountryCode = isset($BillingAddress['CountryCode']) ? $BillingAddress['CountryCode'] : ''; 
  2009.  
  2010. $ExpirationDate = isset($DataArray['ExpirationDate']) ? $DataArray['ExpirationDate'] : array(); 
  2011. $Month = isset($ExpirationDate['Month']) ? $ExpirationDate['Month'] : ''; 
  2012. $Year = isset($ExpirationDate['Year']) ? $ExpirationDate['Year'] : ''; 
  2013.  
  2014. $WebOptions = isset($DataArray['WebOptions']) ? $DataArray['WebOptions'] : array(); 
  2015. $ReturnURL = isset($WebOptions['ReturnURL']) ? $WebOptions['ReturnURL'] : ''; 
  2016. $CancelURL = isset($WebOptions['CancelURL']) ? $WebOptions['CancelURL'] : ''; 
  2017. $ReturnURLDescription = isset($WebOptions['ReturnURLDescription']) ? $WebOptions['ReturnURLDescription'] : ''; 
  2018. $CancelURLDescription = isset($WebOptions['CancelURLDescription']) ? $WebOptions['CancelURLDescription'] : ''; 
  2019.  
  2020. // Generate XML Request 
  2021. $XMLRequest = '<?xml version="1.0" encoding="utf-8"?>'; 
  2022. $XMLRequest .= '<AddPaymentCardRequest xmlns="' . $this -> XMLNamespace . '">'; 
  2023. $XMLRequest .= $this -> GetXMLRequestEnvelope(); 
  2024. $XMLRequest .= $EmailAddress != '' ? '<emailAddress xmlns="">' . $EmailAddress . '</emailAddress>' : ''; 
  2025. $XMLRequest .= $AccountID != '' ? '<accountId xmlns="">' . $AccountID . '</accountId>' : ''; 
  2026. $XMLRequest .= $CreateAccountKey != '' ? '<createAccountKey xmlns="">' . $CreateAccountKey . '</createAccountKey>' : ''; 
  2027.  
  2028. if(!empty($NameOnCard)) 
  2029. $XMLRequest .= '<nameOnCard xmlns="">'; 
  2030. $XMLRequest .= $Salutation != '' ? '<salutation xmlns="">' . $Salutation . '</salutation>' : ''; 
  2031. $XMLRequest .= $FirstName != '' ? '<firstName xmlns="">' . $FirstName . '</firstName>' : ''; 
  2032. $XMLRequest .= $MiddleName != '' ? '<middleName xmlns="">' . $MiddleName . '</middleName>' : ''; 
  2033. $XMLRequest .= $LastName != '' ? '<lastName xmlns="">' . $LastName . '</lastName>' : ''; 
  2034. $XMLRequest .= $Suffix != '' ? '<suffix xmlns="">' . $Suffix . '</suffix>' : ''; 
  2035. $XMLRequest .= '</nameOnCard>'; 
  2036.  
  2037. if(!empty($BillingAddress)) 
  2038. $XMLRequest .= '<billingAddress xmlns="">'; 
  2039. $XMLRequest .= $Line1 != '' ? '<line1 xmlns="">' . $Line1 . '</line1>' : ''; 
  2040. $XMLRequest .= $Line2 != '' ? '<line2 xmlns="">' . $Line2 . '</line2>' : ''; 
  2041. $XMLRequest .= $City != '' ? '<city xmlns="">' . $City . '</city>' : ''; 
  2042. $XMLRequest .= $State != '' ? '<state xmlns="">' . $State . '</state>' : ''; 
  2043. $XMLRequest .= $PostalCode != '' ? '<postalCode xmlns="">' . $PostalCode . '</postalCode>' : ''; 
  2044. $XMLRequest .= $CountryCode != '' ? '<countryCode xmlns="">' . $CountryCode . '</countryCode>' : '';  
  2045. $XMLRequest .= '</billingAddress>';  
  2046.  
  2047. $XMLRequest .= $CardOwnerDateOfBirth != '' ? '<cardOwnerDateOfBirth xmlns="">' . $CardOwnerDateOfBirth . '</cardOwnerDateOfBirth>' : ''; 
  2048. $XMLRequest .= $CardNumber != '' ? '<cardNumber xmlns="">' . $CardNumber . '</cardNumber>' : ''; 
  2049. $XMLRequest .= $CardType != '' ? '<cardType xmlns="">' . $CardType . '</cardType>' : ''; 
  2050.  
  2051. if(!empty($ExpirationDate)) 
  2052. $XMLRequest .= '<expirationDate xmlns="">'; 
  2053. $XMLRequest .= $Month != '' ? '<month xmlns="">' . $Month . '</month>' : ''; 
  2054. $XMLRequest .= $Year != '' ? '<year xmlns="">' . $Year . '</year>' : '';  
  2055. $XMLRequest .= '</expirationDate>';  
  2056.  
  2057. $XMLRequest .= $CardVerificationNumber != '' ? '<cardVerificationNumber xmlns="">' . $CardVerificationNumber . '</cardVerificationNumber>' : ''; 
  2058. $XMLRequest .= $StartDate != '' ? '<startDate xmlns="">' . $StartDate . '</startDate>' : ''; 
  2059. $XMLRequest .= $IssueNumber != '' ? '<issueNumber xmlns="">' . $IssueNumber . '</issueNumber>' : ''; 
  2060. $XMLRequest .= $ConfirmationType != '' ? '<confirmationType xmlns="">' . $ConfirmationType . '</confirmationType>' : ''; 
  2061.  
  2062. if(!empty($WebOptions)) 
  2063. $XMLRequest .= '<webOptions xmlns="">'; 
  2064. $XMLRequest .= $ReturnURL != '' ? '<returnUrl xmlns="">' . $ReturnURL . '</returnUrl>' : ''; 
  2065. $XMLRequest .= $CancelURL != '' ? '<cancelUrl xmlns="">' . $CancelURL . '</cancelUrl>' : ''; 
  2066. $XMLRequest .= $ReturnURLDescription != '' ? '<returnUrlDescription xmlns="">' . $ReturnURLDescription . '</returnUrlDescription>' : ''; 
  2067. $XMLRequest .= $CancelURLDescription != '' ? '<cancelUrlDescription xmlns="">' . $CancelURLDescription . '</cancelUrlDescription>' : '';  
  2068. $XMLRequest .= '</webOptions>'; 
  2069.  
  2070. $XMLRequest .= '</AddPaymentCardRequest>'; 
  2071.  
  2072. // Call the API and load XML response into DOM 
  2073. $XMLResponse = $this -> CURLRequest($XMLRequest, 'AdaptiveAccounts', 'AddPaymentCard'); 
  2074. $DOM = new DOMDocument(); 
  2075. $DOM -> loadXML($XMLResponse); 
  2076.  
  2077. // Parse XML values 
  2078. $Fault = $DOM -> getElementsByTagName('FaultMessage') -> length > 0 ? true : false; 
  2079. $Errors = $this -> GetErrors($XMLResponse); 
  2080. $Ack = $DOM -> getElementsByTagName('ack') -> length > 0 ? $DOM -> getElementsByTagName('ack') -> item(0) -> nodeValue : ''; 
  2081. $Build = $DOM -> getElementsByTagName('build') -> length > 0 ? $DOM -> getElementsByTagName('build') -> item(0) -> nodeValue : ''; 
  2082. $CorrelationID = $DOM -> getElementsByTagName('correlationId') -> length > 0 ? $DOM -> getElementsByTagName('correlationId') -> item(0) -> nodeValue : ''; 
  2083. $Timestamp = $DOM -> getElementsByTagName('timestamp') -> length > 0 ? $DOM -> getElementsByTagName('timestamp') -> item(0) -> nodeValue : ''; 
  2084.  
  2085. $ExecStatus = $DOM -> getElementsByTagName('execStatus') -> length > 0 ? $DOM -> getElementsByTagName('execStatus') -> item(0) -> nodeValue : ''; 
  2086. $FundingSourceKey = $DOM -> getElementsByTagName('fundingSourceKey') -> length > 0 ? $DOM -> getElementsByTagName('fundingSourceKey') -> item(0) -> nodeValue : ''; 
  2087. $RedirectURL = $DOM -> getElementsByTagName('redirectURL') -> length > 0 ? $DOM -> getElementsByTagName('redirectURL') -> item(0) -> nodeValue : ''; 
  2088.  
  2089. $ResponseDataArray = array( 
  2090. 'Errors' => $Errors,  
  2091. 'Ack' => $Ack,  
  2092. 'Build' => $Build,  
  2093. 'CorrelationID' => $CorrelationID,  
  2094. 'Timestamp' => $Timestamp,  
  2095. 'ExecStatus' => $ExecStatus,  
  2096. 'FundingSourceKey' => $FundingSourceKey,  
  2097. 'RedirectURL' => $RedirectURL,  
  2098. 'XMLRequest' => $XMLRequest,  
  2099. 'XMLResponse' => $XMLResponse 
  2100. ); 
  2101.  
  2102. return $ResponseDataArray; 
  2103.  
  2104.  
  2105. /** 
  2106. * Submit SetFundingSourceConfirmed API request to PayPal. 
  2107. * @access public 
  2108. * @param array call config data 
  2109. * @return array 
  2110. */ 
  2111. function SetFundingSourceConfirmed($DataArray) 
  2112. $SetFundingSourceConfirmedFields = isset($DataArray['SetFundingSourceConfirmedFields']) ? $DataArray['SetFundingSourceConfirmedFields'] : array(); 
  2113. $EmailAddress = isset($SetFundingSourceConfirmedFields['EmailAddress']) ? $SetFundingSourceConfirmedFields['EmailAddress'] : ''; 
  2114. $AccountID = isset($SetFundingSourceConfirmedFields['AccountID']) ? $SetFundingSourceConfirmedFields['AccountID'] : ''; 
  2115. $FundingSourceKey = isset($SetFundingSourceConfirmedFields['FundingSourceKey']) ? $SetFundingSourceConfirmedFields['FundingSourceKey'] : ''; 
  2116.  
  2117. // Generate XML Request 
  2118. $XMLRequest = '<?xml version="1.0" encoding="utf-8"?>'; 
  2119. $XMLRequest .= '<SetFundingSourceConfirmedRequest xmlns="' . $this -> XMLNamespace . '">'; 
  2120. $XMLRequest .= $this -> GetXMLRequestEnvelope(); 
  2121. $XMLRequest .= $EmailAddress != '' ? '<emailAddress xmlns="">' . $EmailAddress . '</emailAddress>' : ''; 
  2122. $XMLRequest .= $AccountID != '' ? '<accountId xmlns="">' . $AccountID . '</accountId>' : ''; 
  2123. $XMLRequest .= $FundingSourceKey != '' ? '<fundingSourceKey xmlns="">' . $FundingSourceKey . '</fundingSourceKey>' : '';  
  2124. $XMLRequest .= '</SetFundingSourceConfirmedRequest>'; 
  2125.  
  2126. // Call the API and load XML response into DOM 
  2127. $XMLResponse = $this -> CURLRequest($XMLRequest, 'AdaptiveAccounts', 'SetFundingSourceConfirmed'); 
  2128. $DOM = new DOMDocument(); 
  2129. $DOM -> loadXML($XMLResponse); 
  2130.  
  2131. // Parse XML values 
  2132. $Fault = $DOM -> getElementsByTagName('FaultMessage') -> length > 0 ? true : false; 
  2133. $Errors = $this -> GetErrors($XMLResponse); 
  2134. $Ack = $DOM -> getElementsByTagName('ack') -> length > 0 ? $DOM -> getElementsByTagName('ack') -> item(0) -> nodeValue : ''; 
  2135. $Build = $DOM -> getElementsByTagName('build') -> length > 0 ? $DOM -> getElementsByTagName('build') -> item(0) -> nodeValue : ''; 
  2136. $CorrelationID = $DOM -> getElementsByTagName('correlationId') -> length > 0 ? $DOM -> getElementsByTagName('correlationId') -> item(0) -> nodeValue : ''; 
  2137. $Timestamp = $DOM -> getElementsByTagName('timestamp') -> length > 0 ? $DOM -> getElementsByTagName('timestamp') -> item(0) -> nodeValue : ''; 
  2138.  
  2139. $ResponseDataArray = array( 
  2140. 'Errors' => $Errors,  
  2141. 'Ack' => $Ack,  
  2142. 'Build' => $Build,  
  2143. 'CorrelationID' => $CorrelationID,  
  2144. 'Timestamp' => $Timestamp,  
  2145. 'XMLRequest' => $XMLRequest,  
  2146. 'XMLResponse' => $XMLResponse 
  2147. ); 
  2148.  
  2149. return $ResponseDataArray; 
  2150.  
  2151.  
  2152. /** 
  2153. * Submit GetVerifiedStatus API request to PayPal. 
  2154. * @access public 
  2155. * @param array call config data 
  2156. * @return array 
  2157. */ 
  2158. function GetVerifiedStatus($DataArray) 
  2159. $GetVerifiedStatusFields = isset($DataArray['GetVerifiedStatusFields']) ? $DataArray['GetVerifiedStatusFields'] : array(); 
  2160. $EmailAddress = isset($GetVerifiedStatusFields['EmailAddress']) ? $GetVerifiedStatusFields['EmailAddress'] : ''; 
  2161. $MatchCriteria = isset($GetVerifiedStatusFields['MatchCriteria']) ? $GetVerifiedStatusFields['MatchCriteria'] : ''; 
  2162. $FirstName = isset($GetVerifiedStatusFields['FirstName']) ? $GetVerifiedStatusFields['FirstName'] : ''; 
  2163. $LastName = isset($GetVerifiedStatusFields['LastName']) ? $GetVerifiedStatusFields['LastName'] : ''; 
  2164.  
  2165. // Generate XML Request 
  2166. $XMLRequest = '<?xml version="1.0" encoding="utf-8"?>'; 
  2167. $XMLRequest .= '<GetVerifiedStatusRequest xmlns="' . $this -> XMLNamespace . '">'; 
  2168. $XMLRequest .= $this -> GetXMLRequestEnvelope(); 
  2169. $XMLRequest .= $EmailAddress != '' ? '<emailAddress xmlns="">' . $EmailAddress . '</emailAddress>' : ''; 
  2170. $XMLRequest .= $MatchCriteria != '' ? '<matchCriteria xmlns="">' . $MatchCriteria . '</matchCriteria>' : ''; 
  2171. $XMLRequest .= $FirstName != '' ? '<firstName xmlns="">' . $FirstName . '</firstName>' : ''; 
  2172. $XMLRequest .= $LastName != '' ? '<lastName xmlns="">' . $LastName . '</lastName>' : ''; 
  2173. $XMLRequest .= '</GetVerifiedStatusRequest>'; 
  2174.  
  2175. // Call the API and load XML response into DOM 
  2176. $XMLResponse = $this -> CURLRequest($XMLRequest, 'AdaptiveAccounts', 'GetVerifiedStatus'); 
  2177. $DOM = new DOMDocument(); 
  2178. $DOM -> loadXML($XMLResponse); 
  2179.  
  2180. // Parse XML values 
  2181. $Fault = $DOM -> getElementsByTagName('FaultMessage') -> length > 0 ? true : false; 
  2182. $Errors = $this -> GetErrors($XMLResponse); 
  2183. $Ack = $DOM -> getElementsByTagName('ack') -> length > 0 ? $DOM -> getElementsByTagName('ack') -> item(0) -> nodeValue : ''; 
  2184. $Build = $DOM -> getElementsByTagName('build') -> length > 0 ? $DOM -> getElementsByTagName('build') -> item(0) -> nodeValue : ''; 
  2185. $CorrelationID = $DOM -> getElementsByTagName('correlationId') -> length > 0 ? $DOM -> getElementsByTagName('correlationId') -> item(0) -> nodeValue : ''; 
  2186. $Timestamp = $DOM -> getElementsByTagName('timestamp') -> length > 0 ? $DOM -> getElementsByTagName('timestamp') -> item(0) -> nodeValue : ''; 
  2187.  
  2188. $AccountStatus = $DOM -> getElementsByTagName('accountStatus') -> length > 0 ? $DOM -> getElementsByTagName('accountStatus') -> item(0) -> nodeValue : ''; 
  2189. $CountryCode = $DOM -> getElementsByTagName('countryCode') -> length > 0 ? $DOM -> getElementsByTagName('countryCode') -> item(0) -> nodeValue : ''; 
  2190. $EmailAddress = $DOM -> getElementsByTagName('emailAddress') -> length > 0 ? $DOM -> getElementsByTagName('emailAddress') -> item(0) -> nodeValue : ''; 
  2191. $AccountID = $DOM -> getElementsByTagName('accountId') -> length > 0 ? $DOM -> getElementsByTagName('accountId') -> item(0) -> nodeValue : ''; 
  2192. $AccountType = $DOM -> getElementsByTagName('accountType') -> length > 0 ? $DOM -> getElementsByTagName('accountType') -> item(0) -> nodeValue : ''; 
  2193. $BusinessName = $DOM -> getElementsByTagName('businessName') -> length > 0 ? $DOM -> getElementsByTagName('businessName') -> item(0) -> nodeValue : ''; 
  2194. $Salutation = $DOM -> getElementsByTagName('salutation') -> length > 0 ? $DOM -> getElementsByTagName('salutation') -> item(0) -> nodeValue : ''; 
  2195. $FirstName = $DOM -> getElementsByTagName('firstName') -> length > 0 ? $DOM -> getElementsByTagName('firstName') -> item(0) -> nodeValue : ''; 
  2196. $MiddleName = $DOM -> getElementsByTagName('middleName') -> length > 0 ? $DOM -> getElementsByTagName('middleName') -> item(0) -> nodeValue : ''; 
  2197. $LastName = $DOM -> getElementsByTagName('lastName') -> length > 0 ? $DOM -> getElementsByTagName('lastName') -> item(0) -> nodeValue : ''; 
  2198. $Suffix = $DOM -> getElementsByTagName('suffix') -> length > 0 ? $DOM -> getElementsByTagName('suffix') -> item(0) -> nodeValue : ''; 
  2199.  
  2200. $ResponseDataArray = array( 
  2201. 'Errors' => $Errors,  
  2202. 'Ack' => $Ack,  
  2203. 'Build' => $Build,  
  2204. 'CorrelationID' => $CorrelationID,  
  2205. 'Timestamp' => $Timestamp,  
  2206. 'AccountStatus' => $AccountStatus,  
  2207. 'CountryCode' => $CountryCode,  
  2208. 'EmailAddress' => $EmailAddress,  
  2209. 'AccountID' => $AccountID,  
  2210. 'BusinessName' => $BusinessName,  
  2211. 'Salutation' => $Salutation,  
  2212. 'FirstName' => $FirstName,  
  2213. 'MiddleName' => $MiddleName,  
  2214. 'LastName' => $LastName,  
  2215. 'Suffix' => $Suffix,  
  2216. 'XMLRequest' => $XMLRequest,  
  2217. 'XMLResponse' => $XMLResponse 
  2218. ); 
  2219.  
  2220. return $ResponseDataArray; 
  2221.  
  2222.  
  2223. /** 
  2224. * Submit GetFundingPlans API request to PayPal. 
  2225. * @access public 
  2226. * @param array call config data 
  2227. * @return array 
  2228. */ 
  2229. function GetFundingPlans($DataArray) 
  2230. $GetFundingPlansFields = isset($DataArray['GetFundingPlansFields']) ? $DataArray['GetFundingPlansFields'] : array(); 
  2231. $PayKey = isset($GetFundingPlansFields['PayKey']) ? $GetFundingPlansFields['PayKey'] : ''; 
  2232.  
  2233. // Generate XML Request 
  2234. $XMLRequest = '<?xml version="1.0" encoding="utf-8"?>'; 
  2235. $XMLRequest .= '<GetFundingPlansRequest xmlns="' . $this -> XMLNamespace . '">'; 
  2236. $XMLRequest .= $this -> GetXMLRequestEnvelope(); 
  2237. $XMLRequest .= $PayKey != '' ? '<payKey xmlns="">' . $PayKey . '</payKey>' : ''; 
  2238. $XMLRequest .= '</GetFundingPlansRequest>'; 
  2239.  
  2240. // Call the API and load XML response into DOM 
  2241. $XMLResponse = $this -> CURLRequest($XMLRequest, 'AdaptiveAccounts', 'GetFundingPlans'); 
  2242. $DOM = new DOMDocument(); 
  2243. $DOM -> loadXML($XMLResponse); 
  2244.  
  2245. // Parse XML values 
  2246. $Fault = $DOM -> getElementsByTagName('FaultMessage') -> length > 0 ? true : false; 
  2247. $Errors = $this -> GetErrors($XMLResponse); 
  2248. $Ack = $DOM -> getElementsByTagName('ack') -> length > 0 ? $DOM -> getElementsByTagName('ack') -> item(0) -> nodeValue : ''; 
  2249. $Build = $DOM -> getElementsByTagName('build') -> length > 0 ? $DOM -> getElementsByTagName('build') -> item(0) -> nodeValue : ''; 
  2250. $CorrelationID = $DOM -> getElementsByTagName('correlationId') -> length > 0 ? $DOM -> getElementsByTagName('correlationId') -> item(0) -> nodeValue : ''; 
  2251. $Timestamp = $DOM -> getElementsByTagName('timestamp') -> length > 0 ? $DOM -> getElementsByTagName('timestamp') -> item(0) -> nodeValue : ''; 
  2252.  
  2253. $FundingPlanType = $DOM -> getElementsByTagName('fundingPlan') -> length > 0 ? $DOM -> getElementsByTagName('fundingPlan') : array(); 
  2254. foreach($FundingPlanType as $FundingPlan) 
  2255. $FundingPlanID = $FundingPlan -> getElementsByTagName('fundingPlanId') -> length > 0 ? $FundingPlan -> getElementsByTagName('fundingPlanId') -> item(0) -> nodeValue : ''; 
  2256. $FundingAmountType = $FundingPlan -> getElementsByTagName('fundingAmount') -> length > 0 ? $FundingPlan -> getElementsByTagName('fundingAmount') : array(); 
  2257.  
  2258. foreach($FundingAmountType as $FundingAmount) 
  2259. $FundingAmountCode = $FundingAmount -> getElementsByTagName('code') -> length > 0 ? $FundingAmount -> getElementsByTagName('code') -> item(0) -> nodeValue : ''; 
  2260. $FundingAmountAmount = $FundingAmount -> getElementsByTagName('amount') -> length > 0 ? $FundingAmount -> getElementsByTagName('amount') -> item(0) -> nodeValue : ''; 
  2261.  
  2262. $BackupFundingSourceType = $FundingPlan -> getElementsByTagName('backupFundingSource') -> length > 0 ? $FundingPlan -> getElementsByTagName('backupFundingSource') : array(); 
  2263. foreach($BackupFundingSourceType as $BackupFundingSource) 
  2264. $BackupFundingSource_LastFourOfAccountNumber = $BackupFundingSource -> getElementsByTagName('lastFourOfAccountNumber') -> length > 0 ? $BackupFundingSource -> getElementsByTagName('lastFourOfAccountNumber') -> item(0) -> nodeValue : ''; 
  2265. $BackupFundingSource_Type = $BackupFundingSource -> getElementsByTagName('type') -> length > 0 ? $BackupFundingSource -> getElementsByTagName('type') -> item(0) -> nodeValue : ''; 
  2266. $BackupFundingSource_DisplayName = $BackupFundingSource -> getElementsByTagName('displayName') -> length > 0 ? $BackupFundingSource -> getElementsByTagName('displayName') -> item(0) -> nodeValue : ''; 
  2267. $BackupFundingSource_FundingSourceID = $BackupFundingSource -> getElementsByTagName('fundingSourceId') -> length > 0 ? $BackupFundingSource -> getElementsByTagName('fundingSourceId') -> item(0) -> nodeValue : ''; 
  2268. $BackupFundingSource_Allowed = $BackupFundingSource -> getElementsByTagName('allowed') -> length > 0 ? $BackupFundingSource -> getElementsByTagName('allowed') -> item(0) -> nodeValue : ''; 
  2269.  
  2270. $SenderFeesType = $FundingPlan -> getElementsByTagName('senderFees') -> length > 0 ? $FundingPlan -> getElementsByTagName('senderFees') : array(); 
  2271. foreach($SenderFeesType as $SenderFees) 
  2272. $SenderFeesCode = $SenderFees -> getElementsByTagName('code') -> length > 0 ? $SenderFees -> getElementsByTagName('code') -> item(0) -> nodeValue : ''; 
  2273. $SenderFeesAmount = $SenderFees -> getElementsByTagName('amount') -> length > 0 ? $SenderFees -> getElementsByTagName('amount') -> item(0) -> nodeValue : ''; 
  2274.  
  2275. $CurrencyConversionType = $FundingPlan -> getElementsByTagName('currencyConversion') -> length > 0 ? $FundingPlan -> getElementsByTagName('currencyConversion') : array(); 
  2276. foreach($CurrencyConversionType as $CurrencyConversion) 
  2277. $CurrencyConversion_From = $CurrencyConversion -> getElementsByTagName('from') -> length > 0 ? $CurrencyConversion -> getElementsByTagName('from') -> item(0) -> nodeValue : ''; 
  2278. $CurrencyConversion_To = $CurrencyConversion -> getElementsByTagName('to') -> length > 0 ? $CurrencyConversion -> getElementsByTagName('to') -> item(0) -> nodeValue : ''; 
  2279. $CurrencyConversion_ExchangeRate = $CurrencyConversion -> getElementsByTagName('exchangeRate') -> length > 0 ? $CurrencyConversion -> getElementsByTagName('exchangeRate') -> item(0) -> nodeValue : ''; 
  2280.  
  2281. $FundingPlanChargeType = $FundingPlan -> getElementsByTagName('charge') -> length > 0 ? $FundingPlan -> getElementsByTagName('charge') : array(); 
  2282. foreach($FundingPlanChargeType as $FundingPlanCharge) 
  2283. $FundingPlanChargeCode = $FundingPlanCharge -> getElementsByTagName('code') -> length > 0 ? $FundingPlanCharge -> getElementsByTagName('code') -> item(0) -> nodeValue : ''; 
  2284. $FundingPlanChargeAmount = $FundingPlanCharge -> getElementsByTagName('amount') -> length > 0 ? $FundingPlanCharge -> getElementsByTagName('amount') -> item(0) -> nodeValue : ''; 
  2285. $FundingPlanChargeFundingSourceType = $FundingPlanCharge -> getElementsByTagName('fundingSource') -> length > 0 ? $FundingPlanCharge -> getElementsByTagName('fundingSource') : array(); 
  2286. foreach($FundingPlanChargeFundingSourceType as $FundingPlanChargeFundingSource) 
  2287. $FundingPlanChargeFundingSource_LastFourOfAccountNumber = $FundingPlanChargeFundingSource -> getElementsByTagName('lastFourOfAccountNumber') -> length > 0 ? $FundingPlanChargeFundingSource -> getElementsByTagName('lastFourOfAccountNumber') -> item(0) -> nodeValue : ''; 
  2288. $FundingPlanChargeFundingSource_Type = $FundingPlanChargeFundingSource -> getElementsByTagName('type') -> length > 0 ? $FundingPlanChargeFundingSource -> getElementsByTagName('type') -> item(0) -> nodeValue : ''; 
  2289. $FundingPlanChargeFundingSource_DisplayName = $FundingPlanChargeFundingSource -> getElementsByTagName('displayName') -> length > 0 ? $FundingPlanChargeFundingSource -> getElementsByTagName('displayName') -> item(0) -> nodeValue : ''; 
  2290. $FundingPlanChargeFundingSource_FundingSourceID = $FundingPlanChargeFundingSource -> getElementsByTagName('fundingSourceId') -> length > 0 ? $FundingPlanChargeFundingSource -> getElementsByTagName('fundingSourceId') -> item(0) -> nodeValue : ''; 
  2291. $FundingPlanChargeFundingSource_Allowed = $FundingPlanChargeFundingSource -> getElementsByTagName('allowed') -> length > 0 ? $FundingPlanChargeFundingSource -> getElementsByTagName('allowed') -> item(0) -> nodeValue : '';  
  2292. }  
  2293.  
  2294. $ResponseDataArray = array( 
  2295. 'Errors' => $Errors,  
  2296. 'Ack' => $Ack,  
  2297. 'Build' => $Build,  
  2298. 'CorrelationID' => $CorrelationID,  
  2299. 'Timestamp' => $Timestamp,  
  2300. 'FundingPlanID' => isset($FundingPlanID) ? $FundingPlanID : '',  
  2301. 'FundingAmountCode' => isset($FundingAmountCode) ? $FundingAmountCode : '',  
  2302. 'FundingAmountAmount' => isset($FundingAmountAmount) ? $FundingAmountAmount : '',  
  2303. 'SenderFeesCode' => isset($SenderFeesCode) ? $SenderFeesCode : '',  
  2304. 'SenderFeesAmount' => isset($SenderFeesAmount) ? $SenderFeesAmount : '',  
  2305. 'BackupFundingSource_LastFourOfAccountNumber' => isset($BackupFundingSource_LastFourOfAccountNumber) ? $BackupFundingSource_LastFourOfAccountNumber : '',  
  2306. 'BackupFundingSource_Type' => isset($BackupFundingSource_Type) ? $BackupFundingSource_Type : '',  
  2307. 'BackupFundingSource_DisplayName' => isset($BackupFundingSource_DisplayName) ? $BackupFundingSource_DisplayName : '',  
  2308. 'BackupFundingSource_FundingSourceID' => isset($BackupFundingSource_FundingSourceID) ? $BackupFundingSource_FundingSourceID : '',  
  2309. 'BackupFundingSource_Allowed' => isset($BackupFundingSource_Allowed) ? $BackupFundingSource_Allowed : '',  
  2310. 'CurrencyConversion_From' => isset($CurrencyConversion_From) ? $CurrencyConversion_From : '',  
  2311. 'CurrencyConversion_To' => isset($CurrencyConversion_To) ? $CurrencyConversion_To : '',  
  2312. 'CurrencyConversion_ExchangeRate' => isset($CurrencyConversion_ExchangeRate) ? $CurrencyConversion_ExchangeRate : '',  
  2313. 'FundingPlanChargeCode' => isset($FundingPlanChargeCode) ? $FundingPlanChargeCode : '',  
  2314. 'FundingPlanChargeAmount' => isset($FundingPlanChargeAmount) ? $FundingPlanChargeAmount : '',  
  2315. 'FundingPlanChargeFundingSource_LastFourOfAccountNumber' => isset($FundingPlanChargeFundingSource_LastFourOfAccountNumber) ? $FundingPlanChargeFundingSource_LastFourOfAccountNumber : '',  
  2316. 'FundingPlanChargeFundingSource_Type' => isset($FundingPlanChargeFundingSource_Type) ? $FundingPlanChargeFundingSource_Type : '',  
  2317. 'FundingPlanChargeFundingSource_DisplayName' => isset($FundingPlanChargeFundingSource_DisplayName) ? $FundingPlanChargeFundingSource_DisplayName : '',  
  2318. 'FundingPlanChargeFundingSource_FundingSourceID' => isset($FundingPlanChargeFundingSource_FundingSourceID) ? $FundingPlanChargeFundingSource_FundingSourceID : '',  
  2319. 'FundingPlanChargeFundingSource_Allowed' => isset($FundingPlanChargeFundingSource_Allowed) ? $FundingPlanChargeFundingSource_Allowed : '',  
  2320. 'XMLRequest' => $XMLRequest,  
  2321. 'XMLResponse' => $XMLResponse 
  2322. ); 
  2323.  
  2324. return $ResponseDataArray; 
  2325.  
  2326.  
  2327. /** 
  2328. * Submit GetShippingAddresses API request to PayPal. 
  2329. * @access public 
  2330. * @param array call config data 
  2331. * @return array 
  2332. */ 
  2333. function GetShippingAddresses($PayKey) 
  2334. // Generate XML Request 
  2335. $XMLRequest = '<?xml version="1.0" encoding="utf-8"?>'; 
  2336. $XMLRequest .= '<GetShippingAddressesRequest xmlns="' . $this -> XMLNamespace . '">'; 
  2337. $XMLRequest .= $this -> GetXMLRequestEnvelope(); 
  2338. $XMLRequest .= $PayKey != '' ? '<key xmlns="">' . $PayKey . '</key>' : ''; 
  2339. $XMLRequest .= '</GetShippingAddressesRequest>'; 
  2340.  
  2341. // Call the API and load XML response into DOM 
  2342. $XMLResponse = $this -> CURLRequest($XMLRequest, 'AdaptivePayments', 'GetShippingAddresses'); 
  2343.  
  2344. $DOM = new DOMDocument(); 
  2345. $DOM -> loadXML($XMLResponse); 
  2346.  
  2347. // Parse XML values 
  2348. $Fault = $DOM -> getElementsByTagName('FaultMessage') -> length > 0 ? true : false; 
  2349. $Errors = $this -> GetErrors($XMLResponse); 
  2350. $Ack = $DOM -> getElementsByTagName('ack') -> length > 0 ? $DOM -> getElementsByTagName('ack') -> item(0) -> nodeValue : ''; 
  2351. $Build = $DOM -> getElementsByTagName('build') -> length > 0 ? $DOM -> getElementsByTagName('build') -> item(0) -> nodeValue : ''; 
  2352. $CorrelationID = $DOM -> getElementsByTagName('correlationId') -> length > 0 ? $DOM -> getElementsByTagName('correlationId') -> item(0) -> nodeValue : ''; 
  2353. $Timestamp = $DOM -> getElementsByTagName('timestamp') -> length > 0 ? $DOM -> getElementsByTagName('timestamp') -> item(0) -> nodeValue : ''; 
  2354.  
  2355. $AddresseeName = $DOM -> getElementsByTagName('addresseeName') -> length > 0 ? $DOM -> getElementsByTagName('addresseeName') -> item(0) -> nodeValue : ''; 
  2356. $AddressID = $DOM -> getElementsByTagName('addressId') -> length > 0 ? $DOM -> getElementsByTagName('addressId') -> item(0) -> nodeValue : ''; 
  2357. $Line1 = $DOM -> getElementsByTagName('line1') -> length > 0 ? $DOM -> getElementsByTagName('line1') -> item(0) -> nodeValue : ''; 
  2358. $Line2 = $DOM -> getElementsByTagName('line2') -> length > 0 ? $DOM -> getElementsByTagName('line2') -> item(0) -> nodeValue : ''; 
  2359. $City = $DOM -> getElementsByTagName('city') -> length > 0 ? $DOM -> getElementsByTagName('city') -> item(0) -> nodeValue : ''; 
  2360. $State = $DOM -> getElementsByTagName('state') -> length > 0 ? $DOM -> getElementsByTagName('state') -> item(0) -> nodeValue : ''; 
  2361. $PostalCode = $DOM -> getElementsByTagName('postalCode') -> length > 0 ? $DOM -> getElementsByTagName('postalCode') -> item(0) -> nodeValue : ''; 
  2362. $CountryCode = $DOM -> getElementsByTagName('countryCode') -> length > 0 ? $DOM -> getElementsByTagName('countryCode') -> item(0) -> nodeValue : ''; 
  2363. $Type = $DOM -> getElementsByTagName('timestamp') -> length > 0 ? $DOM -> getElementsByTagName('timestamp') -> item(0) -> nodeValue : ''; 
  2364.  
  2365.  
  2366. $ResponseDataArray = array( 
  2367. 'Errors' => $Errors,  
  2368. 'Ack' => $Ack,  
  2369. 'Build' => $Build,  
  2370. 'CorrelationID' => $CorrelationID,  
  2371. 'Timestamp' => $Timestamp,  
  2372. 'AddresseeName' => $AddresseeName,  
  2373. 'AddressID' => $AddressID,  
  2374. 'Line1' => $Line1,  
  2375. 'Line2' => $Line2,  
  2376. 'City' => $City,  
  2377. 'State' => $State,  
  2378. 'PostalCode' => $PostalCode,  
  2379. 'CountryCode' => $CountryCode,  
  2380. 'XMLRequest' => $XMLRequest,  
  2381. 'XMLResponse' => $XMLResponse 
  2382. ); 
  2383.  
  2384. return $ResponseDataArray; 
  2385.  
  2386.  
  2387. /** 
  2388. * Submit CreateInvoice API request to PayPal. 
  2389. * @access public 
  2390. * @param array call config data 
  2391. * @return array 
  2392. */ 
  2393. function CreateInvoice($DataArray) 
  2394. $CreateInvoiceFields = isset($DataArray['CreateInvoiceFields']) ? $DataArray['CreateInvoiceFields'] : array(); 
  2395. $MerchantEmail = isset($CreateInvoiceFields['MerchantEmail']) ? $CreateInvoiceFields['MerchantEmail'] : ''; 
  2396. $PayerEmail = isset($CreateInvoiceFields['PayerEmail']) ? $CreateInvoiceFields['PayerEmail'] : ''; 
  2397. $Number = isset($CreateInvoiceFields['Number']) ? $CreateInvoiceFields['Number'] : ''; 
  2398. $CurrencyCode = isset($CreateInvoiceFields['CurrencyCode']) ? $CreateInvoiceFields['CurrencyCode'] : ''; 
  2399. $InvoiceDate = isset($CreateInvoiceFields['InvoiceDate']) ? $CreateInvoiceFields['InvoiceDate'] : ''; 
  2400. $DueDate = isset($CreateInvoiceFields['DueDate']) ? $CreateInvoiceFields['DueDate'] : ''; 
  2401. $PaymentTerms = isset($CreateInvoiceFields['PaymentTerms']) ? $CreateInvoiceFields['PaymentTerms'] : ''; 
  2402. $DiscountPercent = isset($CreateInvoiceFields['DiscountPercent']) ? $CreateInvoiceFields['DiscountPercent'] : ''; 
  2403. $DiscountAmount = isset($CreateInvoiceFields['DiscountAmount']) ? $CreateInvoiceFields['DiscountAmount'] : ''; 
  2404. $Terms = isset($CreateInvoiceFields['Terms']) ? $CreateInvoiceFields['Terms'] : ''; 
  2405. $Note = isset($CreateInvoiceFields['Note']) ? $CreateInvoiceFields['Note'] : ''; 
  2406. $MerchantMemo = isset($CreateInvoiceFields['MerchantMemo']) ? $CreateInvoiceFields['MerchantMemo'] : ''; 
  2407. $ShippingAmount = isset($CreateInvoiceFields['ShippingAmount']) ? $CreateInvoiceFields['ShippingAmount'] : ''; 
  2408. $ShippingTaxName = isset($CreateInvoiceFields['ShippingTaxName']) ? $CreateInvoiceFields['ShippingTaxName'] : ''; 
  2409. $ShippingTaxRate = isset($CreateInvoiceFields['ShippingTaxRate']) ? $CreateInvoiceFields['ShippingTaxRate'] : ''; 
  2410. $LogoURL = isset($CreateInvoiceFields['LogoURL']) ? $CreateInvoiceFields['LogoURL'] : ''; 
  2411.  
  2412. $BusinessInfo = isset($DataArray['BusinessInfo']) ? $DataArray['BusinessInfo'] : array(); 
  2413. $BusinessFirstName = isset($BusinessInfo['FirstName']) ? $BusinessInfo['FirstName'] : ''; 
  2414. $BusinessLastName = isset($BusinessInfo['LastName']) ? $BusinessInfo['LastName'] : ''; 
  2415. $BusinessBusinessName = isset($BusinessInfo['BusinessName']) ? $BusinessInfo['BusinessName'] : ''; 
  2416. $BusinessPhone = isset($BusinessInfo['Phone']) ? $BusinessInfo['Phone'] : ''; 
  2417. $BusinessFax = isset($BusinessInfo['Fax']) ? $BusinessInfo['Fax'] : ''; 
  2418. $BusinessWebsite = isset($BusinessInfo['Website']) ? $BusinessInfo['Website'] : ''; 
  2419. $BusinessCustom = isset($BusinessInfo['Custom']) ? $BusinessInfo['Custom'] : ''; 
  2420.  
  2421. $BusinessInfoAddress = isset($DataArray['BusinessInfoAddress']) ? $DataArray['BusinessInfoAddress'] : array(); 
  2422. $BusinessInfoAddressLine1 = isset($BusinessInfoAddress['Line1']) ? $BusinessInfoAddress['Line1'] : ''; 
  2423. $BusinessInfoAddressLine2 = isset($BusinessInfoAddress['Line2']) ? $BusinessInfoAddress['Line2'] : ''; 
  2424. $BusinessInfoAddressCity = isset($BusinessInfoAddress['City']) ? $BusinessInfoAddress['City'] : ''; 
  2425. $BusinessInfoAddressState = isset($BusinessInfoAddress['State']) ? $BusinessInfoAddress['State'] : ''; 
  2426. $BusinessInfoAddressPostalCode = isset($BusinessInfoAddress['PostalCode']) ? $BusinessInfoAddress['PostalCode'] : ''; 
  2427. $BusinessInfoAddressCountryCode = isset($BusinessInfoAddress['CountryCode']) ? $BusinessInfoAddress['CountryCode'] : ''; 
  2428. $BusinessInfoAddressType = isset($BusinessInfoAddress['AddressType']) ? $BusinessInfoAddress['AddressType'] : ''; 
  2429.  
  2430. $BillingInfo = isset($DataArray['BillingInfo']) ? $DataArray['BillingInfo'] : array(); 
  2431. $BillingFirstName = isset($BillingInfo['FirstName']) ? $BillingInfo['FirstName'] : ''; 
  2432. $BillingLastName = isset($BillingInfo['LastName']) ? $BillingInfo['LastName'] : ''; 
  2433. $BillingBusinessName = isset($BillingInfo['BusinessName']) ? $BillingInfo['BusinessName'] : ''; 
  2434. $BillingPhone = isset($BillingInfo['Phone']) ? $BillingInfo['Phone'] : ''; 
  2435. $BillingFax = isset($BillingInfo['Fax']) ? $BillingInfo['Fax'] : ''; 
  2436. $BillingWebsite = isset($BillingInfo['Website']) ? $BillingInfo['Website'] : ''; 
  2437. $BillingCustom = isset($BillingInfo['Custom']) ? $BillingInfo['Custom'] : ''; 
  2438.  
  2439. $BillingInfoAddress = isset($DataArray['BillingInfoAddress']) ? $DataArray['BillingInfoAddress'] : array(); 
  2440. $BillingInfoAddressLine1 = isset($BillingInfoAddress['Line1']) ? $BillingInfoAddress['Line1'] : ''; 
  2441. $BillingInfoAddressLine2 = isset($BillingInfoAddress['Line2']) ? $BillingInfoAddress['Line2'] : ''; 
  2442. $BillingInfoAddressCity = isset($BillingInfoAddress['City']) ? $BillingInfoAddress['City'] : ''; 
  2443. $BillingInfoAddressState = isset($BillingInfoAddress['State']) ? $BillingInfoAddress['State'] : ''; 
  2444. $BillingInfoAddressPostalCode = isset($BillingInfoAddress['PostalCode']) ? $BillingInfoAddress['PostalCode'] : ''; 
  2445. $BillingInfoAddressCountryCode = isset($BillingInfoAddress['CountryCode']) ? $BillingInfoAddress['CountryCode'] : ''; 
  2446. $BillingInfoAddressType = isset($BillingInfoAddress['AddressType']) ? $BillingInfoAddress['AddressType'] : ''; 
  2447.  
  2448. $ShippingInfo = isset($DataArray['ShippingInfo']) ? $DataArray['ShippingInfo'] : array(); 
  2449. $ShippingFirstName = isset($ShippingInfo['FirstName']) ? $ShippingInfo['FirstName'] : ''; 
  2450. $ShippingLastName = isset($ShippingInfo['LastName']) ? $ShippingInfo['LastName'] : ''; 
  2451. $ShippingBusinessName = isset($ShippingInfo['BusinessName']) ? $ShippingInfo['BusinessName'] : ''; 
  2452. $ShippingPhone = isset($ShippingInfo['Phone']) ? $ShippingInfo['Phone'] : ''; 
  2453. $ShippingFax = isset($ShippingInfo['Fax']) ? $ShippingInfo['Fax'] : ''; 
  2454. $ShippingWebsite = isset($ShippingInfo['Website']) ? $ShippingInfo['Website'] : ''; 
  2455. $ShippingCustom = isset($ShippingInfo['Custom']) ? $ShippingInfo['Custom'] : ''; 
  2456.  
  2457. $ShippingInfoAddress = isset($DataArray['ShippingInfoAddress']) ? $DataArray['ShippingInfoAddress'] : array(); 
  2458. $ShippingInfoAddressLine1 = isset($ShippingInfoAddress['Line1']) ? $ShippingInfoAddress['Line1'] : ''; 
  2459. $ShippingInfoAddressLine2 = isset($ShippingInfoAddress['Line2']) ? $ShippingInfoAddress['Line2'] : ''; 
  2460. $ShippingInfoAddressCity = isset($ShippingInfoAddress['City']) ? $ShippingInfoAddress['City'] : ''; 
  2461. $ShippingInfoAddressState = isset($ShippingInfoAddress['State']) ? $ShippingInfoAddress['State'] : ''; 
  2462. $ShippingInfoAddressPostalCode = isset($ShippingInfoAddress['PostalCode']) ? $ShippingInfoAddress['PostalCode'] : ''; 
  2463. $ShippingInfoAddressCountryCode = isset($ShippingInfoAddress['CountryCode']) ? $ShippingInfoAddress['CountryCode'] : ''; 
  2464. $ShippingInfoAddressType = isset($ShippingInfoAddress['AddressType']) ? $ShippingInfoAddress['AddressType'] : ''; 
  2465.  
  2466. $InvoiceItems = isset($DataArray['InvoiceItems']) ? $DataArray['InvoiceItems'] : array(); 
  2467.  
  2468. // Generate XML Request 
  2469. $XMLRequest = '<?xml version="1.0" encoding="utf-8"?>'; 
  2470. $XMLRequest .= '<CreateInvoiceRequest xmlns="' . $this -> XMLNamespace . '">'; 
  2471. $XMLRequest .= $this -> GetXMLRequestEnvelope(); 
  2472. $XMLRequest .= '<invoice xmlns="">'; 
  2473. $XMLRequest .= $MerchantEmail != '' ? '<merchantEmail xmlns="">' . $MerchantEmail . '</merchantEmail>' : ''; 
  2474. $XMLRequest .= $PayerEmail != '' ? '<payerEmail xmlns="">' . $PayerEmail . '</payerEmail>' : ''; 
  2475. $XMLRequest .= $Number != '' ? '<number xmlns="">' . $Number . '</number>' : ''; 
  2476.  
  2477. if(!empty($BusinessInfo)) 
  2478. $XMLRequest .= '<merchantInfo xmlns="">'; 
  2479. $XMLRequest .= $BusinessFirstName != '' ? '<firstName xmlns="">' . $BusinessFirstName . '</firstName>' : ''; 
  2480. $XMLRequest .= $BusinessLastName != '' ? '<lastName xmlns="">' . $BusinessLastName . '</lastName>' : ''; 
  2481. $XMLRequest .= $BusinessBusinessName != '' ? '<businessName xmlns="">' . $BusinessBusinessName . '</businessName>' : ''; 
  2482. $XMLRequest .= $BusinessPhone != '' ? '<phone xmlns="">' . $BusinessPhone . '</phone>' : ''; 
  2483. $XMLRequest .= $BusinessFax != '' ? '<fax xmlns="">' . $BusinessFax . '</fax>' : ''; 
  2484. $XMLRequest .= $BusinessWebsite != '' ? '<website xmlns="">' . $BusinessWebsite . '</website>' : ''; 
  2485. $XMLRequest .= $BusinessCustom != '' ? '<customValue xmlns="">' . $BusinessCustom . '</customValue>' : ''; 
  2486.  
  2487. if(!empty($BusinessInfoAddress)) 
  2488. $XMLRequest .= '<address xmlns="">'; 
  2489. $XMLRequest .= $BusinessInfoAddressLine1 != '' ? '<line1 xmlns="">' . $BusinessInfoAddressLine1 . '</line1>' : ''; 
  2490. $XMLRequest .= $BusinessInfoAddressLine2 != '' ? '<line2 xmlns="">' . $BusinessInfoAddressLine2 . '</line2>' : ''; 
  2491. $XMLRequest .= $BusinessInfoAddressCity != '' ? '<city xmlns="">' . $BusinessInfoAddressCity . '</city>' : ''; 
  2492. $XMLRequest .= $BusinessInfoAddressState != '' ? '<state xmlns="">' . $BusinessInfoAddressState . '</state>' : ''; 
  2493. $XMLRequest .= $BusinessInfoAddressPostalCode != '' ? '<postalCode xmlns="">' . $BusinessInfoAddressPostalCode . '</postalCode>' : ''; 
  2494. $XMLRequest .= $BusinessInfoAddressCountryCode != '' ? '<countryCode xmlns="">' . $BusinessInfoAddressCountryCode . '</countryCode>' : ''; 
  2495. $XMLRequest .= $BusinessInfoAddressType != '' ? '<type xmlns="">' . $BusinessInfoAddressType . '</type>' : ''; 
  2496. $XMLRequest .= '</address>'; 
  2497. $XMLRequest .= '</merchantInfo>'; 
  2498.  
  2499. if(!empty($InvoiceItems)) 
  2500. $XMLRequest .= '<itemList xmlns="">'; 
  2501. foreach($InvoiceItems as $InvoiceItem) 
  2502. $XMLRequest .= '<item xmlns="">'; 
  2503. $XMLRequest .= $InvoiceItem['Name'] != '' ? '<name xmlns="">' . $InvoiceItem['Name'] . '</name>' : ''; 
  2504. $XMLRequest .= $InvoiceItem['Description'] != '' ? '<description xmlns="">' . $InvoiceItem['Description'] . '</description>' : ''; 
  2505. $XMLRequest .= $InvoiceItem['Date'] != '' ? '<date xmlns="">' . $InvoiceItem['Date'] . '</date>' : ''; 
  2506. $XMLRequest .= $InvoiceItem['Quantity'] != '' ? '<quantity xmlns="">' . $InvoiceItem['Quantity'] . '</quantity>' : ''; 
  2507. $XMLRequest .= $InvoiceItem['UnitPrice'] != '' ? '<unitPrice xmlns="">' . $InvoiceItem['UnitPrice'] . '</unitPrice>' : ''; 
  2508. $XMLRequest .= $InvoiceItem['TaxName'] != '' ? '<taxName xmlns="">' . $InvoiceItem['TaxName'] . '</taxName>' : ''; 
  2509. $XMLRequest .= $InvoiceItem['TaxRate'] != '' ? '<taxRate xmlns="">' . $InvoiceItem['TaxRate'] . '</taxRate>' : ''; 
  2510. $XMLRequest .= '</item>';  
  2511. $XMLRequest .= '</itemList>'; 
  2512.  
  2513. $XMLRequest .= $CurrencyCode != '' ? '<currencyCode xmlns="">' . $CurrencyCode . '</currencyCode>' : ''; 
  2514. $XMLRequest .= $InvoiceDate != '' ? '<invoiceDate xmlns="">' . $InvoiceDate . '</invoiceDate>' : ''; 
  2515. $XMLRequest .= $DueDate != '' ? '<dueDate xmlns="">' . $DueDate . '</dueDate>' : ''; 
  2516. $XMLRequest .= $PaymentTerms != '' ? '<paymentTerms xmlns="">' . $PaymentTerms . '</paymentTerms>' : ''; 
  2517. $XMLRequest .= $DiscountPercent != '' ? '<discountPercent xmlns="">' . $DiscountPercent . '</discountPercent>' : ''; 
  2518. $XMLRequest .= $DiscountAmount != '' ? '<discountAmount xmlns="">' . $DiscountAmount . '</discountAmount>' : ''; 
  2519. $XMLRequest .= $Terms != '' ? '<terms xmlns="">' . $Terms . '</terms>' : ''; 
  2520. $XMLRequest .= $Note != '' ? '<note xmlns="">' . $Note . '</note>' : ''; 
  2521. $XMLRequest .= $MerchantMemo != '' ? '<merchantMemo xmlns="">' . $MerchantMemo . '</merchantMemo>' : ''; 
  2522.  
  2523. if(!empty($BillingInfo)) 
  2524. $XMLRequest .= '<billingInfo xmlns="">'; 
  2525. $XMLRequest .= $BillingFirstName != '' ? '<firstName xmlns="">' . $BillingFirstName . '</firstName>' : ''; 
  2526. $XMLRequest .= $BillingLastName != '' ? '<lastName xmlns="">' . $BillingLastName . '</lastName>' : ''; 
  2527. $XMLRequest .= $BillingBusinessName != '' ? '<businessName xmlns="">' . $BillingBusinessName . '</businessName>' : ''; 
  2528. $XMLRequest .= $BillingPhone != '' ? '<phone xmlns="">' . $BillingPhone . '</phone>' : ''; 
  2529. $XMLRequest .= $BillingFax != '' ? '<fax xmlns="">' . $BillingFax . '</fax>' : ''; 
  2530. $XMLRequest .= $BillingWebsite != '' ? '<website xmlns="">' . $BillingWebsite . '</website>' : ''; 
  2531. $XMLRequest .= $BillingCustom != '' ? '<customValue xmlns="">' . $BillingCustom . '</customValue>' : ''; 
  2532.  
  2533. if(!empty($BillingInfoAddress)) 
  2534. $XMLRequest .= '<address xmlns="">'; 
  2535. $XMLRequest .= $BillingInfoAddressLine1 != '' ? '<line1 xmlns="">' . $BillingInfoAddressLine1 . '</line1>' : ''; 
  2536. $XMLRequest .= $BillingInfoAddressLine2 != '' ? '<line2 xmlns="">' . $BillingInfoAddressLine2 . '</line2>' : ''; 
  2537. $XMLRequest .= $BillingInfoAddressCity != '' ? '<city xmlns="">' . $BillingInfoAddressCity . '</city>' : ''; 
  2538. $XMLRequest .= $BillingInfoAddressState != '' ? '<state xmlns="">' . $BillingInfoAddressState . '</state>' : ''; 
  2539. $XMLRequest .= $BillingInfoAddressPostalCode != '' ? '<postalCode xmlns="">' . $BillingInfoAddressPostalCode . '</postalCode>' : ''; 
  2540. $XMLRequest .= $BillingInfoAddressCountryCode != '' ? '<countryCode xmlns="">' . $BillingInfoAddressCountryCode . '</countryCode>' : ''; 
  2541. $XMLRequest .= $BillingInfoAddressType != '' ? '<type xmlns="">' . $BillingInfoAddressType . '</type>' : ''; 
  2542. $XMLRequest .= '</address>'; 
  2543. $XMLRequest .= '</billingInfo>'; 
  2544.  
  2545. if(!empty($ShippingInfo)) 
  2546. $XMLRequest .= '<shippingInfo xmlns="">'; 
  2547. $XMLRequest .= $ShippingFirstName != '' ? '<firstName xmlns="">' . $ShippingFirstName . '</firstName>' : ''; 
  2548. $XMLRequest .= $ShippingLastName != '' ? '<lastName xmlns="">' . $ShippingLastName . '</lastName>' : ''; 
  2549. $XMLRequest .= $ShippingBusinessName != '' ? '<businessName xmlns="">' . $ShippingBusinessName . '</businessName>' : ''; 
  2550. $XMLRequest .= $ShippingPhone != '' ? '<phone xmlns="">' . $ShippingPhone . '</phone>' : ''; 
  2551. $XMLRequest .= $ShippingFax != '' ? '<fax xmlns="">' . $ShippingFax . '</fax>' : ''; 
  2552. $XMLRequest .= $ShippingWebsite != '' ? '<website xmlns="">' . $ShippingWebsite . '</website>' : ''; 
  2553. $XMLRequest .= $ShippingCustom != '' ? '<customValue xmlns="">' . $ShippingCustom . '</customValue>' : ''; 
  2554.  
  2555. if(!empty($ShippingInfoAddress)) 
  2556. $XMLRequest .= '<address xmlns="">'; 
  2557. $XMLRequest .= $ShippingInfoAddressLine1 != '' ? '<line1 xmlns="">' . $ShippingInfoAddressLine1 . '</line1>' : ''; 
  2558. $XMLRequest .= $ShippingInfoAddressLine2 != '' ? '<line2 xmlns="">' . $ShippingInfoAddressLine2 . '</line2>' : ''; 
  2559. $XMLRequest .= $ShippingInfoAddressCity != '' ? '<city xmlns="">' . $ShippingInfoAddressCity . '</city>' : ''; 
  2560. $XMLRequest .= $ShippingInfoAddressState != '' ? '<state xmlns="">' . $ShippingInfoAddressState . '</state>' : ''; 
  2561. $XMLRequest .= $ShippingInfoAddressPostalCode != '' ? '<postalCode xmlns="">' . $ShippingInfoAddressPostalCode . '</postalCode>' : ''; 
  2562. $XMLRequest .= $ShippingInfoAddressCountryCode != '' ? '<countryCode xmlns="">' . $ShippingInfoAddressCountryCode . '</countryCode>' : ''; 
  2563. $XMLRequest .= $ShippingInfoAddressType != '' ? '<type xmlns="">' . $ShippingInfoAddressType . '</type>' : ''; 
  2564. $XMLRequest .= '</address>'; 
  2565. $XMLRequest .= '</shippingInfo>'; 
  2566.  
  2567. $XMLRequest .= $ShippingAmount != '' ? '<shippingAmount xmlns="">' . $ShippingAmount . '</shippingAmount>' : ''; 
  2568. $XMLRequest .= $ShippingTaxName != '' ? '<shippingTaxName xmlns="">' . $ShippingTaxName . '</shippingTaxName>' : ''; 
  2569. $XMLRequest .= $ShippingTaxRate != '' ? '<shippingTaxRate xmlns="">' . $ShippingTaxRate . '</shippingTaxRate>' : ''; 
  2570. $XMLRequest .= $LogoURL != '' ? '<logoUrl xmlns="">' . $LogoURL . '</logoUrl>' : ''; 
  2571. $XMLRequest .= '<referrerCode xmlns="">'.$this->APIButtonSource.'</referrerCode>'; 
  2572. $XMLRequest .= '</invoice>'; 
  2573. $XMLRequest .= '</CreateInvoiceRequest>'; 
  2574.  
  2575. // Call the API and load XML response into DOM 
  2576. $XMLResponse = $this -> CURLRequest($XMLRequest, 'Invoice', 'CreateInvoice'); 
  2577. $DOM = new DOMDocument(); 
  2578. $DOM -> loadXML($XMLResponse); 
  2579.  
  2580. // Parse XML values 
  2581. $Fault = $DOM -> getElementsByTagName('FaultMessage') -> length > 0 ? true : false; 
  2582. $Errors = $this -> GetErrors($XMLResponse); 
  2583. $Ack = $DOM -> getElementsByTagName('ack') -> length > 0 ? $DOM -> getElementsByTagName('ack') -> item(0) -> nodeValue : ''; 
  2584. $Build = $DOM -> getElementsByTagName('build') -> length > 0 ? $DOM -> getElementsByTagName('build') -> item(0) -> nodeValue : ''; 
  2585. $CorrelationID = $DOM -> getElementsByTagName('correlationId') -> length > 0 ? $DOM -> getElementsByTagName('correlationId') -> item(0) -> nodeValue : ''; 
  2586. $Timestamp = $DOM -> getElementsByTagName('timestamp') -> length > 0 ? $DOM -> getElementsByTagName('timestamp') -> item(0) -> nodeValue : ''; 
  2587.  
  2588. $InvoiceID = $DOM -> getElementsByTagName('invoiceID') -> length > 0 ? $DOM -> getElementsByTagName('invoiceID') -> item(0) -> nodeValue : ''; 
  2589. $InvoiceNumber = $DOM -> getElementsByTagName('invoiceNumber') -> length > 0 ? $DOM -> getElementsByTagName('invoiceNumber') -> item(0) -> nodeValue : ''; 
  2590. $InvoiceURL = $DOM -> getElementsByTagName('invoiceURL') -> length > 0 ? $DOM -> getElementsByTagName('invoiceURL') -> item(0) -> nodeValue : ''; 
  2591.  
  2592. $ResponseDataArray = array( 
  2593. 'Errors' => $Errors,  
  2594. 'Ack' => $Ack,  
  2595. 'Build' => $Build,  
  2596. 'CorrelationID' => $CorrelationID,  
  2597. 'Timestamp' => $Timestamp,  
  2598. 'InvoiceID' => $InvoiceID,  
  2599. 'InvoiceNumber' => $InvoiceNumber,  
  2600. 'InvoiceURL' => $InvoiceURL,  
  2601. 'XMLRequest' => $XMLRequest,  
  2602. 'XMLResponse' => $XMLResponse 
  2603. ); 
  2604.  
  2605. return $ResponseDataArray; 
  2606.  
  2607.  
  2608. /** 
  2609. * Submit SendInvoice API request to PayPal. 
  2610. * @access public 
  2611. * @param string InvoiceID 
  2612. * @return array 
  2613. */ 
  2614. function SendInvoice($InvoiceID) 
  2615. // Generate XML Request 
  2616. $XMLRequest = '<?xml version="1.0" encoding="utf-8"?>'; 
  2617. $XMLRequest .= '<SendInvoiceRequest xmlns="' . $this -> XMLNamespace . '">'; 
  2618. $XMLRequest .= $this -> GetXMLRequestEnvelope(); 
  2619. $XMLRequest .= $InvoiceID != '' ? '<invoiceID xmlns="">' . $InvoiceID . '</invoiceID>' : ''; 
  2620. $XMLRequest .= '</SendInvoiceRequest>'; 
  2621.  
  2622. // Call the API and load XML response into DOM 
  2623. $XMLResponse = $this -> CURLRequest($XMLRequest, 'Invoice', 'SendInvoice'); 
  2624. $DOM = new DOMDocument(); 
  2625. $DOM -> loadXML($XMLResponse); 
  2626.  
  2627. // Parse XML values 
  2628. $Fault = $DOM -> getElementsByTagName('FaultMessage') -> length > 0 ? true : false; 
  2629. $Errors = $this -> GetErrors($XMLResponse); 
  2630. $Ack = $DOM -> getElementsByTagName('ack') -> length > 0 ? $DOM -> getElementsByTagName('ack') -> item(0) -> nodeValue : ''; 
  2631. $Build = $DOM -> getElementsByTagName('build') -> length > 0 ? $DOM -> getElementsByTagName('build') -> item(0) -> nodeValue : ''; 
  2632. $CorrelationID = $DOM -> getElementsByTagName('correlationId') -> length > 0 ? $DOM -> getElementsByTagName('correlationId') -> item(0) -> nodeValue : ''; 
  2633. $Timestamp = $DOM -> getElementsByTagName('timestamp') -> length > 0 ? $DOM -> getElementsByTagName('timestamp') -> item(0) -> nodeValue : ''; 
  2634.  
  2635. $InvoiceID = $DOM -> getElementsByTagName('invoiceID') -> length > 0 ? $DOM -> getElementsByTagName('invoiceID') -> item(0) -> nodeValue : ''; 
  2636. $InvoiceURL = $DOM -> getElementsByTagName('invoiceURL') -> length > 0 ? $DOM -> getElementsByTagName('invoiceURL') -> item(0) -> nodeValue : ''; 
  2637.  
  2638. $ResponseDataArray = array( 
  2639. 'Errors' => $Errors,  
  2640. 'Ack' => $Ack,  
  2641. 'Build' => $Build,  
  2642. 'CorrelationID' => $CorrelationID,  
  2643. 'Timestamp' => $Timestamp,  
  2644. 'InvoiceID' => $InvoiceID,  
  2645. 'InvoiceURL' => $InvoiceURL,  
  2646. 'XMLRequest' => $XMLRequest,  
  2647. 'XMLResponse' => $XMLResponse 
  2648. ); 
  2649.  
  2650. return $ResponseDataArray; 
  2651.  
  2652.  
  2653. /** 
  2654. * Submit CreateAndSendInvoice API request to PayPal. 
  2655. * @access public 
  2656. * @param array call config data 
  2657. * @return array 
  2658. */ 
  2659. function CreateAndSendInvoice($DataArray) 
  2660. $CreateInvoiceFields = isset($DataArray['CreateInvoiceFields']) ? $DataArray['CreateInvoiceFields'] : array(); 
  2661. $MerchantEmail = isset($CreateInvoiceFields['MerchantEmail']) ? $CreateInvoiceFields['MerchantEmail'] : ''; 
  2662. $PayerEmail = isset($CreateInvoiceFields['PayerEmail']) ? $CreateInvoiceFields['PayerEmail'] : ''; 
  2663. $Number = isset($CreateInvoiceFields['Number']) ? $CreateInvoiceFields['Number'] : ''; 
  2664. $CurrencyCode = isset($CreateInvoiceFields['CurrencyCode']) ? $CreateInvoiceFields['CurrencyCode'] : ''; 
  2665. $InvoiceDate = isset($CreateInvoiceFields['InvoiceDate']) ? $CreateInvoiceFields['InvoiceDate'] : ''; 
  2666. $DueDate = isset($CreateInvoiceFields['DueDate']) ? $CreateInvoiceFields['DueDate'] : ''; 
  2667. $PaymentTerms = isset($CreateInvoiceFields['PaymentTerms']) ? $CreateInvoiceFields['PaymentTerms'] : ''; 
  2668. $DiscountPercent = isset($CreateInvoiceFields['DiscountPercent']) ? $CreateInvoiceFields['DiscountPercent'] : ''; 
  2669. $DiscountAmount = isset($CreateInvoiceFields['DiscountAmount']) ? $CreateInvoiceFields['DiscountAmount'] : ''; 
  2670. $Terms = isset($CreateInvoiceFields['Terms']) ? $CreateInvoiceFields['Terms'] : ''; 
  2671. $Note = isset($CreateInvoiceFields['Note']) ? $CreateInvoiceFields['Note'] : ''; 
  2672. $MerchantMemo = isset($CreateInvoiceFields['MerchantMemo']) ? $CreateInvoiceFields['MerchantMemo'] : ''; 
  2673. $ShippingAmount = isset($CreateInvoiceFields['ShippingAmount']) ? $CreateInvoiceFields['ShippingAmount'] : ''; 
  2674. $ShippingTaxName = isset($CreateInvoiceFields['ShippingTaxName']) ? $CreateInvoiceFields['ShippingTaxName'] : ''; 
  2675. $ShippingTaxRate = isset($CreateInvoiceFields['ShippingTaxRate']) ? $CreateInvoiceFields['ShippingTaxRate'] : ''; 
  2676. $LogoURL = isset($CreateInvoiceFields['LogoURL']) ? $CreateInvoiceFields['LogoURL'] : ''; 
  2677.  
  2678. $BusinessInfo = isset($DataArray['BusinessInfo']) ? $DataArray['BusinessInfo'] : array(); 
  2679. $BusinessFirstName = isset($BusinessInfo['FirstName']) ? $BusinessInfo['FirstName'] : ''; 
  2680. $BusinessLastName = isset($BusinessInfo['LastName']) ? $BusinessInfo['LastName'] : ''; 
  2681. $BusinessBusinessName = isset($BusinessInfo['BusinessName']) ? $BusinessInfo['BusinessName'] : ''; 
  2682. $BusinessPhone = isset($BusinessInfo['Phone']) ? $BusinessInfo['Phone'] : ''; 
  2683. $BusinessFax = isset($BusinessInfo['Fax']) ? $BusinessInfo['Fax'] : ''; 
  2684. $BusinessWebsite = isset($BusinessInfo['Website']) ? $BusinessInfo['Website'] : ''; 
  2685. $BusinessCustom = isset($BusinessInfo['Custom']) ? $BusinessInfo['Custom'] : ''; 
  2686.  
  2687. $BusinessInfoAddress = isset($DataArray['BusinessInfoAddress']) ? $DataArray['BusinessInfoAddress'] : array(); 
  2688. $BusinessInfoAddressLine1 = isset($BusinessInfoAddress['Line1']) ? $BusinessInfoAddress['Line1'] : ''; 
  2689. $BusinessInfoAddressLine2 = isset($BusinessInfoAddress['Line2']) ? $BusinessInfoAddress['Line2'] : ''; 
  2690. $BusinessInfoAddressCity = isset($BusinessInfoAddress['City']) ? $BusinessInfoAddress['City'] : ''; 
  2691. $BusinessInfoAddressState = isset($BusinessInfoAddress['State']) ? $BusinessInfoAddress['State'] : ''; 
  2692. $BusinessInfoAddressPostalCode = isset($BusinessInfoAddress['PostalCode']) ? $BusinessInfoAddress['PostalCode'] : ''; 
  2693. $BusinessInfoAddressCountryCode = isset($BusinessInfoAddress['CountryCode']) ? $BusinessInfoAddress['CountryCode'] : ''; 
  2694. $BusinessInfoAddressType = isset($BusinessInfoAddress['AddressType']) ? $BusinessInfoAddress['AddressType'] : ''; 
  2695.  
  2696. $BillingInfo = isset($DataArray['BillingInfo']) ? $DataArray['BillingInfo'] : array(); 
  2697. $BillingFirstName = isset($BillingInfo['FirstName']) ? $BillingInfo['FirstName'] : ''; 
  2698. $BillingLastName = isset($BillingInfo['LastName']) ? $BillingInfo['LastName'] : ''; 
  2699. $BillingBusinessName = isset($BillingInfo['BusinessName']) ? $BillingInfo['BusinessName'] : ''; 
  2700. $BillingPhone = isset($BillingInfo['Phone']) ? $BillingInfo['Phone'] : ''; 
  2701. $BillingFax = isset($BillingInfo['Fax']) ? $BillingInfo['Fax'] : ''; 
  2702. $BillingWebsite = isset($BillingInfo['Website']) ? $BillingInfo['Website'] : ''; 
  2703. $BillingCustom = isset($BillingInfo['Custom']) ? $BillingInfo['Custom'] : ''; 
  2704.  
  2705. $BillingInfoAddress = isset($DataArray['BillingInfoAddress']) ? $DataArray['BillingInfoAddress'] : array(); 
  2706. $BillingInfoAddressLine1 = isset($BillingInfoAddress['Line1']) ? $BillingInfoAddress['Line1'] : ''; 
  2707. $BillingInfoAddressLine2 = isset($BillingInfoAddress['Line2']) ? $BillingInfoAddress['Line2'] : ''; 
  2708. $BillingInfoAddressCity = isset($BillingInfoAddress['City']) ? $BillingInfoAddress['City'] : ''; 
  2709. $BillingInfoAddressState = isset($BillingInfoAddress['State']) ? $BillingInfoAddress['State'] : ''; 
  2710. $BillingInfoAddressPostalCode = isset($BillingInfoAddress['PostalCode']) ? $BillingInfoAddress['PostalCode'] : ''; 
  2711. $BillingInfoAddressCountryCode = isset($BillingInfoAddress['CountryCode']) ? $BillingInfoAddress['CountryCode'] : ''; 
  2712. $BillingInfoAddressType = isset($BillingInfoAddress['AddressType']) ? $BillingInfoAddress['AddressType'] : ''; 
  2713.  
  2714. $ShippingInfo = isset($DataArray['ShippingInfo']) ? $DataArray['ShippingInfo'] : array(); 
  2715. $ShippingFirstName = isset($ShippingInfo['FirstName']) ? $ShippingInfo['FirstName'] : ''; 
  2716. $ShippingLastName = isset($ShippingInfo['LastName']) ? $ShippingInfo['LastName'] : ''; 
  2717. $ShippingBusinessName = isset($ShippingInfo['BusinessName']) ? $ShippingInfo['BusinessName'] : ''; 
  2718. $ShippingPhone = isset($ShippingInfo['Phone']) ? $ShippingInfo['Phone'] : ''; 
  2719. $ShippingFax = isset($ShippingInfo['Fax']) ? $ShippingInfo['Fax'] : ''; 
  2720. $ShippingWebsite = isset($ShippingInfo['Website']) ? $ShippingInfo['Website'] : ''; 
  2721. $ShippingCustom = isset($ShippingInfo['Custom']) ? $ShippingInfo['Custom'] : ''; 
  2722.  
  2723. $ShippingInfoAddress = isset($DataArray['ShippingInfoAddress']) ? $DataArray['ShippingInfoAddress'] : array(); 
  2724. $ShippingInfoAddressLine1 = isset($ShippingInfoAddress['Line1']) ? $ShippingInfoAddress['Line1'] : ''; 
  2725. $ShippingInfoAddressLine2 = isset($ShippingInfoAddress['Line2']) ? $ShippingInfoAddress['Line2'] : ''; 
  2726. $ShippingInfoAddressCity = isset($ShippingInfoAddress['City']) ? $ShippingInfoAddress['City'] : ''; 
  2727. $ShippingInfoAddressState = isset($ShippingInfoAddress['State']) ? $ShippingInfoAddress['State'] : ''; 
  2728. $ShippingInfoAddressPostalCode = isset($ShippingInfoAddress['PostalCode']) ? $ShippingInfoAddress['PostalCode'] : ''; 
  2729. $ShippingInfoAddressCountryCode = isset($ShippingInfoAddress['CountryCode']) ? $ShippingInfoAddress['CountryCode'] : ''; 
  2730. $ShippingInfoAddressType = isset($ShippingInfoAddress['AddressType']) ? $ShippingInfoAddress['AddressType'] : ''; 
  2731.  
  2732. $InvoiceItems = isset($DataArray['InvoiceItems']) ? $DataArray['InvoiceItems'] : array(); 
  2733.  
  2734. // Generate XML Request 
  2735. $XMLRequest = '<?xml version="1.0" encoding="utf-8"?>'; 
  2736. $XMLRequest .= '<CreateAndSendInvoiceRequest xmlns="' . $this -> XMLNamespace . '">'; 
  2737. $XMLRequest .= $this -> GetXMLRequestEnvelope(); 
  2738. $XMLRequest .= '<invoice xmlns="">'; 
  2739. $XMLRequest .= $MerchantEmail != '' ? '<merchantEmail xmlns="">' . $MerchantEmail . '</merchantEmail>' : ''; 
  2740. $XMLRequest .= $PayerEmail != '' ? '<payerEmail xmlns="">' . $PayerEmail . '</payerEmail>' : ''; 
  2741. $XMLRequest .= $Number != '' ? '<number xmlns="">' . $Number . '</number>' : ''; 
  2742.  
  2743. if(!empty($BusinessInfo)) 
  2744. $XMLRequest .= '<merchantInfo xmlns="">'; 
  2745. $XMLRequest .= $BusinessFirstName != '' ? '<firstName xmlns="">' . $BusinessFirstName . '</firstName>' : ''; 
  2746. $XMLRequest .= $BusinessLastName != '' ? '<lastName xmlns="">' . $BusinessLastName . '</lastName>' : ''; 
  2747. $XMLRequest .= $BusinessBusinessName != '' ? '<businessName xmlns="">' . $BusinessBusinessName . '</businessName>' : ''; 
  2748. $XMLRequest .= $BusinessPhone != '' ? '<phone xmlns="">' . $BusinessPhone . '</phone>' : ''; 
  2749. $XMLRequest .= $BusinessFax != '' ? '<fax xmlns="">' . $BusinessFax . '</fax>' : ''; 
  2750. $XMLRequest .= $BusinessWebsite != '' ? '<website xmlns="">' . $BusinessWebsite . '</website>' : ''; 
  2751. $XMLRequest .= $BusinessCustom != '' ? '<customValue xmlns="">' . $BusinessCustom . '</customValue>' : ''; 
  2752.  
  2753. if(!empty($BusinessInfoAddress)) 
  2754. $XMLRequest .= '<address xmlns="">'; 
  2755. $XMLRequest .= $BusinessInfoAddressLine1 != '' ? '<line1 xmlns="">' . $BusinessInfoAddressLine1 . '</line1>' : ''; 
  2756. $XMLRequest .= $BusinessInfoAddressLine2 != '' ? '<line2 xmlns="">' . $BusinessInfoAddressLine2 . '</line2>' : ''; 
  2757. $XMLRequest .= $BusinessInfoAddressCity != '' ? '<city xmlns="">' . $BusinessInfoAddressCity . '</city>' : ''; 
  2758. $XMLRequest .= $BusinessInfoAddressState != '' ? '<state xmlns="">' . $BusinessInfoAddressState . '</state>' : ''; 
  2759. $XMLRequest .= $BusinessInfoAddressPostalCode != '' ? '<postalCode xmlns="">' . $BusinessInfoAddressPostalCode . '</postalCode>' : ''; 
  2760. $XMLRequest .= $BusinessInfoAddressCountryCode != '' ? '<countryCode xmlns="">' . $BusinessInfoAddressCountryCode . '</countryCode>' : ''; 
  2761. $XMLRequest .= $BusinessInfoAddressType != '' ? '<type xmlns="">' . $BusinessInfoAddressType . '</type>' : ''; 
  2762. $XMLRequest .= '</address>'; 
  2763. $XMLRequest .= '</merchantInfo>'; 
  2764.  
  2765. if(!empty($InvoiceItems)) 
  2766. $XMLRequest .= '<itemList xmlns="">'; 
  2767. foreach($InvoiceItems as $InvoiceItem) 
  2768. $XMLRequest .= '<item xmlns="">'; 
  2769. $XMLRequest .= $InvoiceItem['Name'] != '' ? '<name xmlns="">' . $InvoiceItem['Name'] . '</name>' : ''; 
  2770. $XMLRequest .= $InvoiceItem['Description'] != '' ? '<description xmlns="">' . $InvoiceItem['Description'] . '</description>' : ''; 
  2771. $XMLRequest .= $InvoiceItem['Date'] != '' ? '<date xmlns="">' . $InvoiceItem['Date'] . '</date>' : ''; 
  2772. $XMLRequest .= $InvoiceItem['Quantity'] != '' ? '<quantity xmlns="">' . $InvoiceItem['Quantity'] . '</quantity>' : ''; 
  2773. $XMLRequest .= $InvoiceItem['UnitPrice'] != '' ? '<unitPrice xmlns="">' . $InvoiceItem['UnitPrice'] . '</unitPrice>' : ''; 
  2774. $XMLRequest .= $InvoiceItem['TaxName'] != '' ? '<taxName xmlns="">' . $InvoiceItem['TaxName'] . '</taxName>' : ''; 
  2775. $XMLRequest .= $InvoiceItem['TaxRate'] != '' ? '<taxRate xmlns="">' . $InvoiceItem['TaxRate'] . '</taxRate>' : ''; 
  2776. $XMLRequest .= '</item>';  
  2777. $XMLRequest .= '</itemList>'; 
  2778.  
  2779. $XMLRequest .= $CurrencyCode != '' ? '<currencyCode xmlns="">' . $CurrencyCode . '</currencyCode>' : ''; 
  2780. $XMLRequest .= $InvoiceDate != '' ? '<invoiceDate xmlns="">' . $InvoiceDate . '</invoiceDate>' : ''; 
  2781. $XMLRequest .= $DueDate != '' ? '<dueDate xmlns="">' . $DueDate . '</dueDate>' : ''; 
  2782. $XMLRequest .= $PaymentTerms != '' ? '<paymentTerms xmlns="">' . $PaymentTerms . '</paymentTerms>' : ''; 
  2783. $XMLRequest .= $DiscountPercent != '' ? '<discountPercent xmlns="">' . $DiscountPercent . '</discountPercent>' : ''; 
  2784. $XMLRequest .= $DiscountAmount != '' ? '<discountAmount xmlns="">' . $DiscountAmount . '</discountAmount>' : ''; 
  2785. $XMLRequest .= $Terms != '' ? '<terms xmlns="">' . $Terms . '</terms>' : ''; 
  2786. $XMLRequest .= $Note != '' ? '<note xmlns="">' . $Note . '</note>' : ''; 
  2787. $XMLRequest .= $MerchantMemo != '' ? '<merchantMemo xmlns="">' . $MerchantMemo . '</merchantMemo>' : ''; 
  2788.  
  2789. if(!empty($BillingInfo)) 
  2790. $XMLRequest .= '<billingInfo xmlns="">'; 
  2791. $XMLRequest .= $BillingFirstName != '' ? '<firstName xmlns="">' . $BillingFirstName . '</firstName>' : ''; 
  2792. $XMLRequest .= $BillingLastName != '' ? '<lastName xmlns="">' . $BillingLastName . '</lastName>' : ''; 
  2793. $XMLRequest .= $BillingBusinessName != '' ? '<businessName xmlns="">' . $BillingBusinessName . '</businessName>' : ''; 
  2794. $XMLRequest .= $BillingPhone != '' ? '<phone xmlns="">' . $BillingPhone . '</phone>' : ''; 
  2795. $XMLRequest .= $BillingFax != '' ? '<fax xmlns="">' . $BillingFax . '</fax>' : ''; 
  2796. $XMLRequest .= $BillingWebsite != '' ? '<website xmlns="">' . $BillingWebsite . '</website>' : ''; 
  2797. $XMLRequest .= $BillingCustom != '' ? '<customValue xmlns="">' . $BillingCustom . '</customValue>' : ''; 
  2798.  
  2799. if(!empty($BillingInfoAddress)) 
  2800. $XMLRequest .= '<address xmlns="">'; 
  2801. $XMLRequest .= $BillingInfoAddressLine1 != '' ? '<line1 xmlns="">' . $BillingInfoAddressLine1 . '</line1>' : ''; 
  2802. $XMLRequest .= $BillingInfoAddressLine2 != '' ? '<line2 xmlns="">' . $BillingInfoAddressLine2 . '</line2>' : ''; 
  2803. $XMLRequest .= $BillingInfoAddressCity != '' ? '<city xmlns="">' . $BillingInfoAddressCity . '</city>' : ''; 
  2804. $XMLRequest .= $BillingInfoAddressState != '' ? '<state xmlns="">' . $BillingInfoAddressState . '</state>' : ''; 
  2805. $XMLRequest .= $BillingInfoAddressPostalCode != '' ? '<postalCode xmlns="">' . $BillingInfoAddressPostalCode . '</postalCode>' : ''; 
  2806. $XMLRequest .= $BillingInfoAddressCountryCode != '' ? '<countryCode xmlns="">' . $BillingInfoAddressCountryCode . '</countryCode>' : ''; 
  2807. $XMLRequest .= $BillingInfoAddressType != '' ? '<type xmlns="">' . $BillingInfoAddressType . '</type>' : ''; 
  2808. $XMLRequest .= '</address>'; 
  2809. $XMLRequest .= '</billingInfo>'; 
  2810.  
  2811. if(!empty($ShippingInfo)) 
  2812. $XMLRequest .= '<shippingInfo xmlns="">'; 
  2813. $XMLRequest .= $ShippingFirstName != '' ? '<firstName xmlns="">' . $ShippingFirstName . '</firstName>' : ''; 
  2814. $XMLRequest .= $ShippingLastName != '' ? '<lastName xmlns="">' . $ShippingLastName . '</lastName>' : ''; 
  2815. $XMLRequest .= $ShippingBusinessName != '' ? '<businessName xmlns="">' . $ShippingBusinessName . '</businessName>' : ''; 
  2816. $XMLRequest .= $ShippingPhone != '' ? '<phone xmlns="">' . $ShippingPhone . '</phone>' : ''; 
  2817. $XMLRequest .= $ShippingFax != '' ? '<fax xmlns="">' . $ShippingFax . '</fax>' : ''; 
  2818. $XMLRequest .= $ShippingWebsite != '' ? '<website xmlns="">' . $ShippingWebsite . '</website>' : ''; 
  2819. $XMLRequest .= $ShippingCustom != '' ? '<customValue xmlns="">' . $ShippingCustom . '</customValue>' : ''; 
  2820.  
  2821. if(!empty($ShippingInfoAddress)) 
  2822. $XMLRequest .= '<address xmlns="">'; 
  2823. $XMLRequest .= $ShippingInfoAddressLine1 != '' ? '<line1 xmlns="">' . $ShippingInfoAddressLine1 . '</line1>' : ''; 
  2824. $XMLRequest .= $ShippingInfoAddressLine2 != '' ? '<line2 xmlns="">' . $ShippingInfoAddressLine2 . '</line2>' : ''; 
  2825. $XMLRequest .= $ShippingInfoAddressCity != '' ? '<city xmlns="">' . $ShippingInfoAddressCity . '</city>' : ''; 
  2826. $XMLRequest .= $ShippingInfoAddressState != '' ? '<state xmlns="">' . $ShippingInfoAddressState . '</state>' : ''; 
  2827. $XMLRequest .= $ShippingInfoAddressPostalCode != '' ? '<postalCode xmlns="">' . $ShippingInfoAddressPostalCode . '</postalCode>' : ''; 
  2828. $XMLRequest .= $ShippingInfoAddressCountryCode != '' ? '<countryCode xmlns="">' . $ShippingInfoAddressCountryCode . '</countryCode>' : ''; 
  2829. $XMLRequest .= $ShippingInfoAddressType != '' ? '<type xmlns="">' . $ShippingInfoAddressType . '</type>' : ''; 
  2830. $XMLRequest .= '</address>'; 
  2831. $XMLRequest .= '</shippingInfo>'; 
  2832.  
  2833. $XMLRequest .= $ShippingAmount != '' ? '<shippingAmount xmlns="">' . $ShippingAmount . '</shippingAmount>' : ''; 
  2834. $XMLRequest .= $ShippingTaxName != '' ? '<shippingTaxName xmlns="">' . $ShippingTaxName . '</shippingTaxName>' : ''; 
  2835. $XMLRequest .= $ShippingTaxRate != '' ? '<shippingTaxRate xmlns="">' . $ShippingTaxRate . '</shippingTaxRate>' : ''; 
  2836. $XMLRequest .= $LogoURL != '' ? '<logoUrl xmlns="">' . $LogoURL . '</logoUrl>' : ''; 
  2837. $XMLRequest .= '<referrerCode xmlns="">'.$this->APIButtonSource.'</referrerCode>'; 
  2838. $XMLRequest .= '</invoice>'; 
  2839. $XMLRequest .= '</CreateAndSendInvoiceRequest>'; 
  2840.  
  2841. // Call the API and load XML response into DOM 
  2842. $XMLResponse = $this -> CURLRequest($XMLRequest, 'Invoice', 'CreateAndSendInvoice'); 
  2843. $DOM = new DOMDocument(); 
  2844. $DOM -> loadXML($XMLResponse); 
  2845.  
  2846. // Parse XML values 
  2847. $Fault = $DOM -> getElementsByTagName('FaultMessage') -> length > 0 ? true : false; 
  2848. $Errors = $this -> GetErrors($XMLResponse); 
  2849. $Ack = $DOM -> getElementsByTagName('ack') -> length > 0 ? $DOM -> getElementsByTagName('ack') -> item(0) -> nodeValue : ''; 
  2850. $Build = $DOM -> getElementsByTagName('build') -> length > 0 ? $DOM -> getElementsByTagName('build') -> item(0) -> nodeValue : ''; 
  2851. $CorrelationID = $DOM -> getElementsByTagName('correlationId') -> length > 0 ? $DOM -> getElementsByTagName('correlationId') -> item(0) -> nodeValue : ''; 
  2852. $Timestamp = $DOM -> getElementsByTagName('timestamp') -> length > 0 ? $DOM -> getElementsByTagName('timestamp') -> item(0) -> nodeValue : ''; 
  2853.  
  2854. $InvoiceID = $DOM -> getElementsByTagName('invoiceID') -> length > 0 ? $DOM -> getElementsByTagName('invoiceID') -> item(0) -> nodeValue : ''; 
  2855. $InvoiceNumber = $DOM -> getElementsByTagName('invoiceNumber') -> length > 0 ? $DOM -> getElementsByTagName('invoiceNumber') -> item(0) -> nodeValue : ''; 
  2856. $InvoiceURL = $DOM -> getElementsByTagName('invoiceURL') -> length > 0 ? $DOM -> getElementsByTagName('invoiceURL') -> item(0) -> nodeValue : ''; 
  2857.  
  2858. $ResponseDataArray = array( 
  2859. 'Errors' => $Errors,  
  2860. 'Ack' => $Ack,  
  2861. 'Build' => $Build,  
  2862. 'CorrelationID' => $CorrelationID,  
  2863. 'Timestamp' => $Timestamp,  
  2864. 'InvoiceID' => $InvoiceID,  
  2865. 'InvoiceNumber' => $InvoiceNumber,  
  2866. 'InvoiceURL' => $InvoiceURL,  
  2867. 'XMLRequest' => $XMLRequest,  
  2868. 'XMLResponse' => $XMLResponse 
  2869. ); 
  2870.  
  2871. return $ResponseDataArray; 
  2872.  
  2873.  
  2874. /** 
  2875. * Submit UpdateInvoice API request to PayPal. 
  2876. * @access public 
  2877. * @param array call config data 
  2878. * @return array 
  2879. */ 
  2880. function UpdateInvoice($DataArray) 
  2881. $UpdateInvoiceFields = isset($DataArray['UpdateInvoiceFields']) ? $DataArray['UpdateInvoiceFields'] : array(); 
  2882. $InvoiceID = isset($UpdateInvoiceFields['InvoiceID']) ? $UpdateInvoiceFields['InvoiceID'] : ''; 
  2883. $MerchantEmail = isset($UpdateInvoiceFields['MerchantEmail']) ? $UpdateInvoiceFields['MerchantEmail'] : ''; 
  2884. $PayerEmail = isset($UpdateInvoiceFields['PayerEmail']) ? $UpdateInvoiceFields['PayerEmail'] : ''; 
  2885. $Number = isset($UpdateInvoiceFields['Number']) ? $UpdateInvoiceFields['Number'] : ''; 
  2886. $CurrencyCode = isset($UpdateInvoiceFields['CurrencyCode']) ? $UpdateInvoiceFields['CurrencyCode'] : ''; 
  2887. $InvoiceDate = isset($UpdateInvoiceFields['InvoiceDate']) ? $UpdateInvoiceFields['InvoiceDate'] : ''; 
  2888. $DueDate = isset($UpdateInvoiceFields['DueDate']) ? $UpdateInvoiceFields['DueDate'] : ''; 
  2889. $PaymentTerms = isset($UpdateInvoiceFields['PaymentTerms']) ? $UpdateInvoiceFields['PaymentTerms'] : ''; 
  2890. $DiscountPercent = isset($UpdateInvoiceFields['DiscountPercent']) ? $UpdateInvoiceFields['DiscountPercent'] : ''; 
  2891. $DiscountAmount = isset($UpdateInvoiceFields['DiscountAmount']) ? $UpdateInvoiceFields['DiscountAmount'] : ''; 
  2892. $Terms = isset($UpdateInvoiceFields['Terms']) ? $UpdateInvoiceFields['Terms'] : ''; 
  2893. $Note = isset($UpdateInvoiceFields['Note']) ? $UpdateInvoiceFields['Note'] : ''; 
  2894. $MerchantMemo = isset($UpdateInvoiceFields['MerchantMemo']) ? $UpdateInvoiceFields['MerchantMemo'] : ''; 
  2895. $ShippingAmount = isset($UpdateInvoiceFields['ShippingAmount']) ? $UpdateInvoiceFields['ShippingAmount'] : ''; 
  2896. $ShippingTaxName = isset($UpdateInvoiceFields['ShippingTaxName']) ? $UpdateInvoiceFields['ShippingTaxName'] : ''; 
  2897. $ShippingTaxRate = isset($UpdateInvoiceFields['ShippingTaxRate']) ? $UpdateInvoiceFields['ShippingTaxRate'] : ''; 
  2898. $LogoURL = isset($UpdateInvoiceFields['LogoURL']) ? $UpdateInvoiceFields['LogoURL'] : ''; 
  2899.  
  2900. $BusinessInfo = isset($DataArray['BusinessInfo']) ? $DataArray['BusinessInfo'] : array(); 
  2901. $BusinessFirstName = isset($BusinessInfo['FirstName']) ? $BusinessInfo['FirstName'] : ''; 
  2902. $BusinessLastName = isset($BusinessInfo['LastName']) ? $BusinessInfo['LastName'] : ''; 
  2903. $BusinessBusinessName = isset($BusinessInfo['BusinessName']) ? $BusinessInfo['BusinessName'] : ''; 
  2904. $BusinessPhone = isset($BusinessInfo['Phone']) ? $BusinessInfo['Phone'] : ''; 
  2905. $BusinessFax = isset($BusinessInfo['Fax']) ? $BusinessInfo['Fax'] : ''; 
  2906. $BusinessWebsite = isset($BusinessInfo['Website']) ? $BusinessInfo['Website'] : ''; 
  2907. $BusinessCustom = isset($BusinessInfo['Custom']) ? $BusinessInfo['Custom'] : ''; 
  2908.  
  2909. $BusinessInfoAddress = isset($DataArray['BusinessInfoAddress']) ? $DataArray['BusinessInfoAddress'] : array(); 
  2910. $BusinessInfoAddressLine1 = isset($BusinessInfoAddress['Line1']) ? $BusinessInfoAddress['Line1'] : ''; 
  2911. $BusinessInfoAddressLine2 = isset($BusinessInfoAddress['Line2']) ? $BusinessInfoAddress['Line2'] : ''; 
  2912. $BusinessInfoAddressCity = isset($BusinessInfoAddress['City']) ? $BusinessInfoAddress['City'] : ''; 
  2913. $BusinessInfoAddressState = isset($BusinessInfoAddress['State']) ? $BusinessInfoAddress['State'] : ''; 
  2914. $BusinessInfoAddressPostalCode = isset($BusinessInfoAddress['PostalCode']) ? $BusinessInfoAddress['PostalCode'] : ''; 
  2915. $BusinessInfoAddressCountryCode = isset($BusinessInfoAddress['CountryCode']) ? $BusinessInfoAddress['CountryCode'] : ''; 
  2916. $BusinessInfoAddressType = isset($BusinessInfoAddress['AddressType']) ? $BusinessInfoAddress['AddressType'] : ''; 
  2917.  
  2918. $BillingInfo = isset($DataArray['BillingInfo']) ? $DataArray['BillingInfo'] : array(); 
  2919. $BillingFirstName = isset($BillingInfo['FirstName']) ? $BillingInfo['FirstName'] : ''; 
  2920. $BillingLastName = isset($BillingInfo['LastName']) ? $BillingInfo['LastName'] : ''; 
  2921. $BillingBusinessName = isset($BillingInfo['BusinessName']) ? $BillingInfo['BusinessName'] : ''; 
  2922. $BillingPhone = isset($BillingInfo['Phone']) ? $BillingInfo['Phone'] : ''; 
  2923. $BillingFax = isset($BillingInfo['Fax']) ? $BillingInfo['Fax'] : ''; 
  2924. $BillingWebsite = isset($BillingInfo['Website']) ? $BillingInfo['Website'] : ''; 
  2925. $BillingCustom = isset($BillingInfo['Custom']) ? $BillingInfo['Custom'] : ''; 
  2926.  
  2927. $BillingInfoAddress = isset($DataArray['BillingInfoAddress']) ? $DataArray['BillingInfoAddress'] : array(); 
  2928. $BillingInfoAddressLine1 = isset($BillingInfoAddress['Line1']) ? $BillingInfoAddress['Line1'] : ''; 
  2929. $BillingInfoAddressLine2 = isset($BillingInfoAddress['Line2']) ? $BillingInfoAddress['Line2'] : ''; 
  2930. $BillingInfoAddressCity = isset($BillingInfoAddress['City']) ? $BillingInfoAddress['City'] : ''; 
  2931. $BillingInfoAddressState = isset($BillingInfoAddress['State']) ? $BillingInfoAddress['State'] : ''; 
  2932. $BillingInfoAddressPostalCode = isset($BillingInfoAddress['PostalCode']) ? $BillingInfoAddress['PostalCode'] : ''; 
  2933. $BillingInfoAddressCountryCode = isset($BillingInfoAddress['CountryCode']) ? $BillingInfoAddress['CountryCode'] : ''; 
  2934. $BillingInfoAddressType = isset($BillingInfoAddress['AddressType']) ? $BillingInfoAddress['AddressType'] : ''; 
  2935.  
  2936. $ShippingInfo = isset($DataArray['ShippingInfo']) ? $DataArray['ShippingInfo'] : array(); 
  2937. $ShippingFirstName = isset($ShippingInfo['FirstName']) ? $ShippingInfo['FirstName'] : ''; 
  2938. $ShippingLastName = isset($ShippingInfo['LastName']) ? $ShippingInfo['LastName'] : ''; 
  2939. $ShippingBusinessName = isset($ShippingInfo['BusinessName']) ? $ShippingInfo['BusinessName'] : ''; 
  2940. $ShippingPhone = isset($ShippingInfo['Phone']) ? $ShippingInfo['Phone'] : ''; 
  2941. $ShippingFax = isset($ShippingInfo['Fax']) ? $ShippingInfo['Fax'] : ''; 
  2942. $ShippingWebsite = isset($ShippingInfo['Website']) ? $ShippingInfo['Website'] : ''; 
  2943. $ShippingCustom = isset($ShippingInfo['Custom']) ? $ShippingInfo['Custom'] : ''; 
  2944.  
  2945. $ShippingInfoAddress = isset($DataArray['ShippingInfoAddress']) ? $DataArray['ShippingInfoAddress'] : array(); 
  2946. $ShippingInfoAddressLine1 = isset($ShippingInfoAddress['Line1']) ? $ShippingInfoAddress['Line1'] : ''; 
  2947. $ShippingInfoAddressLine2 = isset($ShippingInfoAddress['Line2']) ? $ShippingInfoAddress['Line2'] : ''; 
  2948. $ShippingInfoAddressCity = isset($ShippingInfoAddress['City']) ? $ShippingInfoAddress['City'] : ''; 
  2949. $ShippingInfoAddressState = isset($ShippingInfoAddress['State']) ? $ShippingInfoAddress['State'] : ''; 
  2950. $ShippingInfoAddressPostalCode = isset($ShippingInfoAddress['PostalCode']) ? $ShippingInfoAddress['PostalCode'] : ''; 
  2951. $ShippingInfoAddressCountryCode = isset($ShippingInfoAddress['CountryCode']) ? $ShippingInfoAddress['CountryCode'] : ''; 
  2952. $ShippingInfoAddressType = isset($ShippingInfoAddress['AddressType']) ? $ShippingInfoAddress['AddressType'] : ''; 
  2953.  
  2954. $InvoiceItems = isset($DataArray['InvoiceItems']) ? $DataArray['InvoiceItems'] : array(); 
  2955.  
  2956. // Generate XML Request 
  2957. $XMLRequest = '<?xml version="1.0" encoding="utf-8"?>'; 
  2958. $XMLRequest .= '<UpdateInvoiceRequest xmlns="' . $this -> XMLNamespace . '">'; 
  2959. $XMLRequest .= $this -> GetXMLRequestEnvelope(); 
  2960. $XMLRequest .= $InvoiceID != '' ? '<invoiceID xmlns="">' . $InvoiceID . '</invoiceID>' : ''; 
  2961. $XMLRequest .= '<invoice xmlns="">'; 
  2962. $XMLRequest .= $MerchantEmail != '' ? '<merchantEmail xmlns="">' . $MerchantEmail . '</merchantEmail>' : ''; 
  2963. $XMLRequest .= $PayerEmail != '' ? '<payerEmail xmlns="">' . $PayerEmail . '</payerEmail>' : ''; 
  2964. $XMLRequest .= $Number != '' ? '<number xmlns="">' . $Number . '</number>' : ''; 
  2965.  
  2966. if(!empty($BusinessInfo)) 
  2967. $XMLRequest .= '<merchantInfo xmlns="">'; 
  2968. $XMLRequest .= $BusinessFirstName != '' ? '<firstName xmlns="">' . $BusinessFirstName . '</firstName>' : ''; 
  2969. $XMLRequest .= $BusinessLastName != '' ? '<lastName xmlns="">' . $BusinessLastName . '</lastName>' : ''; 
  2970. $XMLRequest .= $BusinessBusinessName != '' ? '<businessName xmlns="">' . $BusinessBusinessName . '</businessName>' : ''; 
  2971. $XMLRequest .= $BusinessPhone != '' ? '<phone xmlns="">' . $BusinessPhone . '</phone>' : ''; 
  2972. $XMLRequest .= $BusinessFax != '' ? '<fax xmlns="">' . $BusinessFax . '</fax>' : ''; 
  2973. $XMLRequest .= $BusinessWebsite != '' ? '<website xmlns="">' . $BusinessWebsite . '</website>' : ''; 
  2974. $XMLRequest .= $BusinessCustom != '' ? '<customValue xmlns="">' . $BusinessCustom . '</customValue>' : ''; 
  2975.  
  2976. if(!empty($BusinessInfoAddress)) 
  2977. $XMLRequest .= '<address xmlns="">'; 
  2978. $XMLRequest .= $BusinessInfoAddressLine1 != '' ? '<line1 xmlns="">' . $BusinessInfoAddressLine1 . '</line1>' : ''; 
  2979. $XMLRequest .= $BusinessInfoAddressLine2 != '' ? '<line2 xmlns="">' . $BusinessInfoAddressLine2 . '</line2>' : ''; 
  2980. $XMLRequest .= $BusinessInfoAddressCity != '' ? '<city xmlns="">' . $BusinessInfoAddressCity . '</city>' : ''; 
  2981. $XMLRequest .= $BusinessInfoAddressState != '' ? '<state xmlns="">' . $BusinessInfoAddressState . '</state>' : ''; 
  2982. $XMLRequest .= $BusinessInfoAddressPostalCode != '' ? '<postalCode xmlns="">' . $BusinessInfoAddressPostalCode . '</postalCode>' : ''; 
  2983. $XMLRequest .= $BusinessInfoAddressCountryCode != '' ? '<countryCode xmlns="">' . $BusinessInfoAddressCountryCode . '</countryCode>' : ''; 
  2984. $XMLRequest .= $BusinessInfoAddressType != '' ? '<type xmlns="">' . $BusinessInfoAddressType . '</type>' : ''; 
  2985. $XMLRequest .= '</address>'; 
  2986. $XMLRequest .= '</merchantInfo>'; 
  2987.  
  2988. if(!empty($InvoiceItems)) 
  2989. $XMLRequest .= '<itemList xmlns="">'; 
  2990. foreach($InvoiceItems as $InvoiceItem) 
  2991. $XMLRequest .= '<item xmlns="">'; 
  2992. $XMLRequest .= $InvoiceItem['Name'] != '' ? '<name xmlns="">' . $InvoiceItem['Name'] . '</name>' : ''; 
  2993. $XMLRequest .= $InvoiceItem['Description'] != '' ? '<description xmlns="">' . $InvoiceItem['Description'] . '</description>' : ''; 
  2994. $XMLRequest .= $InvoiceItem['Date'] != '' ? '<date xmlns="">' . $InvoiceItem['Date'] . '</date>' : ''; 
  2995. $XMLRequest .= $InvoiceItem['Quantity'] != '' ? '<quantity xmlns="">' . $InvoiceItem['Quantity'] . '</quantity>' : ''; 
  2996. $XMLRequest .= $InvoiceItem['UnitPrice'] != '' ? '<unitPrice xmlns="">' . $InvoiceItem['UnitPrice'] . '</unitPrice>' : ''; 
  2997. $XMLRequest .= $InvoiceItem['TaxName'] != '' ? '<taxName xmlns="">' . $InvoiceItem['TaxName'] . '</taxName>' : ''; 
  2998. $XMLRequest .= $InvoiceItem['TaxRate'] != '' ? '<taxRate xmlns="">' . $InvoiceItem['TaxRate'] . '</taxRate>' : ''; 
  2999. $XMLRequest .= '</item>';  
  3000. $XMLRequest .= '</itemList>'; 
  3001.  
  3002. $XMLRequest .= $CurrencyCode != '' ? '<currencyCode xmlns="">' . $CurrencyCode . '</currencyCode>' : ''; 
  3003. $XMLRequest .= $InvoiceDate != '' ? '<invoiceDate xmlns="">' . $InvoiceDate . '</invoiceDate>' : ''; 
  3004. $XMLRequest .= $DueDate != '' ? '<dueDate xmlns="">' . $DueDate . '</dueDate>' : ''; 
  3005. $XMLRequest .= $PaymentTerms != '' ? '<paymentTerms xmlns="">' . $PaymentTerms . '</paymentTerms>' : ''; 
  3006. $XMLRequest .= $DiscountPercent != '' ? '<discountPercent xmlns="">' . $DiscountPercent . '</discountPercent>' : ''; 
  3007. $XMLRequest .= $DiscountAmount != '' ? '<discountAmount xmlns="">' . $DiscountAmount . '</discountAmount>' : ''; 
  3008. $XMLRequest .= $Terms != '' ? '<terms xmlns="">' . $Terms . '</terms>' : ''; 
  3009. $XMLRequest .= $Note != '' ? '<note xmlns="">' . $Note . '</note>' : ''; 
  3010. $XMLRequest .= $MerchantMemo != '' ? '<merchantMemo xmlns="">' . $MerchantMemo . '</merchantMemo>' : ''; 
  3011.  
  3012. if(!empty($BillingInfo)) 
  3013. $XMLRequest .= '<billingInfo xmlns="">'; 
  3014. $XMLRequest .= $BillingFirstName != '' ? '<firstName xmlns="">' . $BillingFirstName . '</firstName>' : ''; 
  3015. $XMLRequest .= $BillingLastName != '' ? '<lastName xmlns="">' . $BillingLastName . '</lastName>' : ''; 
  3016. $XMLRequest .= $BillingBusinessName != '' ? '<businessName xmlns="">' . $BillingBusinessName . '</businessName>' : ''; 
  3017. $XMLRequest .= $BillingPhone != '' ? '<phone xmlns="">' . $BillingPhone . '</phone>' : ''; 
  3018. $XMLRequest .= $BillingFax != '' ? '<fax xmlns="">' . $BillingFax . '</fax>' : ''; 
  3019. $XMLRequest .= $BillingWebsite != '' ? '<website xmlns="">' . $BillingWebsite . '</website>' : ''; 
  3020. $XMLRequest .= $BillingCustom != '' ? '<customValue xmlns="">' . $BillingCustom . '</customValue>' : ''; 
  3021.  
  3022. if(!empty($BillingInfoAddress)) 
  3023. $XMLRequest .= '<address xmlns="">'; 
  3024. $XMLRequest .= $BillingInfoAddressLine1 != '' ? '<line1 xmlns="">' . $BillingInfoAddressLine1 . '</line1>' : ''; 
  3025. $XMLRequest .= $BillingInfoAddressLine2 != '' ? '<line2 xmlns="">' . $BillingInfoAddressLine2 . '</line2>' : ''; 
  3026. $XMLRequest .= $BillingInfoAddressCity != '' ? '<city xmlns="">' . $BillingInfoAddressCity . '</city>' : ''; 
  3027. $XMLRequest .= $BillingInfoAddressState != '' ? '<state xmlns="">' . $BillingInfoAddressState . '</state>' : ''; 
  3028. $XMLRequest .= $BillingInfoAddressPostalCode != '' ? '<postalCode xmlns="">' . $BillingInfoAddressPostalCode . '</postalCode>' : ''; 
  3029. $XMLRequest .= $BillingInfoAddressCountryCode != '' ? '<countryCode xmlns="">' . $BillingInfoAddressCountryCode . '</countryCode>' : ''; 
  3030. $XMLRequest .= $BillingInfoAddressType != '' ? '<type xmlns="">' . $BillingInfoAddressType . '</type>' : ''; 
  3031. $XMLRequest .= '</address>'; 
  3032. $XMLRequest .= '</billingInfo>'; 
  3033.  
  3034. if(!empty($ShippingInfo)) 
  3035. $XMLRequest .= '<shippingInfo xmlns="">'; 
  3036. $XMLRequest .= $ShippingFirstName != '' ? '<firstName xmlns="">' . $ShippingFirstName . '</firstName>' : ''; 
  3037. $XMLRequest .= $ShippingLastName != '' ? '<lastName xmlns="">' . $ShippingLastName . '</lastName>' : ''; 
  3038. $XMLRequest .= $ShippingBusinessName != '' ? '<businessName xmlns="">' . $ShippingBusinessName . '</businessName>' : ''; 
  3039. $XMLRequest .= $ShippingPhone != '' ? '<phone xmlns="">' . $ShippingPhone . '</phone>' : ''; 
  3040. $XMLRequest .= $ShippingFax != '' ? '<fax xmlns="">' . $ShippingFax . '</fax>' : ''; 
  3041. $XMLRequest .= $ShippingWebsite != '' ? '<website xmlns="">' . $ShippingWebsite . '</website>' : ''; 
  3042. $XMLRequest .= $ShippingCustom != '' ? '<customValue xmlns="">' . $ShippingCustom . '</customValue>' : ''; 
  3043.  
  3044. if(!empty($ShippingInfoAddress)) 
  3045. $XMLRequest .= '<address xmlns="">'; 
  3046. $XMLRequest .= $ShippingInfoAddressLine1 != '' ? '<line1 xmlns="">' . $ShippingInfoAddressLine1 . '</line1>' : ''; 
  3047. $XMLRequest .= $ShippingInfoAddressLine2 != '' ? '<line2 xmlns="">' . $ShippingInfoAddressLine2 . '</line2>' : ''; 
  3048. $XMLRequest .= $ShippingInfoAddressCity != '' ? '<city xmlns="">' . $ShippingInfoAddressCity . '</city>' : ''; 
  3049. $XMLRequest .= $ShippingInfoAddressState != '' ? '<state xmlns="">' . $ShippingInfoAddressState . '</state>' : ''; 
  3050. $XMLRequest .= $ShippingInfoAddressPostalCode != '' ? '<postalCode xmlns="">' . $ShippingInfoAddressPostalCode . '</postalCode>' : ''; 
  3051. $XMLRequest .= $ShippingInfoAddressCountryCode != '' ? '<countryCode xmlns="">' . $ShippingInfoAddressCountryCode . '</countryCode>' : ''; 
  3052. $XMLRequest .= $ShippingInfoAddressType != '' ? '<type xmlns="">' . $ShippingInfoAddressType . '</type>' : ''; 
  3053. $XMLRequest .= '</address>'; 
  3054. $XMLRequest .= '</shippingInfo>'; 
  3055.  
  3056. $XMLRequest .= $ShippingAmount != '' ? '<shippingAmount xmlns="">' . $ShippingAmount . '</shippingAmount>' : ''; 
  3057. $XMLRequest .= $ShippingTaxName != '' ? '<shippingTaxName xmlns="">' . $ShippingTaxName . '</shippingTaxName>' : ''; 
  3058. $XMLRequest .= $ShippingTaxRate != '' ? '<shippingTaxRate xmlns="">' . $ShippingTaxRate . '</shippingTaxRate>' : ''; 
  3059. $XMLRequest .= $LogoURL != '' ? '<logoUrl xmlns="">' . $LogoURL . '</logoUrl>' : ''; 
  3060. $XMLRequest .= '</invoice>'; 
  3061. $XMLRequest .= '</UpdateInvoiceRequest>'; 
  3062.  
  3063. // Call the API and load XML response into DOM 
  3064. $XMLResponse = $this -> CURLRequest($XMLRequest, 'Invoice', 'UpdateInvoice'); 
  3065. $DOM = new DOMDocument(); 
  3066. $DOM -> loadXML($XMLResponse); 
  3067.  
  3068. // Parse XML values 
  3069. $Fault = $DOM -> getElementsByTagName('FaultMessage') -> length > 0 ? true : false; 
  3070. $Errors = $this -> GetErrors($XMLResponse); 
  3071. $Ack = $DOM -> getElementsByTagName('ack') -> length > 0 ? $DOM -> getElementsByTagName('ack') -> item(0) -> nodeValue : ''; 
  3072. $Build = $DOM -> getElementsByTagName('build') -> length > 0 ? $DOM -> getElementsByTagName('build') -> item(0) -> nodeValue : ''; 
  3073. $CorrelationID = $DOM -> getElementsByTagName('correlationId') -> length > 0 ? $DOM -> getElementsByTagName('correlationId') -> item(0) -> nodeValue : ''; 
  3074. $Timestamp = $DOM -> getElementsByTagName('timestamp') -> length > 0 ? $DOM -> getElementsByTagName('timestamp') -> item(0) -> nodeValue : ''; 
  3075.  
  3076. $InvoiceID = $DOM -> getElementsByTagName('invoiceID') -> length > 0 ? $DOM -> getElementsByTagName('invoiceID') -> item(0) -> nodeValue : ''; 
  3077. $InvoiceNumber = $DOM -> getElementsByTagName('invoiceNumber') -> length > 0 ? $DOM -> getElementsByTagName('invoiceNumber') -> item(0) -> nodeValue : ''; 
  3078. $InvoiceURL = $DOM -> getElementsByTagName('invoiceURL') -> length > 0 ? $DOM -> getElementsByTagName('invoiceURL') -> item(0) -> nodeValue : ''; 
  3079.  
  3080. $ResponseDataArray = array( 
  3081. 'Errors' => $Errors,  
  3082. 'Ack' => $Ack,  
  3083. 'Build' => $Build,  
  3084. 'CorrelationID' => $CorrelationID,  
  3085. 'Timestamp' => $Timestamp,  
  3086. 'InvoiceID' => $InvoiceID,  
  3087. 'InvoiceNumber' => $InvoiceNumber,  
  3088. 'InvoiceURL' => $InvoiceURL,  
  3089. 'XMLRequest' => $XMLRequest,  
  3090. 'XMLResponse' => $XMLResponse 
  3091. ); 
  3092.  
  3093. return $ResponseDataArray; 
  3094.  
  3095.  
  3096. /** 
  3097. * Submit UpdateInvoice API request to PayPal. 
  3098. * @access public 
  3099. * @param string 
  3100. * @return array 
  3101. */ 
  3102. function GetInvoiceDetails($InvoiceID) 
  3103. // Generate XML Request 
  3104. $XMLRequest = '<?xml version="1.0" encoding="utf-8"?>'; 
  3105. $XMLRequest .= '<GetInvoiceDetailsRequest xmlns="' . $this -> XMLNamespace . '">'; 
  3106. $XMLRequest .= $this -> GetXMLRequestEnvelope(); 
  3107. $XMLRequest .= $InvoiceID != '' ? '<invoiceID xmlns="">' . $InvoiceID . '</invoiceID>' : ''; 
  3108. $XMLRequest .= '</GetInvoiceDetailsRequest>'; 
  3109.  
  3110. // Call the API and load XML response into DOM 
  3111. $XMLResponse = $this -> CURLRequest($XMLRequest, 'Invoice', 'GetInvoiceDetails'); 
  3112. $DOM = new DOMDocument(); 
  3113. $DOM -> loadXML($XMLResponse); 
  3114.  
  3115. // Parse XML values 
  3116. $Fault = $DOM -> getElementsByTagName('FaultMessage') -> length > 0 ? true : false; 
  3117. $Errors = $this -> GetErrors($XMLResponse); 
  3118. $Ack = $DOM -> getElementsByTagName('ack') -> length > 0 ? $DOM -> getElementsByTagName('ack') -> item(0) -> nodeValue : ''; 
  3119. $Build = $DOM -> getElementsByTagName('build') -> length > 0 ? $DOM -> getElementsByTagName('build') -> item(0) -> nodeValue : ''; 
  3120. $CorrelationID = $DOM -> getElementsByTagName('correlationId') -> length > 0 ? $DOM -> getElementsByTagName('correlationId') -> item(0) -> nodeValue : ''; 
  3121. $Timestamp = $DOM -> getElementsByTagName('timestamp') -> length > 0 ? $DOM -> getElementsByTagName('timestamp') -> item(0) -> nodeValue : ''; 
  3122.  
  3123. $InvoiceURL = $DOM -> getElementsByTagName('invoiceURL') -> length > 0 ? $DOM -> getElementsByTagName('invoiceURL') -> item(0) -> nodeValue : ''; 
  3124.  
  3125. $InvoiceType = $DOM -> getElementsByTagName('invoice') -> length > 0 ? $DOM -> getElementsByTagName('invoice') : array(); 
  3126. foreach($InvoiceType as $Invoice) 
  3127. $MerchantEmail = $Invoice -> getElementsByTagName('merchantEmail') -> length > 0 ? $Invoice -> getElementsByTagName('merchantEmail') -> item(0) -> nodeValue : ''; 
  3128. $PayerEmail = $Invoice -> getElementsByTagName('payerEmail') -> length > 0 ? $Invoice -> getElementsByTagName('payerEmail') -> item(0) -> nodeValue : ''; 
  3129. $Number = $Invoice -> getElementsByTagName('number') -> length > 0 ? $Invoice -> getElementsByTagName('number') -> item(0) -> nodeValue : ''; 
  3130. $CurrencyCode = $Invoice -> getElementsByTagName('currencyCode') -> length > 0 ? $Invoice -> getElementsByTagName('currencyCode') -> item(0) -> nodeValue : ''; 
  3131. $InvoiceDate = $Invoice -> getElementsByTagName('invoiceDate') -> length > 0 ? $Invoice -> getElementsByTagName('invoiceDate') -> item(0) -> nodeValue : ''; 
  3132. $DueDate = $Invoice -> getElementsByTagName('dueDate') -> length > 0 ? $Invoice -> getElementsByTagName('dueDate') -> item(0) -> nodeValue : ''; 
  3133. $PaymentTerms = $Invoice -> getElementsByTagName('paymentTerms') -> length > 0 ? $Invoice -> getElementsByTagName('paymentTerms') -> item(0) -> nodeValue : ''; 
  3134. $DiscountPercent = $Invoice -> getElementsByTagName('discountPercent') -> length > 0 ? $Invoice -> getElementsByTagName('discountPercent') -> item(0) -> nodeValue : ''; 
  3135. $DiscountAmount = $Invoice -> getElementsByTagName('discountAmount') -> length > 0 ? $Invoice -> getElementsByTagName('discountAmount') -> item(0) -> nodeValue : ''; 
  3136. $Terms = $Invoice -> getElementsByTagName('terms') -> length > 0 ? $Invoice -> getElementsByTagName('terms') -> item(0) -> nodeValue : ''; 
  3137. $InvoiceNote = $Invoice -> getElementsByTagName('note') -> length > 0 ? $Invoice -> getElementsByTagName('note') -> item(0) -> nodeValue : ''; 
  3138. $MerchantMemo = $Invoice -> getElementsByTagName('merchantMemo') -> length > 0 ? $Invoice -> getElementsByTagName('merchantMemo') -> item(0) -> nodeValue : ''; 
  3139. $ShippingAmount = $Invoice -> getElementsByTagName('shippingAmount') -> length > 0 ? $Invoice -> getElementsByTagName('shippingAmount') -> item(0) -> nodeValue : ''; 
  3140. $ShippingTaxName = $Invoice -> getElementsByTagName('shippingTaxName') -> length > 0 ? $Invoice -> getElementsByTagName('shippingTaxName') -> item(0) -> nodeValue : ''; 
  3141. $ShippingTaxRate = $Invoice -> getElementsByTagName('shippingTaxRate') -> length > 0 ? $Invoice -> getElementsByTagName('shippingTaxRate') -> item(0) -> nodeValue : ''; 
  3142. $LogoURL = $Invoice -> getElementsByTagName('logoUrl') -> length > 0 ? $Invoice -> getElementsByTagName('logoUrl') -> item(0) -> nodeValue : ''; 
  3143.  
  3144. $InvoiceDetailsType = $DOM -> getElementsByTagName('invoiceDetails') -> length > 0 ? $DOM -> getElementsByTagName('invoiceDetails') : array(); 
  3145. foreach($InvoiceDetailsType as $InvoiceDetails) 
  3146. $Status = $InvoiceDetails -> getElementsByTagName('status') -> length > 0 ? $InvoiceDetails -> getElementsByTagName('status') -> item(0) -> nodeValue : ''; 
  3147. $TotalAmount = $InvoiceDetails -> getElementsByTagName('totalAmount') -> length > 0 ? $InvoiceDetails -> getElementsByTagName('totalAmount') -> item(0) -> nodeValue : ''; 
  3148. $Origin = $InvoiceDetails -> getElementsByTagName('origin') -> length > 0 ? $InvoiceDetails -> getElementsByTagName('origin') -> item(0) -> nodeValue : ''; 
  3149. $CreatedDate = $InvoiceDetails -> getElementsByTagName('createdDate') -> length > 0 ? $InvoiceDetails -> getElementsByTagName('createdDate') -> item(0) -> nodeValue : ''; 
  3150. $CreatedBy = $InvoiceDetails -> getElementsByTagName('createdBy') -> length > 0 ? $InvoiceDetails -> getElementsByTagName('createdBy') -> item(0) -> nodeValue : ''; 
  3151. $CanceledDate = $InvoiceDetails -> getElementsByTagName('canceledDate') -> length > 0 ? $InvoiceDetails -> getElementsByTagName('canceledDate') -> item(0) -> nodeValue : ''; 
  3152. $CanceledByActor = $InvoiceDetails -> getElementsByTagName('canceledByActor') -> length > 0 ? $InvoiceDetails -> getElementsByTagName('canceledByActor') -> item(0) -> nodeValue : ''; 
  3153. $CanceledBy = $InvoiceDetails -> getElementsByTagName('canceledBy') -> length > 0 ? $InvoiceDetails -> getElementsByTagName('canceledBy') -> item(0) -> nodeValue : ''; 
  3154. $LastUpdatedDate = $InvoiceDetails -> getElementsByTagName('lastUpdatedDate') -> length > 0 ? $InvoiceDetails -> getElementsByTagName('lastUpdatedDate') -> item(0) -> nodeValue : ''; 
  3155. $LastUpdatedBy = $InvoiceDetails -> getElementsByTagName('lastUpdatedBy') -> length > 0 ? $InvoiceDetails -> getElementsByTagName('lastUpdatedBy') -> item(0) -> nodeValue : ''; 
  3156. $FirstSentDate = $InvoiceDetails -> getElementsByTagName('firstSentDate') -> length > 0 ? $InvoiceDetails -> getElementsByTagName('firstSentDate') -> item(0) -> nodeValue : ''; 
  3157. $LastSentDate = $InvoiceDetails -> getElementsByTagName('lastSentDate') -> length > 0 ? $InvoiceDetails -> getElementsByTagName('lastSentDate') -> item(0) -> nodeValue : ''; 
  3158. $LastSentBy = $InvoiceDetails -> getElementsByTagName('lastSentBy') -> length > 0 ? $InvoiceDetails -> getElementsByTagName('lastSentBy') -> item(0) -> nodeValue : ''; 
  3159. $PaidDate = $InvoiceDetails -> getElementsByTagName('paidDate') -> length > 0 ? $InvoiceDetails -> getElementsByTagName('paidDate') -> item(0) -> nodeValue : ''; 
  3160.  
  3161. $InvoiceItems = array(); 
  3162. $InvoiceItemsType = $DOM -> getElementsByTagName('item') -> length > 0 ? $DOM -> getElementsByTagName('item') : array(); 
  3163. foreach($InvoiceItemsType as $InvoiceItem) 
  3164. $ItemName = $InvoiceItem -> getElementsByTagName('name') -> length > 0 ? $InvoiceItem -> getElementsByTagName('name') -> item(0) -> nodeValue : ''; 
  3165. $ItemDescription = $InvoiceItem -> getElementsByTagName('description') -> length > 0 ? $InvoiceItem -> getElementsByTagName('description') -> item(0) -> nodeValue : ''; 
  3166. $ItemDate = $InvoiceItem -> getElementsByTagName('date') -> length > 0 ? $InvoiceItem -> getElementsByTagName('date') -> item(0) -> nodeValue : ''; 
  3167. $ItemQuantity = $InvoiceItem -> getElementsByTagName('quantity') -> length > 0 ? $InvoiceItem -> getElementsByTagName('quantity') -> item(0) -> nodeValue : ''; 
  3168. $ItemUnitPrice = $InvoiceItem -> getElementsByTagName('unitPrice') -> length > 0 ? $InvoiceItem -> getElementsByTagName('unitPrice') -> item(0) -> nodeValue : ''; 
  3169. $ItemTaxName = $InvoiceItem -> getElementsByTagName('taxName') -> length > 0 ? $InvoiceItem -> getElementsByTagName('taxName') -> item(0) -> nodeValue : ''; 
  3170. $ItemTaxRate = $InvoiceItem -> getElementsByTagName('taxRate') -> length > 0 ? $InvoiceItem -> getElementsByTagName('taxRate') -> item(0) -> nodeValue : ''; 
  3171. $InvoiceItemArray = array( 
  3172. 'Name' => $ItemName,  
  3173. 'Description' => $ItemDescription,  
  3174. 'Date' => $ItemDate,  
  3175. 'Quantity' => $ItemQuantity,  
  3176. 'UnitPrice' => $ItemUnitPrice,  
  3177. 'TaxName' => $ItemTaxName,  
  3178. 'TaxRate' => $ItemTaxRate 
  3179. ); 
  3180. array_push($InvoiceItems, $InvoiceItemArray); 
  3181.  
  3182. $MerchantInfoType = $DOM -> getElementsByTagName('merchantInfo') -> length > 0 ? $DOM -> getElementsByTagName('merchantInfo') : array(); 
  3183. foreach($MerchantInfoType as $MerchantInfo) 
  3184. $MerchantFirstName = $MerchantInfo -> getElementsByTagName('firstName') -> length > 0 ? $MerchantInfo -> getElementsByTagName('firstName') -> item(0) -> nodeValue : ''; 
  3185. $MerchantLastName = $MerchantInfo -> getElementsByTagName('lastName') -> length > 0 ? $MerchantInfo -> getElementsByTagName('lastName') -> item(0) -> nodeValue : ''; 
  3186. $MerchantBusinessName = $MerchantInfo -> getElementsByTagName('businessName') -> length > 0 ? $MerchantInfo -> getElementsByTagName('businessName') -> item(0) -> nodeValue : ''; 
  3187. $MerchantPhone = $MerchantInfo -> getElementsByTagName('phone') -> length > 0 ? $MerchantInfo -> getElementsByTagName('phone') -> item(0) -> nodeValue : ''; 
  3188. $MerchantFax = $MerchantInfo -> getElementsByTagName('fax') -> length > 0 ? $MerchantInfo -> getElementsByTagName('fax') -> item(0) -> nodeValue : ''; 
  3189. $MerchantWebsite = $MerchantInfo -> getElementsByTagName('website') -> length > 0 ? $MerchantInfo -> getElementsByTagName('website') -> item(0) -> nodeValue : ''; 
  3190. $MerchantCustom = $MerchantInfo -> getElementsByTagName('customValue') -> length > 0 ? $MerchantInfo -> getElementsByTagName('customValue') -> item(0) -> nodeValue : ''; 
  3191.  
  3192. $MerchantInfoAddressType = $MerchantInfo -> getElementsByTagName('address') -> length > 0 ? $MerchantInfo -> getElementsByTagName('address') : array(); 
  3193. foreach($MerchantInfoAddressType as $MerchantInfoAddress) 
  3194. $MerchantAddressLine1 = $MerchantInfoAddress -> getElementsByTagName('line1') -> length > 0 ? $MerchantInfoAddress -> getElementsByTagName('line1') -> item(0) -> nodeValue : ''; 
  3195. $MerchantAddressLine2 = $MerchantInfoAddress -> getElementsByTagName('line2') -> length > 0 ? $MerchantInfoAddress -> getElementsByTagName('line2') -> item(0) -> nodeValue : ''; 
  3196. $MerchantAddressCity = $MerchantInfoAddress -> getElementsByTagName('city') -> length > 0 ? $MerchantInfoAddress -> getElementsByTagName('city') -> item(0) -> nodeValue : ''; 
  3197. $MerchantAddressState = $MerchantInfoAddress -> getElementsByTagName('state') -> length > 0 ? $MerchantInfoAddress -> getElementsByTagName('state') -> item(0) -> nodeValue : ''; 
  3198. $MerchantAddressPostalCode = $MerchantInfoAddress -> getElementsByTagName('postalCode') -> length > 0 ? $MerchantInfoAddress -> getElementsByTagName('postalCode') -> item(0) -> nodeValue : ''; 
  3199. $MerchantAddressCountryCode = $MerchantInfoAddress -> getElementsByTagName('countryCode') -> length > 0 ? $MerchantInfoAddress -> getElementsByTagName('countryCode') -> item(0) -> nodeValue : ''; 
  3200. $MerchantAddressType = $MerchantInfoAddress -> getElementsByTagName('type') -> length > 0 ? $MerchantInfoAddress -> getElementsByTagName('type') -> item(0) -> nodeValue : ''; 
  3201.  
  3202. $BillingInfoType = $DOM -> getElementsByTagName('billingInfo') -> length > 0 ? $DOM -> getElementsByTagName('billingInfo') : array(); 
  3203. foreach($BillingInfoType as $BillingInfo) 
  3204. $BillingFirstName = $BillingInfo -> getElementsByTagName('firstName') -> length > 0 ? $BillingInfo -> getElementsByTagName('firstName') -> item(0) -> nodeValue : ''; 
  3205. $BillingLastName = $BillingInfo -> getElementsByTagName('lastName') -> length > 0 ? $BillingInfo -> getElementsByTagName('lastName') -> item(0) -> nodeValue : ''; 
  3206. $BillingBusinessName = $BillingInfo -> getElementsByTagName('businessName') -> length > 0 ? $BillingInfo -> getElementsByTagName('businessName') -> item(0) -> nodeValue : ''; 
  3207. $BillingPhone = $BillingInfo -> getElementsByTagName('phone') -> length > 0 ? $BillingInfo -> getElementsByTagName('phone') -> item(0) -> nodeValue : ''; 
  3208. $BillingFax = $BillingInfo -> getElementsByTagName('fax') -> length > 0 ? $BillingInfo -> getElementsByTagName('fax') -> item(0) -> nodeValue : ''; 
  3209. $BillingWebsite = $BillingInfo -> getElementsByTagName('website') -> length > 0 ? $BillingInfo -> getElementsByTagName('website') -> item(0) -> nodeValue : ''; 
  3210. $BillingCustom = $BillingInfo -> getElementsByTagName('customValue') -> length > 0 ? $BillingInfo -> getElementsByTagName('customValue') -> item(0) -> nodeValue : ''; 
  3211.  
  3212. $BillingInfoAddressType = $BillingInfo -> getElementsByTagName('address') -> length > 0 ? $BillingInfo -> getElementsByTagName('address') : array(); 
  3213. foreach($BillingInfoAddressType as $BillingInfoAddress) 
  3214. $BillingAddressLine1 = $BillingInfoAddress -> getElementsByTagName('line1') -> length > 0 ? $BillingInfoAddress -> getElementsByTagName('line1') -> item(0) -> nodeValue : ''; 
  3215. $BillingAddressLine2 = $BillingInfoAddress -> getElementsByTagName('line2') -> length > 0 ? $BillingInfoAddress -> getElementsByTagName('line2') -> item(0) -> nodeValue : ''; 
  3216. $BillingAddressCity = $BillingInfoAddress -> getElementsByTagName('city') -> length > 0 ? $BillingInfoAddress -> getElementsByTagName('city') -> item(0) -> nodeValue : ''; 
  3217. $BillingAddressState = $BillingInfoAddress -> getElementsByTagName('state') -> length > 0 ? $BillingInfoAddress -> getElementsByTagName('state') -> item(0) -> nodeValue : ''; 
  3218. $BillingAddressPostalCode = $BillingInfoAddress -> getElementsByTagName('postalCode') -> length > 0 ? $BillingInfoAddress -> getElementsByTagName('postalCode') -> item(0) -> nodeValue : ''; 
  3219. $BillingAddressCountryCode = $BillingInfoAddress -> getElementsByTagName('countryCode') -> length > 0 ? $BillingInfoAddress -> getElementsByTagName('countryCode') -> item(0) -> nodeValue : ''; 
  3220. $BillingAddressType = $BillingInfoAddress -> getElementsByTagName('type') -> length > 0 ? $BillingInfoAddress -> getElementsByTagName('type') -> item(0) -> nodeValue : ''; 
  3221.  
  3222. $ShippingInfoType = $DOM -> getElementsByTagName('shippingInfo') -> length > 0 ? $DOM -> getElementsByTagName('shippingInfo') : array(); 
  3223. foreach($ShippingInfoType as $ShippingInfo) 
  3224. $ShippingFirstName = $ShippingInfo -> getElementsByTagName('firstName') -> length > 0 ? $ShippingInfo -> getElementsByTagName('firstName') -> item(0) -> nodeValue : ''; 
  3225. $ShippingLastName = $ShippingInfo -> getElementsByTagName('lastName') -> length > 0 ? $ShippingInfo -> getElementsByTagName('lastName') -> item(0) -> nodeValue : ''; 
  3226. $ShippingBusinessName = $ShippingInfo -> getElementsByTagName('businessName') -> length > 0 ? $ShippingInfo -> getElementsByTagName('businessName') -> item(0) -> nodeValue : ''; 
  3227. $ShippingPhone = $ShippingInfo -> getElementsByTagName('phone') -> length > 0 ? $ShippingInfo -> getElementsByTagName('phone') -> item(0) -> nodeValue : ''; 
  3228. $ShippingFax = $ShippingInfo -> getElementsByTagName('fax') -> length > 0 ? $ShippingInfo -> getElementsByTagName('fax') -> item(0) -> nodeValue : ''; 
  3229. $ShippingWebsite = $ShippingInfo -> getElementsByTagName('website') -> length > 0 ? $ShippingInfo -> getElementsByTagName('website') -> item(0) -> nodeValue : ''; 
  3230. $ShippingCustom = $ShippingInfo -> getElementsByTagName('customValue') -> length > 0 ? $ShippingInfo -> getElementsByTagName('customValue') -> item(0) -> nodeValue : ''; 
  3231.  
  3232. $ShippingInfoAddressType = $ShippingInfo -> getElementsByTagName('address') -> length > 0 ? $ShippingInfo -> getElementsByTagName('address') : array(); 
  3233. foreach($ShippingInfoAddressType as $ShippingInfoAddress) 
  3234. $ShippingAddressLine1 = $ShippingInfoAddress -> getElementsByTagName('line1') -> length > 0 ? $ShippingInfoAddress -> getElementsByTagName('line1') -> item(0) -> nodeValue : ''; 
  3235. $ShippingAddressLine2 = $ShippingInfoAddress -> getElementsByTagName('line2') -> length > 0 ? $ShippingInfoAddress -> getElementsByTagName('line2') -> item(0) -> nodeValue : ''; 
  3236. $ShippingAddressCity = $ShippingInfoAddress -> getElementsByTagName('city') -> length > 0 ? $ShippingInfoAddress -> getElementsByTagName('city') -> item(0) -> nodeValue : ''; 
  3237. $ShippingAddressState = $ShippingInfoAddress -> getElementsByTagName('state') -> length > 0 ? $ShippingInfoAddress -> getElementsByTagName('state') -> item(0) -> nodeValue : ''; 
  3238. $ShippingAddressPostalCode = $ShippingInfoAddress -> getElementsByTagName('postalCode') -> length > 0 ? $ShippingInfoAddress -> getElementsByTagName('postalCode') -> item(0) -> nodeValue : ''; 
  3239. $ShippingAddressCountryCode = $ShippingInfoAddress -> getElementsByTagName('countryCode') -> length > 0 ? $ShippingInfoAddress -> getElementsByTagName('countryCode') -> item(0) -> nodeValue : ''; 
  3240. $ShippingAddressType = $ShippingInfoAddress -> getElementsByTagName('type') -> length > 0 ? $ShippingInfoAddress -> getElementsByTagName('type') -> item(0) -> nodeValue : ''; 
  3241.  
  3242. $ViaPayPal = $DOM -> getElementsByTagName('viaPayPal') -> length > 0 ? $DOM -> getElementsByTagName('viaPayPal') -> item(0) -> nodeValue : ''; 
  3243. $PayPalPaymentDetailsType = $DOM -> getElementsByTagName('paypalPayment') -> length > 0 ? $DOM -> getElementsByTagName('paypalPayment') : array(); 
  3244. foreach($PayPalPaymentDetailsType as $PayPalPaymentDetails) 
  3245. $PayPalTransactionID = $PayPalPaymentDetails -> getElementsByTagName('transactionID') -> length > 0 ? $PayPalPaymentDetails -> getElementsByTagName('transactionID') -> item(0) -> nodeValue : ''; 
  3246. $PayPalTransactionDate = $PayPalPaymentDetails -> getElementsByTagName('date') -> length > 0 ? $PayPalPaymentDetails -> getElementsByTagName('date') -> item(0) -> nodeValue : ''; 
  3247.  
  3248. $OtherPaymentDetailsType = $DOM -> getElementsByTagName('otherPayment') -> length > 0 ? $DOM -> getElementsByTagName('otherPayment') : array(); 
  3249. foreach($OtherPaymentDetailsType as $OtherPaymentDetails) 
  3250. $PaymentMethod = $OtherPaymentDetails -> getElementsByTagName('method') -> length > 0 ? $OtherPaymentDetails -> getElementsByTagName('method') -> item(0) -> nodeValue : ''; 
  3251. $PaymentMethodNote = $OtherPaymentDetails -> getElementsByTagName('note') -> length > 0 ? $OtherPaymentDetails -> getElementsByTagName('note') -> item(0) -> nodeValue : ''; 
  3252. $PaymentMethodDate = $OtherPaymentDetails -> getElementsByTagName('date') -> length > 0 ? $OtherPaymentDetails -> getElementsByTagName('date') -> item(0) -> nodeValue : ''; 
  3253.  
  3254. $ResponseDataArray = array( 
  3255. 'Errors' => $Errors,  
  3256. 'Ack' => $Ack,  
  3257. 'Build' => $Build,  
  3258. 'CorrelationID' => $CorrelationID,  
  3259. 'Timestamp' => $Timestamp,  
  3260. 'InvoiceURL' => $InvoiceURL,  
  3261. 'MerchantEmail' => isset($MerchantEmail) ? $MerchantEmail : '',  
  3262. 'PayerEmail' => isset($PayerEmail) ? $PayerEmail : '',  
  3263. 'Number' => isset($Number) ? $Number : '',  
  3264. 'CurrencyCode' => isset($CurrencyCode) ? $CurrencyCode : '',  
  3265. 'InvoiceDate' => isset($InvoiceDate) ? $InvoiceDate : '',  
  3266. 'DueDate' => isset($DueDate) ? $DueDate : '',  
  3267. 'PaymentTerms' => isset($PaymentTerms) ? $PaymentTerms : '',  
  3268. 'DiscountPercent' => isset($DiscountPercent) ? $DiscountPercent : '',  
  3269. 'DiscountAmount' => isset($DiscountAmount) ? $DiscountAmount : '',  
  3270. 'Terms' => isset($Terms) ? $Terms : '',  
  3271. 'InvoiceNote' => isset($InvoiceNote) ? $InvoiceNote : '',  
  3272. 'MerchantMemo' => isset($MerchantMemo) ? $MerchantMemo : '',  
  3273. 'ShippingAmount' => isset($ShippingAmount) ? $ShippingAmount : '',  
  3274. 'ShippingTaxName' => isset($ShippingTaxName) ? $ShippingTaxName : '',  
  3275. 'ShippingTaxRate' => isset($ShippingTaxRate) ? $ShippingTaxRate : '',  
  3276. 'LogoURL' => isset($LogoURL) ? $LogoURL : '',  
  3277. 'Status' => isset($Status) ? $Status : '',  
  3278. 'TotalAmount' => isset($TotalAmount) ? $TotalAmount : '',  
  3279. 'Origin' => isset($Origin) ? $Origin : '',  
  3280. 'CreatedDate' => isset($CreatedDate) ? $CreatedDate : '',  
  3281. 'CreatedBy' => isset($CreatedBy) ? $CreatedBy : '',  
  3282. 'CanceledDate' => isset($CanceledDate) ? $CanceledDate : '',  
  3283. 'CanceledByActor' => isset($CanceledByActor) ? $CanceledByActor : '',  
  3284. 'CanceledBy' => isset($CanceledBy) ? $CanceledBy : '',  
  3285. 'LastUpdatedDate' => isset($LastUpdatedDate) ? $LastUpdatedDate : '',  
  3286. 'LastUpdatedBy' => isset($LastUpdatedBy) ? $LastUpdatedBy : '',  
  3287. 'FistSentDate' => isset($FirstSentDate) ? $FirstSentDate : '',  
  3288. 'LastSentDate' => isset($LastSentDate) ? $LastSentDate : '',  
  3289. 'LastSentBy' => isset($LastSentBy) ? $LastSentBy : '',  
  3290. 'PaidDate' => isset($PaidDate) ? $PaidDate : '',  
  3291. 'InvoiceItems' => isset($InvoiceItems) ? $InvoiceItems : '',  
  3292. 'MerchantFirstName' => isset($MerchantFirstName) ? $MerchantFirstName : '',  
  3293. 'MerchantLastName' => isset($MerchantLastName) ? $MerchantLastName : '',  
  3294. 'MerchantBusinessName' => isset($MerchantBusinessName) ? $MerchantBusinessName : '',  
  3295. 'MerchantPhone' => isset($MerchantPhone) ? $MerchantPhone : '',  
  3296. 'MerchantFax' => isset($MerchantFax) ? $MerchantFax : '',  
  3297. 'MerchantWebsite' => isset($MerchantWebsite) ? $MerchantWebsite : '',  
  3298. 'MerchantCustom' => isset($MerchantCustom) ? $MerchantCustom : '',  
  3299. 'MerchantAddressLine1' => isset($MerchantAddressLine1) ? $MerchantAddressLine1 : '',  
  3300. 'MerchantAddressLine2' => isset($MerchantAddressLine2) ? $MerchantAddressLine2 : '',  
  3301. 'MerchantAddressCity' => isset($MerchantAddressCity) ? $MerchantAddressCity : '',  
  3302. 'MerchantAddressState' => isset($MerchantAddressState) ? $MerchantAddressState : '',  
  3303. 'MerchantAddressPostalCode' => isset($MerchantAddressPostalCode) ? $MerchantAddressPostalCode : '',  
  3304. 'MerchantAddressCountryCode' => isset($MerchantAddressCountryCode) ? $MerchantAddressCountryCode : '',  
  3305. 'MerchantAddressType' => isset($MerchantAddressType) ? $MerchantAddressType : '',  
  3306. 'BillingFirstName' => isset($BillingFirstName) ? $BillingFirstName : '',  
  3307. 'BillingLastName' => isset($BillingLastName) ? $BillingLastName : '',  
  3308. 'BillingBusinessName' => isset($BillingBusinessName) ? $BillingBusinessName : '',  
  3309. 'BillingPhone' => isset($BillingPhone) ? $BillingPhone : '',  
  3310. 'BillingFax' => isset($BillingFax) ? $BillingFax : '',  
  3311. 'BillingWebsite' => isset($BillingWebsite) ? $BillingWebsite : '',  
  3312. 'BillingCustom' => isset($BillingCustom) ? $BillingCustom : '',  
  3313. 'BillingAddressLine1' => isset($BillingAddressLine1) ? $BillingAddressLine1 : '',  
  3314. 'BillingAddressLine2' => isset($BillingAddressLine2) ? $BillingAddressLine2 : '',  
  3315. 'BillingAddressCity' => isset($BillingAddressCity) ? $BillingAddressCity : '',  
  3316. 'BillingAddressState' => isset($BillingAddressState) ? $BillingAddressState : '',  
  3317. 'BillingAddressPostalCode' => isset($BillingAddressPostalCode) ? $BillingAddressPostalCode : '',  
  3318. 'BillingAddressCountryCode' => isset($BillingAddressCountryCode) ? $BillingAddressCountryCode : '',  
  3319. 'BillingAddressType' => isset($BillingAddressType) ? $BillingAddressType : '',  
  3320. 'ShippingFirstName' => isset($ShippingFirstName) ? $ShippingFirstName : '',  
  3321. 'ShippingLastName' => isset($ShippingLastName) ? $ShippingLastName : '',  
  3322. 'ShippingBusinessName' => isset($ShippingBusinessName) ? $ShippingBusinessName : '',  
  3323. 'ShippingPhone' => isset($ShippingPhone) ? $ShippingPhone : '',  
  3324. 'ShippingFax' => isset($ShippingFax) ? $ShippingFax : '',  
  3325. 'ShippingWebsite' => isset($ShippingWebsite) ? $ShippingWebsite : '',  
  3326. 'ShippingCustom' => isset($ShippingCustom) ? $ShippingCustom : '',  
  3327. 'ShippingAddressLine1' => isset($ShippingAddressLine1) ? $ShippingAddressLine1 : '',  
  3328. 'ShippingAddressLine2' => isset($ShippingAddressLine2) ? $ShippingAddressLine2 : '',  
  3329. 'ShippingAddressCity' => isset($ShippingAddressCity) ? $ShippingAddressCity : '',  
  3330. 'ShippingAddressState' => isset($ShippingAddressState) ? $ShippingAddressState : '',  
  3331. 'ShippingAddressPostalCode' => isset($ShippingAddressPostalCode) ? $ShippingAddressPostalCode : '',  
  3332. 'ShippingAddressCountryCode' => isset($ShippingAddressCountryCode) ? $ShippingAddressCountryCode : '',  
  3333. 'ShippingAddressType' => isset($ShippingAddressType) ? $ShippingAddressType : '',  
  3334. 'ViaPayPal' => isset($ViaPayPal) ? $ViaPayPal : '',  
  3335. 'PayPalTransactionID' => isset($PayPalTransactionID) ? $PayPalTransactionID : '',  
  3336. 'PayPalTransactionDate' => isset($PayPalTransactionDate) ? $PayPalTransactionDate : '',  
  3337. 'PaymentMethod' => isset($PaymentMethod) ? $PaymentMethod : '',  
  3338. 'PaymentMethodNote' => isset($PaymentMethodNote) ? $PaymentMethodNote : '',  
  3339. 'PaymentMethodDate' => isset($PaymentMethodDate) ? $PaymentMethodDate : '',  
  3340. 'XMLRequest' => $XMLRequest,  
  3341. 'XMLResponse' => $XMLResponse 
  3342. ); 
  3343.  
  3344. return $ResponseDataArray; 
  3345.  
  3346.  
  3347. /** 
  3348. * Submit CancelInvoice API request to PayPal. 
  3349. * @access public 
  3350. * @param array call config data 
  3351. * @return array 
  3352. */ 
  3353. function CancelInvoice($DataArray) 
  3354. $CancelInvoiceFields = isset($DataArray['CancelInvoiceFields']) ? $DataArray['CancelInvoiceFields'] : array(); 
  3355. $InvoiceID = isset($CancelInvoiceFields['InvoiceID']) ? $CancelInvoiceFields['InvoiceID'] : ''; 
  3356. $Subject = isset($CancelInvoiceFields['Subject']) ? $CancelInvoiceFields['Subject'] : ''; 
  3357. $NoteForPayer = isset($CancelInvoiceFields['NoteForPayer']) ? $CancelInvoiceFields['NoteForPayer'] : ''; 
  3358. $SendCopyToMerchant = isset($CancelInvoiceFields['SendCopyToMerchant']) ? $CancelInvoiceFields['SendCopyToMerchant'] : ''; 
  3359.  
  3360. // Generate XML Request 
  3361. $XMLRequest = '<?xml version="1.0" encoding="utf-8"?>'; 
  3362. $XMLRequest .= '<CancelInvoiceRequest xmlns="' . $this -> XMLNamespace . '">'; 
  3363. $XMLRequest .= $this -> GetXMLRequestEnvelope(); 
  3364. $XMLRequest .= $InvoiceID != '' ? '<invoiceID xmlns="">' . $InvoiceID . '</invoiceID>' : ''; 
  3365. $XMLRequest .= $Subject != '' ? '<subject xmlns="">' . $Subject . '</subject>' : ''; 
  3366. $XMLRequest .= $NoteForPayer != '' ? '<noteForPayer xmlns="">' . $NoteForPayer . '</noteForPayer>' : ''; 
  3367. $XMLRequest .= $SendCopyToMerchant != '' ? '<sendCopyToMerchant xmlns="">' . $SendCopyToMerchant . '</sendCopyToMerchant>' : ''; 
  3368. $XMLRequest .= '</CancelInvoiceRequest>'; 
  3369.  
  3370. // Call the API and load XML response into DOM 
  3371. $XMLResponse = $this -> CURLRequest($XMLRequest, 'Invoice', 'CancelInvoice'); 
  3372. $DOM = new DOMDocument(); 
  3373. $DOM -> loadXML($XMLResponse); 
  3374.  
  3375. // Parse XML values 
  3376. $Fault = $DOM -> getElementsByTagName('FaultMessage') -> length > 0 ? true : false; 
  3377. $Errors = $this -> GetErrors($XMLResponse); 
  3378. $Ack = $DOM -> getElementsByTagName('ack') -> length > 0 ? $DOM -> getElementsByTagName('ack') -> item(0) -> nodeValue : ''; 
  3379. $Build = $DOM -> getElementsByTagName('build') -> length > 0 ? $DOM -> getElementsByTagName('build') -> item(0) -> nodeValue : ''; 
  3380. $CorrelationID = $DOM -> getElementsByTagName('correlationId') -> length > 0 ? $DOM -> getElementsByTagName('correlationId') -> item(0) -> nodeValue : ''; 
  3381. $Timestamp = $DOM -> getElementsByTagName('timestamp') -> length > 0 ? $DOM -> getElementsByTagName('timestamp') -> item(0) -> nodeValue : ''; 
  3382.  
  3383. $InvoiceID = $DOM -> getElementsByTagName('invoiceID') -> length > 0 ? $DOM -> getElementsByTagName('invoiceID') -> item(0) -> nodeValue : ''; 
  3384. $InvoiceNumber = $DOM -> getElementsByTagName('invoiceNumber') -> length > 0 ? $DOM -> getElementsByTagName('invoiceNumber') -> item(0) -> nodeValue : ''; 
  3385. $InvoiceURL = $DOM -> getElementsByTagName('invoiceURL') -> length > 0 ? $DOM -> getElementsByTagName('invoiceURL') -> item(0) -> nodeValue : ''; 
  3386.  
  3387. $ResponseDataArray = array( 
  3388. 'Errors' => $Errors,  
  3389. 'Ack' => $Ack,  
  3390. 'Build' => $Build,  
  3391. 'CorrelationID' => $CorrelationID,  
  3392. 'Timestamp' => $Timestamp,  
  3393. 'InvoiceID' => $InvoiceID,  
  3394. 'InvoiceNumber' => $InvoiceNumber,  
  3395. 'InvoiceURL' => $InvoiceURL,  
  3396. 'XMLRequest' => $XMLRequest,  
  3397. 'XMLResponse' => $XMLResponse 
  3398. ); 
  3399.  
  3400. return $ResponseDataArray; 
  3401.  
  3402.  
  3403. /** 
  3404. * Submit SearchInvoices API request to PayPal. 
  3405. * @access public 
  3406. * @param array call config data 
  3407. * @return array 
  3408. */ 
  3409. function SearchInvoices($DataArray) 
  3410. $SearchInvoicesFields = isset($DataArray['SearchInvoicesFields']) ? $DataArray['SearchInvoicesFields'] : array(); 
  3411. $MerchantEmail = isset($SearchInvoicesFields['MerchantEmail']) ? $SearchInvoicesFields['MerchantEmail'] : ''; 
  3412. $Page = isset($SearchInvoicesFields['Page']) ? $SearchInvoicesFields['Page'] : ''; 
  3413. $PageSize = isset($SearchInvoicesFields['PageSize']) ? $SearchInvoicesFields['PageSize'] : '';  
  3414.  
  3415. $Parameters = isset($DataArray['Parameters']) ? $DataArray['Parameters'] : array(); 
  3416. $Email = isset($Parameters['Email']) ? $Parameters['Email'] : ''; 
  3417. $RecipientName = isset($Parameters['RecipientName']) ? $Parameters['RecipientName'] : ''; 
  3418. $BusinessName = isset($Parameters['BusinessName']) ? $Parameters['BusinessName'] : ''; 
  3419. $InvoiceNumber = isset($Parameters['InvoiceNumber']) ? $Parameters['InvoiceNumber'] : ''; 
  3420. $Status = isset($Parameters['Status']) ? $Parameters['Status'] : ''; 
  3421. $LowerAmount = isset($Parameters['LowerAmount']) ? $Parameters['LowerAmount'] : ''; 
  3422. $UpperAmount = isset($Parameters['UpperAmount']) ? $Parameters['UpperAmount'] : ''; 
  3423. $CurrencyCode = isset($Parameters['CurrencyCode']) ? $Parameters['CurrencyCode'] : ''; 
  3424. $Memo = isset($Parameters['Memo']) ? $Parameters['Memo'] : ''; 
  3425. $Origin = isset($Parameters['Origin']) ? $Parameters['Origin'] : ''; 
  3426. $InvoiceDate = isset($Parameters['InvoiceDate']) ? $Parameters['InvoiceDate'] : array(); 
  3427. $DueDate = isset($Parameters['DueDate']) ? $Parameters['DueDate'] : array(); 
  3428. $PaymentDate = isset($Parameters['PaymentDate']) ? $Parameters['PaymentDate'] : array(); 
  3429. $CreationDate = isset($Parameters['CreationDate']) ? $Parameters['CreationDate'] : array(); 
  3430.  
  3431. // Generate XML Request 
  3432. $XMLRequest = '<?xml version="1.0" encoding="utf-8"?>'; 
  3433. $XMLRequest .= '<SearchInvoicesRequest xmlns="' . $this -> XMLNamespace . '">'; 
  3434. $XMLRequest .= $this -> GetXMLRequestEnvelope(); 
  3435. $XMLRequest .= $MerchantEmail != '' ? '<merchantEmail xmlns="">' . $MerchantEmail . '</merchantEmail>' : ''; 
  3436. $XMLRequest .= $Page != '' ? '<page xmlns="">' . $Page . '</page>' : ''; 
  3437. $XMLRequest .= $PageSize != '' ? '<pageSize xmlns="">' . $PageSize . '</pageSize>' : ''; 
  3438.  
  3439. if(!empty($Parameters)) 
  3440. $XMLRequest .= '<parameters xmlns="">'; 
  3441. $XMLRequest .= $Email != '' ? '<email xmlns="">' . $Email . '</email>' : ''; 
  3442. $XMLRequest .= $RecipientName != '' ? '<recipientName xmlns="">' . $RecipientName . '</recipientName>' : ''; 
  3443. $XMLRequest .= $BusinessName != '' ? '<businessName xmlns="">' . $BusinessName . '</businessName>' : ''; 
  3444. $XMLRequest .= $InvoiceNumber != '' ? '<invoiceNumber xmlns="">' . $InvoiceNumber . '</invoiceNumber>' : ''; 
  3445. $XMLRequest .= $Status != '' ? '<status xmlns="">' . $Status . '</status>' : ''; 
  3446. $XMLRequest .= $LowerAmount != '' ? '<lowerAmount xmlns="">' . $LowerAmount . '</lowerAmount>' : ''; 
  3447. $XMLRequest .= $UpperAmount != '' ? '<upperAmount xmlns="">' . $UpperAmount . '</upperAmount>' : ''; 
  3448. $XMLRequest .= $CurrencyCode != '' ? '<currencyCode xmlns="">' . $CurrencyCode . '</currencyCode>' : ''; 
  3449. $XMLRequest .= $Memo != '' ? '<memo xmlns="">' . $Memo . '</memo>' : ''; 
  3450. $XMLRequest .= $Origin != '' ? '<origin xmlns="">' . $Origin . '</origin>' : ''; 
  3451.  
  3452. if(!empty($InvoiceDate)) 
  3453. $XMLRequest .= '<invoiceDate xmlns="">'; 
  3454. $XMLRequest .= '<startDate xmlns="">' . $InvoiceDate['StartDate'] . '</startDate>'; 
  3455. $XMLRequest .= '<endDate xmlns="">' . $InvoiceDate['EndDate'] . '</endDate>'; 
  3456. $XMLRequest .= '</invoiceDate>';  
  3457.  
  3458. if(!empty($DueDate)) 
  3459. $XMLRequest .= '<dueDate xmlns="">'; 
  3460. $XMLRequest .= '<startDate xmlns="">' . $DueDate['StartDate'] . '</startDate>'; 
  3461. $XMLRequest .= '<endDate xmlns="">' . $DueDate['EndDate'] . '</endDate>'; 
  3462. $XMLRequest .= '</dueDate>';  
  3463.  
  3464. if(!empty($PaymentDate)) 
  3465. $XMLRequest .= '<paymentDate xmlns="">'; 
  3466. $XMLRequest .= '<startDate xmlns="">' . $PaymentDate['StartDate'] . '</startDate>'; 
  3467. $XMLRequest .= '<endDate xmlns="">' . $PaymentDate['EndDate'] . '</endDate>'; 
  3468. $XMLRequest .= '</paymentDate>';  
  3469.  
  3470. if(!empty($CreationDate)) 
  3471. $XMLRequest .= '<creationDate xmlns="">'; 
  3472. $XMLRequest .= '<startDate xmlns="">' . $CreationDate['StartDate'] . '</startDate>'; 
  3473. $XMLRequest .= '<endDate xmlns="">' . $CreationDate['EndDate'] . '</endDate>'; 
  3474. $XMLRequest .= '</creationDate>';  
  3475.  
  3476. $XMLRequest .= '</parameters>';  
  3477.  
  3478. $XMLRequest .= '</SearchInvoicesRequest>'; 
  3479.  
  3480. // Call the API and load XML response into DOM 
  3481. $XMLResponse = $this -> CURLRequest($XMLRequest, 'Invoice', 'SearchInvoices'); 
  3482. $DOM = new DOMDocument(); 
  3483. $DOM -> loadXML($XMLResponse); 
  3484.  
  3485. // Parse XML values 
  3486. $Fault = $DOM -> getElementsByTagName('FaultMessage') -> length > 0 ? true : false; 
  3487. $Errors = $this -> GetErrors($XMLResponse); 
  3488. $Ack = $DOM -> getElementsByTagName('ack') -> length > 0 ? $DOM -> getElementsByTagName('ack') -> item(0) -> nodeValue : ''; 
  3489. $Build = $DOM -> getElementsByTagName('build') -> length > 0 ? $DOM -> getElementsByTagName('build') -> item(0) -> nodeValue : ''; 
  3490. $CorrelationID = $DOM -> getElementsByTagName('correlationId') -> length > 0 ? $DOM -> getElementsByTagName('correlationId') -> item(0) -> nodeValue : ''; 
  3491. $Timestamp = $DOM -> getElementsByTagName('timestamp') -> length > 0 ? $DOM -> getElementsByTagName('timestamp') -> item(0) -> nodeValue : ''; 
  3492.  
  3493. $Count = $DOM -> getElementsByTagName('count') -> length > 0 ? $DOM -> getElementsByTagName('count') -> item(0) -> nodeValue : ''; 
  3494. $Page = $DOM -> getElementsByTagName('page') -> length > 0 ? $DOM -> getElementsByTagName('page') -> item(0) -> nodeValue : ''; 
  3495. $HasNextPage = $DOM -> getElementsByTagName('hasNextPage') -> length > 0 ? $DOM -> getElementsByTagName('hasNextPage') -> item(0) -> nodeValue : ''; 
  3496. $HasPreviousPage = $DOM -> getElementsByTagName('hasPreviousPage') -> length > 0 ? $DOM -> getElementsByTagName('hasPreviousPage') -> item(0) -> nodeValue : ''; 
  3497. $InvoicesType = $DOM -> getElementsByTagName('invoice') -> length > 0 ? $DOM -> getElementsByTagName('invoice') : array(); 
  3498.  
  3499. $Invoices = array(); 
  3500. foreach($InvoicesType as $Invoice) 
  3501. $InvoiceID = $Invoice -> getElementsByTagName('invoiceID') -> length > 0 ? $Invoice -> getElementsByTagName('invoiceID') -> item(0) -> nodeValue : '';  
  3502. $MerchantEmail = $Invoice -> getElementsByTagName('merchantEmail') -> length > 0 ? $Invoice -> getElementsByTagName('merchantEmail') -> item(0) -> nodeValue : '';  
  3503. $PayerEmail = $Invoice -> getElementsByTagName('payerEmail') -> length > 0 ? $Invoice -> getElementsByTagName('payerEmail') -> item(0) -> nodeValue : '';  
  3504. $Number = $Invoice -> getElementsByTagName('number') -> length > 0 ? $Invoice -> getElementsByTagName('number') -> item(0) -> nodeValue : '';  
  3505. $BillingBusinessName = $Invoice -> getElementsByTagName('billingBusinessName') -> length > 0 ? $Invoice -> getElementsByTagName('billingBusinessName') -> item(0) -> nodeValue : '';  
  3506. $BillingFirstName = $Invoice -> getElementsByTagName('billingFirstName') -> length > 0 ? $Invoice -> getElementsByTagName('billingFirstName') -> item(0) -> nodeValue : '';  
  3507. $BillingLastName = $Invoice -> getElementsByTagName('billingLastName') -> length > 0 ? $Invoice -> getElementsByTagName('billingLastName') -> item(0) -> nodeValue : '';  
  3508. $ShippingBusinessName = $Invoice -> getElementsByTagName('shippingBusinessName') -> length > 0 ? $Invoice -> getElementsByTagName('shippingBusinessName') -> item(0) -> nodeValue : '';  
  3509. $ShippingFirstName = $Invoice -> getElementsByTagName('shippingFirstName') -> length > 0 ? $Invoice -> getElementsByTagName('shippingFirstName') -> item(0) -> nodeValue : '';  
  3510. $ShippingLastName = $Invoice -> getElementsByTagName('shippingLastName') -> length > 0 ? $Invoice -> getElementsByTagName('shippingLastName') -> item(0) -> nodeValue : '';  
  3511. $TotalAmount = $Invoice -> getElementsByTagName('totalAmount') -> length > 0 ? $Invoice -> getElementsByTagName('totalAmount') -> item(0) -> nodeValue : '';  
  3512. $CurrencyCode = $Invoice -> getElementsByTagName('currencyCode') -> length > 0 ? $Invoice -> getElementsByTagName('currencyCode') -> item(0) -> nodeValue : '';  
  3513. $InvoiceDate = $Invoice -> getElementsByTagName('invoiceDate') -> length > 0 ? $Invoice -> getElementsByTagName('invoiceDate') -> item(0) -> nodeValue : '';  
  3514. $DueDate = $Invoice -> getElementsByTagName('dueDate') -> length > 0 ? $Invoice -> getElementsByTagName('dueDate') -> item(0) -> nodeValue : '';  
  3515. $Status = $Invoice -> getElementsByTagName('status') -> length > 0 ? $Invoice -> getElementsByTagName('status') -> item(0) -> nodeValue : '';  
  3516. $Origin = $Invoice -> getElementsByTagName('origin') -> length > 0 ? $Invoice -> getElementsByTagName('origin') -> item(0) -> nodeValue : '';  
  3517.  
  3518. $InvoiceItem = array( 
  3519. 'InvoiceID' => $InvoiceID,  
  3520. 'MerchantEmail' => $MerchantEmail,  
  3521. 'PayerEmail' => $PayerEmail,  
  3522. 'Number' => $Number,  
  3523. 'BillingBusinessName' => $BillingBusinessName,  
  3524. 'BillingFirstName' => $BillingFirstName,  
  3525. 'BillingLastName' => $BillingLastName,  
  3526. 'ShippingBusinessName' => $ShippingBusinessName,  
  3527. 'ShippingFirstName' => $ShippingFirstName,  
  3528. 'ShippingLastName' => $ShippingLastName,  
  3529. 'TotalAmount' => $TotalAmount,  
  3530. 'CurrencyCode' => $CurrencyCode,  
  3531. 'InvoiceDate' => $InvoiceDate,  
  3532. 'DueDate' => $DueDate,  
  3533. 'Status' => $Status,  
  3534. 'Origin' => $Origin 
  3535. ); 
  3536. array_push($Invoices, $InvoiceItem); 
  3537.  
  3538. $ResponseDataArray = array( 
  3539. 'Errors' => $Errors,  
  3540. 'Ack' => $Ack,  
  3541. 'Build' => $Build,  
  3542. 'CorrelationID' => $CorrelationID,  
  3543. 'Timestamp' => $Timestamp,  
  3544. 'Count' => $Count,  
  3545. 'Page' => $Page,  
  3546. 'HasNextPage' => $HasNextPage,  
  3547. 'HasPreviousPage' => $HasPreviousPage,  
  3548. 'Invoices' => $Invoices,  
  3549. 'XMLRequest' => $XMLRequest,  
  3550. 'XMLResponse' => $XMLResponse 
  3551. ); 
  3552.  
  3553. return $ResponseDataArray; 
  3554.  
  3555.  
  3556.  
  3557. /** 
  3558. * Submit MarkInvoiceAsPaid API request to PayPal. 
  3559. * @access public 
  3560. * @param array call config data 
  3561. * @return array 
  3562. */ 
  3563. function MarkInvoiceAsPaid($DataArray) 
  3564. $MarkInvoiceAsPaidFields = isset($DataArray['MarkInvoiceAsPaidFields']) ? $DataArray['MarkInvoiceAsPaidFields'] : array(); 
  3565. $InvoiceID = isset($MarkInvoiceAsPaidFields['InvoiceID']) ? $MarkInvoiceAsPaidFields['InvoiceID'] : ''; 
  3566. $Method = isset($MarkInvoiceAsPaidFields['Method']) ? $MarkInvoiceAsPaidFields['Method'] : ''; 
  3567. $Note = isset($MarkInvoiceAsPaidFields['Note']) ? $MarkInvoiceAsPaidFields['Note'] : ''; 
  3568. $Date = isset($MarkInvoiceAsPaidFields['Date']) ? $MarkInvoiceAsPaidFields['Date'] : ''; 
  3569.  
  3570. // Generate XML Request 
  3571. $XMLRequest = '<?xml version="1.0" encoding="utf-8"?>'; 
  3572. $XMLRequest .= '<MarkInvoiceAsPaidRequest xmlns="' . $this -> XMLNamespace . '">'; 
  3573. $XMLRequest .= $this -> GetXMLRequestEnvelope(); 
  3574. $XMLRequest .= $InvoiceID != '' ? '<invoiceID xmlns="">' . $InvoiceID . '</invoiceID>' : ''; 
  3575.  
  3576. $XMLRequest .= '<payment xmlns="">'; 
  3577. $XMLRequest .= $Method != '' ? '<method xmlns="">' . $Method . '</method>' : ''; 
  3578. $XMLRequest .= $Note != '' ? '<note xmlns="">' . $Note . '</note>' : ''; 
  3579. $XMLRequest .= $Date != '' ? '<date xmlns="">' . $Date . '</date>' : '';  
  3580. $XMLRequest .= '</payment>'; 
  3581.  
  3582. $XMLRequest .= '</MarkInvoiceAsPaidRequest>'; 
  3583.  
  3584. // Call the API and load XML response into DOM 
  3585. $XMLResponse = $this -> CURLRequest($XMLRequest, 'Invoice', 'MarkInvoiceAsPaid'); 
  3586. $DOM = new DOMDocument(); 
  3587. $DOM -> loadXML($XMLResponse); 
  3588.  
  3589. // Parse XML values 
  3590. $Fault = $DOM -> getElementsByTagName('FaultMessage') -> length > 0 ? true : false; 
  3591. $Errors = $this -> GetErrors($XMLResponse); 
  3592. $Ack = $DOM -> getElementsByTagName('ack') -> length > 0 ? $DOM -> getElementsByTagName('ack') -> item(0) -> nodeValue : ''; 
  3593. $Build = $DOM -> getElementsByTagName('build') -> length > 0 ? $DOM -> getElementsByTagName('build') -> item(0) -> nodeValue : ''; 
  3594. $CorrelationID = $DOM -> getElementsByTagName('correlationId') -> length > 0 ? $DOM -> getElementsByTagName('correlationId') -> item(0) -> nodeValue : ''; 
  3595. $Timestamp = $DOM -> getElementsByTagName('timestamp') -> length > 0 ? $DOM -> getElementsByTagName('timestamp') -> item(0) -> nodeValue : ''; 
  3596.  
  3597. $InvoiceID = $DOM -> getElementsByTagName('invoiceID') -> length > 0 ? $DOM -> getElementsByTagName('invoiceID') -> item(0) -> nodeValue : ''; 
  3598. $InvoiceNumber = $DOM -> getElementsByTagName('invoiceNumber') -> length > 0 ? $DOM -> getElementsByTagName('invoiceNumber') -> item(0) -> nodeValue : ''; 
  3599. $InvoiceURL = $DOM -> getElementsByTagName('invoiceURL') -> length > 0 ? $DOM -> getElementsByTagName('invoiceURL') -> item(0) -> nodeValue : ''; 
  3600.  
  3601. $ResponseDataArray = array( 
  3602. 'Errors' => $Errors,  
  3603. 'Ack' => $Ack,  
  3604. 'Build' => $Build,  
  3605. 'CorrelationID' => $CorrelationID,  
  3606. 'Timestamp' => $Timestamp,  
  3607. 'InvoiceID' => $InvoiceID,  
  3608. 'InvoiceNumber' => $InvoiceNumber,  
  3609. 'InvoiceURL' => $InvoiceURL,  
  3610. 'XMLRequest' => $XMLRequest,  
  3611. 'XMLResponse' => $XMLResponse 
  3612. ); 
  3613.  
  3614. return $ResponseDataArray; 
  3615.  
  3616.  
  3617.  
  3618. /** 
  3619. * Submit RequestPermissions API request to PayPal. 
  3620. * @access public 
  3621. * @param array call config data 
  3622. * @return array 
  3623. */ 
  3624. function RequestPermissions($DataArray) 
  3625. $RequestPermissionsFields = isset($DataArray['RequestPermissionsFields']) ? $DataArray['RequestPermissionsFields'] : array(); 
  3626. $Scope = isset($RequestPermissionsFields['Scope']) ? $RequestPermissionsFields['Scope'] : array(); 
  3627. $Callback = isset($RequestPermissionsFields['Callback']) ? $RequestPermissionsFields['Callback'] : ''; 
  3628.  
  3629. // Generate XML Request 
  3630. $XMLRequest = '<?xml version="1.0" encoding="utf-8"?>'; 
  3631. $XMLRequest .= '<RequestPermissionsRequest xmlns="' . $this -> XMLNamespace . '">'; 
  3632. $XMLRequest .= $this -> GetXMLRequestEnvelope(); 
  3633.  
  3634. foreach($Scope as $Value) 
  3635. $XMLRequest .= $Scope != '' ? '<scope xmlns="">' . $Value . '</scope>' : ''; 
  3636.  
  3637. $XMLRequest .= $Callback != '' ? '<callback xmlns="">' . $Callback . '</callback>' : ''; 
  3638. $XMLRequest .= '</RequestPermissionsRequest>'; 
  3639.  
  3640. // Call the API and load XML response into DOM 
  3641. $XMLResponse = $this -> CURLRequest($XMLRequest, 'Permissions', 'RequestPermissions'); 
  3642. $DOM = new DOMDocument(); 
  3643. $DOM -> loadXML($XMLResponse); 
  3644.  
  3645. // Parse XML values 
  3646. $Fault = $DOM -> getElementsByTagName('FaultMessage') -> length > 0 ? true : false; 
  3647. $Errors = $this -> GetErrors($XMLResponse); 
  3648. $Ack = $DOM -> getElementsByTagName('ack') -> length > 0 ? $DOM -> getElementsByTagName('ack') -> item(0) -> nodeValue : ''; 
  3649. $Build = $DOM -> getElementsByTagName('build') -> length > 0 ? $DOM -> getElementsByTagName('build') -> item(0) -> nodeValue : ''; 
  3650. $CorrelationID = $DOM -> getElementsByTagName('correlationId') -> length > 0 ? $DOM -> getElementsByTagName('correlationId') -> item(0) -> nodeValue : ''; 
  3651. $Timestamp = $DOM -> getElementsByTagName('timestamp') -> length > 0 ? $DOM -> getElementsByTagName('timestamp') -> item(0) -> nodeValue : ''; 
  3652.  
  3653. $Token = $DOM -> getElementsByTagName('token') -> length > 0 ? $DOM -> getElementsByTagName('token') -> item(0) -> nodeValue : ''; 
  3654. $RedirectURL = $this->Sandbox ? 'https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_grant-permission&request_token=' . $Token : 'https://www.paypal.com/cgi-bin/webscr?cmd=_grant-permission&request_token=' . $Token; 
  3655.  
  3656. $ResponseDataArray = array( 
  3657. 'Errors' => $Errors,  
  3658. 'Ack' => $Ack,  
  3659. 'Build' => $Build,  
  3660. 'CorrelationID' => $CorrelationID,  
  3661. 'Timestamp' => $Timestamp,  
  3662. 'Token' => $Token,  
  3663. 'RedirectURL' => $RedirectURL,  
  3664. 'XMLRequest' => $XMLRequest,  
  3665. 'XMLResponse' => $XMLResponse 
  3666. ); 
  3667.  
  3668. return $ResponseDataArray;  
  3669.  
  3670.  
  3671. /** 
  3672. * Submit GetAccessToken API request to PayPal. 
  3673. * @access public 
  3674. * @param array call config data 
  3675. * @return array 
  3676. */ 
  3677. function GetAccessToken($DataArray) 
  3678. $GetAccessTokenFields = isset($DataArray['GetAccessTokenFields']) ? $DataArray['GetAccessTokenFields'] : array(); 
  3679. $Token = isset($GetAccessTokenFields['Token']) ? $GetAccessTokenFields['Token'] : ''; 
  3680. $Verifier = isset($GetAccessTokenFields['Verifier']) ? $GetAccessTokenFields['Verifier'] : ''; 
  3681. $SubjectAlias = isset($GetAccessTokenFields['SubjectAlias']) ? $GetAccessTokenFields['SubjectAlias'] : ''; 
  3682.  
  3683. // Generate XML Request 
  3684. $XMLRequest = '<?xml version="1.0" encoding="utf-8"?>'; 
  3685. $XMLRequest .= '<GetAccessTokenRequest xmlns="' . $this -> XMLNamespace . '">'; 
  3686. $XMLRequest .= $this -> GetXMLRequestEnvelope(); 
  3687. $XMLRequest .= $Token != '' ? '<token xmlns="">' . $Token . '</token>' : ''; 
  3688. $XMLRequest .= $Verifier != '' ? '<verifier xmlns="">' . $Verifier . '</verifier>' : ''; 
  3689. $XMLRequest .= $SubjectAlias != '' ? '<subjectAlias xmlns="">' . $SubjectAlias . '</subjectAlias>' : ''; 
  3690. $XMLRequest .= '</GetAccessTokenRequest>'; 
  3691.  
  3692. // Call the API and load XML response into DOM 
  3693. $XMLResponse = $this -> CURLRequest($XMLRequest, 'Permissions', 'GetAccessToken'); 
  3694. $DOM = new DOMDocument(); 
  3695. $DOM -> loadXML($XMLResponse); 
  3696.  
  3697. // Parse XML values 
  3698. $Fault = $DOM -> getElementsByTagName('FaultMessage') -> length > 0 ? true : false; 
  3699. $Errors = $this -> GetErrors($XMLResponse); 
  3700. $Ack = $DOM -> getElementsByTagName('ack') -> length > 0 ? $DOM -> getElementsByTagName('ack') -> item(0) -> nodeValue : ''; 
  3701. $Build = $DOM -> getElementsByTagName('build') -> length > 0 ? $DOM -> getElementsByTagName('build') -> item(0) -> nodeValue : ''; 
  3702. $CorrelationID = $DOM -> getElementsByTagName('correlationId') -> length > 0 ? $DOM -> getElementsByTagName('correlationId') -> item(0) -> nodeValue : ''; 
  3703. $Timestamp = $DOM -> getElementsByTagName('timestamp') -> length > 0 ? $DOM -> getElementsByTagName('timestamp') -> item(0) -> nodeValue : ''; 
  3704.  
  3705. $Scope = array(); 
  3706. $Scopes = $DOM -> getElementsByTagName('scope') -> length > 0 ? $DOM -> getElementsByTagName('scope') : array(); 
  3707. foreach($Scopes as $ScopeType) 
  3708. array_push($Scope, $ScopeType->nodeValue); 
  3709.  
  3710. $Token = $DOM -> getElementsByTagName('token') -> length > 0 ? $DOM -> getElementsByTagName('token') -> item(0) -> nodeValue : ''; 
  3711. $TokenSecret = $DOM -> getElementsByTagName('tokenSecret') -> length > 0 ? $DOM -> getElementsByTagName('tokenSecret') -> item(0) -> nodeValue : ''; 
  3712.  
  3713. $ResponseDataArray = array( 
  3714. 'Errors' => $Errors,  
  3715. 'Ack' => $Ack,  
  3716. 'Build' => $Build,  
  3717. 'CorrelationID' => $CorrelationID,  
  3718. 'Timestamp' => $Timestamp,  
  3719. 'Scope' => $Scope,  
  3720. 'Token' => $Token,  
  3721. 'TokenSecret' => $TokenSecret,  
  3722. 'XMLRequest' => $XMLRequest,  
  3723. 'XMLResponse' => $XMLResponse 
  3724. ); 
  3725.  
  3726. return $ResponseDataArray;  
  3727.  
  3728.  
  3729. /** 
  3730. * Submit GetPermissions API request to PayPal. 
  3731. * @access public 
  3732. * @param array call config data 
  3733. * @return array 
  3734. */ 
  3735. function GetPermissions($Token) 
  3736. // Generate XML Request 
  3737. $XMLRequest = '<?xml version="1.0" encoding="utf-8"?>'; 
  3738. $XMLRequest .= '<GetPermissionsRequest xmlns="' . $this -> XMLNamespace . '">'; 
  3739. $XMLRequest .= $this -> GetXMLRequestEnvelope(); 
  3740. $XMLRequest .= $Token != '' ? '<token xmlns="">' . $Token . '</token>' : ''; 
  3741. $XMLRequest .= '</GetPermissionsRequest>'; 
  3742.  
  3743. // Call the API and load XML response into DOM 
  3744. $XMLResponse = $this -> CURLRequest($XMLRequest, 'Permissions', 'GetPermissions'); 
  3745. $DOM = new DOMDocument(); 
  3746. $DOM -> loadXML($XMLResponse); 
  3747.  
  3748. // Parse XML values 
  3749. $Fault = $DOM -> getElementsByTagName('FaultMessage') -> length > 0 ? true : false; 
  3750. $Errors = $this -> GetErrors($XMLResponse); 
  3751. $Ack = $DOM -> getElementsByTagName('ack') -> length > 0 ? $DOM -> getElementsByTagName('ack') -> item(0) -> nodeValue : ''; 
  3752. $Build = $DOM -> getElementsByTagName('build') -> length > 0 ? $DOM -> getElementsByTagName('build') -> item(0) -> nodeValue : ''; 
  3753. $CorrelationID = $DOM -> getElementsByTagName('correlationId') -> length > 0 ? $DOM -> getElementsByTagName('correlationId') -> item(0) -> nodeValue : ''; 
  3754. $Timestamp = $DOM -> getElementsByTagName('timestamp') -> length > 0 ? $DOM -> getElementsByTagName('timestamp') -> item(0) -> nodeValue : ''; 
  3755.  
  3756. $Scope = array(); 
  3757. $Scopes = $DOM -> getElementsByTagName('scope') -> length > 0 ? $DOM -> getElementsByTagName('scope') : array(); 
  3758. foreach($Scopes as $ScopeType) 
  3759. array_push($Scope, $ScopeType->nodeValue); 
  3760.  
  3761.  
  3762. $ResponseDataArray = array( 
  3763. 'Errors' => $Errors,  
  3764. 'Ack' => $Ack,  
  3765. 'Build' => $Build,  
  3766. 'CorrelationID' => $CorrelationID,  
  3767. 'Timestamp' => $Timestamp,  
  3768. 'Scope' => $Scope,  
  3769. 'XMLRequest' => $XMLRequest,  
  3770. 'XMLResponse' => $XMLResponse 
  3771. ); 
  3772.  
  3773. return $ResponseDataArray;  
  3774.  
  3775.  
  3776. /** 
  3777. * Submit CancelPermissions API request to PayPal. 
  3778. * @access public 
  3779. * @param array call config data 
  3780. * @return array 
  3781. */ 
  3782. function CancelPermissions($Token) 
  3783. // Generate XML Request 
  3784. $XMLRequest = '<?xml version="1.0" encoding="utf-8"?>'; 
  3785. $XMLRequest .= '<CancelPermissionsRequest xmlns="' . $this -> XMLNamespace . '">'; 
  3786. $XMLRequest .= $this -> GetXMLRequestEnvelope(); 
  3787. $XMLRequest .= $Token != '' ? '<token xmlns="">' . $Token . '</token>' : ''; 
  3788. $XMLRequest .= '</CancelPermissionsRequest>'; 
  3789.  
  3790. // Call the API and load XML response into DOM 
  3791. $XMLResponse = $this -> CURLRequest($XMLRequest, 'Permissions', 'CancelPermissions'); 
  3792. $DOM = new DOMDocument(); 
  3793. $DOM -> loadXML($XMLResponse); 
  3794.  
  3795. // Parse XML values 
  3796. $Fault = $DOM -> getElementsByTagName('FaultMessage') -> length > 0 ? true : false; 
  3797. $Errors = $this -> GetErrors($XMLResponse); 
  3798. $Ack = $DOM -> getElementsByTagName('ack') -> length > 0 ? $DOM -> getElementsByTagName('ack') -> item(0) -> nodeValue : ''; 
  3799. $Build = $DOM -> getElementsByTagName('build') -> length > 0 ? $DOM -> getElementsByTagName('build') -> item(0) -> nodeValue : ''; 
  3800. $CorrelationID = $DOM -> getElementsByTagName('correlationId') -> length > 0 ? $DOM -> getElementsByTagName('correlationId') -> item(0) -> nodeValue : ''; 
  3801. $Timestamp = $DOM -> getElementsByTagName('timestamp') -> length > 0 ? $DOM -> getElementsByTagName('timestamp') -> item(0) -> nodeValue : ''; 
  3802.  
  3803. $ResponseDataArray = array( 
  3804. 'Errors' => $Errors,  
  3805. 'Ack' => $Ack,  
  3806. 'Build' => $Build,  
  3807. 'CorrelationID' => $CorrelationID,  
  3808. 'Timestamp' => $Timestamp,  
  3809. 'XMLRequest' => $XMLRequest,  
  3810. 'XMLResponse' => $XMLResponse 
  3811. ); 
  3812.  
  3813. return $ResponseDataArray;  
  3814.  
  3815.  
  3816. /** 
  3817. * Submit GetBasicPersonalData API request to PayPal. 
  3818. * @access public 
  3819. * @param array call config data 
  3820. * @return array 
  3821. */ 
  3822. function GetBasicPersonalData($AttributeList) 
  3823. // Generate XML Request 
  3824. $XMLRequest = '<?xml version="1.0" encoding="utf-8"?>'; 
  3825. $XMLRequest .= '<GetBasicPersonalDataRequest xmlns="' . $this -> XMLNamespace . '">'; 
  3826. $XMLRequest .= $this -> GetXMLRequestEnvelope(); 
  3827. $XMLRequest .= '<attributeList xmlns="">'; 
  3828. foreach($AttributeList as $Attribute) 
  3829. $XMLRequest .= '<attribute xmlns="">' . $Attribute . '</attribute>'; 
  3830. $XMLRequest .= '</attributeList>'; 
  3831. $XMLRequest .= '</GetBasicPersonalDataRequest>'; 
  3832.  
  3833. // Call the API and load XML response into DOM 
  3834. $XMLResponse = $this -> CURLRequest($XMLRequest, 'Permissions', 'GetBasicPersonalData'); 
  3835. $DOM = new DOMDocument(); 
  3836. $DOM -> loadXML($XMLResponse); 
  3837.  
  3838. // Parse XML values 
  3839. $Fault = $DOM -> getElementsByTagName('FaultMessage') -> length > 0 ? true : false; 
  3840. $Errors = $this -> GetErrors($XMLResponse); 
  3841. $Ack = $DOM -> getElementsByTagName('ack') -> length > 0 ? $DOM -> getElementsByTagName('ack') -> item(0) -> nodeValue : ''; 
  3842. $Build = $DOM -> getElementsByTagName('build') -> length > 0 ? $DOM -> getElementsByTagName('build') -> item(0) -> nodeValue : ''; 
  3843. $CorrelationID = $DOM -> getElementsByTagName('correlationId') -> length > 0 ? $DOM -> getElementsByTagName('correlationId') -> item(0) -> nodeValue : ''; 
  3844. $Timestamp = $DOM -> getElementsByTagName('timestamp') -> length > 0 ? $DOM -> getElementsByTagName('timestamp') -> item(0) -> nodeValue : ''; 
  3845.  
  3846. $PersonalDataList = $DOM -> getElementsByTagName('personalData') -> length > 0 ? $DOM -> getElementsByTagName('personalData') : array(); 
  3847.  
  3848. $PersonalData = array(); 
  3849. foreach($PersonalDataList as $PersonalDataType) 
  3850. $PersonalDataKey = $PersonalDataType -> getElementsByTagName('personalDataKey') -> length > 0 ? $PersonalDataType -> getElementsByTagName('personalDataKey') -> item(0) -> nodeValue : ''; 
  3851. $PersonalDataValue = $PersonalDataType -> getElementsByTagName('personalDataValue') -> length > 0 ? $PersonalDataType -> getElementsByTagName('personalDataValue') -> item(0) -> nodeValue : ''; 
  3852.  
  3853. $PersonalDataItem = array('PersonalDataKey' => $PersonalDataKey, 'PersonalDataValue' => $PersonalDataValue); 
  3854. array_push($PersonalData, $PersonalDataItem); 
  3855.  
  3856. $PersonalDataKey = $DOM -> getElementsByTagName('timestamp') -> length > 0 ? $DOM -> getElementsByTagName('timestamp') -> item(0) -> nodeValue : ''; 
  3857. $PersonalDataValue = $DOM -> getElementsByTagName('timestamp') -> length > 0 ? $DOM -> getElementsByTagName('timestamp') -> item(0) -> nodeValue : ''; 
  3858.  
  3859. $ResponseDataArray = array( 
  3860. 'Errors' => $Errors,  
  3861. 'Ack' => $Ack,  
  3862. 'Build' => $Build,  
  3863. 'CorrelationID' => $CorrelationID,  
  3864. 'Timestamp' => $Timestamp,  
  3865. 'PersonalData' => $PersonalData,  
  3866. 'XMLRequest' => $XMLRequest,  
  3867. 'XMLResponse' => $XMLResponse 
  3868. ); 
  3869.  
  3870. return $ResponseDataArray;  
  3871.  
  3872.  
  3873. /** 
  3874. * Submit GetAdvancedPersonalData API request to PayPal. 
  3875. * @access public 
  3876. * @param array call config data 
  3877. * @return array 
  3878. */ 
  3879. function GetAdvancedPersonalData($AttributeList) 
  3880. // Generate XML Request 
  3881. $XMLRequest = '<?xml version="1.0" encoding="utf-8"?>'; 
  3882. $XMLRequest .= '<GetAdvancedPersonalDataRequest xmlns="' . $this -> XMLNamespace . '">'; 
  3883. $XMLRequest .= $this -> GetXMLRequestEnvelope(); 
  3884. $XMLRequest .= '<attributeList xmlns="">'; 
  3885. foreach($AttributeList as $Attribute) 
  3886. $XMLRequest .= '<attribute xmlns="">' . $Attribute . '</attribute>'; 
  3887. $XMLRequest .= '</attributeList>'; 
  3888. $XMLRequest .= '</GetAdvancedPersonalDataRequest>'; 
  3889.  
  3890. // Call the API and load XML response into DOM 
  3891. $XMLResponse = $this -> CURLRequest($XMLRequest, 'Permissions', 'GetAdvancedPersonalData'); 
  3892. $DOM = new DOMDocument(); 
  3893. $DOM -> loadXML($XMLResponse); 
  3894.  
  3895. // Parse XML values 
  3896. $Fault = $DOM -> getElementsByTagName('FaultMessage') -> length > 0 ? true : false; 
  3897. $Errors = $this -> GetErrors($XMLResponse); 
  3898. $Ack = $DOM -> getElementsByTagName('ack') -> length > 0 ? $DOM -> getElementsByTagName('ack') -> item(0) -> nodeValue : ''; 
  3899. $Build = $DOM -> getElementsByTagName('build') -> length > 0 ? $DOM -> getElementsByTagName('build') -> item(0) -> nodeValue : ''; 
  3900. $CorrelationID = $DOM -> getElementsByTagName('correlationId') -> length > 0 ? $DOM -> getElementsByTagName('correlationId') -> item(0) -> nodeValue : ''; 
  3901. $Timestamp = $DOM -> getElementsByTagName('timestamp') -> length > 0 ? $DOM -> getElementsByTagName('timestamp') -> item(0) -> nodeValue : ''; 
  3902.  
  3903. $PersonalDataList = $DOM -> getElementsByTagName('personalData') -> length > 0 ? $DOM -> getElementsByTagName('personalData') : array(); 
  3904.  
  3905. $PersonalData = array(); 
  3906. foreach($PersonalDataList as $PersonalDataType) 
  3907. $PersonalDataKey = $PersonalDataType -> getElementsByTagName('personalDataKey') -> length > 0 ? $PersonalDataType -> getElementsByTagName('personalDataKey') -> item(0) -> nodeValue : ''; 
  3908. $PersonalDataValue = $PersonalDataType -> getElementsByTagName('personalDataValue') -> length > 0 ? $PersonalDataType -> getElementsByTagName('personalDataValue') -> item(0) -> nodeValue : ''; 
  3909.  
  3910. $PersonalDataItem = array('PersonalDataKey' => $PersonalDataKey, 'PersonalDataValue' => $PersonalDataValue); 
  3911. array_push($PersonalData, $PersonalDataItem); 
  3912.  
  3913. $PersonalDataKey = $DOM -> getElementsByTagName('timestamp') -> length > 0 ? $DOM -> getElementsByTagName('timestamp') -> item(0) -> nodeValue : ''; 
  3914. $PersonalDataValue = $DOM -> getElementsByTagName('timestamp') -> length > 0 ? $DOM -> getElementsByTagName('timestamp') -> item(0) -> nodeValue : ''; 
  3915.  
  3916. $ResponseDataArray = array( 
  3917. 'Errors' => $Errors,  
  3918. 'Ack' => $Ack,  
  3919. 'Build' => $Build,  
  3920. 'CorrelationID' => $CorrelationID,  
  3921. 'Timestamp' => $Timestamp,  
  3922. 'PersonalData' => $PersonalData,  
  3923. 'XMLRequest' => $XMLRequest,  
  3924. 'XMLResponse' => $XMLResponse 
  3925. ); 
  3926.  
  3927. return $ResponseDataArray; 
  3928.  
  3929.  
  3930. } // End Class PayPal_Adaptive