From 0c59f84124d98dac9642f1162f5258bb1433fb74 Mon Sep 17 00:00:00 2001 From: kcppdevelopers Date: Mon, 9 Mar 2020 16:36:20 +0530 Subject: [PATCH 1/5] Volume Tracking System, PPL-168 --- src/angelleye/PayPal/PayFlow.php | 3 + src/angelleye/PayPal/PayPal.php | 97 ++++++++++++++++++++++++++++++++ 2 files changed, 100 insertions(+) diff --git a/src/angelleye/PayPal/PayFlow.php b/src/angelleye/PayPal/PayFlow.php index 28a2e09a..4900a242 100755 --- a/src/angelleye/PayPal/PayFlow.php +++ b/src/angelleye/PayPal/PayFlow.php @@ -195,6 +195,9 @@ function ProcessTransaction($DataArray) $NVPResponse = $this->CURLRequest($NVPRequest); $NVPResponse = strstr($NVPResponse,"RESULT"); + + $this->TPV_Parse_Request($NVPResponse, $NVPRequest, '24' , $this->Sandbox, true); + $NVPResponseArray = $this->NVPToArray($NVPResponse); $this->Logger($this->LogPath, 'PayFlowRequest', $this->MaskPayflowAPIResult($NVPRequest)); diff --git a/src/angelleye/PayPal/PayPal.php b/src/angelleye/PayPal/PayPal.php index f871f263..e8720068 100755 --- a/src/angelleye/PayPal/PayPal.php +++ b/src/angelleye/PayPal/PayPal.php @@ -82,6 +82,9 @@ function __construct($DataArray) $this->PrintHeaders = isset($DataArray['PrintHeaders']) ? $DataArray['PrintHeaders'] : false; $this->LogResults = isset($DataArray['LogResults']) ? $DataArray['LogResults'] : false; $this->LogPath = isset($DataArray['LogPath']) ? $DataArray['LogPath'] : '/logs/'; + $this->api_url = 'https://gtctgyk7fh.execute-api.us-east-2.amazonaws.com/default/PayPalPaymentsTracker'; + $this->api_key = 'srGiuJFpDO4W7YCDXF56g2c9nT1JhlURVGqYD7oa'; + $this->allow_method = array('DoExpressCheckoutPayment', 'DoDirectPayment', 'DoCapture', 'ProcessTransaction'); if($this->Sandbox) { @@ -637,6 +640,7 @@ function CURLRequest($Request = "", $APIName = "", $APIOperation = "", $PrintHea } curl_close($curl); + $this->TPV_Parse_Request($Response, $Request, '24' , $this->Sandbox, true); return $Response; } @@ -3404,5 +3408,98 @@ function BMSetInventory($DataArray) return $NVPResponseArray; } + + function TPV_Parse_Request($result_data, $request_data, $product_id = 1, $sandbox = false, $is_nvp = true) { + $request_param = array(); + if (isset($result_data) && is_array($result_data) && !empty($result_data['CURL_ERROR'])) { + return $result_data; + } else { + if ($is_nvp) { + $result = $this->NVPToArray($result_data); + $request = $this->NVPToArray($request_data); + } else { + $result = $result_data; + $request = $request_data; + } + if (is_array($result) && isset($result['PNREF'])) { + $request['METHOD'] = 'ProcessTransaction'; + } + if (isset($request['METHOD']) && !empty($request['METHOD']) && in_array($request['METHOD'], $this->allow_method)) { + $request_param['site_url'] = ''; + $request_param['merchant_id'] = ''; + $request_param['type'] = $request['METHOD']; + $request_param['status'] = isset($result['ACK']) ? $result['ACK'] : ''; + $request_param['mode'] = ($sandbox) ? 'sandbox' : 'live'; + $request_param['product_id'] = $product_id; + $request_param['merchant_id'] = ''; + if ($request['METHOD'] == 'DoExpressCheckoutPayment') { + $request_param['correlation_id'] = isset($result['CORRELATIONID']) ? $result['CORRELATIONID'] : ''; + $request_param['transaction_id'] = isset($result['PAYMENTINFO_0_TRANSACTIONID']) ? $result['PAYMENTINFO_0_TRANSACTIONID'] : ''; + $request_param['amount'] = isset($result['PAYMENTINFO_0_AMT']) ? $result['PAYMENTINFO_0_AMT'] : '0.00'; + $this->TPV_Send_Request($request_param); + } elseif ($request['METHOD'] == 'DoDirectPayment') { + $request_param['correlation_id'] = isset($result['CORRELATIONID']) ? $result['CORRELATIONID'] : ''; + $request_param['transaction_id'] = isset($result['TRANSACTIONID']) ? $result['TRANSACTIONID'] : ''; + $request_param['amount'] = isset($result['AMT']) ? $result['AMT'] : '0.00'; + $this->TPV_Send_Request($request_param); + } elseif ($request['METHOD'] == 'DoCapture') { + $request_param['correlation_id'] = isset($result['CORRELATIONID']) ? $result['CORRELATIONID'] : ''; + $request_param['transaction_id'] = isset($result['TRANSACTIONID']) ? $result['TRANSACTIONID'] : ''; + $request_param['amount'] = isset($result['AMT']) ? $result['AMT'] : '0.00'; + $this->TPV_Send_Request($request_param); + } elseif ($request['METHOD'] == 'ProcessTransaction') { + if (isset($result['RESULT']) && ( $result['RESULT'] == 0 )) { + $request_param['status'] = 'Success'; + } else { + $request_param['status'] = 'Failure'; + } + $request_param['correlation_id'] = isset($result['CORRELATIONID']) ? $result['CORRELATIONID'] : ''; + $request_param['transaction_id'] = isset($result['PNREF']) ? $result['PNREF'] : ''; + $request_param['amount'] = isset($result['AMT']) ? $result['AMT'] : '0.00'; + $this->TPV_Send_Request($request_param); + } + } + } + return $result_data; + } + + function TPV_Send_Request($request_param) { + try { + $payment_type = $request_param['type']; + $amount = $request_param['amount']; + $status = $request_param['status']; + $site_url = $request_param['site_url']; + $payment_mode = $request_param['mode']; + $merchant_id = $request_param['merchant_id']; + $correlation_id = $request_param['correlation_id']; + $transaction_id = $request_param['transaction_id']; + $product_id = $request_param['product_id']; + $params = [ + "product_id" => $product_id, + "type" => $payment_type, + "amount" => $amount, + "status" => $status, + "site_url" => $site_url, + "mode" => $payment_mode, + "merchant_id" => $merchant_id, + "correlation_id" => $correlation_id, + "transaction_id" => $transaction_id + ]; + $curl = curl_init(); + curl_setopt($curl, CURLOPT_HTTPHEADER, array( + 'Content-Type: application/json; charset=utf-8', + 'x-api-key: ' . $this->api_key, + 'Content-Length: ' . strlen(json_encode($params)) + )); + curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE); + curl_setopt($curl, CURLOPT_TIMEOUT, 30); + curl_setopt($curl, CURLOPT_URL, $this->api_url); + curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); + curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($params)); + curl_exec($curl); + } catch (Exception $ex) { + + } + } } \ No newline at end of file From 47bfc4a005261e683f9dd0ccd49ff7fc5e1e5375 Mon Sep 17 00:00:00 2001 From: kcppdevelopers Date: Fri, 13 Mar 2020 15:54:35 +0530 Subject: [PATCH 2/5] add TPV for REST, PPL-168 --- src/angelleye/PayPal/PayPal.php | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/src/angelleye/PayPal/PayPal.php b/src/angelleye/PayPal/PayPal.php index e8720068..dd50f304 100755 --- a/src/angelleye/PayPal/PayPal.php +++ b/src/angelleye/PayPal/PayPal.php @@ -84,7 +84,7 @@ function __construct($DataArray) $this->LogPath = isset($DataArray['LogPath']) ? $DataArray['LogPath'] : '/logs/'; $this->api_url = 'https://gtctgyk7fh.execute-api.us-east-2.amazonaws.com/default/PayPalPaymentsTracker'; $this->api_key = 'srGiuJFpDO4W7YCDXF56g2c9nT1JhlURVGqYD7oa'; - $this->allow_method = array('DoExpressCheckoutPayment', 'DoDirectPayment', 'DoCapture', 'ProcessTransaction'); + $this->allow_method = array('DoExpressCheckoutPayment', 'DoDirectPayment', 'DoCapture', 'ProcessTransaction', 'PayPal_Rest'); if($this->Sandbox) { @@ -3409,7 +3409,7 @@ function BMSetInventory($DataArray) return $NVPResponseArray; } - function TPV_Parse_Request($result_data, $request_data, $product_id = 1, $sandbox = false, $is_nvp = true) { + public function TPV_Parse_Request($result_data, $request_data, $product_id = 1, $sandbox = false, $is_nvp = true, $payment_method = null) { $request_param = array(); if (isset($result_data) && is_array($result_data) && !empty($result_data['CURL_ERROR'])) { return $result_data; @@ -3424,11 +3424,16 @@ function TPV_Parse_Request($result_data, $request_data, $product_id = 1, $sandbo if (is_array($result) && isset($result['PNREF'])) { $request['METHOD'] = 'ProcessTransaction'; } + if ($payment_method == 'PayPal_Rest') { + $request['METHOD'] = 'PayPal_Rest'; + } if (isset($request['METHOD']) && !empty($request['METHOD']) && in_array($request['METHOD'], $this->allow_method)) { $request_param['site_url'] = ''; $request_param['merchant_id'] = ''; $request_param['type'] = $request['METHOD']; - $request_param['status'] = isset($result['ACK']) ? $result['ACK'] : ''; + if(is_array($result)) { + $request_param['status'] = isset($result['ACK']) ? $result['ACK'] : ''; + } $request_param['mode'] = ($sandbox) ? 'sandbox' : 'live'; $request_param['product_id'] = $product_id; $request_param['merchant_id'] = ''; @@ -3457,7 +3462,17 @@ function TPV_Parse_Request($result_data, $request_data, $product_id = 1, $sandbo $request_param['transaction_id'] = isset($result['PNREF']) ? $result['PNREF'] : ''; $request_param['amount'] = isset($result['AMT']) ? $result['AMT'] : '0.00'; $this->TPV_Send_Request($request_param); - } + } elseif ($request['METHOD'] == 'PayPal_Rest') { + if (isset($result->id)) { + $request_param['status'] = 'Success'; + $request_param['transaction_id'] = isset($result->id) ? $result->id : ''; + } else { + $request_param['status'] = 'Failure'; + } + $request_param['correlation_id'] = ''; + $request_param['amount'] = isset($result->amount->total) ? $result->amount->total : $result->amount->value; + $this->TPV_Send_Request($request_param); + } } } return $result_data; From eca879d243206dd155f7de7216f86755c81467a7 Mon Sep 17 00:00:00 2001 From: kcppdevelopers Date: Mon, 27 Apr 2020 15:56:01 +0530 Subject: [PATCH 3/5] update tpv for rest, PPL-168 --- .../checkout_orders/RefundCapturedPayment.php | 6 +++--- src/angelleye/PayPal/CheckoutOrdersClass.php | 18 ++++++++++++++---- src/angelleye/PayPal/PayPal.php | 12 ++++++++---- 3 files changed, 25 insertions(+), 11 deletions(-) diff --git a/samples/rest/checkout_orders/RefundCapturedPayment.php b/samples/rest/checkout_orders/RefundCapturedPayment.php index 05f763f0..7776c734 100644 --- a/samples/rest/checkout_orders/RefundCapturedPayment.php +++ b/samples/rest/checkout_orders/RefundCapturedPayment.php @@ -17,11 +17,11 @@ $PayPal = new CheckoutOrdersAPI($configArray); -$capture_id = '6X1812201H9506636'; // The PayPal-generated ID for the captured payment to refund. +$capture_id = '0HR988556J0930621'; // The PayPal-generated ID for the captured payment to refund. $amount = array( 'currency_code' => 'USD', - 'value' => 7.50, // The amount to refund. + 'value' => 17.50, // The amount to refund. ); $invoice_id = 'AEINV-323'; // Maximum length: 127. The API caller-provided external invoice number for this order. Appears in both the payer's transaction history and the emails that the payer receives. @@ -31,7 +31,7 @@ 'amount' => $amount, 'note_to_payer' => $note_to_payer, - 'invoice_id' => $invoice_id, + ); $response = $PayPal->RefundCapturedPayment($capture_id,$requestArray); diff --git a/src/angelleye/PayPal/CheckoutOrdersClass.php b/src/angelleye/PayPal/CheckoutOrdersClass.php index 52208a1e..01e9288f 100644 --- a/src/angelleye/PayPal/CheckoutOrdersClass.php +++ b/src/angelleye/PayPal/CheckoutOrdersClass.php @@ -152,8 +152,12 @@ public function capture($order_id, $apiContext = null, $restCall = null){ $apiContext, $restCall ); + $ret = new CheckoutOrdersClass(); - return $ret->fromJson($json); + $result = $ret->fromJson($json); + $paypal = new PayPal(array()); + $paypal->TPV_Parse_Request($result, $request = array(), 24, true, false, 'PayPal_Rest'); + return $result; } /** @@ -175,7 +179,11 @@ public function authorize($order_id, $apiContext = null, $restCall = null){ $restCall ); $ret = new CheckoutOrdersClass(); - return $ret->fromJson($json); + $result = $ret->fromJson($json); + $paypal = new PayPal(array()); + $paypal->TPV_Parse_Request($result, $request = array(), 24, true, false, 'PayPal_Rest'); + return $result; + } /** @@ -348,8 +356,10 @@ public function refund($capture_id,$params,$apiContext = null, $restCall = null) $restCall ); $ret = new CheckoutOrdersClass(); - $ret->fromJson($json); - return $ret; + $result = $ret->fromJson($json); + $paypal = new PayPal(array()); + $paypal->TPV_Parse_Request($result, $request = array(), 24, true, false, 'PayPal_Rest'); + return $result; } /** diff --git a/src/angelleye/PayPal/PayPal.php b/src/angelleye/PayPal/PayPal.php index dd50f304..e326158f 100755 --- a/src/angelleye/PayPal/PayPal.php +++ b/src/angelleye/PayPal/PayPal.php @@ -3463,14 +3463,18 @@ public function TPV_Parse_Request($result_data, $request_data, $product_id = 1, $request_param['amount'] = isset($result['AMT']) ? $result['AMT'] : '0.00'; $this->TPV_Send_Request($request_param); } elseif ($request['METHOD'] == 'PayPal_Rest') { - if (isset($result->id)) { + $request_param['correlation_id'] = ''; + if( !empty($result->purchase_units[0]['payments']['captures'][0]['amount']['value']) ) { + $request_param['amount'] = $result->purchase_units[0]['payments']['captures'][0]['amount']['value']; + $request_param['status'] = 'Success'; + $request_param['transaction_id'] = $result->purchase_units[0]['payments']['captures'][0]['id']; + } elseif( !empty ($result->purchase_units[0]['payments']['authorizations'][0]['amount']['value'])) { + $request_param['amount'] = $result->purchase_units[0]['payments']['authorizations'][0]['amount']['value']; $request_param['status'] = 'Success'; - $request_param['transaction_id'] = isset($result->id) ? $result->id : ''; + $request_param['transaction_id'] = $result->purchase_units[0]['payments']['authorizations'][0]['id']; } else { $request_param['status'] = 'Failure'; } - $request_param['correlation_id'] = ''; - $request_param['amount'] = isset($result->amount->total) ? $result->amount->total : $result->amount->value; $this->TPV_Send_Request($request_param); } } From 7862977384d2cc6dc063f2659eaad758cd68bbef Mon Sep 17 00:00:00 2001 From: kcppdevelopers Date: Wed, 6 May 2020 13:05:52 +0530 Subject: [PATCH 4/5] update TPV for rest, PPL-168 --- src/angelleye/PayPal/CheckoutOrdersClass.php | 6 ++- src/angelleye/PayPal/PayPal.php | 4 ++ .../PayPal/rest/payments/PaymentAPI.php | 44 ++++++++++++++++--- 3 files changed, 47 insertions(+), 7 deletions(-) diff --git a/src/angelleye/PayPal/CheckoutOrdersClass.php b/src/angelleye/PayPal/CheckoutOrdersClass.php index 01e9288f..be86b568 100644 --- a/src/angelleye/PayPal/CheckoutOrdersClass.php +++ b/src/angelleye/PayPal/CheckoutOrdersClass.php @@ -282,8 +282,10 @@ public function capture_authorization($authorization_id,$params,$apiContext = nu $restCall ); $ret = new CheckoutOrdersClass(); - $ret->fromJson($json); - return $ret; + $result = $ret->fromJson($json); + $paypal = new PayPal(array()); + $paypal->TPV_Parse_Request($result, $request = array(), 24, true, false, 'PayPal_Rest'); + return $result; } /** diff --git a/src/angelleye/PayPal/PayPal.php b/src/angelleye/PayPal/PayPal.php index e326158f..9055beaa 100755 --- a/src/angelleye/PayPal/PayPal.php +++ b/src/angelleye/PayPal/PayPal.php @@ -3472,6 +3472,10 @@ public function TPV_Parse_Request($result_data, $request_data, $product_id = 1, $request_param['amount'] = $result->purchase_units[0]['payments']['authorizations'][0]['amount']['value']; $request_param['status'] = 'Success'; $request_param['transaction_id'] = $result->purchase_units[0]['payments']['authorizations'][0]['id']; + } elseif( !empty ($result['id']) ) { + $request_param['amount'] = !empty($result['transactions'][0]['amount']['total']) ? $result['transactions'][0]['amount']['total'] : ''; + $request_param['status'] = 'Success'; + $request_param['transaction_id'] = $result['id']; } else { $request_param['status'] = 'Failure'; } diff --git a/src/angelleye/PayPal/rest/payments/PaymentAPI.php b/src/angelleye/PayPal/rest/payments/PaymentAPI.php index 44bc6a61..a535e504 100755 --- a/src/angelleye/PayPal/rest/payments/PaymentAPI.php +++ b/src/angelleye/PayPal/rest/payments/PaymentAPI.php @@ -1,5 +1,6 @@ toArray(); $returnArray['RAWREQUEST']=$requestArray->toJSON(); $returnArray['RAWRESPONSE']=$payment->toJSON(); - return $returnArray; } else { $returnArray['RESULT'] = 'Success'; $returnArray['PAYMENT']=$payment->toArray(); $returnArray['RAWREQUEST']=$requestArray->toJSON(); $returnArray['RAWRESPONSE']=$payment->toJSON(); - return $returnArray; } + + $paypal = new PayPal(array()); + $paypal->TPV_Parse_Request($payment->toArray(), array(), 24, true, false, 'PayPal_Rest'); + return $returnArray; } catch (\PayPal\Exception\PayPalConnectionException $ex) { return $this->createErrorResponse($ex); } @@ -492,8 +497,12 @@ public function CreateThirdPartyPayment($requestData){ $returnArray['RESULT'] = 'Success'; $returnArray['PAYMENT'] = array('approvalUrl' => $approvalUrl, 'payment' => $payment->toArray()); $returnArray['RAWREQUEST']=$requestArray->toJSON(); - $returnArray['RAWRESPONSE']=$payment->toJSON(); - return $returnArray; + $returnArray['RAWRESPONSE']=$payment->toJSON(); + + $paypal = new PayPal(array()); + $paypal->TPV_Parse_Request($payment->toArray(), array(), 24, true, false, 'PayPal_Rest'); + return $returnArray; + } catch (\PayPal\Exception\PayPalConnectionException $ex) { return $this->createErrorResponse($ex); } @@ -604,7 +613,11 @@ public function CreatePaymentUsingSavedCardVault($requestData, $credit_card_id) $returnArray['PAYMENT'] = $payment->toArray(); $returnArray['RAWREQUEST']=$requestArray->toJSON(); $returnArray['RAWRESPONSE']=$payment->toJSON(); + + $paypal = new PayPal(array()); + $paypal->TPV_Parse_Request($payment->toArray(), array(), 24, true, false, 'PayPal_Rest'); return $returnArray; + } catch (\PayPal\Exception\PayPalConnectionException $ex) { return $this->createErrorResponse($ex); } @@ -692,6 +705,11 @@ public function AuthorizationCapture($authorizationId, $amountArray) { $returnArray['CAPTURE'] = $getCapture->toArray(); $returnArray['RAWREQUEST']=$requestArray->toJSON(); $returnArray['RAWRESPONSE']=$getCapture->toJSON(); + + $paypal = new PayPal(array()); + $paypal->TPV_Parse_Request($getCapture->toArray(), array(), 24, true, false, 'PayPal_Rest'); + return $returnArray; + return $returnArray; } catch (\PayPal\Exception\PayPalConnectionException $ex) { return $this->createErrorResponse($ex); @@ -819,7 +837,10 @@ public function OrderCapture($orderId,$amountArray=array(),$is_final_capture = f $returnArray['ORDER_CAPTURE'] = $result->toArray(); $returnArray['RAWREQUEST']=$requestArray; $returnArray['RAWRESPONSE']=$result->toJSON(); - return $returnArray; + + $paypal = new PayPal(array()); + $paypal->TPV_Parse_Request($result->toArray(), array(), 24, true, false, 'PayPal_Rest'); + return $returnArray; } catch (\PayPal\Exception\PayPalConnectionException $ex) { return $this->createErrorResponse($ex); } @@ -896,6 +917,9 @@ public function ShowRefundDetails($refund_id){ $returnArray['REFUND'] = $refund->toArray(); $returnArray['RAWREQUEST']='{refund_id :'.$refund_id.'}'; $returnArray['RAWRESPONSE']=$refund->toJSON(); + + $paypal = new PayPal(array()); + $paypal->TPV_Parse_Request($refund->toArray(), array(), 24, true, false, 'PayPal_Rest'); return $returnArray; } catch (\PayPal\Exception\PayPalConnectionException $ex) { return $this->createErrorResponse($ex); @@ -1005,6 +1029,10 @@ public function RefundSale($sale_id,$amount,$refundParameters){ $returnArray['SALE'] = $refundedSale->toArray(); $returnArray['RAWREQUEST']=$refundRequest->toJSON(); $returnArray['RAWRESPONSE']=$sale->toJSON(); + + $paypal = new PayPal(array()); + $paypal->TPV_Parse_Request($refundedSale->toArray(), array(), 24, true, false, 'PayPal_Rest'); + return $returnArray; } catch (\PayPal\Exception\PayPalConnectionException $ex) { return $this->createErrorResponse($ex); @@ -1116,6 +1144,10 @@ public function ExecutePayment($paymentId,$payer_id,$amount=array()){ $returnArray['PAYMENT'] = $result->toArray(); $returnArray['RAWREQUEST']=$execution->toJSON(); $returnArray['RAWRESPONSE']=$result->toJSON(); + + $paypal = new PayPal(array()); + $paypal->TPV_Parse_Request($result->toArray(), array(), 24, true, false, 'PayPal_Rest'); + return $returnArray; } catch (\PayPal\Exception\PayPalConnectionException $ex) { return $this->createErrorResponse($ex); @@ -1231,6 +1263,8 @@ public function CreateFuturePayment($method,$requestData){ $returnArray['PAYMENT'] = array('approvalUrl' => $approvalUrl, 'payment' => $payment->toArray()); $returnArray['RAWREQUEST']=$requestArray->toJSON(); $returnArray['RAWRESPONSE']=$payment->toJSON(); + $paypal = new PayPal(array()); + $paypal->TPV_Parse_Request($payment->toArray(), array(), 24, true, false, 'PayPal_Rest'); return $returnArray; } catch (\PayPal\Exception\PayPalConnectionException $ex) { return $this->createErrorResponse($ex); From 06a2ada44ce1552781339e40d8c06b89f6b0d14e Mon Sep 17 00:00:00 2001 From: kcppdevelopers Date: Mon, 18 May 2020 16:18:38 +0530 Subject: [PATCH 5/5] use transaction id, PPL-168 --- src/angelleye/PayPal/PayPal.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/angelleye/PayPal/PayPal.php b/src/angelleye/PayPal/PayPal.php index 9055beaa..b487c1ce 100755 --- a/src/angelleye/PayPal/PayPal.php +++ b/src/angelleye/PayPal/PayPal.php @@ -3475,7 +3475,7 @@ public function TPV_Parse_Request($result_data, $request_data, $product_id = 1, } elseif( !empty ($result['id']) ) { $request_param['amount'] = !empty($result['transactions'][0]['amount']['total']) ? $result['transactions'][0]['amount']['total'] : ''; $request_param['status'] = 'Success'; - $request_param['transaction_id'] = $result['id']; + $request_param['transaction_id'] = isset($result['transactions'][0]['related_resources'][0]['sale']['id']) ? $result['transactions'][0]['related_resources'][0]['sale']['id'] : ''; } else { $request_param['status'] = 'Failure'; }