diff --git a/easysocialpoints/easysocialpoints.php b/easysocialpoints/easysocialpoints.php
index 7e6861f..5cdb65d 100755
--- a/easysocialpoints/easysocialpoints.php
+++ b/easysocialpoints/easysocialpoints.php
@@ -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
@@ -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' ))
{
@@ -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'];
@@ -179,7 +223,7 @@ class Plgpaymenteasysocialpoints extends JPlugin
}
// Amount check
- if ($isValid )
+ if ($isValid)
{
if (!empty($vars))
{
@@ -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);
}
diff --git a/easysocialpoints/easysocialpoints.xml b/easysocialpoints/easysocialpoints.xml
index c263c53..92fd121 100755
--- a/easysocialpoints/easysocialpoints.xml
+++ b/easysocialpoints/easysocialpoints.xml
@@ -28,6 +28,10 @@
+
+
+
+
diff --git a/easysocialpoints/en-GB/en-GB.plg_payment_easysocialpoints.ini b/easysocialpoints/en-GB/en-GB.plg_payment_easysocialpoints.ini
index a30e29d..67f3114 100755
--- a/easysocialpoints/en-GB/en-GB.plg_payment_easysocialpoints.ini
+++ b/easysocialpoints/en-GB/en-GB.plg_payment_easysocialpoints.ini
@@ -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"