VirtueMart Forum

VirtueMart General => Commercial Jobs => Topic started by: aussieute on July 11, 2006, 22:16:18 PM

Title: Intergration of Mastercard Gateway in Australia
Post by: aussieute on July 11, 2006, 22:16:18 PM
I've got a client who I'm working with who has direct connection with the Mastercard Internet Gateway Service (MIGS) in Australia. No third party processor required.

Urgently need someone who can assist with this.

Can't change my settings so email me at aussieute [at] gmail.com for more details and compensation discussions.
Title: Re: Intergration of Mastercard Gateway in Australia
Post by: findshorty on November 09, 2006, 05:49:48 AM
did you manage to find someone for this job mate?

if you did, and you managed to get the MIGS integration working, email me and let me know how much you want for the code if you're willing to let me have it!

nice one mate

shorty [] findshorty.com
Title: Re: Intergration of Mastercard Gateway in Australia
Post by: aussieute on November 09, 2006, 06:29:32 AM
I wish

No I didn't.

Mastercard were not all that helpful and we had to do it on OS commerce. <shrug>
Title: Re: Intergration of Mastercard Gateway in Australia
Post by: findshorty on November 14, 2006, 02:02:16 AM
i've just written the payment gateway successfully (only for "pay" and "capture" commands, refunds are handled at the MIGS control panel), so if you are thinking of using virtuemart again, let me know.
Title: Re: Intergration of Mastercard Gateway in Australia
Post by: Mike on March 29, 2007, 16:14:18 PM
Quote from: findshorty on November 14, 2006, 02:02:16 AM
i've just written the payment gateway successfully (only for "pay" and "capture" commands, refunds are handled at the MIGS control panel), so if you are thinking of using virtuemart again, let me know.
Hey any chance you can shed some light on getting this running?
Thanks
Title: Re: Intergration of Mastercard Gateway in Australia
Post by: aussieute on May 07, 2007, 09:36:47 AM
Looks like his name is a real one ... I can't find him <ROFL>

PM'd him and emailed as well

Anyone any the wiser with this option?



Title: Re: Intergration of Mastercard Gateway in Australia
Post by: findshorty on May 08, 2007, 04:44:31 AM
gday fellas

had a couple of requests for this

you can download from

http://findshorty.com/downloads/ps_migs.zip

by the way

NO GUARANTEE IS MADE WHATSOEVER THAT THIS WILL WORK FOR YOU!!!!

it works for me but is by no means complete. all refunds etc. are handled by the MIGS control panel, which you or your client should have access to.

i haven't had any failed transactions with it, but this doesn't mean you won't!!
Title: Re: Intergration of Mastercard Gateway in Australia
Post by: aussieute on May 08, 2007, 04:58:00 AM
yay ... he live and breathes

Ripper shorty thanks for that ..
Title: Re: Intergration of Mastercard Gateway in Australia
Post by: Jabin on May 08, 2007, 05:09:35 AM
Thank you Shorty!

Do we set this up as:

Do we also leave the Payment Extra Info field blank?


Jabin.
Title: Re: Intergration of Mastercard Gateway in Australia
Post by: findshorty on May 08, 2007, 05:48:43 AM
pretty simple to add


the files need to be uploaded to administrator/components/com_virtuemart/classes/payment

once there, select Store > Add Payment Method

Name it "Credit Card" (because this is what shows up on the checkout page)
The Code can be anything you like
Payment class name is ps_migs
Payment method type is Use payment processor

and i'm pretty sure MIGs only does Visa and Mastercard. I think the client has the option of adding AMEX so i suppose you can check that if they have

Then save the new payment method and it'll go back to the list.

Select the Payment Method from the list and you can then edit the config details.



Title: Re: Intergration of Mastercard Gateway in Australia
Post by: Jabin on May 14, 2007, 07:40:58 AM
FYI:

I'm attempting to use this with the ANZ eGate MIGS, and am currently getting an usual error... "Secure Hash Not Calculated".   :)

The ANZ eGate "Virtual Payment Client URL" is: https://migs.mastercard.com.au/vpcpay
(without the "https://" being entered in the config.)

Relevant debug:


Jabin.
Title: Re: Intergration of Mastercard Gateway in Australia
Post by: Jabin on May 14, 2007, 08:22:33 AM
One additional piece of information:

I haven't completed the required changed yet, but so far I've modified:

Changes that still need to be made:


Jabin.
Title: Re: Intergration of Mastercard Gateway in Australia
Post by: Jabin on May 14, 2007, 08:36:07 AM
Just in case I've confused everyone with the "Merchant Hosted" and "Server Hosted" comments:


Jabin.
Title: Re: Intergration of Mastercard Gateway in Australia
Post by: tez on September 17, 2007, 09:33:05 AM
I can't see how to pick VISA and Mastercard or AMEX. The problem was using the "minted 1.5" admin template by JoomlaWorks or maybe just using the non-standard one as I don't have others installed.

What does MIGS call the "Merchant Access Code" ?

What is the "Secure Hash"?

I get this error,
"vpc_Message=Merchant+%5BREMOVED%5D+does+not+have+the+required+privilege+to+use+the+VirtualPaymentClient+API."
Does this mean my client does not have the correct account to even use virtuemart payment method? They see to have a online shop but I don't know how it is hosted and don't have access to it.
Title: Re: Intergration of Mastercard Gateway in Australia
Post by: mongrel43 on November 20, 2007, 05:29:11 AM
Hey there Jabin,

Quote from: Jabin on May 14, 2007, 08:22:33 AM
One additional piece of information:

  • I'm using the "Bank Hosted" / "Server hosted" implementation.

I haven't completed the required changed yet, but so far I've modified:

  • The "Virtual Payment Client URL" to be alterable via the "Configuration" tab.
  • The "Payment Server Display Language Locale" to be alterable via the "Configuration" tab.
    I've also added the "vpc_Locale" to the list of variables sent via the URL
  • As I am using the "Server Hosted" implementation, I've altered the code to not
  • As I am using the "Server Hosted" implementation, I'm using a Payment Method Type of "PayPal (or related)"

Changes that still need to be made:

  • Adding the "vpc_ReturnURL" field to the list of variables sent to the server.
    In the interim, I'm just using a hard-coded value of the website's homepage.
  • Processing the result of the transaction... very important. ;)
  • Adding an option to the configuration to allow choosing between "Merchant Hosted" and "Bank Hosted".


Jabin.

Did you ever finish all of this? I have a client who needs a MIGs gateway and it would be really good to be able to use virtuemart for it.

Cheers
George
Title: Re: Intergration of Mastercard Gateway in Australia
Post by: tez on December 11, 2007, 05:50:57 AM
Here is a link to their support info if anyone needs it. I know it is impossible to find otherwise (intentionally I bet!).

http://business.commbank.com.au/merchants/
Title: Re: Intergration of Mastercard Gateway in Australia
Post by: tez on January 29, 2008, 05:15:15 AM
Seems my client doesn't even have the Merchant Account required to get a Sercure Hash. It took me feakin ages to work this out as the CommBank support refuse to discuss anything unless I am the account holder and the account holder is too technophobic to handle the situation.

Is there a Virtuemart plugin for a Commbank payment gateway (go from your shop to CBA site to pay and then back to shop). I don't know what the merchant accounts or terminology for this is because none of the documentation or login screens or anything I can find mentions anything helpful!

Sorry... I really really hate payment systems with such abysmal documentation and support. And it's freakin CBA! WTF!
Title: Re: Intergration of Mastercard Gateway in Australia
Post by: brandon23 on February 22, 2008, 00:29:31 AM
This may or may not help for any of you having a play with this code. We have gotten the code to work Server side MIGS by including the required variables and sending them across to vpcpay. Make sure you include your info for md5HashData and vpc_ReturnURL. The MIGS gateway requires the info sent across sorted and encrypted which you can see below.


Quote/**************************************************************************
        ** name: process_payment()
   ** created by: findshorty.com
   ** modified to work as a Server hosted by Paul(outsourced) and Brandon www.lateralplains.com
   ** description: Server Hosted, 3-Party Payment
   ** returns:
   ***************************************************************************/
   function process_payment($order_number, $order_total, &$d) {
      global $vendor_mail, $vendor_currency, $VM_LANG, $vmLogger;
      $database = new ps_DB;
      $ps_vendor_id = $_SESSION["ps_vendor_id"];
      $auth = $_SESSION['auth'];
      $ps_checkout = new ps_checkout;
      require_once(CLASSPATH ."payment/".$this->classname.".cfg.php");
         
      $database->query( "SELECT DECODE(payment_passkey,'".ENCODE_KEY."') as passkey FROM #__{vm}_payment_method WHERE payment_class='".$this->classname."' AND shopper_group_id='".$auth['shopper_group_id']."'" );
      
      $transaction = $database->record[0];

      if( empty($transaction->passkey)) {

         $vmLogger->err( $VM_LANG->_PHPSHOP_PAYMENT_ERROR.'. Technical Note: The required transaction key is empty! The payment method settings must be reviewed.' );
         return false;
      }

            $vpcURL   = "https://".virtualPaymentClientURL."?";   
            $md5HashData = "";
            $formdata = array (
            'vpc_ReturnURL' => '',
            'vpc_Version' => vpc_Version,
            'vpc_Command' => vpc_Command,
            'vpc_MerchTxnRef' => $order_number,
            'vpc_AccessCode' => vpc_AccessCode,
            'vpc_Merchant' => vpc_Merchant,
            // Invoice Information
            'vpc_OrderInfo' => $order_number,
            // Transaction Data
            'vpc_Amount' => $order_total*100,      
            );         
            ksort($formdata);
            // Get the URL and append the variables
            foreach($formdata as $key => $value) {
               if(!empty($value)) { // Eliminate the empty variables
                  $vpcURL .= urlencode($key) . '=' . urlencode($value) . '&';
                  $md5HashData .= $value;   // Append to md5 hash data
               }
            }
            $vpcURL .= "vpc_SecureHash=" . strtoupper(md5($md5HashData));
            header("Location: " . $vpcURL);   
      return true;
   }

This may or may not help you and we hold no responsibilities as to how it will go for you.
Title: Re: Intergration of Mastercard Gateway in Australia
Post by: yerg on April 02, 2008, 06:33:53 AM
Ok seeing as I started this thread I figured I'd return and see if anyone is willing to assist me and receive some stackable stuff in return for getting VM working with MIGS for me?

Alternatively give me some pointers ... I coped the wrath of MIGS them having claimed I brought their system down when setting up OSC. (don't see how but I'm not about to go there again)

So can you PM me or email me as per my original post?
Title: Re: Intergration of Mastercard Gateway in Australia
Post by: 1Rover1 on April 09, 2008, 04:19:33 AM
Sorry, I couldn't see your original post... I'm only a n00b as far as forums and VirtueMart are concerned but I know much about MIGS.

I'm surprise to hear that OSC caused MIGS problems. I suspect that that was a mis-communication somewhere.
Title: Re: Intergration of Mastercard Gateway in Australia
Post by: asterix on April 19, 2008, 07:01:27 AM
Tested and working with ANZ eGATE.
For those having trouble:
Make sure you get access to the Migs anz control panel from ANZ eGATE. They'll set you up a TEST account, in which  you need to setup an 'operator' that has the correct privileges to accept gateway payments. Login as the operator to retrieve your secure HASH etc.

From there, simply:
upload the find_shortly's ps_migs files into your administrator/components/com_virtuemart/classes/payments/ directory.
Login to your virtuemart console and add a new payment method. Make sure your payment class name is ps_migs  and payment method types is usage payment processor!
Hit save, then click on the ps_migs payment method link again to open the payment method form.
Go to the configuration tab and enter all the right details.
migs.mastercard.com.au/vpcdps
1
pay
then your access code etc...

you will need to enter your administrator password to enter a new secure hash.


Once thats done, you should be able to use the dummy cc numbers supplied by ANZ eGATE to run some tests. Be sure to point to the live url when you've done testing!

I've found diners and amex aren't working. Strange.
Title: Re: Intergration of Mastercard Gateway in Australia
Post by: yerg on April 19, 2008, 07:13:42 AM
Asterix thanks but that doesn't help me with Bendigo Bank .. does it?

MIGS ANZ
MIGS CommBank
MIGS StGeorge Bank
MIGS Bendigo Bank

... all seem to integrate with the actual MIGS system in a different way. That's my understanding of it at this point.

Shoot me down if I'm wrong ;D


Title: Re: Intergration of Mastercard Gateway in Australia
Post by: asterix on April 20, 2008, 04:58:53 AM
No, it works the same way from what I understand. The 'front end' login to the migs system might vary from bank to bank but logically they would each have the same requirements.
Title: Re: Integration of Mastercard Gateway in Australia
Post by: toivo on May 17, 2008, 17:47:13 PM
Hi,

I have just integrated the ANZ eGate MIGS Virtual Payment Client with Joomla eCommerce release 1.0.15, using the Bank Hosted mode of operation.  The solution utilises the configuration functions from findshorty's ps_migs.zip module, the request and the receipt cover the essential parts of the sample code from the VPC Developers Kit.

The receipt module:
- validates the hash
- checks that the order number exists
- checks that the order number is not a duplicate
- writes the response from the bank to a transaction log
- sends the email only if the card transaction was approved

As an added bonus, the shopper details are posted as a weblead to Salesforce.com.

If anyone is interested, drop me a line  :-)

Best Regards,
Title: Re: Intergration of Mastercard Gateway in Australia
Post by: asterix on May 18, 2008, 15:29:19 PM
I've cleaned out some of the code, and added error code handling so it tells the user exactly why their transaction failed if it did so:

<?php
defined
'_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );
/**
* The ps_migs class, containing the payment processing code
*  for transactions with mastercard 
*
* @package VirtueMart
* @subpackage payment
* @copyright Copyright (C) 2001-2007 Ian Young. All rights reserved.
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
* VirtueMart is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See /administrator/components/com_virtuemart/COPYRIGHT.php for copyright notices and details.
*
* http://virtuemart.net
*/

class ps_migs {

var $payment_code "MIGS";
var $classname "ps_migs";

/**
    * Show all configuration parameters for this payment method
    * @returns boolean False when the Payment method has no configration
    */
function show_configuration() {

global $VM_LANG$sess;
$db =& new ps_DB;
$payment_method_id mosGetParam$_REQUEST'payment_method_id'null );
/** Read current Configuration ***/
require_once(CLASSPATH ."payment/".$this->classname.".cfg.php");
    
?>

      <table>
  <tr>
<td><strong>Virtual Payment Client URL</strong></td>
<td><input type="text" class="inputbox" name="virtualPaymentClientURL" value="<?php echo virtualPaymentClientURL ?>" size="40" /></td>
<td>Domain only, no https:// as this is required by default</td>
</tr>
        <tr>
            <td><strong>VPC Version</strong></td>
            <td><input type="text" class="inputbox" size="4" value="<?php echo vpc_Version ?>" name="vpc_Version"/></td>
<td>&nbsp;</td>
        </tr>
        <tr>
            <td><strong>Command Type</strong></td>
            <td><input type="text" name="vpc_Command" value="<?php echo vpc_Command ?>" size="20" class="inputbox" maxlength="16" /></td>
<td>&nbsp;</td>
        </tr>
        <tr>
            <td><strong>Merchant AccessCode</strong></td>
            <td><input type="text" name="vpc_AccessCode" value="<?php echo vpc_AccessCode ?>" size="20" maxlength="9" class="inputbox" /></td>
<td>&nbsp;</td>
        </tr>
        <tr>
            <td><strong>MerchantID</strong></td>
            <td><input type="text" name="vpc_Merchant" value="<?php echo vpc_Merchant ?>" size="20" maxlength="16" class="inputbox" /></td>
<td>&nbsp;</td>
        </tr>
<tr>
            <td><strong>Secure Hash</strong></td>
            <td>
                <a id="changekey" href="<?php $sess->purl($_SERVER['PHP_SELF']."?page=store.payment_method_keychange&pshop_mode=admin&payment_method_id=$payment_method_id"?>" >
                <input onclick="document.location=document.getElementById('changekey').href" type="button" name="" value="View/Change Secure Hash" /></a>
            </td>
            <td>&nbsp;</td>
        </tr>

        <tr>
            <td><strong>Payment Server Display Language Locale</strong></td>
            <td><input type="text" name="vpc_Locale" value="en" size="20" maxlength="5" class="inputbox" /></td>
<td>&nbsp;</td>
        </tr>
        <tr><td colspan="3"><hr/></td></tr>
        <tr>
            <td><strong>Order Status for successful transactions</strong></td>
            <td>
                <select name="MIGS_VERIFIED_STATUS" class="inputbox" >
                <?php
                $q 
"SELECT order_status_name,order_status_code FROM #__{vm}_order_status ORDER BY list_order";
                
$db->query($q);
                
$order_status_code = Array();
                
$order_status_name = Array();

                while (
$db->next_record()) {
                
$order_status_code[] = $db->f("order_status_code");
                
$order_status_name[] =  $db->f("order_status_name");
                }
                for (
$i 0$i sizeof($order_status_code); $i++) {
                
echo "<option value=\"" $order_status_code[$i];
                
if (MIGS_VERIFIED_STATUS == $order_status_code[$i])
                
echo "\" selected=\"selected\">";
                
else
                
echo "\">";
                
echo $order_status_name[$i] . "</option>\n";
                    }
?>

                    </select>
            </td>
            <td>Select the order status to which the actual order is set, if the MIGS Transaction was successful.
            If using download selling options: select the status which enables the download (then the customer is instantly notified about the download via e-mail).
            </td>
        </tr>
            <tr>
            <td><strong>Order Status for failed transactions</strong></td>
            <td>
                <select name="MIGS_INVALID_STATUS" class="inputbox" >
                <?php
                
for ($i 0$i sizeof($order_status_code); $i++) {
                
echo "<option value=\"" $order_status_code[$i];
                
if (MIGS_INVALID_STATUS == $order_status_code[$i])
                
echo "\" selected=\"selected\">";
                
else
                
echo "\">";
                
echo $order_status_name[$i] . "</option>\n";
                    } 
?>

                    </select>
            </td>
            <td>Select an order status for failed MIGS Transactions.</td>
        </tr>
<?
?>
      </table>
   <?php
   
// return false if there's no configuration
   
return true;
}

function has_configuration() {
// return false if there's no configuration
return true;
}

/**
* Returns the "is_writeable" status of the configuration file
* @param void
* @returns boolean True when the configuration file is writeable, false when not
*/
function configfile_writeable() {
return is_writeableCLASSPATH."payment/".$this->classname.".cfg.php" );
}

/**
* Returns the "is_readable" status of the configuration file
* @param void
* @returns boolean True when the configuration file is writeable, false when not
*/
function configfile_readable() {
return is_readableCLASSPATH."payment/".$this->classname.".cfg.php" );
}
/**
* Writes the configuration file for this payment method
* @param array An array of objects
* @returns boolean True when writing was successful
*/
function write_configuration( &$d ) {

$my_config_array = array("virtualPaymentClientURL" => $d['virtualPaymentClientURL'],
"vpc_Version" => $d['vpc_Version'],
"vpc_Command" => $d['vpc_Command'],
"vpc_AccessCode" => $d['vpc_AccessCode'],
"vpc_Merchant" => $d['vpc_Merchant'],
"vpc_Locale" => $d['vpc_Locale'],
"MIGS_VERIFIED_STATUS" => $d["MIGS_VERIFIED_STATUS"],
"MIGS_INVALID_STATUS" => $d["MIGS_INVALID_STATUS"],
//asterix
"vpc_SecureHash" => $d["vpc_SecureHash"]
);
$config "<?php\n";
$config .= "defined('_VALID_MOS') or die('Direct Access to this location is not allowed.'); \n\n";
foreach( $my_config_array as $key => $value ) {
$config .= "define ('$key', '$value');\n";
}

$config .= "?>
";

if ($fp = fopen(CLASSPATH ."payment/".$this->classname.".cfg.php", "w")) {
fputs($fp, $config, strlen($config));
                        fclose ($fp);
                        return true;
                }
                else {
                        return false;
                }
        }

        /**************************************************************************
        ** name: process_payment()
** created by: findshorty.com
** description: process transaction with MasterCard Internet Gateway Service
** parameters: $order_number, the number of the order, we're processing here
**            $order_total, the total $ of the order
** returns:
***************************************************************************/
function process_payment($order_number, $order_total, &$d) {

global $vendor_mail, $vendor_currency, $VM_LANG, $vmLogger;
$database = new ps_DB;
$ps_vendor_id = $_SESSION["ps_vendor_id"];
$auth = $_SESSION['auth'];
$ps_checkout = new ps_checkout;

/*** Get the Configuration File for MIGS ***/
require_once(CLASSPATH ."payment/".$this->classname.".cfg.php");

// Get the Transaction Key securely from the database

$database->query( "SELECT DECODE(payment_passkey,'".ENCODE_KEY."') as passkey FROM #__{vm}_payment_method WHERE payment_class='".$this->classname."' AND shopper_group_id='".$auth['shopper_group_id']."'" );
$transaction = $database->record[0];
if( empty($transaction->passkey)) {
$vmLogger->err( $VM_LANG->_PHPSHOP_PAYMENT_ERROR.'. Technical Note: The required transaction key is empty! The payment method settings must be reviewed.' );
return false;
}
$host = virtualPaymentClientURL;

// MIGS vars to send
$formdata = array (
'vpc_Version' => vpc_Version,
'vpc_Command' => vpc_Command,
'vpc_MerchTxnRef' => $order_number,
'vpc_AccessCode' => vpc_AccessCode,
'vpc_Merchant' => vpc_Merchant,
'vpc_SecureHash' => $transaction->passkey,

// Gateway Response Configuration

// Invoice Information
'vpc_OrderInfo' => $order_number,
//asterix added
'vpc_MerchantTransactionReference' => $order_number,

// Transaction Data
'vpc_Amount' => $order_total*100,
'vpc_CardNum' => $_SESSION['ccdata']['order_payment_number'],
'vpc_CardSecurityCode' => $_SESSION['ccdata']['credit_card_code'],
'vpc_CardExp' => (substr($_SESSION['ccdata']['order_payment_expire_year'],2)) . ($_SESSION['ccdata']['order_payment_expire_month']),

);
ksort($formdata);
$md5HashData = $transaction->passkey;
//build the post string
$poststring = '';
foreach($formdata as $key => $val){
$poststring .= urlencode($key) . "=" . urlencode($val) . "&";
$md5HashData .= $val;
}
// strip off trailing ampersand
$poststring = substr($poststring, 0, -1)."&vpc_SecureHash=".strtoupper(md5($md5HashData));

if( function_exists( "curl_init" )) {

$vmLogger->debug( 'Using the cURL library for communicating with '.$host );

$CR = curl_init();
curl_setopt($CR, CURLOPT_URL, "https://".$host);
curl_setopt($CR, CURLOPT_POST, 1);
curl_setopt($CR, CURLOPT_FAILONERROR, true);
curl_setopt($CR, CURLOPT_POSTFIELDS, $poststring);
//curl_setopt($CR, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($CR, CURLOPT_RETURNTRANSFER, 1);

// No PEER certificate validation...as we don't have
// a certificate file for it to authenticate the host against!
//curl_setopt($CR, CURLOPT_SSL_VERIFYPEER, 0);
//curl_setopt($CR, CURLOPT_SSLCERT , "/usr/locale/xxxx/clientcertificate.pem");

$result = curl_exec( $CR );

$error = curl_error( $CR );
if( !empty( $error )) {
$vmLogger->err( $error );
$html = "<br/><span class=\"message\">".$VM_LANG->_PHPSHOP_PAYMENT_INTERNAL_ERROR." MIGS</span>";
return false;
}
else {
//echo $result; exit();
}
curl_close( $CR );
} else {
// Not sure MIGS allows following
}
// extract array from returned string output
$responsearr = explode("&", $result);
$response = array();
foreach($responsearr as $var) {
$tarr = explode("=",$var);
$response[$tarr[0]] = $tarr[1];
}

$vmLogger->debug('Beginning to analyse the response from '.$host);

$vpc_Txn_Secure_Hash = $response["vpc_SecureHash"];
//unset($response["vpc_SecureHash"]);
// set a flag to indicate if hash has been validated
$errorExists = false;
if (strlen($transaction->passkey) > 0 && strlen($vpc_Txn_Secure_Hash) > 0 && $response["vpc_TxnResponseCode"] != "7" && $response["vpc_TxnResponseCode"] != "No Value Returned") {
$md5HashData = $transaction->passkey;
ksort($response);
    // sort all the incoming vpc response fields and leave out any with no value
    foreach($response as $key => $value) {
        if ($key != "vpc_SecureHash" or strlen($value) > 0) {
            $md5HashData .= $value;
        }
    }
   
    // Validate the Secure Hash (remember MD5 hashes are not case sensitive)
// This is just one way of displaying the result of checking the hash.
// In production, you would work out your own way of presenting the result.
// The hash check is all about detecting if the data has changed in transit.
    if (strtoupper($vpc_Txn_Secure_Hash) == strtoupper(md5($md5HashData))) {
// Secure Hash validation succeeded, add a data field to be displayed
// later.

$vmLogger->debug("Secure Hash validated");
    } else {
        // Secure Hash validation failed, add a data field to be displayed
        // later.
        $errorExists = true;
$vmLogger->err("Secure Hash validation failed");
$vmLogger->err( strtoupper(md5($md5HashData)) );
$vmLogger->err( strtoupper($vpc_Txn_Secure_Hash) );
    }
} else {
    // Secure Hash was not validated, add a data field to be displayed later.
    $vmLogger->debug("Secure Hash Not Calculated");
}

// Approved - Success!
if ($response["vpc_TxnResponseCode"] == '0' && !$errorExists) {
$d["order_payment_log"] = $VM_LANG->_PHPSHOP_PAYMENT_TRANSACTION_SUCCESS.": ";
//$d["order_payment_log"] .= $response[3];

$vmLogger->debug( $d['order_payment_log']);

// Catch Transaction Number
$d["order_payment_trans_id"] = $response["vpc_TransactionNo"];

return true;
} else {
// log errors
// Modified by Asterix - www.imagineer.net.au. Display the correct error codes for failed transactions
if ($response["vpc_TxnResponseCode"] == '1') {
$d["order_payment_log"] = "Transaction could not be processed";
$vmLogger->err("Transaction could not be processed");
$d["order_payment_trans_id"] = $response["vpc_TransactionNo"];
} else if ($response["vpc_TxnResponseCode"] == '2') {
$d["order_payment_log"] = "Transaction declined - contact issuing bank";
$vmLogger->err("Transaction declined - contact issuing bank");
$d["order_payment_trans_id"] = $response["vpc_TransactionNo"];
} else if ($response["vpc_TxnResponseCode"] == '3') {
$d["order_payment_log"] = "No reply from Processing Host. ANZ EGATE may be temporarily offline";
$d["order_payment_trans_id"] = $response["vpc_TransactionNo"];
$vmLogger->err("No reply from Processing Host. ANZ EGATE may be temporarily offline. Please try again.");
} else if ($response["vpc_TxnResponseCode"] == '4') {
$d["order_payment_log"] = "Card has expired";
$vmLogger->err("Card has expired");
$d["order_payment_trans_id"] = $response["vpc_TransactionNo"];
} else if ($response["vpc_TxnResponseCode"] == '5') {
$d["order_payment_log"] = "Insufficient credit";
$vmLogger->err("Insufficient credit");
$d["order_payment_trans_id"] = $response["vpc_TransactionNo"];
} else {

$vmLogger->err( str_replace("&","\n",$result) );

$d["order_payment_log"] = str_replace("&","<br/>",$result);
// Catch Transaction ID
$d["order_payment_trans_id"] = $response["vpc_TransactionNo"];
}

return false;
}
}

/**************************************************************************
** name: capture_payment()
** created by: Soeren
** description: Process a previous transaction with authorize.net, Capture the Payment
** parameters: $order_number, the number of the order, we're processing here
** returns:
***************************************************************************/
function capture_payment( &$d ) {

global $vendor_mail, $vendor_currency, $VM_LANG, $vmLogger;
$database = new ps_DB();


}

}
Title: Re: Intergration of Mastercard Gateway in Australia
Post by: aussieute on May 22, 2008, 00:36:03 AM
I'm having an issue with choosing the ps_migs as the Payment Method (http://forum.virtuemart.net/index.php?topic=40360.msg127290#msg127290)

I can add/edit any other of the payment methods and things get saved but not with the MIGS option.

The file dates are 8/May/2007 ... is there a later version?
Or is this something else?

More questions

Do we edit the contents of the ps_migs.cfg.php manually or should this be able to be completed via the VM admin interface?
Title: Re: Intergration of Mastercard Gateway in Australia
Post by: toivo on May 28, 2008, 00:06:37 AM
You should be able to update the contents via the VM admin interface.  I am using the interface from ps_migs to support Bank Hosted mode of operation.
Title: Re: Intergration of Mastercard Gateway in Australia
Post by: aussieute on May 28, 2008, 00:39:46 AM
Toivo am having all sorts of issues

The migs file doesn't like J1.5.3 + VM1.1.0 (http://forum.virtuemart.net/index.php?topic=40360.msg129064#msg129064)
Getting some issues with some tables not installing (http://forum.virtuemart.net/index.php?topic=40899.msg129210#msg129210) and
Australia Post Module isn't functional on my install combo <grin>

Ya gotta love it <grin>
Title: Re: Intergration of Mastercard Gateway in Australia
Post by: tez on June 02, 2008, 15:08:07 PM
Seems I had already started on Joomla1.5 and VM, works okay. I started with e-commerce edition.

I can't work out what to use between the two URLs (server hosted / merchant hosted), is it a choice or can you only use whatever is relevant to your account?. Which one is it that sends to you the CBA site to input your details?

Also I had this error,
Error: . Technical Note: The required transaction key is empty! The payment method settings must be reviewed.
Is "transaction key" something auto generated per order, not based on any of my settings?. The bank error said it was above 34 characters.


Another error I had was that the vpc_MerchTxnRef and vpc_OrderInfo being sent were really massive numbers. See below. Whats up with that? It should be an order number, but mine are only about 000005 or so and the rest looks like a session ID.
vpc_MerchTxnRef=62_a79009c1f7414c7d72c7129f0b7206d8
vpc_Message=Field+vpc_OrderInfo+value+%5B62_a79009c1f7414c7d72c7129f0b7206d8%5D+is+too+long.+The+maximum+field+length+is+34+chars.
vpc_OrderInfo=62_a79009c1f7414c7d72c7129f0b7206d8
Title: Re: Intergration of Mastercard Gateway in Australia
Post by: toivo on June 02, 2008, 16:55:04 PM
Hi,

The Server Hosted, also called the Bank Hosted mode of operation sends the customer to the bank's website.  This mode mode does not store the credit card numbers in your web server, in other words one less thing to worry about.

The ps_migs.php software in a previous post is meant to be used in the Merchant Hosted mode of operation.  I used that as a basis for configuring the options, included the Extra Info from the sample programs in the VPC Development Kit to send the card transaction, removed ps_migs from the settings of the payment method and cobbled together a module to receive the response from the gateway, write the details to a transaction log for later reconciliation and finally to  update the order status in VM.

I am now waiting for the bank and MIGS to confirm that it is OK to publish the integration code in this forum, to avoid possible copyright issues.
Title: Re: Intergration of Mastercard Gateway in Australia
Post by: tez on June 03, 2008, 16:59:00 PM
that would be cool.
I don't need to store the credit card numbers, not even parts of them I guess. They are stored in the CBA logs I imagine anyway. But processing the card numbers on the shop site or the CBA site is fine - customers like it both ways.
Title: Re: Intergration of Mastercard Gateway in Australia
Post by: toivo on June 04, 2008, 09:17:39 AM
Hopefully the Merchant Hosted sites follow the Payment Card Industry (PCI) Data Security manual:  http://www.mastercard.com/us/wce/PDF/10172_MasterCard_PCI_Manual.pdf

Mind you, the writing is on the wall for retailers not to store the card numbers:  http://www.darkreading.com/document.asp?doc_id=135602



Title: Re: Intergration of Mastercard Gateway in Australia
Post by: tez on June 07, 2008, 07:59:12 AM
It looks like function get_order_number() will return larger than 34 characters as it joins user ID with the md5 of session and time. Commbank does not like that, should I truncate it to 34 characters? I'd imagine then it would break the confirmation part of the returned data from the Commbank server.

This is related to the error I get,
vpc_Message=Field+vpc_OrderInfo+value+%5B62_54387a77d194af18135d9c6b6a74d1f3%5D+is+too+long.+The+maximum+field+length+is+34+chars.

If customer ID was only 1 character it would work, but yeah that wouldn't last long.




Title: Re: Intergration of Mastercard Gateway in Australia
Post by: tez on June 07, 2008, 10:26:24 AM
Another question:

When using the TEST merchantIDs does it always decline non-testing credit card numbers?
I keep getting vpc_TxnResponseCode = 2 and vpc_AcqResponseCode = 14 (meaning Invalid card number (no such number) )
Title: Re: Intergration of Mastercard Gateway in Australia
Post by: toivo on June 07, 2008, 16:17:43 PM
That seems to be the case.  I used my test merchantID with a transaction ending in .00 and a valid Mastercard, and got response code 1 -Unspecified Failure.
Title: Re: Intergration of Mastercard Gateway in Australia
Post by: toivo on June 07, 2008, 16:33:12 PM
Quote from: tez on June 07, 2008, 07:59:12 AM
It looks like function get_order_number() will return larger than 34 characters as it joins user ID with the md5 of session and time. Commbank does not like that, should I truncate it to 34 characters? I'd imagine then it would break the confirmation part of the returned data from the Commbank server.
This is related to the error I get,
vpc_Message=Field+vpc_OrderInfo+value+%5B62_54387a77d194af18135d9c6b6a74d1f3%5D+is+too+long.+The+maximum+field+length+is+34+chars.

If customer ID was only 1 character it would work, but yeah that wouldn't last long.

I am using the variable $order_number which is the field order_number in the table jos_vm_orders and 32 characters long.  I think that is unique enough for security and reconciliation purposes. 

When the order number is returned with the response from the gateway, I check that the order number exists in jos_vm_orders and that the order status is Pending.  If the order status is something else, an error is logged and the order status remains unchanged.
Title: Re: Intergration of Mastercard Gateway in Australia
Post by: d1023319 on June 07, 2008, 23:49:56 PM
Hi,
I was reading with interest this threat especially about the ps_migs file.

FYI - I have a joomla 1.5 test site and I have my test ANZ egate working with the supplied files, i.e.
VPC_PHP_3P_DR.PHP
VPC_PHP_3P_DO.PHP
VPC_PHP_3P.HTML  = leads to card entry screen?
VPC_PHP_QueryDR.PHP
VPC_PHP_QueryDO.PHP


My question is - does the PS_migs replace the above files to integrate into ANZ egate, as it mentions inserting the hash info  or would I directly link the payment type of credit card to the VPC_PHP_3P.HTML.


Cheers
Title: Re: Integration of Mastercard Gateway in Australia
Post by: toivo on June 08, 2008, 00:47:56 AM
If you are working in a Bank Hosted scenario where you pass the user session to the MIGS site for the entry of the card information, ps_migs is not going to help because it is meant to request the card details in VirtueMart and pass them to the MIGS gateway.  In other words, it uses the Merchant Hosted mode of  operation.

The admin part of ps_migs.php inserts the secure secret hash from the ANZ Merchant Administration to the ps_migs.cfg.php from where it is read before calculating the hash total for the request and also before verifying the hash from the response received from the bank.

The sample modules from the VPC Development Kit are useful in testing and getting the algorithms for the hash calculation integrated into VirtueMart.

Regards,


Title: Re: Intergration of Mastercard Gateway in Australia
Post by: d1023319 on June 10, 2008, 08:52:06 AM
Hi

Thanks for your prompt reply.

FYI - Eftpos New Zealand has approved NZ Business Platforms for implementation using the Server Hosted  processing model only.


Cheers
Title: Re: Intergration of Mastercard Gateway in Australia
Post by: tez on June 20, 2008, 05:30:58 AM
I still have trouble with the function process_payment()
The $order_number value always seems to be a long string which is not related to the order ID, it always starts with the same number (62_ in my tests). It shows up in the CBA "Merchant Administration - Order List" under the "Order Reference" column - but this is not good to cross-referencing payments at all because it doesn't relate to anything, weird?.
edit: realised that the 62_ part is  userID, still weird though, shouldn't $order_number be related to order_ID?

I know that order_number is stored in the database, but since MIGS can't handle more than 34 characters does it matter that it does not match?

Is "refund" from within MIGS administration meant to affect virtuemart in any way?
Title: Re: Intergration of Mastercard Gateway in Australia
Post by: toivo on June 20, 2008, 12:06:45 PM
The MIGS Administration is separate from VirtueMart but if a confirmed transaction is refunded, a similar operation may have to be done fron the back end of VirtueMart, to maintain accurate the stock figures and keep the auditors happy.

You must be using the Merchant Hosted model of operation if you are  working on process_payment().  My integration of the VPC to VirtueMart works in the Bank Hosted mode.


Title: Re: Intergration of Mastercard Gateway in Australia
Post by: foxweb on June 30, 2008, 03:00:21 AM
Quote from: Toivo Talikka on May 17, 2008, 17:47:13 PM
Hi,
I have just integrated the ANZ eGate MIGS Virtual Payment Client with Joomla eCommerce release 1.0.15, using the Bank Hosted mode of operation.  The solution utilises the configuration functions from findshorty's ps_migs.zip module, the request and the receipt cover the essential parts of the sample code from the VPC Developers Kit.
The receipt module:
- validates the hash
- checks that the order number exists
- checks that the order number is not a duplicate
- writes the response from the bank to a transaction log
- sends the email only if the card transaction was approved
As an added bonus, the shopper details are posted as a weblead to Salesforce.com.
If anyone is interested, drop me a line  :-)
Best Regards,

Hi Toivo, I am integrating ANZ egate with Virtuemart and would love to see your bank hosted module if you could post it or email it to me. Thanks a million.
Title: Re: Integration of Mastercard Gateway in Australia
Post by: toivo on July 01, 2008, 16:51:05 PM
Hi,

Here is the MIGS Bank Hosted implementation for VirtueMart 1.0.15 with installation instructions, for ANZ eGate, CBA CommWeb and other bank gateways using the MIGS system.

2008-07-02 Version 1.0
2008-07-18 Version 1.0.1 fixes problem with freight missing from card total

Regards,


[attachment deleted by admin]
Title: Re: Intergration of Mastercard Gateway in Australia
Post by: foxweb on July 02, 2008, 01:24:37 AM
Quote from: Toivo Talikka on July 01, 2008, 16:51:05 PM
Hi,
Here is the MIGS Bank Hosted implementation for VirtueMart 1.0.15 with installation instructions, for ANZ eGate, CBA CommWeb and other bank gateways using the MIGS system.
Regards,

Hi Toivo,
Thanks for putting that on the forum. In the file ps_migs_pay.php I needed to change line 193 to 'return true;' rather than just 'return;'.

Hopes this helps others if they are having trouble.
Title: Re: Intergration of Mastercard Gateway in Australia
Post by: toivo on July 02, 2008, 02:51:00 AM
Hi,
If you follow the instructions on page 8 and remove 'ps_migs_pay' from the Payment Class Name, it will work. 

Using 'Address only / Cash on delivery' is a workaround to skip the payment processing.

Regards,
Title: Re: Intergration of Mastercard Gateway in Australia
Post by: asterix on July 05, 2008, 16:26:27 PM
Quote from: tez on June 20, 2008, 05:30:58 AM
I still have trouble with the function process_payment()
The $order_number value always seems to be a long string which is not related to the order ID, it always starts with the same number (62_ in my tests).

TEZ, just use the send the customer name under the merchant_txn_ref. You can still track them through the bank interface by using order date/time and customer name from your orders list. :)
Title: Re: Intergration of Mastercard Gateway in Australia
Post by: darshanpm on July 09, 2008, 05:27:01 AM
Hi Everyone,

I am not able to get the MIGS working.  I am using the shorty's script and i have a client merchant account with bendigo bank.  I am not getting any error but on the payment page, there are no credit cards listed to select one from there.  Can anyone tell me how to get the payment thing working with the bendigo bank merchant account.

Waiting for some reply,

Thanks,
Darshan
Title: Re: Intergration of Mastercard Gateway in Australia
Post by: toivo on July 09, 2008, 12:23:44 PM
Hi Darshan,

Are you working on the Merchant Hosted scenario where VirtueMart is in control?  My solution from the previous page integrates code from different sources, including shorty's, and implements the Bank Hosted model of MIGS. It includes a detailed document.

If you create a payment method, make sure you associate it with the default shopper group or the group to which your shoppers belong.

Regards,
Title: Re: Intergration of Mastercard Gateway in Australia
Post by: darshanpm on July 09, 2008, 13:46:59 PM
Hi Toivo,

Thanks for your reply.

I tried that code also but it also doesn't list any credit card in the drop-down list.  I checked and I have associated it with the default shopper group.  I have attached few screenshots of the same.  Can you tell me what am i doing wrong.

In the Virtual Payment Client URL:, I have entered migs.mastercard.com.au/vpcpay
Is that correct?

I am using vm 1.1.0 and Joomla! 1.0.15 Stable

Waiting for reply,

Thanks,
Darshan

[attachment cleanup by admin]
Title: Re: Intergration of Mastercard Gateway in Australia
Post by: toivo on July 09, 2008, 14:35:14 PM
Hi Darshan,

The VPC URL is correct.  My installation is in production under Joomla 1.0.15 and  VM 1.0.15 eCommerce Edition.  I have not had a chance to try it under VM 1.1.0.

Your first screenshot shows that you have selected 'Use Payment Processor'.  I have not tested that approach, I wanted to bypass the Payment Processor because that would lead to the Merchant Hosted mode of operation.  Therefore I removed the name of the payment class as the last step of the installation of the MIGS Payment Method and selected 'Address Only / Cash On Delivery' as the Payment Method Type.  The installation instructions clarify this step by step.

Another approach was suggested by Foxweb who gave the following patch which you may want to try:
QuoteIn the file ps_migs_pay.php I needed to change line 193 to 'return true;' rather than just 'return;'.

The Bank Hosted solution is not supposed to prompt any credit card information, compared to your 2nd screenshot. The card type and the other details are prompted after the control is passed through the VPC URL to the MIGS Gateway at the end of the Payment Extra Info code. 

Regards,





Title: Re: Integration of Mastercard Gateway in Australia
Post by: toivo on July 17, 2008, 17:37:53 PM
Thanks to Dan for reporting that freight was not included in the credit card total. 

The Payment Extra Info needs to be amended:


// 20080718 shipping
// $order_total = round($db->f("order_subtotal") + $tax_total - $discount_total, 2);
$order_total = round($db->f("order_subtotal") + $tax_total + $db->f("order_shipping") - $discount_total, 2);
// 20080718 end


A new version is now posted at http://forum.virtuemart.net/index.php?topic=19994.42.
Title: Re: Intergration of Mastercard Gateway in Australia
Post by: RobertL on July 27, 2008, 23:59:20 PM
Hi Tovio,

thanks for posting your work, great stuff.

Regards
Title: Re: Intergration of Mastercard Gateway in Australia
Post by: RobertL on July 28, 2008, 01:48:34 AM
Got a little stuck hope you might help. Running VM v1.1.0, still testing on local server. I have added the secure_secret, only thing I couldn't do is remove ps_migs_pay (page 6).

regards

[attachment cleanup by admin]
Title: Re: Intergration of Mastercard Gateway in Australia
Post by: toivo on July 28, 2008, 10:06:52 AM
Hi,

I do not have VM 1.1.0.  If you cannot remove ps_migs_pay from the configuration, I suggest that you edit the row in the table containing the payment methods before you try a test transaction.

Regards,
Title: Re: Intergration of Mastercard Gateway in Australia
Post by: RobertL on July 28, 2008, 14:26:23 PM
thanks for the reply. have done but still same message, seems that for some reason, it's not getting the secure hash correctly. I added them manually into both ps_migs_pay and cfg but it didn't work. Can code in extra_info perhaps be changed to include secure hash directly rather than draw from form?

regards
Title: Re: Intergration of Mastercard Gateway in Australia
Post by: toivo on July 28, 2008, 14:52:40 PM
The secure secret is retrieved in the extra_info code from the table jos_vm_payment_method, using the payment method name as the key.  I do not think it is safe practice to hard code it in.

The error message you receive from the bank indicates that the secure secret is not included in the transaction.  Have you possibly changed the name of the payment method?

If you have changed the name of the payment method from 'MIGS Credit Card', you need to modify line 35 in extra_info accordingly. 

Regards,

Title: Re: Intergration of Mastercard Gateway in Australia
Post by: RobertL on July 28, 2008, 18:32:33 PM
Sadly no, payment method has remained the same but it's not getting it
Title: Re: Intergration of Mastercard Gateway in Australia
Post by: tez on August 03, 2008, 08:31:17 AM
Quote from: asterix on July 05, 2008, 16:26:27 PM
Quote from: tez on June 20, 2008, 05:30:58 AM
I still have trouble with the function process_payment()
The $order_number value always seems to be a long string which is not related to the order ID, it always starts with the same number (62_ in my tests).
TEZ, just use the send the customer name under the merchant_txn_ref. You can still track them through the bank interface by using order date/time and customer name from your orders list. :)
Oh, I thought this merchant_txn_ref was a key which needed to contain the order hash for security.
Title: Re: Intergration of Mastercard Gateway in Australia
Post by: goeasy on August 05, 2008, 12:03:04 PM
have you finally fine someone for intergration of mastercard gadeway in Australia?
Title: Re: Intergration of Mastercard Gateway in Australia
Post by: toivo on August 05, 2008, 15:09:17 PM
The download for VirtueMart 1.0.15 is in Reply #42.
Title: Re: Intergration of Mastercard Gateway in Australia
Post by: chibee on August 19, 2008, 09:09:38 AM
Hi, im just have an error that maybe you could help me.

Error: the order number is duplicate or not found.

bookings.citect.com  MIGS

Response
Transaction Reference/Order Number:
fcba7fbacc81f27ac13ae6256ff20eae

Purchase Amount (AUD, Australian dollars):
10.83
--------------------------------------------------------------------------------

Response:
Unknown Error

Message:
Unspecified Failure

Receipt Number:
080819000009

Transaction Number:
9

Bank Authorization ID:
No Value Returned

Batch Number:
20080819

Card Type:
VC


i am running vm 1.0.15 stable, joomla 1.0.15 stable (locally)
i have followed Toivo's instructions and have copied the files to the right dirs.

The error appears when i submit the test visa credit card details into migs page.

Please help


[attachment cleanup by admin]
Title: Re: Intergration of Mastercard Gateway in Australia
Post by: toivo on August 19, 2008, 11:39:55 AM
Obviously something has not been done right.  The idea behind matching the order number returned from MIGS to an existing order number and the order status in VirtueMart is to make sure the transactions are not re-played by pressing the Back key in the browser. 

The order has to be in the Pending state and a successful card transaction changes the status to Confirmed, otherwise Cancelled.

You have to follow the instructions provided by MIGS regarding test transactions.  The cents in the amount determine the response from the gateway.  If I remember correctly, the transaction is only approved if the amount ends in .00.
Title: Re: Intergration of Mastercard Gateway in Australia
Post by: RobertL on August 19, 2008, 15:35:05 PM
Hi again,

my website is now live, and though I was close to getting it happening,
going to do a test now, it's gone donwhill. I'm starting from scratch,
but here is the error i got using old setup (where it just didn't get
the key properly). any help would be great. thanks

[attachment cleanup by admin]
Title: Re: Intergration of Mastercard Gateway in Australia
Post by: toivo on August 19, 2008, 23:32:31 PM
Hi,

Did you modify the code for VM 1.1?  The original has only been tested with VM 1.0.15.

If you added the secure hash by hard coding to the request, you need to do the same when checking the result from the gateway.  The original code extracts it from the configuration file.

The screenshot you provided does not come from checkout.result_migs.php but something else.  Are you sure you have implemented the bank hosted solution as instructed in the documentation?

Regards,
Title: MIGS Bank Hosted plugin for VM 1.1
Post by: toivo on August 26, 2008, 16:38:42 PM
Here is the plugin for MasterCard Internet Gateway Service (MIGS), Bank Hosted mode of operation, for VirtueMart 1.1.

It has been tested with Joomla 1.0.15 and VM1.1.2. 

The installation instructions are included with screenshots.

Regards,
toivo

[attachment cleanup by admin]
Title: MIGS Bank Hosted plugin for VM 1.1 and Joomla 1.5
Post by: toivo on August 31, 2008, 06:25:38 AM
Hi,

The plugin in the previous post does not work with Joomla 1.5.  Here is a new version which has been tested on VirtueMart 1.1.2 and Joomla 1.5.6.  

Regards,
Toivo

Update 16/3/2010:  The attachment migs_bank_hosted_J15_VM11.zip from 31/8/2008 has now been restored, after it had been deleted inadvertently.

[attachment cleanup by admin]
Title: Re: Intergration of Mastercard Gateway in Australia
Post by: spauldingsmails on September 03, 2008, 02:31:32 AM
Hi Toivo

New Joomla 1.5 version of the module's working great, thanks.

Have you considered licensing this under a F/OSS license and creating a joomlacode project? That way you could more easily manage distribution and add it to the joomla extensions repository.
Title: Re: Intergration of Mastercard Gateway in Australia
Post by: toivo on September 03, 2008, 10:25:48 AM
Hi,

That is interesting but may be tricky because of the copyright in the code from the MIGS VPC demo scripts, which I got permission to include in the plugin and post to this forum.

Regards,
Title: Re: Intergration of Mastercard Gateway in Australia
Post by: spauldingsmails on September 05, 2008, 05:15:23 AM
Quote from: Toivo Talikka on September 03, 2008, 10:25:48 AM
That is interesting but may be tricky because of the copyright in the code from the MIGS VPC demo scripts, which I got permission to include in the plugin and post to this forum.

Hmm. Good point. Are the VPC demo scripts isolated or are they integrated tightly into the rest of the code base? If they are isolated, I'm wondering if there is a way to distribute it in such a way that it can be open sourced with infringing on the proprietary VPC license (I.e. not permitting the user to change the VPC code).
Title: Re: Intergration of Mastercard Gateway in Australia
Post by: toivo on September 05, 2008, 10:59:32 AM
QuoteHmm. Good point. Are the VPC demo scripts isolated or are they integrated tightly into the rest of the code base? If they are isolated, I'm wondering if there is a way to distribute it in such a way that it can be open sourced with infringing on the proprietary VPC license (I.e. not permitting the user to change the VPC code).

You mean 'without infringing'? Both the code which prepares the request with the hash and the code which validates the returned hash and presents the result from the gateway come from the VPC demo, just slightly improved to avoid PHP warnings. The demo modules are meant to be run on their own. 

Regards,
Title: Re: Intergration of Mastercard Gateway in Australia
Post by: scottnight on January 14, 2009, 00:05:36 AM
Thanks Toivo, you're code works perfectly.  Appreciate you sharing with the community.
Title: Re: Intergration of Mastercard Gateway in Australia
Post by: freifer on June 24, 2009, 10:11:38 AM
Hi Tovio and all,

I am new to this, I need to process payment by credit card directly to our account with CBA, I downloaded  MIGS Bank Hosted plugin for VM 1.1 and Joomla 1.5, and followed the instructions, but when tried to process a sale through VM it displayed the following:

THANK YOU FOR YOUR ORDER.

Your order has been successfully placed!

A confirmation email has been sent to: info@websitenames.com.au

global $VM_LANG; $database =& new ps_DB; $ps_vendor_id = $_SESSION['ps_vendor_id']; $tax_total = $db->f('order_tax') + $db->f('order_shipping_tax'); $discount_total = $db->f('coupon_discount') + $db->f('order_discount'); $order_total = round($db->f('order_subtotal') + $tax_total + $db->f('order_shipping') - $discount_total, 2); $order_shipping = sprintf('%.2f', $db->f('order_shipping')); $order_id = $db->f('order_id') ; $order_number = $db->f('order_number'); $order_item_sku = $db->f('order_item_sku') ; $order_item_name = $db->f('order_item_name') ; require_once(CLASSPATH . 'payment/ps_migs_pay.cfg.php'); if( !defined('_VALID_MOS') && !defined('_JEXEC') ) die( 'Direct Access to ' . basename(__FILE__). ' is not allowed.' ); $database->query( "SELECT ".VM_DECRYPT_FUNCTION."(payment_passkey,'".ENCODE_KEY."') AS `passkey` FROM #__vm_payment_method WHERE payment_method_code = 'MIGS'" ); $transaction = $database->record[0]; if (empty($transaction->passkey)) { error_log('checkout.result_migs.php error: passkey empty'); echo $VM_LANG->_('VM_CHECKOUT_FAILURE') . '. Technical Note 1: The required transaction key is empty! The payment method settings must be reviewed.'; return false; } $vpcURL = "https://" . virtualPaymentClientURL . "?"; $SECURE_SECRET = trim($transaction->passkey); // remove cr or lf $md5HashData = $SECURE_SECRET; // https $vm_url = SECUREURL . 'index.php?option=com_virtuemart'; $vm_url .= '&page=checkout.result_migs'; $formdata = array ( 'vpc_ReturnURL' => $vm_url, 'vpc_Version' => vpc_Version, 'vpc_Command' => vpc_Command, 'vpc_MerchTxnRef' => $order_number, 'vpc_AccessCode' => vpc_AccessCode, 'vpc_Merchant' => vpc_Merchant, 'vpc_OrderInfo' => $order_number, 'vpc_Amount' => $order_total * 100 ); ksort($formdata); // Get the URL and append variables foreach($formdata as $key => $value) { if (!empty($value)) { // skip empty variables $vpcURL .= urlencode($key) . '=' . urlencode($value) . '&'; $md5HashData .= $value; // Append to md5 hash data } } // create secure hash and append it to virtual payment client data if secure secret has been provided if (strlen($SECURE_SECRET) > 0) { $vpcURL .= "vpc_SecureHash=" . strtoupper(md5($md5HashData)); } header( "Location: " . $vpcURL); ?>

Follow this link to view the Order Details.


I am not sure what i am doing wrong or how this Plugin is supposed to behave... can you please help, and please excuse my ignorance ...

I am running with joomla 1.5.9  and Virtuemart 1.1.3

Regards

Freifer
Title: Re: Intergration of Mastercard Gateway in Australia
Post by: toivo on June 24, 2009, 16:15:25 PM
You must have missed the initial PHP tag <?php when you copied the code to the Payment Extra Info.
Title: Re: Intergration of Mastercard Gateway in Australia
Post by: mikk on July 12, 2009, 05:09:05 AM
I'm using Virtuemart 1.0.15 and Joomla 1.0.12.

This payment method is great!

Does anyone know how to change it so that the Mastercard Gateway gets the Customer Name as the Order Reference instead of the order number?

Also, I'm using PayPal, but since commenting out the sending of the email from around line 1040 of ps_checkout.php:
$this->email_receipt($order_id);

, I don't get emails about pending PayPal orders. How do I change it to check for PayPal payment method before the email is sent?
Title: Re: Intergration of Mastercard Gateway in Australia
Post by: tiju_t on November 11, 2009, 02:40:03 AM
Hi Toivo

I realise this is a very old topic, but I am just starting to implement ANZ egate integration on my website (J 1.5.10 | VM 1.1.3)

I have downloaded the plugin attached to your earlier post, but find that it only contains a doc file. Where would I get the php files from?

Thanks heaps.
Title: Re: Intergration of Mastercard Gateway in Australia
Post by: lessleep on February 09, 2010, 14:09:15 PM
Hi Toivo, Thank you very much for all the effort and great job!

Now its the bug report time. The amount doesnot show correctly when there is a coupon entered.

For instance, one item cost $349.90, when there is NO coupon entered, the amount need to pay showing on mastercard website is $349.90, correct. However, after I put in a coupon for -$9, same item shows $340.08 on mastercard website instead of $340.90

I cannot think of where the problem is. So I need your help! Test environment Joomla 1.5.14 + VM 1.1.3. The coupon code is buildin with VM. Thank you again for such great job.
Title: Re: Intergration of Mastercard Gateway in Australia
Post by: lessleep on February 09, 2010, 14:33:17 PM
$tax_total = $db->f('order_tax') + $db->f('order_shipping_tax');
$discount_total = $db->f('coupon_discount') + $db->f('order_discount');
$order_total = round($db->f('order_subtotal') + $tax_total + $db->f('order_shipping') - $discount_total, 2);


The formula looks correct, maybe something to do with VM itself?
Title: Re: Intergration of Mastercard Gateway in Australia
Post by: toivo on February 12, 2010, 13:23:07 PM
Quote from: tiju_t on November 11, 2009, 02:40:03 AM
Hi Toivo

I realise this is a very old topic, but I am just starting to implement ANZ egate integration on my website (J 1.5.10 | VM 1.1.3)

I have downloaded the plugin attached to your earlier post, but find that it only contains a doc file. Where would I get the php files from?

Thanks heaps.
All the other files are in a folder in the archive, including the PHP files.
Title: Re: Intergration of Mastercard Gateway in Australia
Post by: toivo on February 12, 2010, 13:27:30 PM
Quote from: lessleep on February 09, 2010, 14:33:17 PM
$tax_total = $db->f('order_tax') + $db->f('order_shipping_tax');
$discount_total = $db->f('coupon_discount') + $db->f('order_discount');
$order_total = round($db->f('order_subtotal') + $tax_total + $db->f('order_shipping') - $discount_total, 2);


The formula looks correct, maybe something to do with VM itself?
The difference is close to the GST calculated from the amount of the coupon.  I do not have a VM system available right now, therefore I cannot check but does that sound feasible?
Title: Re: Intergration of Mastercard Gateway in Australia
Post by: thewebxpert on March 15, 2010, 04:42:04 AM

Hi Toivo,

I have integrated the ANZ egate payment system in a website and its working fine, although recently there have been some problems with the orders when the credit card used is expiring in the same month to that of the order month.  The money goes through but the order status gets set to Pending and the admin doesn't receive any email about the order placed.  I don't know why its doing so, but if you have any idea about what might be the cause of this and let me know it would be great.

Let me know if you didn't quite understand what i mean to say.

Thanks
Title: Re: Intergration of Mastercard Gateway in Australia
Post by: toivo on March 15, 2010, 10:55:15 AM
Quoterecently there have been some problems with the orders when the credit card used is expiring in the same month to that of the order month.  The money goes through but the order status gets set to Pending and the admin doesn't receive any email about the order placed.
This is a bank hosted solution and the VM plugin does not receive any card related information from the gateway, other than the transaction status, a verbal message and an optional card type. If the response code is zero (0) and the message is 'Approved', the plugin regards the payment as having been approved by Mastercard. 

Please check the problem entries from the transaction log, stored in the table jos_vm_payment_trans, especially the columns 'txn_response_code' and 'message'.  If the response is different from 0 and 'Approved', you may need to provide all the information from that row to your bank so that they can work out what happened at their end.
Title: Re: Intergration of Mastercard Gateway in Australia
Post by: mikesoden on May 25, 2010, 14:04:33 PM
MIGS "Bank Hosted" / "Server hosted" implementation SOLUTION


Hey all, recently I was stuck trying to get a Server Hosted MIGs on Joomla 1.5.17 with Virtuemart 1.1.4

I found this guy Tony Milne who was blogging about a solution at his blog, http://tonymilne.com.au. He was nice enough to release his solution to the public..!

Here's the solution: http://tonymilne.com.au/posts/migs-payments-in-joomla-virtuemart

cheers Tony..!

Mike
Title: Re: Intergration of Mastercard Gateway in Australia
Post by: sftranna on August 31, 2010, 09:21:01 AM

dear all,
i am facing a problem while using MIGS. Problem is this that whenever im direccted to card details (Payment Details Page) amount that i sent t0 the VPC is divided by 100 so causing problems e.g. my order total is SAR 559 but on payment detail page this shows 5.59 but on the response page its again multiplied by 100 and shown as 559...
so i get far behind the success message :)

my client is a saudi company and this MIGS module deals in (currency) SAR and my payment method is Server-Hosted Payment using Command:pay
and im using custom php5 , no cms or framework
plz help me
Shahzeb Chohan
sftranna at gmail.com
Title: Re: Intergration of Mastercard Gateway in Australia
Post by: marketing2010 on September 15, 2010, 11:24:07 AM
I get this error too
"vpc_Message=Merchant+%5BREMOVED%5D+does+not+have+the+required+privilege+to+use+the+VirtualPaymentClient+API."
Does this mean my client does not have the correct account to even use virtuemart payment method? They see to have a online shop but I don't know how it is hosted and don't have access to it.
Title: Re: Intergration of Mastercard Gateway in Australia
Post by: ttkim1 on November 13, 2010, 10:23:42 AM
Hi, i get this error after entering credit card details:

Transaction Reference/Order Number:    62_82432fa1297041d7a602a657b23fb
Purchase Amount (AUD, Australian dollars):    1.00
Response:    Payment Server System Error
Message:    Field vpc_Command value [vpc_Command] is invalid

What am I suppose to enter for the VPC version and Command type fields?

Appreciate the help!
Title: Re: Intergration of Mastercard Gateway in Australia
Post by: emaryanncarpenteri on November 13, 2010, 11:35:04 AM
Quote from: marketing2010 on September 15, 2010, 11:24:07 AM
I get this error too
"vpc_Message=Merchant+%5BREMOVED%5D+does+not+have+the+required+privilege+to+use+the+VirtualPaymentClient+API."
Does this mean my client does not have the correct account to even use virtuemart payment method? They see to have a online shop but I don't know how it is hosted and don't have access to it.
I'm having the same problem with the API thing
Title: Re: Intergration of Mastercard Gateway in Australia
Post by: Slashman on October 26, 2011, 11:42:44 AM
Hi all I just wanted to bump this back up with updates. I am in NZ and successfully integrated 3-party MIGS payment with ANZ eGate.

Tovio's zip file at reply #64-#65 of this thread is all I needed.

I have copied some lines of code before and after the changes I made so it will be easy to find in the files.

I had to make small changes to the following file to reflect the exact wording required for transactions. "checkout.result_migs.php"

Changed this original code:

case "0" : $result = "Transaction Successful"; break;
        case "?" : $result = "Transaction status is unknown"; break;
        case "1" : $result = "Unknown Error"; break;
        case "2" : $result = "Bank Declined Transaction"; break;
        case "3" : $result = "No Reply from Bank"; break;
        case "4" : $result = "Expired Card"; break;
        case "5" : $result = "Insufficient funds"; break;
        case "6" : $result = "Error Communicating with Bank"; break;
        case "7" : $result = "Payment Server System Error"; break;
        case "8" : $result = "Transaction Type Not Supported"; break;
        case "9" : $result = "Bank declined transaction (Do not contact Bank)"; break;
        case "A" : $result = "Transaction Aborted"; break;
        case "C" : $result = "Transaction Cancelled"; break;
        case "D" : $result = "Deferred transaction has been received and is awaiting processing"; break;
        case "F" : $result = "3D Secure Authentication failed"; break;
        case "I" : $result = "Card Security Code verification failed"; break;
        case "L" : $result = "Shopping Transaction Locked (Please try the transaction again later)"; break;
        case "N" : $result = "Cardholder is not enrolled in Authentication scheme"; break;
        case "P" : $result = "Transaction has been received by the Payment Adaptor and is being processed"; break;
        case "R" : $result = "Transaction was not processed - Reached limit of retry attempts allowed"; break;
        case "S" : $result = "Duplicate SessionID (OrderInfo)"; break;
        case "T" : $result = "Address Verification Failed"; break;
        case "U" : $result = "Card Security Code Failed"; break;
        case "V" : $result = "Address Verification and Card Security Code Failed"; break;
        default  : $result = "Unable to be determined";

To this:

case "0" : $result = "Transaction Approved"; break;
        case "?" : $result = "Transaction status is unknown"; break;
        case "1" : $result = "Transaction could not be processed"; break;
        case "2" : $result = "Transaction declined - contact issuing
bank"; break;
        case "3" : $result = "No reply from Processing Host"; break;
        case "4" : $result = "Card Expired"; break;
        case "5" : $result = "Insufficient credit"; break;
        case "6" : $result = "Error Communicating with Bank"; break;
        case "7" : $result = "Payment Server System Error"; break;
        case "8" : $result = "Transaction Type Not Supported"; break;
        case "9" : $result = "Bank Declined Transaction"; break;
        case "A" : $result = "Transaction Aborted"; break;
        case "C" : $result = "Transaction Cancelled"; break;
        case "D" : $result = "Deferred transaction has been received and is awaiting processing"; break;
        case "F" : $result = "3D Secure Authentication failed"; break;
        case "I" : $result = "Card Security Code verification failed"; break;
        case "L" : $result = "Shopping Transaction Locked (Please try the transaction again later)"; break;
        case "N" : $result = "Cardholder is not enrolled in Authentication scheme"; break;
        case "P" : $result = "Transaction has been received by the Payment Adaptor and is being processed"; break;
        case "R" : $result = "Transaction was not processed - Reached limit of retry attempts allowed"; break;
        case "S" : $result = "Duplicate SessionID (OrderInfo)"; break;
        case "T" : $result = "Address Verification Failed"; break;
        case "U" : $result = "Card Security Code Failed"; break;
        case "V" : $result = "Address Verification and Card Security Code Failed"; break;
        default  : $result = "Unable to be determined";

and to only display the required information after transaction is processed and display in NZD,

<!-- end branding table -->
        <center><h1><?php echo $errorTxt; ?>Response</h1></center>
        <table width="85%" align="center" cellpadding="5" border="0">
            <tr class="shade">
                <td align="right"><strong><i>Transaction Reference/Order Number: </i></strong></td>
                <td><?php echo $merchTxnRef ?></td>
            </tr>
            <tr>
                <td align="right"><strong><i>Purchase Amount (AUD, Australian dollars): </i></strong></td>
                <td><?php echo $amount_fmt ?></td>
            </tr>
            <tr>
                <td colspan="2" align="center">
                    <HR />
                </td>
            </tr>
            <tr class="shade">
                <td align="right"><strong><i>Response: </i></strong></td>
                <td><?php echo getResponseDescription($txnResponseCode) ?></td>
            </tr>
            <tr>
                <td align="right"><strong><i>Message: </i></strong></td>
                <td><?php echo $message ?></td>
            </tr>
<?php
    // only display the following fields if no error condition
    if ($txnResponseCode != "7" && $txnResponseCode != "No Value Returned") {
?>
            <tr class="shade">
                <td align="right"><strong><i>Receipt Number: </i></strong></td>
                <td><?php echo $receiptNo ?></td>
            </tr>
            <tr>
                <td align="right"><strong><i>Transaction Number: </i></strong></td>
                <td><?php echo $transactionNo ?></td>
            </tr>
            <tr class="shade">
                <td align="right"><strong><i>Bank Authorization ID: </i></strong></td>
                <td><?php echo $authorizeID ?></td>
            </tr>
            <tr>
                <td align="right"><strong><i>Batch Number: </i></strong></td>
                <td><?php echo $batchNo ?></td>
            </tr>
            <tr class="shade">
                <td align="right"><strong><i>Card Type: </i></strong></td>
                <td><?php echo $cardType ?></td>
            </tr>

to this:

<!-- end branding table -->
        <center><h1><?php echo $errorTxt; ?>Payment Transaction Overview</h1></center>
        <table width="85%" align="center" cellpadding="5" border="0">
            <tr class="shade">
                <td align="right"><strong><i>Transaction Reference: </i></strong></td>
                <td><?php echo $merchTxnRef ?></td>
            </tr>
            <tr>
                <td align="right"><strong><i>Purchase Amount (NZD): </i></strong></td>
                <td><?php echo $amount_fmt ?></td>
            </tr>
            <tr>
                <td colspan="2" align="center">
                    <HR />
                </td>
            </tr>
            <tr class="shade">
                <td align="right"><strong><i>Transaction Status: </i></strong></td>
                <td><?php echo getResponseDescription($txnResponseCode) ?></td>
            </tr>
         
<?php
    // only display the following fields if no error condition
    if ($txnResponseCode != "7" && $txnResponseCode != "No Value Returned") {
?>
            <tr class="shade">
                <td align="right"><strong><i>Receipt Number: </i></strong></td>
                <td><?php echo $receiptNo ?></td>
            </tr>
            <tr class="shade">
                <td align="right"><strong><i>Card Type: </i></strong></td>
                <td><?php echo $cardType ?></td>
            </tr>


Those were to display NZD not AUD and also it removed alot of the information not required by ANZ eGate Merchant Services. All you need is one unique identifier from your end as the merchant, and one unique identifier from eGate end to be displayed.

The other file to edit is: "get_final_confirmation.tpl.php"

The only changes here are to add the required logos to the checkout page.

<?php
if(  PSHOP_AGREE_TO_TOS_ONORDER == '1' ) {
   echo vmCommonHTML::scriptTag('', "function submit_order( form ) {
    if (!form.agreed.checked) {
        alert( \"". $VM_LANG->_('PHPSHOP_AGREE_TO_TOS',false) ."\" );
        return false;
    }
    else {
        return true;
    }
}" );
} else {
   echo vmCommonHTML::scriptTag('', "function submit_order( form ) { return true;  }" );
}
?>
<center><img src="http://www.yourdomain.co.nz/images/visav.gif"><img src="http://www.yourdomain.co.nz/images/master.gif"></center>
<center><img src="http://www.yourdomain.co.nz/images/egate.jpg"></center>
</div></div>

The eGate one is optional but I wanted to add it.

Hope it is as straightforward for you as it was for me and that my post helps anyone in NZ trying to do this.

I didnt even bother with their attached .do. dr zip files etc that eGate supplies you to get you started, I just went straight for Tovios zip.

Thanks,

Aaron.

P.S. The bottom Visa image you must display somewhere on your website but the Verified by Visa and MasterCard SecureCode must go on the last step checkout right before you get passed to ANZ eGate. In this case I added them right under the confirm order button.

[attachment cleanup by admin]
Title: Re: Intergration of Mastercard Gateway in Australia
Post by: egyguy on January 19, 2012, 16:28:34 PM
Quote from: Toivo Talikka on August 31, 2008, 06:25:38 AM
Hi,

The plugin in the previous post does not work with Joomla 1.5.  Here is a new version which has been tested on VirtueMart 1.1.2 and Joomla 1.5.6. 

Regards,
Toivo

Update 16/3/2010:  The attachment migs_bank_hosted_J15_VM11.zip from 31/8/2008 has now been restored, after it had been deleted inadvertently.
i want to thank you for your great help, you did save my day, i used this plug-in you have post and it working like a charm, i only have 2 questions:
1- does it work on both (test & production) mods
2- the process is going like this (My Shop checkout) > (MIGS Payment gateway) > (My Shop Order confirmation Page) is this is right or wrong ?
3- i am getting a string of transaction details in the location bar of the internet browser - how can i remove it for security reasons.

Thanks again for your king help
Title: Re: Intergration of Mastercard Gateway in Australia
Post by: adamwydeman on January 20, 2012, 10:57:43 AM
Quote from: Jabin on May 14, 2007, 07:40:58 AM
FYI:

I'm attempting to use this with the ANZ eGate MIGS, and am currently getting an usual error... "Secure Hash Not Calculated".   :)

The ANZ eGate "Virtual Payment Client URL" is: https://migs.mastercard.com.au/vpcpay
(without the "https://" being entered in the config.)

Relevant debug:

  • Debug: Using the cURL library for communicating with migs.mastercard.com.au/vpcpay
  • Debug: Beginning to analyse the response from migs.mastercard.com.au/vpcpay
  • Debug: Secure Hash Not Calculated
  • Error: 1
  • Error: Failure in Processing the Payment (ps_migs)


Jabin.

ANZ eGate uses a different system. You can download the custom file I have built here: http://adamwydeman.com/joomlacomponents/ANZ_j15_vm11.rar

Is built for Joomla 1.5x and VM 1.1 but has been installed and working on several VM 1.8 and 1.9 installations

Contact me if you need any help - www.adamwydeman.com
Title: Re: Intergration of Mastercard Gateway in Australia
Post by: toivo on January 20, 2012, 23:18:24 PM
QuoteANZ eGate uses a different system. You can download the custom file I have built
Adam,

Replacing "MIGS" globally with "ANZ" in the source code from http://forum.virtuemart.net/index.php?topic=19994.msg144050#msg144050 may allow you to call your cloned version a "custom" file, but it is customary in the Open Source community to credit the previous authors as well.

Toivo
Title: Re: Intergration of Mastercard Gateway in Australia
Post by: lalmohan on February 22, 2012, 08:23:26 AM
I need migs in joomla1.7,virtuemart 2.0 please help me
Title: Re: Intergration of Mastercard Gateway in Australia
Post by: tez on November 23, 2012, 02:14:59 AM
Where can I find a screenshot of the ANZ eGate bank hosted payment page? I'm trying to compare it against another option to see whether it is worth making a plugin for DirectOne or using the hosted plugin from this topic.
Title: Re: Intergration of Mastercard Gateway in Australia
Post by: tez on November 23, 2012, 04:34:26 AM
I got some screenshots by using this handy test data. It's annoying that there isn't any other way to test this out without actually having a test account, so I'm posting this here to help everyone out.

visa card number: 4005550000000001
any date
security code: 123

MerchantID: TESTANZTEST2
Merchant AccessCode: 8ED23813
Secure Hash: 5816DF2E29819E43EA7C1F6E0DC2F1B5

But my $1.00 purchases test still fails with Unspecified Error ( I assume this is because I shouldn't be using this test account ).



[attachment cleanup by admin]