How to Apply Adaptive Payment in paypal?

1) pay.php page create
include(“config/class/class.se_paypal.php”);
$abcd = new se_paypal();

$abcd->splitPay($a,$b,$c); function

2) class.se_paypal.php page create

<?php
class se_paypal{

var $api_user = “abc@paypal.com”;
var $api_pass = “1393674471”;
var $api_sig = “AFcWxV21C7fd0v3bYYYRCpSSRl31A4R9DtVt5l5HIzffuVxFFfGYufLR”;
var $app_id = “APP-80W284485P519543T”;
var $apiUrl = “https://demo/”;
var $paypalUrl=”https://www.demo.com”;

var $job_cats; var $DB; var $fbid;

function se_paypal() {
$this->job_cats = “”;
$this->fbid = “”;
$this->DB = new MySqlDB();
}

function __construct(){
$this->headers = array(
“X-PAYPAL-SECURITY-USERID: “.$this->api_user,
“X-PAYPAL-SECURITY-PASSWORD: “.$this->api_pass,
“X-PAYPAL-SECURITY-SIGNATURE: “.$this->api_sig,
“X-PAYPAL-REQUEST-DATA-FORMAT: JSON”,
“X-PAYPAL-RESPONSE-DATA-FORMAT: JSON”,
“X-PAYPAL-APPLICATION-ID: “.$this->app_id,
);
$this->envelope = array(
“errorLanguage” => “en_US”,
“detailLevel” => “ReturnAll”
);
}

function getabcdOptions($paykey){
$packet = array(
“requestEnvelope” => $this->envelope,
“payKey” => $paykey
);
return $this->_paypalSend($packet,”GetabcdOptions”);
}

function setabcdOptions(){}

function createPayRequest(){}

function _paypalSend($data,$call){
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $this->apiUrl.$call);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_HTTPHEADER, $this->headers);

$response = json_decode(curl_exec($ch),true);
return $response;
}

function splitPay($a,$b,$c){
$remain = number_format(($total – $trendcy),2);
$createPacket = array(
“actionType” =>”PAY”,
“currencyCode” => “USD”,
“feesPayer”=>”PRIMARYRECEIVER”,
“receiverList” => array(
“receiver” => array(
array(
“amount”=> “$a”,
“email”=>”abc@paypal.com”,
//”email”=>”$c”,
“primary”=>”true”
),
array(
“amount”=> “$b”,
“email”=>”xyz@paypal.com”,
“primary”=>”false”
),
),
),
“returnUrl” => “http://xyz.php”,
“cancelUrl” => “http://xyz/error.php”,
“requestEnvelope” => $this->envelope
);

$response = $this->_paypalSend($createPacket,”Pay”);

$paykey = $response[‘payKey’];
$dets = $this->getabcdOptions($paykey);
header(“Location: “.$this->paypalUrl.$paykey);
}
}

Any help for this link
1) https://www.youtube.com/watch?v=rzRR1i-F_VA
2) https://www.youtube.com/watch?v=TPFFIuydHn4