Virtuemart + add code (moneris) - Joomla! Forum - community, help and support


hi,

joomla 3.7
virtuemart 3.2.1
one page checkout virtuemart http://vmonepage.com

----
i add moneris payment methode in virtuemart.

can tell me way this?

here moneris info:

https://developer.moneris.com/documentation/na/e-commerce%20solutions/api/purchase?lang=php


in above link, need add code (this php version of "purchase, vault , recurent billing"):



code: select all

require "../../mpgclasses.php";

/************************ request variables **********************************/

$store_id='store5';
$api_token='yesguy';

/************************ transaction variables ******************************/

$data_key='t8rcndwbnfnt4dx32ccnl2tlz';
$orderid='res-purch-'.date("dmy-g:i:s");
$amount='1.00';
$custid='cust';
$crypt_type='1';

/************************** cvd variables *****************************/

$cvd_indicator = '1';
$cvd_value = '198';

/********************** cvd associative array *************************/

$cvdtemplate = array(
                  cvd_indicator => $cvd_indicator,
                     cvd_value => $cvd_value
                    );

$mpgcvdinfo = new mpgcvdinfo ($cvdtemplate);

/************************** recur variables *****************************/

$recurunit = 'day';
$startdate = '2015/11/30';
$numrecurs = '4';
$recurinterval = '10';
$recuramount = '31.00';
$startnow = 'true';

/****************************** recur array **************************/

$recurarray = array(recur_unit=>$recurunit,  // (day | week | month)
               start_date=>$startdate, //yyyy/mm/dd
               num_recurs=>$numrecurs,
               start_now=>$startnow,
               period => $recurinterval,
               recur_amount=> $recuramount
               );

$mpgrecur = new mpgrecur($recurarray);

/************************ transaction array **********************************/

$txnarray=array(type=>'res_purchase_cc',
            data_key=>$data_key,
              order_id=>$orderid,
              cust_id=>$custid,
              amount=>$amount,
              crypt_type=>$crypt_type
               );

/************************ transaction object *******************************/

$mpgtxn = new mpgtransaction($txnarray);
$mpgtxn->setcvdinfo($mpgcvdinfo);
$mpgtxn->setrecur($mpgrecur);

/************************ request object **********************************/

$mpgrequest = new mpgrequest($mpgtxn);
$mpgrequest->setproccountrycode("ca"); //"us" sending transaction environment
$mpgrequest->settestmode(true); //false or comment out line production transactions

/************************ mpghttpspost object ******************************/

$mpghttppost  =new mpghttpspost($store_id,$api_token,$mpgrequest);

/************************ response object **********************************/

$mpgresponse=$mpghttppost->getmpgresponse();

print("\ndatakey = " . $mpgresponse->getdatakey());
print("\nreceiptid = " . $mpgresponse->getreceiptid());
print("\nreferencenum = " . $mpgresponse->getreferencenum());
print("\nresponsecode = " . $mpgresponse->getresponsecode());
print("\niso = " . $mpgresponse->getiso());
print("\nauthcode = " . $mpgresponse->getauthcode());
print("\nmessage = " . $mpgresponse->getmessage());
print("\ntransdate = " . $mpgresponse->gettransdate());
print("\ntranstime = " . $mpgresponse->gettranstime());
print("\ntranstype = " . $mpgresponse->gettranstype());
print("\ncomplete = " . $mpgresponse->getcomplete());
print("\ntransamount = " . $mpgresponse->gettransamount());
print("\ncardtype = " . $mpgresponse->getcardtype());
print("\ntxnnumber = " . $mpgresponse->gettxnnumber());
print("\ntimedout = " . $mpgresponse->gettimedout());
print("\navsresponse = " . $mpgresponse->getavsresultcode());
print("\nrecursuccess = " . $mpgresponse->getrecursuccess());
print("\nressuccess = " . $mpgresponse->getressuccess());
print("\npaymenttype = " . $mpgresponse->getpaymenttype());

//----------------- resolvedata ------------------------------

print("\n\ncust id = " . $mpgresponse->getresdatacustid());
print("\nphone = " . $mpgresponse->getresdataphone());
print("\nemail = " . $mpgresponse->getresdataemail());
print("\nnote = " . $mpgresponse->getresdatanote());
print("\nmasked pan = " . $mpgresponse->getresdatamaskedpan());
print("\nexp date = " . $mpgresponse->getresdataexpdate());
print("\ncrypt type = " . $mpgresponse->getresdatacrypttype());
print("\navs street number = " . $mpgresponse->getresdataavsstreetnumber());
print("\navs street name = " . $mpgresponse->getresdataavsstreetname());
print("\navs zipcode = " . $mpgresponse->getresdataavszipcode());

?>

               


once done (where put it?), can test out here:
https://esqa.moneris.com/mpg/index.php



once working, can activate own merchant id , store id.


so first question be...

where add moneris code? in virtuemart? or onepage checkout? or need create new component, module or plugin?

thanks help!!!

any appreciated. have seen lot of people looking moneris pluggin benefit quite few people too!

cheers,

for futur reference, virtuemart has detailed page on how make payment plugin:

https://dev.virtuemart.net/projects/virtuemart/wiki/payment_plugins

code: select all

 

payment plugins used both in front-end , backend. must created classes deriving base class vmpaymentplugin:

class plgvmpayment<myplugin> extends vmpaymentplugin {
    function plgvmpayment<myplugin>(&$subject, $config) {
        $this->_pelement = basename(__file__, '.php');    // required!
        $this->_createtable();                // required, see below
        parent::__construct($subject, $config);
    }
}
below list events , description on moment fired.
plgvmonselectpayment() - event fired during checkout process. allows shopper select 1 of available payment methods.
it should display radio button (name: paym_id) select payment method. other information (like credit card info) might selected well, depending on plugin.
return:
it must return html code displaying form (radio button , optional selections).
parameters:
(virtuemartcart object) cart object
(integer, default 0) id of selected payment method id, if any
plgvmonpaymentselectcheck() - event fired after payment method has been selected. can used store
additional payment info in cart.
return:
plugins not selected must return null, otherwise true of false must returned indicating success or failure.
parameters:
(virtuemartcart object) cart object
plgvmoncheckoutcheckpaymentdata() - event fired during checkout process. can used validate payment data entered user.
return:
plugins not selected must return null, otherwise true of false must returned indicating success or failure.
parameters:
none
plgvmonconfirmedorderstorepaymentdata() - event fired after payment has been processed; stores payment method-specific data.
all plugins must reimplement method.
return:
if plugin not executed (not selected payment method), method must return null
if plugin executed, must return order status code order should get. triggers stock updates if required
parameters:
(integer) ordernumber being processed
(object) data cart
(array) price information order
plgvmonshoworderpaymentbe() - method fired when showing order details in backend. displays the payment method-specific data.
all plugins must reimplement method.
return:
null when payment methods not selected, text (html) otherwise
parameters:
(integer) order id
(integer) payment method used order
plgvmoncancelpayment() - event fired each time status of order changed cancelled. can used refund payments, void authorization etc.
when reimplementing methis, body must start code:
$_paymethodid = $this->getpaymentmethodfororder($_orderid);
if (!$this->selectedthismethod($this->_pelement, $_paymethodid)) {
    return;
}

parameters:
(integer order id
(char) previous order status
(char) new order status
plgvmonshiporderpayment() - event fired when status of order changed shipped. can used confirm or capture payments
when reimplementing methis, body must start code:
$_paymethodid = $this->getpaymentmethodfororder($_orderid);
if (!$this->selectedthismethod($this->_pelement, $_paymethodid)) {
    return;
}

return:
true on success, false on failure, null if plugin not activated
parameters:
(integer) order id
plgvmonpaymentnotification() - event fired after receiving asynchronous payment notification. can used store payment specific data.
parameters:
(integer ) pelement
plgvmonpaymentresponsereceived() - event fired after asynchronous payment response has been received
parameters:
(integer ) pelement
other helper functions inherited base class:

_ createtable() - method used create , maintain plugin specific database table(s).
it must reimplemented plugins.
example:
$_scheme = dbscheme::get_instance();
$_scheme->create_scheme('#__vm_order_payment_'.$this->_pelement);
$_schemecols = array(
     'id' => array (
             'type' => 'int'
            ,'length' => 11
            ,'auto_inc' => true
            ,'null' => false
    )
    ,'order_id' => array (
             'type' => 'int'
            ,'length' => 11
            ,'null' => false
    )
    ,'payment_method_id' => array (
             'type' => 'text'
            ,'null' => false
    )
);
$_schemeidx = array(
     'idx_order_payment' => array(
             'columns' => array ('order_id')
            ,'primary' => false
            ,'unique' => false
            ,'type' => null
    )
);
$_scheme->define_scheme($_schemecols);
$_scheme->define_index($_schemeidx);
if (!$_scheme->scheme()) {
    jerror::raisewarning(500, $_scheme->get_db_error());
}
$_scheme->reset();
getpaymentmethodfororder() - order payment id given order number
return:
the payment method id, or -1 when not found
parameters:
(integer) order id
getthismethodname() - name of payment method.
this method can not reimplemented
return:
paymenent method name
parameters:
(integer) payment method id
selectedthismethod() - method checks if selected payment method matches current plugin
return:
true if calling plugin has given payment id, false otherwise.
parameters:
(string) element name, taken plugin filename
(integer) payment method id
writepaymentdata() - method writes payment plugin specific data plugin's table
return:
true if calling plugin has given payment id, false otherwise.
parameters:
(array) indexed array in format 'column_name' => 'value'
(string) table name
back plugin system]





Comments

Popular posts from this blog

Falang and too many redirects - Joomla! Forum - community, help and support

Infinite loop detected in JErrorInfinite loop detected in JError - Joomla! Forum - community, help and support

logged out from joomla! - Joomla! Forum - community, help and support