I built our website to be 100% automated and dynamic, including adding additional merchant accounts.
I created an administrative back office to manage the website, including adding new merchant accounts.
I was building it where they had the same subroutine in the file, named: chargeCard.
Then I named the file the name of the database Name, and then when it picked the Merchant Account to use I would do a require:
require "/home/path/to/ma/files/$_fileName.conf";
however, we have a 25M limit with one bank that the gateway is a custom gateway that does not support discover cards yet, so I have my programming pick one of the authorize.net accounts we have if it is a discover card and then all others go to the main merchant account.
Now we discovered that we are getting about 30 declines per day, which when we force them to one of the authorize.net accounts it is approved 9 out of 10 times.
So now I want to use BOTH in the instance that the first one is declined. In view of that I made them modules.
My question is this, how can I pull them in, if the file to use is a variable:
use strict;
my ($sth, $_mad);
$sth = $dbh->prepare(qq{SELECT * FROM `merchantAccounts` WHERE `u` = "
+1" AND (`volume_capable` < (`current_volume` + $_GrandTotal))});
$sth->execute();
$_mad = $sth->fetchrow_hashref();
$sth->finish();
my $_madFile = $_mad->{name};
use MA::$_madFile;
Of course with that I get an error: syntax error at /path/to/subs.data line 174, near "use MA::$_madType"
I've also tried that code with this 'use' statement:
my $_madFile = 'MA::' . $_mad->{name};
use $_madFile;
# AND I've tried it this way:
use "$_madFile";
I get the same errors every time.
So How can I do this with a variable name, so that I can pull in several files at one time and call them like this:
$_cardCharged = MA::$_madFile::chargeCard();
I'd appreciate any assistance or pointers you have for me.
Richard
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.