News:

You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

Main Menu

Credit card Payment plugin . generate SalesPrice on order done page.

Started by kratzi, May 29, 2013, 15:32:56 PM

Previous topic - Next topic

kratzi

Hi,

I am using the quickpay plugin for my credit card payments which is coded very close to the paypal plugin.

I need to generate a link on the thank you page that includes the order number and salesPrice.

Unfortunately this code somehow does not work even though $order['details']['BT']->order_salesPrice and $order['details']['BT']->order_number  are working perfectly in other parts of the script.

  function plgVmOnPaymentResponseReceived( &$html) {
        // the payment itself should send the parameter needed.
    $virtuemart_paymentmethod_id = JRequest::getInt('pm', 0);
   
    $vendorId = 0;
    if (!($method = $this->getVmPluginMethod($virtuemart_paymentmethod_id))) {
        return null; // Another method was selected, do nothing
    }
    if (!$this->selectedThisElement($method->payment_element)) {
        return false;
    }
   
    $payment_data = JRequest::get('get');
    vmdebug('plgVmOnPaymentResponseReceived', $payment_data);
    $order_number = $payment_data['ordernumber'];
if (!class_exists('VirtueMartModelOrders'))
        require( JPATH_VM_ADMINISTRATOR . DS . 'models' . DS . 'orders.php' );
   
    $virtuemart_order_id = VirtueMartModelOrders::getOrderIdByOrderNumber($order_number);
    $payment_name = $this->renderPluginName($method);
    $html = ""; // Here we could add some Quickpay status info, but we dont


?>
<div class="default1234"> <?php echo '<img src="http://www.blabla.com&ordrenummer='.$order['details']['BT']->order_number.'&varenummer=x&antal=1&omprsalg='.$order['details']['BT']->order_salesPrice.'">Link</a>'?>
</div>
<?php


When using this I can at least generate the order number but i still don't get the salesprice.

?>
<div class="default1234"> <?php echo '<img src="http://www.blabla.com&ordrenummer='.$order_number $payment_data['ordernumber'].'&varenummer=x&antal=1&omprsalg='.$order['details']['BT']->order_salesPrice.'">Link</a>'?>
</div>
<?php


I appreciate all help.

Thank you

J.2.5.9 VM 2.0.18a

AH

Coded very close to paypal but not the same! So things will either have to be fixed or made closer to the original.

I have no ide how quikpay works but there is something missing in your "return" data.

This function is getting the details based on the url returned

Paypal returns and url Something like this
http://sitename/index.php?option=com_virtuemart&view=pluginresponse&task=pluginresponsereceived&on=1650042&pm=2&Itemid=471


Based on being sent a "return" url data string that contained the order number:
"return"           => JROUTE::_ (JURI::root () . 'index.php?option=com_virtuemart&view=pluginresponse&task=pluginresponsereceived&on=' . $order['details']['BT']->order_number . '&pm=' . $order['details']['BT']->virtuemart_paymentmethod_id . '&Itemid=' . JRequest::getInt ('Itemid')),


The function extracts order-number from "on" and payment plugin from "pm"

Then gets the Sales price from the payment plugin database table based on the order number.


IN your function the order number details have been stripped out so the function cannot get the order data from the table

function plgVmOnPaymentResponseReceived (&$html) {

if (!class_exists ('VirtueMartCart')) {
require(JPATH_VM_SITE . DS . 'helpers' . DS . 'cart.php');
}
if (!class_exists ('shopFunctionsF')) {
require(JPATH_VM_SITE . DS . 'helpers' . DS . 'shopfunctionsf.php');
}
if (!class_exists ('VirtueMartModelOrders')) {
require(JPATH_VM_ADMINISTRATOR . DS . 'models' . DS . 'orders.php');
}

//vmdebug('PAYPAL plgVmOnPaymentResponseReceived', $paypal_data);
// the payment itself should send the parameter needed.
$virtuemart_paymentmethod_id = JRequest::getInt ('pm', 0);
[b]$order_number = JRequest::getString ('on', 0);[/b]
$vendorId = 0;
if (!($method = $this->getVmPluginMethod ($virtuemart_paymentmethod_id))) {
return NULL; // Another method was selected, do nothing
}
if (!$this->selectedThisElement ($method->payment_element)) {
return NULL;
}

if (!($virtuemart_order_id = VirtueMartModelOrders::getOrderIdByOrderNumber ($order_number))) {
return NULL;
}
if (!($paymentTable = $this->getDataByOrderId ($virtuemart_order_id))) {
// JError::raiseWarning(500, $db->getErrorMsg());
return '';
}
$payment_name = $this->renderPluginName ($method);
$html = $this->_getPaymentResponseHtml ($paymentTable, $payment_name);

//We delete the old stuff
// get the correct cart / session
$cart = VirtueMartCart::getCart ();
$cart->emptyCart ();
return TRUE;
}



This function to display the details (note sales total // out but can be reinstated)

function _getPaymentResponseHtml ($paypalTable, $payment_name) {

$html = '<table>' . "\n";
$html .= $this->getHtmlRow ('PAYPAL_PAYMENT_NAME', $payment_name);
if (!empty($paypalTable)) {
$html .= $this->getHtmlRow ('PAYPAL_ORDER_NUMBER', $paypalTable->order_number);
//$html .= $this->getHtmlRow('PAYPAL_AMOUNT', $paypalTable->payment_order_total. " " . $paypalTable->payment_currency);
}
$html .= '</table>' . "\n";

return $html;
}



gethtmlrow from vmpsplugin


protected function getHtmlRow ($key, $value, $class = '') {

$lang = JFactory::getLanguage ();
$key_text = '';
$complete_key = strtoupper ($this->_type . '_' . $key);
// vmdebug('getHtmlRow',$key,$complete_key);
//if ($lang->hasKey($complete_key)) {
$key_text = JText::_ ($complete_key);
//}
$more_key = $complete_key . '_' . $value;
if ($lang->hasKey ($more_key)) {
$value .= " (" . JText::_ ($more_key) . ")";
}
$html = "<tr>\n<td " . $class . ">" . $key_text . "</td>\n <td align='left'>" . $value . "</td>\n</tr>\n";
return $html;
}



Regards
A

Joomla 4.4.5
php 8.1

kratzi

Hello Hutson and thank you for your answer:

The whole code of quickpay is attached


As I see the quickpay plugin also uses this "return" code however as "continueurl"

'continueurl' => JROUTE::_(JURI::root() . 'index.php?option=com_virtuemart&view=pluginresponse&task=pluginresponsereceived&pm=' . $order['details']['BT']->virtuemart_paymentmethod_id . '&ordernumber=' . $order['details']['BT']->order_number),

QuoteIN your function the order number details have been stripped out so the function cannot get the order data from the table

QuoteThen gets the Sales price from the payment plugin database table based on the order number.

Does that mean I would need to include a query into the code to ask for the sales price depending on order number??


I have also tried to generate the link with the help of function _getPaymentResponseHtml ($order) { however it didn't show the values for order number and salesprice at all.

Regards

Simon






[attachment cleanup by admin]

AH

You really need to go back to the suppliers of this plugin

You can extract the order number from the returned url to then use this to get data from the plugin table that was stored when the order was confirmed.

You should do this to validate that the returned url matches an order in your tables.  Then get the sales total from the relevant field.

$order_number = JRequest::getString ('ordernumber', 0);  (should extract the order number from the url) in the same ways as it gets the payment module.


Lots of code has been stripped from the original paypal plugin so too much effort for me to fathom out what they were trying to achieve, best talk to them and get them to fix.

Regards
A

Joomla 4.4.5
php 8.1

kratzi

Hi,

I was talking to the supplier however I couldn't afford his hourly rate. I received another solution which is working prefectly. Could you please check and tell me if this solution is safe as I have to enter the database information.

The code is at the end.

    function plgVmOnPaymentResponseReceived( &$html) {
        // the payment itself should send the parameter needed.
    $virtuemart_paymentmethod_id = JRequest::getInt('pm', 0);
   
    $vendorId = 0;
    if (!($method = $this->getVmPluginMethod($virtuemart_paymentmethod_id))) {
        return null; // Another method was selected, do nothing
    }
    if (!$this->selectedThisElement($method->payment_element)) {
        return false;
    }
   
    $payment_data = JRequest::get('get');
    vmdebug('plgVmOnPaymentResponseReceived', $payment_data);
    $order_number = $payment_data['ordernumber'];
if (!class_exists('VirtueMartModelOrders'))
        require( JPATH_VM_ADMINISTRATOR . DS . 'models' . DS . 'orders.php' );
   
    $virtuemart_order_id = VirtueMartModelOrders::getOrderIdByOrderNumber($order_number);
    $payment_name = $this->renderPluginName($method);
    $html = ""; // Here we could add some Quickpay status info, but we dont


// code for affiliate partner start

$database_conn=mysqli_connect('xxx','xxx','xxx','xxx');


global $partner_ads_salesPrice;

$db_query = mysqli_query($database_conn,"SELECT order_salesPrice FROM e6vw2_virtuemart_orders WHERE order_number = '$order_number'");
$info = mysqli_fetch_array($db_query);
foreach($info as $x=>$x_value)
{
$partner_ads_salesPrice=$x_value;
}

{
mysqli_close($database_conn);
}


// code for affiliate partner end
?>


<div class="defaulttest">
<img src="http://www.partner-ads.com/dk/leadtrack.php?programid=1234&type=salg&ordrenummer=<?php echo $order_number?>&varenummer=x&antal=1&omprsalg=<?php echo $partner_ads_salesPrice?>">
</div>
<?php


Regards


Simon

AH

Not sure what all the partnerads urls are for.

So no idea if it is safe

Must have been a pretty impressive hourly rate if you are willing to try some unknow solution!
Regards
A

Joomla 4.4.5
php 8.1

kratzi

// code for affiliate partner start

$database_conn=mysqli_connect('xxx','xxx','xxx','xxx');


global $partner_ads_salesPrice;

$db_query = mysqli_query($database_conn,"SELECT order_salesPrice FROM e6vw2_virtuemart_orders WHERE order_number = '$order_number'");
$info = mysqli_fetch_array($db_query);
foreach($info as $x=>$x_value)
{
$partner_ads_salesPrice=$x_value;
}

{
mysqli_close($database_conn);
}


// code for affiliate partner end



This is the code that was coded and as it connects to the database I was not sure if this might be an security issue. I mean in config.php I store the same information but is it maybe more unsafe to store this info also in the plugin. Could someone access this info without having access to my ftp.

The partnerads link is ok as I need to create this link with order number and price for the affiliate company I am working with.

Regards

Simon