0

I am using PHP PayPal SDK for payment. I am getting the success response from the data and the whole JSON object. I want to know how I can get individual data from the whole returned object. I am specifically interested in the item_number (sku). This is where I am currently $paymentId = $this->input->get("paymentId") ;

        $PayerID = $this->input->get("PayerID") ;

        $token = $this->input->get("token") ;

        $payment = Payment::get($paymentId, $apiContext);

        $execution = new PaymentExecution();

        $execution->setPayerId($this->input->get('PayerID'));

        try{

            $result = $payment->execute($execution, $apiContext);

        }
        catch (Exception $ex){

            die($ex);

        }

        if($result->getState() == 'approved'){

            //get item ID
             //get transaction code
            // get payer information

        } 

It is not well documented in their documention in github here Any idea how I can go about it?

I am more interested in the item ID so I can update the database.

  • you can look up $result object and see what it has at the end. print_r($result) – f_i Aug 13 '17 at 14:57
  • Not sure what is your question? You don't know whether the json response contained the info that you are looking for? As far as I can tell, [Paypal API](https://developer.paypal.com/docs/api/payments/) is well-documented on both request and response content. Or you don't know how to parse the json response `$result`? – hcheung Aug 13 '17 at 15:07
  • @hcheung my question is, once I have executed the payment here $result = $payment->execute($execution, $apiContext); How exactly do I get the item ID? I saw a tutorial that was explaining that I could get the user email like this--> $paymentJson = json_decode($result,TRUE); $email = $paymentJson["payer"]["payer_info"]["email"]; And its working. Now I want the ID. I can't seem to wrap my head around it. – Academic Writers Aug 13 '17 at 15:14
  • So you don't know how to [Parsing JSON with PHP](https://stackoverflow.com/questions/4343596/parsing-json-file-with-php), hope the link will help. Also as suggested by @FaizKhan, do a `print_r($result)` to understand the content of the response. – hcheung Aug 13 '17 at 15:20

0 Answers0