Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature #116787 chore: Work on Easysocial payment points #32

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 69 additions & 7 deletions easysocialpoints/easysocialpoints.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,23 @@ class Plgpaymenteasysocialpoints extends JPlugin
$db->setQuery($query);
$points_count = $db->loadResult();
$convert_val = $this->params->get('conversion');
$allowCredit = $this->params->get('seller_credit');
$points_charge = $data['total'] * $convert_val;


require_once JPATH_SITE . '/components/com_quick2cart/helper.php';
$comquick2cartHelper = new comquick2cartHelper;
$orderId = explode('-',$data['order_id']);
$orderInfo = $comquick2cartHelper->getorderinfo($orderId[2]);
$orderItems = $orderInfo['items'];

foreach($orderItems as $orderItem)
{
$productNames[] = $orderItem->order_item_name;
}

$product_names = implode(',', $productNames);

if ($points_charge <= $points_count)
{
//insert new entry in history table to deduct points
Expand All @@ -150,6 +165,7 @@ class Plgpaymenteasysocialpoints extends JPlugin
$espoint->state = 1;
$espoint->points = "-". $points_charge;
$espoint->user_id = $data['user_id'];
$espoint->message = JText::sprintf('PLG_POINTS_DEDUCTION',$product_names);
$espoint->created = date("Y-m-d H:i:s"); // 2014-08-12 11:14:54
if (!$db->insertObject( '#__social_points_history', $espoint, 'id' ))
{
Expand All @@ -164,6 +180,34 @@ class Plgpaymenteasysocialpoints extends JPlugin
$isValid = false;
}

// Insert points in seller's account.

if ($allowCredit == 1)
{
foreach ($orderItems as $orderItem)
{
$storeOwner = $comquick2cartHelper->getSoreInfo($orderItem->store_id);

$credit_points = $orderItem->product_item_price * $convert_val;

//insert new entry in history table to credit points
$espoint=new stdClass();
$espoint->id = '';
$espoint->state = 1;
$espoint->points = round($credit_points);
$espoint->user_id = $storeOwner['owner'];
$espoint->message = JText::sprintf('POINTS_CREDIT', $orderItem->order_item_name);
$espoint->created = date("Y-m-d H:i:s");

if (!$db->insertObject('#__social_points_history', $espoint, 'id'))
{
echo $db->stderr();

return false;
}
}
}

// 3.compare response order id and send order id in notify URL
$res_orderid = '';
$res_orderid = $data['order_id'];
Expand All @@ -179,7 +223,7 @@ class Plgpaymenteasysocialpoints extends JPlugin
}

// Amount check
if ($isValid )
if ($isValid)
{
if (!empty($vars))
{
Expand Down Expand Up @@ -213,22 +257,40 @@ class Plgpaymenteasysocialpoints extends JPlugin
return $result;
}

/**
* Method to translate response according to status.
*
* @param String $invoice_status Payment Status
*
* @return array
*
* @since 1.8.1
*/
Public function translateResponse($invoice_status)
{
foreach ($this->responseStatus as $key => $value)
{
if ($key == $invoice_status)
{
return $value;
}
{
if ($key == $invoice_status)
{
return $value;
}
}
}

/**
* Method onTP_Storelog.
*
* @param String $data Data
*
* @return void
*
* @since 1.8.1
*/
Public function onTP_Storelog($data)
{
$log_write = $this->params->get('log_write', '0');

if($log_write == 1)
if ($log_write == 1)
{
$log = plgPaymenteasysocialpointsHelper::Storelog($this->_name, $data);
}
Expand Down
4 changes: 4 additions & 0 deletions easysocialpoints/easysocialpoints.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@
<field name="conversion" type="text" size="10" default="10" label="PLG_EASYSOCIALPOINT_CON_AMT" description="PLG_EASYSOCIALPOINTCON_AMT_DESC"/>
<field name="points" type="hidden" default="point"/>
<field name="plugin_name" type="text" default="EasySocial Points" label="PLG_EASYSOCIALPOINT_NAME" description="PLG_EASYSOCIALPOINT_NAME_DESC" />
<field name="seller_credit" type="radio" default="0" label="PLG_SELLER_CRDIT" description="PLG_SELLER_CRDIT_DESC">
<option value="0">P_NO</option>
<option value="1">P_YES</option>
</field>
<field name="log_write" type="radio" default="0" label="PLG_AUTHONET_WRITE_LOG" description="PLG_AUTHONET_WRITE_LOG_DESC">
<option value="0">P_NO</option>
<option value="1">P_YES</option>
Expand Down
4 changes: 4 additions & 0 deletions easysocialpoints/en-GB/en-GB.plg_payment_easysocialpoints.ini
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,7 @@ PLG_EASYSOCIALPOINT_TOTAL_POINTS_DEDUCTED_MESSAGE="Successfully done.The total p
PLG_EASYSOCIALPOINT_SUBMIT="Pay Now"
PLG_AUTHONET_WRITE_LOG="Log payment gateway responses"
PLG_AUTHONET_WRITE_LOG_DESC="Turn this on only if payment not working correctly & you want do debug it."
PLG_SELLER_CRDIT="Credit points in seller account"
PLG_SELLER_CRDIT_DESC="Please select option for credit points in seller's account"
PLG_POINTS_DEDUCTION = "points has been deducted for Purchasing the product(s): %s"
POINTS_CREDIT="points has been credited for selling the product: %s"