Merge branch 'develop' into gli-2908
This commit is contained in:
@@ -730,50 +730,56 @@ class HotelBranchInformation extends ObjectModel
|
||||
$catName,
|
||||
$parent_category
|
||||
)) {
|
||||
if (is_array($link_rewrite)) {
|
||||
$objCategory = new Category($categoryExists['id_category']);
|
||||
|
||||
foreach (Language::getLanguages() as $lang) {
|
||||
$objCategory->link_rewrite[$lang['id_lang']] = $link_rewrite[$lang['id_lang']];
|
||||
}
|
||||
|
||||
$objCategory->save();
|
||||
}
|
||||
return $categoryExists['id_category'];
|
||||
} else {
|
||||
$category = new Category();
|
||||
foreach (Language::getLanguages(true) as $lang) {
|
||||
if (is_array($name) && isset($name[$lang['id_lang']])) {
|
||||
$catName = $name[$lang['id_lang']];
|
||||
} else {
|
||||
$catName = $name;
|
||||
}
|
||||
$category->name[$lang['id_lang']] = $catName;
|
||||
$category->description[$lang['id_lang']] = $this->moduleInstance->l('Hotel Branch Category', 'HotelBranchInformation');
|
||||
|
||||
$idHotel = isset($params['id_hotel']) ? $params['id_hotel'] : false;
|
||||
$isHotel = isset($params['is_hotel']) ? $params['is_hotel'] : false;
|
||||
$existsCatId = $categoryExists['id_category'];
|
||||
$belongsToSameHotel = ($idHotel == HotelBranchInformation::getHotelIdByIdCategory($existsCatId));
|
||||
if (!$isHotel || $belongsToSameHotel) {
|
||||
if (is_array($link_rewrite)) {
|
||||
$category->link_rewrite[$lang['id_lang']] = $link_rewrite[$lang['id_lang']];
|
||||
} else {
|
||||
$category->link_rewrite[$lang['id_lang']] = Tools::link_rewrite($catName);
|
||||
$objCategory = new Category($existsCatId);
|
||||
|
||||
foreach (Language::getLanguages() as $lang) {
|
||||
$objCategory->link_rewrite[$lang['id_lang']] = $link_rewrite[$lang['id_lang']];
|
||||
}
|
||||
|
||||
$objCategory->save();
|
||||
}
|
||||
return $existsCatId;
|
||||
}
|
||||
|
||||
if ($meta_title) {
|
||||
$category->meta_title = $meta_title;
|
||||
}
|
||||
if ($meta_description) {
|
||||
$category->meta_description = $meta_description;
|
||||
}
|
||||
if ($meta_keywords) {
|
||||
$category->meta_keywords = $meta_keywords;
|
||||
}
|
||||
|
||||
$category->id_parent = $parent_category;
|
||||
$category->groupBox = $group_ids;
|
||||
$category->add();
|
||||
|
||||
return $category->id;
|
||||
}
|
||||
|
||||
$category = new Category();
|
||||
foreach (Language::getLanguages(true) as $lang) {
|
||||
if (is_array($name) && isset($name[$lang['id_lang']])) {
|
||||
$catName = $name[$lang['id_lang']];
|
||||
} else {
|
||||
$catName = $name;
|
||||
}
|
||||
$category->name[$lang['id_lang']] = $catName;
|
||||
$category->description[$lang['id_lang']] = $this->moduleInstance->l('Hotel Branch Category', 'HotelBranchInformation');
|
||||
|
||||
if (is_array($link_rewrite)) {
|
||||
$category->link_rewrite[$lang['id_lang']] = $link_rewrite[$lang['id_lang']];
|
||||
} else {
|
||||
$category->link_rewrite[$lang['id_lang']] = Tools::link_rewrite($catName);
|
||||
}
|
||||
}
|
||||
|
||||
if ($meta_title) {
|
||||
$category->meta_title = $meta_title;
|
||||
}
|
||||
if ($meta_description) {
|
||||
$category->meta_description = $meta_description;
|
||||
}
|
||||
if ($meta_keywords) {
|
||||
$category->meta_keywords = $meta_keywords;
|
||||
}
|
||||
|
||||
$category->id_parent = $parent_category;
|
||||
$category->groupBox = $group_ids;
|
||||
$category->add();
|
||||
|
||||
return $category->id;
|
||||
}
|
||||
|
||||
//Overrided ObjectModet::delete() to delete all the dependencies of the hotel
|
||||
|
||||
@@ -907,6 +907,7 @@ class AdminAddHotelController extends ModuleAdminController
|
||||
public function ajaxProcessChangeCoverImage()
|
||||
{
|
||||
$idImage = Tools::getValue('id_image');
|
||||
$response = array('status' => false);
|
||||
if ($idImage) {
|
||||
$idHotel = Tools::getValue('id_hotel');
|
||||
if ($coverImg = HotelImage::getCover($idHotel)) {
|
||||
@@ -918,17 +919,15 @@ class AdminAddHotelController extends ModuleAdminController
|
||||
$objHtlImage = new HotelImage((int) $idImage);
|
||||
$objHtlImage->cover = 1;
|
||||
if ($objHtlImage->update()) {
|
||||
die(true);
|
||||
} else {
|
||||
die(false);
|
||||
$response['status'] = true;
|
||||
}
|
||||
} else {
|
||||
die(false);
|
||||
}
|
||||
$this->ajaxDie(json_encode($response));
|
||||
}
|
||||
|
||||
public function ajaxProcessDeleteHotelImage()
|
||||
{
|
||||
$response = array('status' => false);
|
||||
if ($idImage = Tools::getValue('id_image')) {
|
||||
if ($idHotel = Tools::getValue('id_hotel')) {
|
||||
if (Validate::isLoadedObject($objHtlImage = new HotelImage((int) $idImage))) {
|
||||
@@ -941,12 +940,12 @@ class AdminAddHotelController extends ModuleAdminController
|
||||
$objHtlImage->save();
|
||||
}
|
||||
}
|
||||
die(true);
|
||||
$response['status'] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
die(false);
|
||||
$this->ajaxDie(json_encode($response));
|
||||
}
|
||||
|
||||
public function ajaxProcessUpdateSlidesPosition()
|
||||
|
||||
@@ -1024,6 +1024,8 @@ class AdminHotelRoomsBookingController extends ModuleAdminController
|
||||
'no_realloc_rm_type_avail_txt' => $this->l('No room type available for reallocation.', null, true),
|
||||
'no_swap_rm_avail_txt' => $this->l('No room available for swap.', null, true),
|
||||
'select_room_txt' => $this->l('Select room', null, true),
|
||||
'added_room_success_txt' => $this->l('Room added to cart successfully', null, true),
|
||||
'removed_room_success_txt' => $this->l('Room removed from cart successfully', null, true),
|
||||
);
|
||||
if (Configuration::get('PS_BACKOFFICE_SEARCH_TYPE') == HotelBookingDetail::SEARCH_TYPE_OWS ) {
|
||||
$jsVars['is_occupancy_wise_search'] = true;
|
||||
|
||||
@@ -293,32 +293,6 @@ $(document).ready(function() {
|
||||
}
|
||||
});
|
||||
|
||||
// delete hotel image
|
||||
$('.deleteHtlImage').on('click', function(){
|
||||
var imgId = $(this).attr('id_htl_img');
|
||||
var $this = $(this);
|
||||
$.ajax({
|
||||
url: statebycountryurl,
|
||||
data: {
|
||||
id_htl_img: imgId,
|
||||
ajax: true,
|
||||
action: 'deleteHotelImage',
|
||||
},
|
||||
method: 'POST',
|
||||
success: function(data) {
|
||||
if (data == 1) {
|
||||
$this.closest('.img-container-div').remove();
|
||||
showSuccessMessage(htlImgDeleteSuccessMsg);
|
||||
} else {
|
||||
showErrorMessage(htlImgDeleteErrMsg);
|
||||
}
|
||||
},
|
||||
error: function(XMLHttpRequest, textStatus, errorThrown) {
|
||||
alert(textStatus);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$('#hotel_country').on('change', function() {
|
||||
$('#hotel_state').empty();
|
||||
$.ajax({
|
||||
|
||||
@@ -386,6 +386,7 @@ $(document).ready(function() {
|
||||
if (result.success) {
|
||||
$(".cart_booking_btn").removeAttr('disabled');
|
||||
$current_btn.removeAttr('disabled');
|
||||
showSuccessMessage(added_room_success_txt);
|
||||
}
|
||||
|
||||
btn.removeClass('btn-primary').removeClass('avai_add_cart').addClass('btn-danger').addClass('avai_delete_cart_data').html(remove);
|
||||
@@ -512,6 +513,7 @@ $(document).ready(function() {
|
||||
if (!result.success) {
|
||||
$(".cart_booking_btn").attr('disabled', 'true');
|
||||
} else {
|
||||
showSuccessMessage(removed_room_success_txt);
|
||||
$("#htl_rooms_list").empty().append(result.data.room_tpl);
|
||||
refreshCartData();
|
||||
refreshStatsData();
|
||||
@@ -571,7 +573,7 @@ $(document).ready(function() {
|
||||
if (!(result.success)) {
|
||||
$(".cart_booking_btn").attr('disabled', 'true');
|
||||
}
|
||||
|
||||
showSuccessMessage(removed_room_success_txt);
|
||||
$(".cart_tbody tr td button[data-id-cart-book-data='" + id_cart_book_data + "']").parent().parent().remove();
|
||||
refreshCartData();
|
||||
refreshStatsData();
|
||||
|
||||
@@ -109,6 +109,7 @@ $(document).ready(function () {
|
||||
$.ajax({
|
||||
type:'POST',
|
||||
url: adminHotelCtrlUrl,
|
||||
dataType: 'json',
|
||||
data: {
|
||||
ajax: true,
|
||||
action: 'changeCoverImage',
|
||||
@@ -116,7 +117,7 @@ $(document).ready(function () {
|
||||
id_image: idImage,
|
||||
},
|
||||
success: function(result) {
|
||||
if (result) {
|
||||
if (result.status) {
|
||||
// remover cover image identifier from old cover image
|
||||
var oldCoverImageTr = $("#hotel-image-table tbody tr.cover-image-tr");
|
||||
oldCoverImageTr.removeClass("cover-image-tr").find("td.cover-image-td").removeClass("cover-image-td").find("a.changer-cover-image").removeClass("text-success").addClass("text-danger").attr("data-is-cover", "0").find("i.icon-check").removeClass("icon-check").addClass("icon-times");
|
||||
@@ -149,6 +150,7 @@ $(document).ready(function () {
|
||||
$.ajax({
|
||||
type:'POST',
|
||||
url: adminHotelCtrlUrl,
|
||||
dataType: 'json',
|
||||
data: {
|
||||
ajax: true,
|
||||
action: 'deleteHotelImage',
|
||||
@@ -156,7 +158,7 @@ $(document).ready(function () {
|
||||
id_image: idImage,
|
||||
},
|
||||
success: function(result) {
|
||||
if (result) {
|
||||
if (result.status) {
|
||||
if (parseInt(isCover)) {
|
||||
location.reload();
|
||||
} else {
|
||||
|
||||
@@ -261,7 +261,7 @@
|
||||
{/if}
|
||||
<td>{HotelRoomInformation::getRoomStatusTitle($unavail_dtl_v['id_status'])|escape:'htmlall':'UTF-8'}</td>
|
||||
<td>
|
||||
{if $unavail_dtl_v['date_from'] && $unavail_dtl_v['date_to']}
|
||||
{if isset($unavail_dtl_v['date_from']) && isset($unavail_dtl_v['date_to'])}
|
||||
{dateFormat date=$unavail_dtl_v['date_from']} - {dateFormat date=$unavail_dtl_v['date_to']}
|
||||
{else}
|
||||
--
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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).'"
|
||||
'
|
||||
);
|
||||
|
||||
@@ -137,39 +137,46 @@ class AdminPaypalCommerceTransactionController extends ModuleAdminController
|
||||
$smartyVars = array();
|
||||
$refundData = array();
|
||||
$totalRefunded = 0;
|
||||
$transactionData = WKPayPalCommerceOrder::getTransactionDetails((int)$idTrans);
|
||||
$orderCurrency = new Currency((int)$transactionData['id_currency']);
|
||||
$refundData = WkPaypalCommerceRefund::getRefundListByTransID((int)$idTrans);
|
||||
$totalRefundedFormatted = WkPaypalCommerceRefund::getTotalRefundedAmount((int)$idTrans, true);
|
||||
if ($transactionData = WKPayPalCommerceOrder::getTransactionDetails((int)$idTrans)) {
|
||||
$orderCurrency = new Currency((int)$transactionData['id_currency']);
|
||||
$refundData = WkPaypalCommerceRefund::getRefundListByTransID((int)$idTrans);
|
||||
$totalRefundedFormatted = WkPaypalCommerceRefund::getTotalRefundedAmount((int)$idTrans, true);
|
||||
|
||||
$totalRefunded = WkPaypalCommerceRefund::getTotalRefundedAmount((int)$idTrans, false);
|
||||
$remainingRefund = (float)($transactionData['pp_paid_total'] - $totalRefunded);
|
||||
$response = Tools::jsonDecode($transactionData['response'], true);
|
||||
$totalRefunded = WkPaypalCommerceRefund::getTotalRefundedAmount((int)$idTrans, false);
|
||||
$remainingRefund = (float)($transactionData['pp_paid_total'] - $totalRefunded);
|
||||
$response = Tools::jsonDecode($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();
|
||||
if (isset($response['data']['purchase_units'][0]['payments']['captures'][0]['status_details']['reason'])
|
||||
&& ($transactionData['pp_payment_status'] == 'PENDING' || $transactionData['pp_payment_status'] == 'DENIED')
|
||||
&& isset($response['data']['purchase_units'][0]['payments']['captures'][0]['status_details']['reason'])
|
||||
) {
|
||||
if (isset($objPPOrder->ppStatusDetail[$response['data']['purchase_units'][0]['payments']['captures'][0]['status_details']['reason']])) {
|
||||
$smartyVars['ppstatusDetailMsg'] = $objPPOrder->ppStatusDetail[$response['data']['purchase_units'][0]['payments']['captures'][0]['status_details']['reason']];
|
||||
// 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();
|
||||
if (
|
||||
isset($response['data']['purchase_units'][0]['payments']['captures'][0]['status_details']['reason'])
|
||||
&& ($transactionData['pp_payment_status'] == 'PENDING' || $transactionData['pp_payment_status'] == 'DENIED')
|
||||
&& isset($response['data']['purchase_units'][0]['payments']['captures'][0]['status_details']['reason'])
|
||||
) {
|
||||
if (isset($objPPOrder->ppStatusDetail[$response['data']['purchase_units'][0]['payments']['captures'][0]['status_details']['reason']])) {
|
||||
$smartyVars['ppstatusDetailMsg'] = $objPPOrder->ppStatusDetail[$response['data']['purchase_units'][0]['payments']['captures'][0]['status_details']['reason']];
|
||||
}
|
||||
}
|
||||
|
||||
$smartyVars['transaction_url'] = $this->context->link->getAdminLink('AdminPaypalCommerceTransaction',Tools::getAdminTokenLite('AdminPaypalCommerceTransaction')).'&viewwk_paypal_commerce_order&id_paypal_commerce_order=' . (int)$idTrans;
|
||||
$smartyVars['transaction_data'] = $transactionData;
|
||||
$smartyVars['refund_data'] = $refundData;
|
||||
$smartyVars['refunded_amount'] = $totalRefundedFormatted;
|
||||
$smartyVars['remaining_refund'] = $remainingRefund;
|
||||
$smartyVars['remaining_refund_format'] = Tools::displayPrice($remainingRefund, $orderCurrency);
|
||||
$smartyVars['currency'] = $orderCurrency;
|
||||
$smartyVars['WK_PAYPAL_COMMERCE_REFUND_TYPE_FULL'] = WkPaypalCommerceRefund::WK_PAYPAL_COMMERCE_REFUND_TYPE_FULL;
|
||||
$smartyVars['WK_PAYPAL_COMMERCE_REFUND_TYPE_PARTIAL'] = WkPaypalCommerceRefund::WK_PAYPAL_COMMERCE_REFUND_TYPE_PARTIAL;
|
||||
|
||||
$this->context->smarty->assign($smartyVars);
|
||||
$this->base_tpl_view = 'view.tpl';
|
||||
return parent::renderView();
|
||||
} else {
|
||||
Tools::redirectAdmin(self::$currentIndex . '&token=' . $this->token);
|
||||
}
|
||||
|
||||
$smartyVars['transaction_data'] = $transactionData;
|
||||
$smartyVars['refund_data'] = $refundData;
|
||||
$smartyVars['refunded_amount'] = $totalRefundedFormatted;
|
||||
$smartyVars['remaining_refund'] = $remainingRefund;
|
||||
$smartyVars['remaining_refund_format'] = Tools::displayPrice($remainingRefund, $orderCurrency);
|
||||
$smartyVars['currency'] = $orderCurrency;
|
||||
$smartyVars['WK_PAYPAL_COMMERCE_REFUND_TYPE_FULL'] = WkPaypalCommerceRefund::WK_PAYPAL_COMMERCE_REFUND_TYPE_FULL;
|
||||
$smartyVars['WK_PAYPAL_COMMERCE_REFUND_TYPE_PARTIAL'] = WkPaypalCommerceRefund::WK_PAYPAL_COMMERCE_REFUND_TYPE_PARTIAL;
|
||||
|
||||
$this->context->smarty->assign($smartyVars);
|
||||
} else {
|
||||
Tools::redirectAdmin(self::$currentIndex . '&token=' . $this->token);
|
||||
}
|
||||
$this->base_tpl_view = 'view.tpl';
|
||||
return parent::renderView();
|
||||
}
|
||||
|
||||
public function postProcess()
|
||||
@@ -231,7 +238,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 +250,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 +260,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 +270,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'];
|
||||
}
|
||||
|
||||
@@ -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':
|
||||
|
||||
@@ -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,14 +116,14 @@ 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
|
||||
$paypalOrderID = $returnData['data']['id'];
|
||||
|
||||
// Save order data
|
||||
$this->saveOrderData($returnData);
|
||||
$transaction_id = $this->saveOrderData($returnData);
|
||||
if ($paypalOrderID) {
|
||||
$currency = $this->context->currency;
|
||||
$total = (float)$cart->getOrderTotal(true, Cart::BOTH);
|
||||
@@ -144,6 +144,7 @@ class QloPaypalCommercePaymentModuleFrontController extends ModuleFrontControlle
|
||||
$orderStatus = Configuration::get('PS_OS_AWAITING_PAYMENT');
|
||||
}
|
||||
|
||||
$extraVars['transaction_id'] = $transaction_id;
|
||||
// create order for the payment
|
||||
$this->module->validateOrder(
|
||||
$cart->id,
|
||||
@@ -151,7 +152,7 @@ class QloPaypalCommercePaymentModuleFrontController extends ModuleFrontControlle
|
||||
$total,
|
||||
$this->module->l('PayPal Checkout', 'payment'),
|
||||
null,
|
||||
null,
|
||||
$extraVars,
|
||||
(int)$currency->id,
|
||||
false,
|
||||
$customer->secure_key
|
||||
@@ -210,7 +211,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');
|
||||
@@ -226,6 +227,7 @@ class QloPaypalCommercePaymentModuleFrontController extends ModuleFrontControlle
|
||||
// Save order data
|
||||
private function saveOrderData($orderData)
|
||||
{
|
||||
$transaction_id = '';
|
||||
if ($orderData) {
|
||||
$purchaseUnits = $orderData['data']['purchase_units'];
|
||||
foreach ($purchaseUnits as $purchase) {
|
||||
@@ -260,15 +262,13 @@ 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();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
return $transaction_id;
|
||||
}
|
||||
|
||||
// Create order data to send to PayPal
|
||||
|
||||
@@ -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':
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -107,7 +107,7 @@
|
||||
{if $transaction_data and $transaction_data.pp_payment_status == 'COMPLETED'}
|
||||
{* show refund form only if there is any remaing amount for refund *}
|
||||
{if $remaining_refund > 0}
|
||||
<form action="" method="post" class="form-horizontal" id="refund_form">
|
||||
<form action="{$transaction_url|escape:'html':'UTF-8'}" method="post" class="form-horizontal" id="refund_form">
|
||||
<div class="panel col-lg-12">
|
||||
<div class="panel-heading">
|
||||
<i class="icon-reply"></i>
|
||||
@@ -176,6 +176,7 @@
|
||||
<th style="text-align: center">{l s='Amount' mod='qlopaypalcommerce'}</th>
|
||||
<th style="text-align: center">{l s='Type' mod='qlopaypalcommerce'}</th>
|
||||
<th style="text-align: center">{l s='Status' mod='qlopaypalcommerce'}</th>
|
||||
<th style="text-align: center">{l s='Remark' mod='qlopaypalcommerce'}</th>
|
||||
<th style="text-align: center">{l s='Date' mod='qlopaypalcommerce'}</th>
|
||||
</tr>
|
||||
{if $refund_data}
|
||||
@@ -197,6 +198,7 @@
|
||||
<label class="label label-danger">{$refund.refund_status|escape:'html':'UTF-8'}</label>
|
||||
{/if}
|
||||
</td>
|
||||
<td style="text-align: center">{$refund.refund_reason|escape:'html':'UTF-8'}</td>
|
||||
<td style="text-align: center">{$refund.date_add|escape:'html':'UTF-8'}</td>
|
||||
</tr>
|
||||
{/foreach}
|
||||
|
||||
@@ -184,7 +184,11 @@ class StatsRegistrations extends ModuleGraph
|
||||
{
|
||||
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($this->query.$this->getDate());
|
||||
foreach ($result as $row) {
|
||||
$this->_values[(int)Tools::substr($row['date_add'], 0, 4)]++;
|
||||
$year = (int)Tools::substr($row['date_add'], 0, 4);
|
||||
if (!isset($this->_values[$year])) {
|
||||
$this->_values[$year] = 0;
|
||||
}
|
||||
$this->_values[$year]++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -204,7 +208,11 @@ class StatsRegistrations extends ModuleGraph
|
||||
{
|
||||
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($this->query.$this->getDate());
|
||||
foreach ($result as $row) {
|
||||
$this->_values[(int)Tools::substr($row['date_add'], 8, 2)]++;
|
||||
$days = (int)Tools::substr($row['date_add'], 8, 2);
|
||||
if (!isset($this->_values[$days])) {
|
||||
$this->_values[$days] = 0;
|
||||
}
|
||||
$this->_values[$days]++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -212,7 +220,11 @@ class StatsRegistrations extends ModuleGraph
|
||||
{
|
||||
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($this->query.$this->getDate());
|
||||
foreach ($result as $row) {
|
||||
$this->_values[(int)Tools::substr($row['date_add'], 11, 2)]++;
|
||||
$hour = (int)Tools::substr($row['date_add'], 11, 2);
|
||||
if (!isset($this->_values[$hour])) {
|
||||
$this->_values[$hour] = 0;
|
||||
}
|
||||
$this->_values[$hour]++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -310,10 +310,14 @@ class StatsSales extends ModuleGraph
|
||||
{
|
||||
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($this->query.$this->getDate().$this->query_group_by.$this->query_having_filter);
|
||||
foreach ($result as $row) {
|
||||
$days = (int)substr($row['invoice_date'], 8, 2);
|
||||
if (!isset($this->_values[$days])) {
|
||||
$this->_values[$days] = 0;
|
||||
}
|
||||
if ($this->option == 1) {
|
||||
$this->_values[(int)substr($row['invoice_date'], 8, 2)] += 1;
|
||||
$this->_values[$days] += 1;
|
||||
} else {
|
||||
$this->_values[(int)substr($row['invoice_date'], 8, 2)] += $row['total_revenue'];
|
||||
$this->_values[$days] += $row['total_revenue'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user