Fixed:Displaying a warning about a deprecated function when trying to view PayPal transaction details.

This commit is contained in:
Amit sharma
2025-12-16 17:14:40 +05:30
committed by azhar bhat
parent 812b6eb731
commit 6840fcb7e8
7 changed files with 33 additions and 33 deletions

View File

@@ -65,7 +65,7 @@ class WkPaypalCommerceHelper
if ($err) {
throw new PrestaShopException(sprintf('cURL Error #: %s', $err));
} else {
$accessToken = Tools::jsonDecode($response, true);
$accessToken = json_decode($response, true);
if (isset($accessToken['error']) && !empty($accessToken['error'])) {
$apiResp['success'] = false;
$apiResp['message'] = $accessToken['error_description'];
@@ -83,12 +83,12 @@ class WkPaypalCommerceHelper
$temp = array(
"alg" => "none"
);
$returnData = base64_encode(Tools::jsonEncode($temp)) . '.';
$returnData = base64_encode(json_encode($temp)) . '.';
$temp = array(
"iss" => trim(Configuration::get('WK_PAYPAL_COMMERCE_CLIENT_ID')),
"payer_id" => Configuration::get('WK_PAYPAL_COMMERCE_MERCHANT_ID')
);
$returnData .= base64_encode(Tools::jsonEncode($temp)) . '.';
$returnData .= base64_encode(json_encode($temp)) . '.';
return $returnData;
}
@@ -145,7 +145,7 @@ class WkPaypalCommerceHelper
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => Tools::jsonEncode($postData),
CURLOPT_POSTFIELDS => json_encode($postData),
CURLOPT_HTTPHEADER => array(
"PayPal-Partner-Attribution-Id: " . PayPalHelper::WK_PAYPAL_COMMERCE_ATTRIBUTION_ID,
"authorization: Bearer " . $token,
@@ -161,7 +161,7 @@ class WkPaypalCommerceHelper
if ($err) {
throw new PrestaShopException(sprintf('cURL Error #: %s', $err));
} else {
$webhookResponse = Tools::jsonDecode($response, true);
$webhookResponse = json_decode($response, true);
if (isset($webhookResponse['id']) && !empty($webhookResponse['id'])) {
$apiResp['success'] = true;
$apiResp['webhook_id'] = $webhookResponse['id'];
@@ -243,7 +243,7 @@ class WkPaypalCommerceHelper
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => Tools::jsonEncode($postData),
CURLOPT_POSTFIELDS => json_encode($postData),
CURLOPT_HTTPHEADER => array(
"PayPal-Partner-Attribution-Id: " . PayPalHelper::WK_PAYPAL_COMMERCE_ATTRIBUTION_ID,
"authorization: Bearer " . $accessToken['access_token'],
@@ -260,7 +260,7 @@ class WkPaypalCommerceHelper
if ($err) {
throw new PrestaShopException(sprintf('cURL Error #: %s', $err));
} else {
$apiResp = Tools::jsonDecode($response, true);
$apiResp = json_decode($response, true);
}
}
return $apiResp;

View File

@@ -52,7 +52,7 @@ class WkPaypalCommerceWebhook
if (isset($eventData['resource']['note_to_payer'])) {
$refundObj->refund_reason = $eventData['resource']['note_to_payer'];
}
$refundObj->response = Tools::jsonEncode($eventData);
$refundObj->response = json_encode($eventData);
$refundObj->refund_status = $eventData['resource']['status'];
$refundObj->save();
}
@@ -188,7 +188,7 @@ class WkPaypalCommerceWebhook
return Db::getInstance()->execute(
'UPDATE `'._DB_PREFIX_.'wk_paypal_commerce_order`
SET `pp_payment_status` = "'.pSQL($payment_status).'",
`response` = "'.pSQL(Tools::jsonEncode($orderData)).'"
`response` = "'.pSQL(json_encode($orderData)).'"
WHERE `pp_transaction_id` = "'.pSQL($transaction_id).'"
'
);

View File

@@ -144,7 +144,7 @@ class AdminPaypalCommerceTransactionController extends ModuleAdminController
$totalRefunded = WkPaypalCommerceRefund::getTotalRefundedAmount((int)$idTrans, false);
$remainingRefund = (float)($transactionData['pp_paid_total'] - $totalRefunded);
$response = Tools::jsonDecode($transactionData['response'], true);
$response = json_decode($transactionData['response'], true);
// Buyer making a payment in a different currency (ex: EUR) which is different from the default currency of merchant (Ex: USD), In all those cross currency cases, After Capture, transaction will fall into Pending state and will require merchant to manually go to his PayPal account and accept the payment.
$objPPOrder = new WKPayPalCommerceOrder();
@@ -231,7 +231,7 @@ class AdminPaypalCommerceTransactionController extends ModuleAdminController
WkPaypalCommerceHelper::logMsg('refund', 'PayPal Transaction ID: '. $transactionData['pp_transaction_id']);
WkPaypalCommerceHelper::logMsg('refund', 'PayPal Order ID: '. $transactionData['pp_order_id']);
WkPaypalCommerceHelper::logMsg('refund', 'Refund request data: ');
WkPaypalCommerceHelper::logMsg('refund', Tools::jsonEncode($postData));
WkPaypalCommerceHelper::logMsg('refund', json_encode($postData));
$objPPCommerce = new PayPalCommerce();
$refundData = $objPPCommerce->orders->refund($postData);
@@ -243,7 +243,7 @@ class AdminPaypalCommerceTransactionController extends ModuleAdminController
WkPaypalCommerceHelper::logMsg('refund', 'Refund success: ', true);
WkPaypalCommerceHelper::logMsg('refund', 'PayPal Refund Id: '. $refundID);
WkPaypalCommerceHelper::logMsg('refund', 'Refund reponse data: ');
WkPaypalCommerceHelper::logMsg('refund', Tools::jsonEncode($refundData));
WkPaypalCommerceHelper::logMsg('refund', json_encode($refundData));
WkPaypalCommerceHelper::logMsg('refund', '----------------------- ', true);
$refundObj = new WkPaypalCommerceRefund();
@@ -253,7 +253,7 @@ class AdminPaypalCommerceTransactionController extends ModuleAdminController
$refundObj->refund_type = (int)$refundType;
$refundObj->currency_code = $transactionData['pp_paid_currency'];
$refundObj->refund_reason = $refundReason;
$refundObj->response = Tools::jsonEncode($refundData);
$refundObj->response = json_encode($refundData);
$refundObj->refund_status = $refundData['data']['status'];
if ($refundObj->save()) {
$urlString = '&viewwk_paypal_commerce_order=&id_paypal_commerce_order=' . (int)Tools::getValue('id_paypal_commerce_order');
@@ -263,7 +263,7 @@ class AdminPaypalCommerceTransactionController extends ModuleAdminController
} else {
WkPaypalCommerceHelper::logMsg('refund', 'Refund failed: ', true);
WkPaypalCommerceHelper::logMsg('refund', 'Refund reponse data: ');
WkPaypalCommerceHelper::logMsg('refund', Tools::jsonEncode($refundData));
WkPaypalCommerceHelper::logMsg('refund', json_encode($refundData));
WkPaypalCommerceHelper::logMsg('refund', '----------------------- ', true);
$this->errors[] = $refundData['data']['message'];
}

View File

@@ -44,25 +44,25 @@ class QloPaypalCommerceCallbackModuleFrontController extends ModuleFrontControll
}
if ($json) {
$payload['webhook_event'] = Tools::jsonDecode($json, true);
$payload['webhook_event'] = json_decode($json, true);
}
if ($payload) {
WkPaypalCommerceHelper::logMsg('webhook', 'Webhook initiated...', true);
WkPaypalCommerceHelper::logMsg('webhook', 'Environment: '. Configuration::get('WK_PAYPAL_COMMERCE_PAYMENT_MODE'));
WkPaypalCommerceHelper::logMsg('webhook', 'Webhook payload data: ');
WkPaypalCommerceHelper::logMsg('webhook', Tools::jsonEncode($payload));
WkPaypalCommerceHelper::logMsg('webhook', json_encode($payload));
WkPaypalCommerceHelper::logMsg('webhook', 'Validating webhook signature...');
$validateSig = WkPaypalCommerceHelper::validateWebhookSig($payload);
WkPaypalCommerceHelper::logMsg('webhook', 'Webhook respose data: ');
WkPaypalCommerceHelper::logMsg('webhook', Tools::jsonEncode($validateSig));
WkPaypalCommerceHelper::logMsg('webhook', json_encode($validateSig));
if (isset($validateSig['verification_status'])
&& $validateSig['verification_status'] == 'SUCCESS'
) {
$eventData = Tools::jsonDecode($json, true);
$eventData = json_decode($json, true);
$objWebhook = new WkPaypalCommerceWebhook();
switch ($eventData['event_type']) {
case 'CHECKOUT.ORDER.APPROVED':

View File

@@ -69,7 +69,7 @@ class QloPaypalCommercePaymentModuleFrontController extends ModuleFrontControlle
switch ($action) {
case 1:
$json = Tools::file_get_contents('php://input');
$orderDetails = Tools::jsonDecode($json, true);
$orderDetails = json_decode($json, true);
$cart = $this->context->cart;
@@ -86,23 +86,23 @@ class QloPaypalCommercePaymentModuleFrontController extends ModuleFrontControlle
// create order
$orderDetails['original'] = $this->getOrderDetails();
WkPaypalCommerceHelper::logMsg('payment', Tools::jsonEncode($orderDetails));
WkPaypalCommerceHelper::logMsg('payment', json_encode($orderDetails));
$ppOrderData = $ppCommerce->orders->create($orderDetails);
WkPaypalCommerceHelper::logMsg('payment', 'Payment response data: ', true);
WkPaypalCommerceHelper::logMsg('payment', Tools::jsonEncode($ppOrderData));
WkPaypalCommerceHelper::logMsg('payment', json_encode($ppOrderData));
die(Tools::jsonEncode($ppOrderData));
die(json_encode($ppOrderData));
case 2:
$json = Tools::file_get_contents('php://input');
$orderData = Tools::jsonDecode($json, true);
$orderData = json_decode($json, true);
if ($orderData['orderID'] && $orderData['getOrderData']) {
$ppCommerce = new PayPalCommerce();
$returnData = $ppCommerce->orders->capture($orderData['orderID']);
header('Content-Type: application/json');
echo Tools::jsonEncode($returnData['data']);
echo json_encode($returnData['data']);
die;
} elseif (Tools::getIsset('order_id')) {
$orderID = Tools::getValue('order_id');
@@ -116,7 +116,7 @@ class QloPaypalCommercePaymentModuleFrontController extends ModuleFrontControlle
WkPaypalCommerceHelper::logMsg('payment', 'Customer ID: '. $cart->id_customer);
WkPaypalCommerceHelper::logMsg('payment', 'Currency ID: '. $cart->id_currency);
WkPaypalCommerceHelper::logMsg('payment', 'Cart Total: '. $cart->getOrderTotal(true, Cart::BOTH));
WkPaypalCommerceHelper::logMsg('payment', Tools::jsonEncode($returnData));
WkPaypalCommerceHelper::logMsg('payment', json_encode($returnData));
if (isset($returnData['data']['id']) && !empty($returnData['data']['id'])) {
// Payment success
@@ -210,7 +210,7 @@ class QloPaypalCommercePaymentModuleFrontController extends ModuleFrontControlle
break;
case 3:
WkPaypalCommerceHelper::logMsg('payment', 'Payment cancelled by customer...', true);
WkPaypalCommerceHelper::logMsg('payment', Tools::jsonEncode(Tools::getAllValues()));
WkPaypalCommerceHelper::logMsg('payment', json_encode(Tools::getAllValues()));
WkPaypalCommerceHelper::logMsg('payment', '--------------', true);
Tools::redirect($this->context->link->getPageLink('order-opc', true, null).'?pp_cancel=1');
@@ -260,7 +260,7 @@ class QloPaypalCommercePaymentModuleFrontController extends ModuleFrontControlle
$orderObj->pp_order_id = $orderData['data']['id'];
$orderObj->pp_transaction_id = $transaction_id;
$orderObj->pp_payment_status = $payment_status;
$orderObj->response = Tools::jsonEncode($orderData);
$orderObj->response = json_encode($orderData);
$orderObj->order_date = date('Y-m-d H:i:s');
$orderObj->save();
}

View File

@@ -44,25 +44,25 @@ class QloPaypalCommerceWebhookModuleFrontController extends ModuleFrontControlle
}
if ($json) {
$payload['webhook_event'] = Tools::jsonDecode($json, true);
$payload['webhook_event'] = json_decode($json, true);
}
if ($payload) {
WkPaypalCommerceHelper::logMsg('webhook', 'Webhook initiated...', true);
WkPaypalCommerceHelper::logMsg('webhook', 'Environment: '. Configuration::get('WK_PAYPAL_COMMERCE_PAYMENT_MODE'));
WkPaypalCommerceHelper::logMsg('webhook', 'Webhook payload data: ');
WkPaypalCommerceHelper::logMsg('webhook', Tools::jsonEncode($payload));
WkPaypalCommerceHelper::logMsg('webhook', json_encode($payload));
WkPaypalCommerceHelper::logMsg('webhook', 'Validating webhook signature...');
$validateSig = WkPaypalCommerceHelper::validateWebhookSig($payload);
WkPaypalCommerceHelper::logMsg('webhook', 'Webhook respose data: ');
WkPaypalCommerceHelper::logMsg('webhook', Tools::jsonEncode($validateSig));
WkPaypalCommerceHelper::logMsg('webhook', json_encode($validateSig));
if (isset($validateSig['verification_status'])
&& $validateSig['verification_status'] == 'SUCCESS'
) {
$eventData = Tools::jsonDecode($json, true);
$eventData = json_decode($json, true);
$objWebhook = new WkPaypalCommerceWebhook();
switch ($eventData['event_type']) {
case 'CHECKOUT.ORDER.APPROVED':

View File

@@ -70,7 +70,7 @@ class HttpHelper {
$headerSize = curl_getinfo($this->_curl, CURLINFO_HEADER_SIZE);
$body = substr($result, $headerSize);
return Tools::jsonDecode($body, true);
return json_decode($body, true);
}
public function resetHelper() {
@@ -85,7 +85,7 @@ class HttpHelper {
public function setBody($postData) {
if(is_array($postData)) {
$postData = Tools::jsonEncode($postData);
$postData = json_encode($postData);
}
curl_setopt($this->_curl, CURLOPT_POSTFIELDS, $postData);
curl_setopt($this->_curl, CURLOPT_POST, true);