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

Specific Information relating to Version 4.x only
Post Reply
CharlieFoxtrot
Confirmed
Confirmed
Posts: 413
Joined: Sun Aug 09, 2009 1:23 pm

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

Post by CharlieFoxtrot »

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):

Code: Select all

$amount = ($this->GetGatewayAmount());
Add just below:

Code: Select all

$amount = substr($amount,0,-(strlen(strrchr($amount,'.'))-3));
Next... find (near line 117)

Code: Select all

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

Code: Select all

// $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.
ISC 4.0.7

"... and let's be honest that whole "by design" thing is getting old too."
ideahost
Posts: 3
Joined: Sun Oct 11, 2009 11:18 pm

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

Post by ideahost »

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
Confirmed
Confirmed
Posts: 413
Joined: Sun Aug 09, 2009 1:23 pm

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

Post by CharlieFoxtrot »

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

"... and let's be honest that whole "by design" thing is getting old too."
Post Reply