";
print_r($xml);
echo "";
$soapBody = $xml->xpath('/SOAP-ENV:Envelope/SOAP-ENV:Body');
$body = $soapBody[0]->GetTransactionDetailsResponse;
$timestamp = $body->Timestamp;
$payerEmail = $body->PaymentTransactionDetails->PayerInfo->Payer;
$paymentStatus = $body->PaymentTransactionDetails->PaymentInfo->PaymentStatus;
*/
function transLookUp($transid)
{
$username = "USERNAME";
$password = "PASSWORD";
$request = <<< End_Of_Quote
$username
$password
1.0
$transid
End_Of_Quote;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.sandbox.paypal.com/2.0/");
curl_setopt($ch, CURLOPT_SSLCERT, "./cert_key_pem-1.txt");
curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_POSTFIELDS, $request);
ob_start();
curl_exec($ch);
$response = ob_get_clean();
echo $response;
if (curl_error($ch))
{
file_put_contents("/tmp/curl_error_log.txt", curl_errno($ch) . ": " . curl_error($ch), "a+");
curl_close($ch);
return null;
}else
{
curl_close($ch);
$xml = simplexml_load_string($response);
return $xml;
echo $response;
}
}
function refund($transid)
{
$username = "USERNAME";
$password = "PASSWORD";
$request = <<< End_Of_Quote
$username
$password
1.0
$transid
Full
End_Of_Quote;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.sandbox.paypal.com/2.0/");
curl_setopt($ch, CURLOPT_SSLCERT, "./cert_key_pem-1.txt");
curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_POSTFIELDS, $request);
ob_start();
curl_exec($ch);
$response = ob_get_clean();
echo $response;
if (curl_error($ch))
{
file_put_contents("/tmp/curl_error_log.txt", curl_errno($ch) . ": " . curl_error($ch), "a+");
curl_close($ch);
return null;
}else
{
curl_close($ch);
$xml = simplexml_load_string($response);
return $xml;
echo $response;
}
}
function makeAPICall($specificAPIName, $APIparameters)
{
$username = "USERNAME";
$password = "PASSWORD";
$paramaterList = "";
foreach ($APIparameters as $paramater)
{
$paramaterList .= "<{$paramater[0]} xsi:type=\"{$paramater[1]}\">{$paramater[2]}{$paramater[0]}>\n";
}
$request = <<< End_Of_Quote
$username
$password
<{$specificAPIName}Req xmlns="urn:ebay:api:PayPalAPI">
<{$specificAPIName}Request xsi:type="ns:{$specificAPIName}RequestType">
1.0
$paramaterList
{$specificAPIName}Request>
{$specificAPIName}Req>
End_Of_Quote;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.sandbox.paypal.com/2.0/");
curl_setopt($ch, CURLOPT_SSLCERT, "./cert_key_pem-1.txt");
curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_POSTFIELDS, $request);
ob_start();
curl_exec($ch);
$response = ob_get_clean();
if (curl_error($ch))
{
file_put_contents("/tmp/curl_error_log.txt", curl_errno($ch) . ": " . curl_error($ch), "a+");
curl_close($ch);
echo "curl error logged";
return null;
}else
{
curl_close($ch);
$response2 = str_replace("><", ">\n<", $response);
//echo $response2;
//echo "
";
$xml = simplexml_load_string($response);
return $xml;
}
}
function searchEmail($email, $date = "2000-01-29T12:00:01.00Z")
{
$parameters = array();
$parameters[] = array("StartDate", "ebl:dateTime", $date);
$parameters[] = array("Payer", "ebl:string", "$email");
$xml = makeAPICall("TransactionSearch", $parameters);
return $xml;
}
function massPay($emails, $subject, $amount)
{
$username = "USERNAME";
$password = "PASSWORD";
$parameters = array();
$parameters[] = array("EmailSubject", "ebl:string", "Weekly Paycheck");
$parameters[] = array("Payer", "ebl:string", "$email");
$specificAPIName = "MassPay";
foreach($emails as $email)
{
$parameterList .= "\n";
$parameterList .= "\t$email\n";
$parameterList .= "\t$amount\n";
$parameterList .= "\tThanks\n";
$parameterList .= "\n";
}
$request = <<< End_Of_Quote
$username
$password
<{$specificAPIName}Req xmlns="urn:ebay:api:PayPalAPI">
<{$specificAPIName}Request xsi:type="ns:{$specificAPIName}RequestType">
1.0
$parameterList
{$specificAPIName}Request>
{$specificAPIName}Req>
End_Of_Quote;
echo $request;
echo "
";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.sandbox.paypal.com/2.0/");
curl_setopt($ch, CURLOPT_SSLCERT, "./cert_key_pem-1.txt");
curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_POSTFIELDS, $request);
ob_start();
curl_exec($ch);
$response = ob_get_clean();
if (curl_error($ch))
{
file_put_contents("/tmp/curl_error_log.txt", curl_errno($ch) . ": " . curl_error($ch), "a+");
curl_close($ch);
echo "curl error logged";
return null;
}else
{
curl_close($ch);
$response2 = str_replace("><", ">\n<", $response);
echo $response2;
//echo "
";
$xml = simplexml_load_string($response);
return $xml;
}
}
function massPay2($emails, $subject, $amount)
{
$parameters = array();
$parameters[] = array("EmailSubject", "ebl:string", "$subject");
foreach($emails as $email)
{
$parameterList = "\t$email\n";
$parameterList .= "\t$amount\n";
$parameterList .= "\tThanks\n";
$parameters[] = array("MassPayItem", "ebl:MassPayItemType", "$parameterList");
}
$xml = makeAPICall("MassPay", $parameters);
return $xml;
}
?>