PayPal_Platform_PHP_SDK help

bc080400222
Contributor
Contributor

Hi Everyone,


                   I have download a Adaptive Payment API 'PayPal_Platform_PHP_SDK'. Its included parallel payment. In Pay-Parallel 'SetPayParallel.php' example included 2 email addresses and 2 amount fields when i tried to submit it redirect me to paypal "https://www.sandbox.paypal.com/webscr&cmd=_ap-payment&paykey=AP-7VD39795W2155581D" successfully. 

My problem is i want to add items description, quantity and amount along each sellers. When i try to edit "PayParallelReceipt.php" and its nothing happen or ineffect in paypal out. Please tell me how i can add it. Thanks

Below is "PayParallelReceipt.php" codes and I want to add following in it:
Description:
Item Name:
Item Quantity
Item Amonut

 

 

 

/********************************************
PayParallelReceipt.php
Called by SetPayParallel.php
Calls CallerService.php,and APIError.php.
********************************************/

require_once '../../../lib/AdaptivePayments.php';
require_once 'web_constants.php';

session_start();

try {


/* The servername and serverport tells PayPal where the buyer
should be directed back to after authorizing payment.
In this case, its the local webserver that is running this script
Using the servername and serverport, the return URL is the first
portion of the URL that buyers will return to after authorizing payment */

$serverName = $_SERVER['SERVER_NAME'];
$serverPort = $_SERVER['SERVER_PORT'];
$url=dirname('http://'.$serverName.':'.$serverPort.$_SERVER['REQUEST_URI']);


/* The returnURL is the location where buyers return when a
payment has been succesfully authorized.
The cancelURL is the location buyers are sent to when they hit the
cancel button during authorization of payment during the PayPal flow */

$returnURL = $url."/PaymentDetails.php";
$cancelURL = "$url/SetPayParallel.php" ;
$currencyCode = $_REQUEST['currencyCode'];
$memo = $_REQUEST["memo"];
$feesPayer = $_REQUEST["feesPayer"];
$email = $_REQUEST["email"];
$requested='';
$receiverEmail='';
$amount='';
$primary='';
$itemPrice='';
$count= count($_POST['receiveremail']);

/* Make the call to PayPal to get the Pay token
If the API call succeded, then redirect the buyer to PayPal
to begin to authorize payment. If an error occured, show the
resulting errors
*/
$payRequest = new PayRequest();
$payRequest->actionType = "PAY";
$payRequest->cancelUrl = $cancelURL ;
$payRequest->returnUrl = $returnURL;
$payRequest->clientDetails = new ClientDetailsType();
$payRequest->clientDetails->applicationId =APPLICATION_ID;
$payRequest->clientDetails->deviceId = DEVICE_ID;
$payRequest->clientDetails->ipAddress = "127.0.0.1";
$payRequest->currencyCode = $currencyCode;
//$payRequest->senderEmail = $email;
$payRequest->requestEnvelope = new RequestEnvelope();
$payRequest->requestEnvelope->errorLanguage = "en_US";

$receiver1 = new receiver();
$receiver1->email = $_POST['receiveremail'][0];
$receiver1->amount = $_REQUEST['amount'][0];
$receiver1->primary = $_REQUEST['primary'][0];
//$receiver1->ItemDescriptions = new PreapprovalRequest();
//$receiver1->phone = "11111111111";

$receiver2 = new receiver();
$receiver2->email = $_POST['receiveremail'][1];
$receiver2->amount = $_REQUEST['amount'][1];
$receiver2->primary = $_REQUEST['primary'][1];
//$receiver2->ItemDescriptions = new PreapprovalRequest();
//$receiver2->phone = "22222222222";

$receiver3 = new receiver();
$receiver3->email = $_POST['receiveremail'][2];
$receiver3->amount = $_REQUEST['amount'][2];
$receiver3->primary = $_REQUEST['primary'][2];
//$receiver3->ItemDescriptions = new PreapprovalRequest();
//$receiver3->phone = "333333333333";

$payRequest->receiverList = array($receiver1,$receiver2,$receiver3);

$payRequest->feesPayer = $feesPayer;
$payRequest->memo = $memo;


/* Make the call to PayPal to get the Pay token
If the API call succeded, then redirect the buyer to PayPal
to begin to authorize payment. If an error occured, show the
resulting errors
*/
$ap = new AdaptivePayments();
$response=$ap->Pay($payRequest);

if(strtoupper($ap->isSuccess) == 'FAILURE')
{
$_SESSION['FAULTMSG']=$ap->getLastError();
$location = "APIError.php";
header("Location: $location");

}
else
{
$_SESSION['payKey'] = $response->payKey;
if($response->paymentExecStatus == "COMPLETED")
{
$location = "PaymentDetails.php";
header("Location: $location");
}
else
{
$token = $response->payKey;
$payPalURL = PAYPAL_REDIRECT_URL.'_ap-payment&paykey='.$token;
header("Location: ".$payPalURL);
}
}
}
catch(Exception $ex) {

$fault = new FaultMessage();
$errorData = new ErrorData();
$errorData->errorId = $ex->getFile() ;
$errorData->message = $ex->getMessage();
$fault->error = $errorData;
$_SESSION['FAULTMSG']=$fault;
$location = "APIError.php";
header("Location: $location");
}

Login to Me Too
1 REPLY 1

Misty11
Advisor
Advisor

Hello bc080400222,

 

There may be some useful information about Adaptive Payment API in the PayPal Developer Forum. That is where discussions about this topic take place, and the people there are in the best position to offer you suggestions.

 

~Misty

Login to Me Too

Haven't Found your Answer?

It happens. Hit the "Login to Ask the community" button to create a question for the PayPal community.