Adaptive paypal payment implementation issue

Dipanshu
New Community Member

Hi,

 

I am trying to implement the paypal adaptive payment with my php code but did not get any luck. As i am trying with below mentioned php code:

 

<?php
class PaypalTest {

public $api_user = "dipanshu.agarwal-facilitator_api1.trigma.in";
public $api_pass = "1406642961";
public $api_sig = "AFcWxV21C7fd0v3bYYYRCpSSRl31A1kt80q4rGlodT87LbfQk-9esOds";
public $app_id = "APP-80W284485P519543T";
public $apiUrl = 'https://svcs.sandbox.paypal.com/AdaptivePayments/Pay';
public $paypalUrl="https://www.paypal.com/webscr?cmd=_ap-payment&paykey=";
public $headers;

public 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: NV",
        "X-PAYPAL-RESPONSE-DATA-FORMAT: NV",
        "X-PAYPAL-APPLICATION-ID: ".$this->app_id,
    );
}

public function getPaymentOptions($paykey) {

}
public function setPaymentOptions() {

}
public 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,$data);
     curl_setopt($ch, CURLOPT_HTTPHEADER, $this->headers);
     $result = curl_exec($ch);
     curl_close($ch);
     echo "<pre>";
     print_r($result);
     echo "</pre>";
     die;
}
public function splitPay() {

         // create the pay request
         "$createPacket = array(
             "actionType" =>"PAY",
             "clientDetails" => array("applicationId" => 'APP-80W284485P519543T'),
             "clientDetails" => array("ipAddress" => '127.0.0.1'),
             "currencyCode" => "USD",
             "feesPayer" => EACHRECEIVER,
             "memo" => 'Adaptive payment paypal',
             "receiverList" => array(
                           "receiver" => array(
                               array(
                                   "amount"=> "1.00",
                                   "email"=> "primary receiver email"
                               ),
                               array(
                                   "amount"=> "2.00",
                                   "email"=> "seconday receiver email"
                               )
                           )
             ),
             "returnUrl" => "Return url",
             "cancelUrl" => "Cancel url",
             "requestEnvelope" => array(
                 "errorLanguage" => "en_US",
                 "detailLevel" => "ReturnAll",
             ),
         );"

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

$payment = new PaypalTest();
$payment->splitPay();
?>

 

When i worked with this code then there are no any response returned back to curl code.

 

Please provide me perfect solution so that i can provide best service to my client.

 

Thanks in advance.

Login to Me Too
0 REPLIES 0

Haven't Found your Answer?

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