YetAnotherForum
Welcome Guest Search | Active Topics | Log In | Register

Problem in calling Masspay API using PHP Options
ranabir
#1 Posted : Friday, January 27, 2006 2:55:47 PM
Rank: Starting Member

Groups: Registered

Joined: 1/27/2006
Posts: 1
Location: ,
Hello, I want to use the Masspay API using php. I tried to make the API call using SOAP and CURL but all in vain since it takes me to paypal.com's index page. My guess is i have messed up the xml part. Here is the xml part: /*********************************************/ <?xml version=\"1.0\" encoding=\"UTF-8\"?> <SOAP-ENV:Envelope xmlns:xsi=\"http://www.w3.org/1999/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/1999/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>$username</Username> <Password>$password</Password> <Subject/> </Credentials> </RequesterCredentials> </SOAP-ENV:Header> <SOAP-ENV:Body> <MassPayReq xmlns=\"urn:ebay:api:PayPalAPI\"> <MassPayRequest xsi:type=\"ns:MassPayRequestType\"> <Version xmlns=\"urn:ebay:apis:eBLBaseComponents\" xsi:type=\"xsd:string\">1.0</Version> <EmailSubject xsi:type=\"xsd:string\">Your payment is here! (Rhesus Monkey Society affiliate program)</EmailSubject> <MassPayItem xsi:type=\"ns:MassPayRequestItemType\"> <ReceiverEmail xsi:type=\"ns:EmailAddressType\">$recipient</ReceiverEmail> <Amount currencyID=\"USD\" xsl:type=\"cc:BasicAmountType\">0.20</Amount> <UniqueID xsi:type=\"xs:string\">$identifier</UniqueID> <Note xsl:type=\"xsd:string\">This is your payment.</Note> </MassPayItem> </MassPayRequest> </MassPayReq> </SOAP-ENV:Body> </SOAP-ENV:Envelope> /*********************************************/ Can somebody help me out from this situation. Thanks in advance. Ranabir
Sponsor  
 
joshcrad
#2 Posted : Monday, February 20, 2006 11:21:34 AM
Rank: Starting Member

Groups: Registered

Joined: 1/18/2006
Posts: 9
Location: ,
Here's what I have. It works when you load the script in the browser, but for some reason, I cannot get it to work properly when called from another script. Hope it helps you though.



&lt;?php

# Set the temp file name to a string based on the process ID
$tempfile = "/home/domain/tempfile";
$apiusername = "username_api1.hotmail.com";
$apipw = "password";
$certpath = "sb_cert_key.pem";
$receiver = "address1@hotmail.com";

$SOAPrequest = &lt;&lt;&lt; End_Of_Quote
&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;SOAP-ENV:Envelope
xmlns:xsi="http://www.w3.org/1999/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/1999/XMLSchema"
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"&gt;
&lt;SOAP-ENV:Header&gt;
&lt;RequesterCredentials
xmlns="urn:ebay:api:PayPalAPI"
SOAP-ENV:mustUnderstand="1"&gt;
&lt;Credentials xmlns="urn:ebay:apis:eBLBaseComponents"&gt;
&lt;Username&gt;$apiusername&lt;/Username&gt;
&lt;Password&gt;$apipw&lt;/Password&gt;
&lt;Subject/&gt;
&lt;/Credentials&gt;
&lt;/RequesterCredentials&gt;
&lt;/SOAP-ENV:Header&gt;
&lt;SOAP-ENV:Body&gt;
&lt;MassPayReq xmlns="urn:ebay:api:PayPalAPI"&gt;
&lt;MassPayRequest xsi:type="ns:MassPayRequestType"&gt;
&lt;Version xmlns="urn:ebay:apis:eBLBaseComponents" xsi:type="xsd:string"&gt;1.0&lt;/Version&gt;
&lt;EmailSubject xsi:type="xsd:string"&gt;Your payment is here!&lt;/EmailSubject&gt;
&lt;MassPayItem xsi:type="ns:MassPayRequestItemType"&gt;
&lt;ReceiverEmail xsi:type="ns:EmailAddressType"&gt;$receiver&lt;/ReceiverEmail&gt;
&lt;Amount currencyID="USD" xsl:type="cc:BasicAmountType"&gt;10.00&lt;/Amount&gt;
&lt;Note xsl:type="xsd:string"&gt;This is your payment.&lt;/Note&gt;
&lt;/MassPayItem&gt;
&lt;/MassPayRequest&gt;
&lt;/MassPayReq&gt;
&lt;/SOAP-ENV:Body&gt;
&lt;/SOAP-ENV:Envelope&gt;

End_Of_Quote;

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,"https://api.sandbox.paypal.com/2.0/");
curl_setopt($ch, CURLOPT_SSLCERT, $certpath);
curl_setopt($ch, CURLOPT_POSTFIELDS, $SOAPrequest);

curl_exec ($ch);
if (curl_error($ch))
printf("Error %s: %s", curl_errno($ch), curl_error($ch));
curl_close ($ch);

?&gt;


This script is pointed at sandbox. If you want it to point at the live site, take out sandbox to look like this line:

curl_setopt($ch, CURLOPT_URL,"https://api.paypal.com/2.0/");

I haven't tried it on the live site yet.
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

YAFVision Theme by Jaben Cargman (Tiny Gecko)
Powered by YAF | YAF © 2003-2009, Yet Another Forum.NET
This page was generated in 0.178 seconds.