[FIX] MyVirtualMerchant (Module for Elavon/Costco) Updated

CharlieFoxtrot

2009-09-01 11:25:40

The "MyVirtualMerchant" payment module for ISC 4.07 appears to have a bug that causes it to send improperly formatted data to the payment gateway.



NOTE: This bug may have been fixed in subsequent releases that I'm not qualified to receive... but if not, here's my quick-fix for it.



The Problem: MyVirtualMerchant requires that the transaction amount (ssl_amount) be in the following format: XXX.xx ... with only TWO digits beyond the decimal point. ~ It appears that this module sends the transaction amount as XXX.xxxx ... with FOUR digits beyond the decimal.



I can't tell if the value contains four decimal places because of something in the ISC code, or if it's a server configuration that's causing it. But even if it's due to a non-standard server configuration, the ISC script needs to handle it.



If the payment processor receives a number with four decimal places, the transaction is rejected. So we need to trim off any excess before submitting the data. Just below are the two minor changes that I made to the module.



INSTRUCTIONS: Open the file \modules\checkout\myvirtualmerchant\module.myvirtualmerchant.php



Find (near line 91):



$amount = ($this->GetGatewayAmount());


Add just below:



$amount = substr($amount,0,-(strlen(strrchr($amount,'.'))-3));


Next... find (near line 117)



$myvPostData['ssl_amount'] = $this->GetGatewayAmount();


Replace with:



// $myvPostData['ssl_amount'] = $this->GetGatewayAmount();
$myvPostData['ssl_amount'] = $amount;


I like to comment-out the original lines (instead of deleting them). It's helpful to me in case I need to make some quick-fixes later on, and I can easily restore it without having to refer to a backup version.



Good luck!

Charlie



PS: When spell-checking this post, my browser didn't recognize "MyVirtualMerchant"... so it suggested "Befuddlement". :)





edit: I found a more elegant way to do this that will not round-up or round-down the numbers.

ideahost

2009-10-11 22:45:58

AWESOME! I spent 22 hours checking and searching all of my code, nearly every ini file, every database, trying to figure out WHY, oh WHY my $1 purchase was an "invalid amount" as I was heck-bent on sticking with MyVirtualMerchant after all of the effort to work with them and my cart was nearly ready and this was driving me crazy and.... :twisted:



Your code edits worked PERFECTLY! Took my under two minutes, start to finish (okay, well, 22 hours, two minutes).



THANK YOU THANK YOU THANK YOU..... :D :D :D

All in all, the cart is fairly graceful, once you get past the things that go bump in the night...

CharlieFoxtrot

2009-10-11 23:22:53

You're welcome! ~ I'm glad to hear the good news! :D