Advertisement

07.28.2008 at 03:11PM PDT, ID: 23602354
[x]
Attachment Details

Pulling data from a class not working as expected...???

Asked by angelleye in PHP Scripting Language

Tags: PHP

I've got a simple class setup to help me build PayPal SOAP requests.  I've included the top portion of this class  as a code snippet.  As you can see I'm storing my API credentials outside of the web root and parsing the values within the class.

When I include this class into another PHP file and then do:

$ppSession = new PayPalSession(true);
echo $ppSession -> SOAPHeader;

I get the SOAPHeader data except the credentials are blank.  For some reason it's not going through the process of opening up that XML file and parsing out the values or something like that.

When I build functions inside this class to generate requests and then do something like:

$SOAPResponse = $ppSession -> GetExpressCheckoutDetails($Token);

That works perfectly and loads the response as expected.  For this particular request, though, there are LOTS of options and I don't really have the time right now to develop this function to handle all possible scenarios.  Therefore, I've simply generated this one request inside the script itself but the class isn't working the same way for me.

I don't understand why the class runs differently when I just pull values out of it rather than running functions inside of it.  At first I was thinking it must have something to do with the $this -> variable but the SOAPHeader itself is inside one of those and it does display, just without the credentials.

Any information on what I can do here would be greatly appreciated.  Thanks!

Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
<?php
class PayPalSession
{
 
	var $APIUsername = "";
	var $APIPassword = "";
	var $APISignature = "";
	var $APIVersion = "";
	var $EndPointURL = "";
	var $SOAPHeader = "";
	var $SOAPFooter = "";
	
	function PayPalSession($sandbox)
	{
	
		$this -> APIVersion = '53.0';
	
		// Open file outside of web root which contains PayPal credentials.  This is for security purposes.
		$PayPalCredentials = simplexml_load_file("C:\WebNonPublic\DE-Credentials.xml");
	
		//set the API credentials based on sandbox boolean passed
		if($sandbox != true)
		{
			$this -> APIUsername = $PayPalCredentials -> PayPal -> Production -> Username;
			$this -> APIPassword = $PayPalCredentials -> PayPal -> Production -> Password;
			$this -> APISignature = $PayPalCredentials -> PayPal -> Production -> Signature;
			$this -> EndPointURL = 'https://api-3t.sandbox.paypal.com/2.0/';
		}
		else
		{
			$this -> APIUsername = $PayPalCredentials -> Sandbox -> Username;
			$this -> APIPassword = $PayPalCredentials -> Sandbox -> Password;
			$this -> APISignature = $PayPalCredentials -> Sandbox-> Signature;
			$this -> EndPointURL = 'https://api-3t.paypal.com/2.0/';
		}
		
		// Create the SOAP header and footer to embed in XML request's later.
		$this -> SOAPHeader = '<?xml version="1.0" encoding="utf-8"?>
									<SOAP-ENV:Envelope
									xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
									xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
									xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
									xmlns:xsd="http://www.w3.org/2001/XMLSchema"
									SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
								<SOAP-ENV:Header>
									<RequesterCredentials xmlns="urn:ebay:api:PayPalAPI" SOAP-ENV:mustUnderstand="1">
										<Credentials xmlns="urn:ebay:apis:eBLBaseComponents">
											<Username>' . $this -> APIUsername . '</Username>
											<Password>' . $this -> APIPassword . '</Password>
											<Signature>' . $this -> APISignature . '</Signature>
											<Subject/>
										</Credentials>
									</RequesterCredentials>
								</SOAP-ENV:Header>
								<SOAP-ENV:Body>';
				
		$this -> SOAPFooter = '</SOAP-ENV:Body>
							</SOAP-ENV:Envelope>'; 
							
	} // End function PayPalSession()
[+][-]07.28.2008 at 03:25PM PDT, ID: 22107277

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.28.2008 at 04:07PM PDT, ID: 22107486

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.28.2008 at 04:20PM PDT, ID: 22107599

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.28.2008 at 04:21PM PDT, ID: 22107600

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.28.2008 at 04:28PM PDT, ID: 22107634

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: PHP Scripting Language
Tags: PHP
Sign Up Now!
Solution Provided By: hielo
Participating Experts: 1
Solution Grade: A
 
 
[+][-]07.28.2008 at 05:08PM PDT, ID: 22107788

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628