cancel
Showing results for 
Search instead for 
Did you mean: 

Get the Transaction ID from paypal plus

Highlighted
New Community Member

Get the Transaction ID from paypal plus

Following Code works fine to close the order. But I need the transaktion id. I have no idea how to manage this. Can anybody help?

 

if (isset($_GET['paymentId']) && isset($_GET['PayerID'])) {

$mode= ".sandbox";

$ch = curl_init();
$headers=array('Content-Type:application/json','Authorization:Bearer '.$access_token);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_URL, "https://api".$mode.".paypal.com/v1/payments/payment/".$_GET['paymentId']."/execute");
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$jsons='{ "payer_id" : "'.$_GET['PayerID'].'" }';
curl_setopt($ch, CURLOPT_POSTFIELDS, $jsons);
$result = curl_exec($ch);
$json = json_decode($result);
$payed=$json->transactions[0]->related_resources[0]->sale->state;

$transaction_id = $json->transactions[0]->related_resources[0]->sale->transactionId;

 

if ($payed != "completed") {

die('Die Zahlung konnte nicht erfolgreich durchgeführt werden');

}

}