topical media & game development
server-webapi-code-10-paypalMain.php / php
<?php
/*Example Usage
xml = makeAPICall("GetTransactionDetails", xml);
echo "</pre>";
xml->xpath('/SOAP-ENV:Envelope/SOAP-ENV:Body');
soapBody[0]->GetTransactionDetailsResponse;
body->Timestamp;
body->PaymentTransactionDetails->PayerInfo->Payer;
body->PaymentTransactionDetails->PaymentInfo->PaymentStatus;
*/
function transLookUp(username = "USERNAME";
request = <<< End_Of_Quote
<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>password</Password>
<Subject/>
</Credentials>
</RequesterCredentials>
</SOAP-ENV:Header>
<SOAP-ENV:Body>
<GetTransactionDetailsReq xmlns="urn:ebay:api:PayPalAPI">
<GetTransactionDetailsRequest
xsi:type="ns:GetTransactionDetailsRequestType">
<Version xmlns="urn:ebay:apis:eBLBaseComponents"
xsi:type="xsd:string">1.0</Version>
<TransactionID xsi:type="ebl:TransactionId">ch = curl_init();
curl_setopt(ch, CURLOPT_SSLCERT, "./cert_key_pem-1.txt");
curl_setopt(ch, CURLOPT_POSTFIELDS, ch);
response;
if (curl_error(ch) . ": " . curl_error(ch);
return null;
}else
{
curl_close(xml = simplexml_load_string(xml;
echo transid)
{
password = "PASSWORD";
username</Username>
<Password>transid</TransactionID>
<RefundType>Full</RefundType>
</RefundTransactionRequest>
</RefundTransactionReq>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
End_Of_Quote;
ch, CURLOPT_URL, "https://api.sandbox.paypal.com/2.0/");
curl_setopt(ch, CURLOPT_POST, TRUE);
curl_setopt(request);
ob_start();
curl_exec(response = ob_get_clean();
echo ch))
{
file_put_contents("/tmp/curl_error_log.txt", curl_errno(ch), "a+");
curl_close(ch);
response);
return response;
}
}
function makeAPICall(APIparameters)
{
password = "PASSWORD";
APIparameters as paramaterList .= "<{paramater[1]}\">{paramater[0]}>\n";
}
username</Username>
<Password>specificAPIName}Req xmlns="urn:ebay:api:PayPalAPI">
<{specificAPIName}RequestType">
<Version xmlns="urn:ebay:apis:eBLBaseComponents"
xsi:type="xsd:string">1.0</Version>
specificAPIName}Request>
</{ch = curl_init();
curl_setopt(ch, CURLOPT_SSLCERT, "./cert_key_pem-1.txt");
curl_setopt(ch, CURLOPT_POSTFIELDS, ch);
ch))
{
file_put_contents("/tmp/curl_error_log.txt", curl_errno(ch), "a+");
curl_close(ch);
response);
//echo xml = simplexml_load_string(xml;
}
}
function searchEmail(date = "2000-01-29T12:00:01.00Z")
{
parameters[] = array("StartDate", "ebl:dateTime", parameters[] = array("Payer", "ebl:string", "xml = makeAPICall("TransactionSearch", xml;
}
function massPay(subject, username = "USERNAME";
parameters = array();
parameters[] = array("Payer", "ebl:string", "specificAPIName = "MassPay";
foreach(email)
{
parameterList .= "\t<ReceiverEmail xsi:type=\"ebl:string\">parameterList .= "\t<Amount currencyID=\"USD\" xsi:type=\"ebl:string\">parameterList .= "\t<Note xsi:type=\"ebl:string\">Thanks</Note>\n";
request = <<< End_Of_Quote
<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>password</Password>
<Subject/>
</Credentials>
</RequesterCredentials>
</SOAP-ENV:Header>
<SOAP-ENV:Body>
<{specificAPIName}Request xsi:type="ns:{parameterList
</{specificAPIName}Req>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
End_Of_Quote;
echo ch = curl_init();
curl_setopt(ch, CURLOPT_SSLCERT, "./cert_key_pem-1.txt");
curl_setopt(ch, CURLOPT_POSTFIELDS, ch);
ch))
{
file_put_contents("/tmp/curl_error_log.txt", curl_errno(ch), "a+");
curl_close(ch);
response);
echo xml = simplexml_load_string(xml;
}
}
function massPay2(subject, parameters = array();
subject");
foreach(email)
{
email</ReceiverEmail>\n";
amount</Amount>\n";
parameters[] = array("MassPayItem", "ebl:MassPayItemType", "xml = makeAPICall("MassPay", xml;
}
?>
(C) Æliens
20/2/2008
You may not copy or print any of this material without explicit permission of the author or the publisher.
In case of other copyright issues, contact the author.