1

I need help to use the following code Paypal Adaptive Payment in WordPress Website.

I do not understand from where the CComponent class extend.

     <?php
          class PaypalTest extends CComponent{
               public $api_user = "**********************";
               public $api_pass = "***********";
               public $api_sig = "**************************";
               public $app_id = "APP-80W284485P519543T";
               public $apiUrl = 'https://svcs.sandbox.paypal.com/AdaptivePayments/';
               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: JSON",
                       "X-PAYPAL-RESPONSE-DATA-FORMAT: JSON",
                       "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, json_encode($data));
                       curl_setopt($ch, CURLOPT_HTTPHEADER, $this->headers);
                       $response = json_decode(curl_exec($ch),true);
                       return $response;

                }

                public function splitPay(){

                        // create the pay request
                       $createPacket = array(
                            "actionType" =>"PAY",
                             "currencyCode" => "USD",
                             "receiverList" => array(
                                   "receiver" => array(
                                         array(
                                             "amount"=> "1.00",
                                             "email"=>"********@hotmail.com"
                                          ),
                                         array(
                                              "amount"=> "2.00",
                                              "email"=>"********@gmail.ca"
                                          ),
                                      ),
                        ),
                        "returnUrl" => "http://test.local/payments/confirm",
                        "cancelUrl" => "http://test.local/payments/cancel",
                        "requestEnvelope" => array(
                                "errorLanguage" => "en_US",
                                "detailLevel" => "ReturnAll",
                         ),
                    );

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

           }
     ?>

It looks like simple, but something I do not understand. And I'm not really familiar with Paypal Adaptive Payments. I'm in sandbox mode.

halfer
  • 19,824
  • 17
  • 99
  • 186
Gurjit
  • 25
  • 7
  • from where you get this content, its must have a library where this class is exist. – dipmala Jun 15 '18 at 13:15
  • I got above code form here https://stackoverflow.com/questions/19645381/paypal-adaptive-payment-php – Gurjit Jun 15 '18 at 13:25
  • First take complete code from https://www.formget.com/paypal-adaptive-payments/ or any other website then check. – dipmala Jun 15 '18 at 13:29
  • I am getting this error message when go to download the code http://prntscr.com/jvc786 – Gurjit Jun 15 '18 at 13:40
  • you need to search something at google although i am sharing this link https://github.com/paypal/adaptivepayments-sdk-php – dipmala Jun 15 '18 at 13:44

0 Answers0