[Date Prev][Date Next][Thread Prev][Thread Next][Interchange by date
][Interchange by thread
]
[ic] Integrating a South African Payment Gateway through globalsub - Problem
Hi List
I'm working kind of in the dark over here in South Africa, and was hoping
you guys could give me a hand. My setup is as follows:
PIII 128MB RAM
OpenBSD 2.8 - standard perl, Apache, MySQL etc
Interchange::Bundle up to date
Interchange running fine
Now I've got to integrate a SA payment gateway - iVeri - and I want to do
this through a globalsub
I found a iTransact module that a guy put on the mail archive, using LWP to
submit to the gateway, receive back, and then continue to receipt page. I
hacked this with my own parameters and replaced urls, defined a few
Variables for the catalog.cfg. Here's the globalsub I ended up with:
GlobalSub <<EOS
sub iVeri {
my %actual = Vend::Order::map_actual();
$actual{mv_credit_card_exp_month} =~ s/\D//g;
#I believe Iveri needs "07" style month
#$actual{mv_credit_card_exp_month} =~ s/^0+//;
$actual{mv_credit_card_exp_year} =~ s/\D//g;
#I also think this will cause problems
# my $exp_year = $actual{mv_credit_card_exp_year};
# $exp_year += 2000 unless $exp_year =~ /\d{4}/;
$actual{mv_credit_card_number} =~ s/\D//g;
my $address = $actual{b_address1};
my $address .= ", $actual{b_address2}" if $actual{b_address2};
::logDebug("address: $address\n actual-address: " . $actual{address});
#make a custom orderid
my($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = gmtime(time());
my $orderID = sprintf("%02d%02d%02d%02d%02d%05d%s", $year + 1900,$mon +
1,$mday,$hour,$min,$Vend::SessionName);
#put total amount in cents
my $totalamount = Vend::Interpolate::total_cost()*100.0;
#put sub total in cents
my $subtotal = Vend::Interpolate::sub_total()*100.0;
#put shipping into cents
my $shipping = Vend::Interpolate::shipping()*100.0;
#put salestax into cents
my $salestax = Vend::Interpolate::salestax()*100.0;
my %values = (
Direct_On_Error_Resume_Next => "True"
Direct_Website_Successful_url =>
$::Variable->{MV_IV_BACK_URL},
Direct_Website_Fail_url =>
$::Variable->{MV_IV_BACK_URL},
Direct_Website_TryLater_url =>
$::Variable->{MV_IV_BACK_URL},
Direct_Website_Error_url =>
$::Variable->{MV_IV_BACK_URL},
Direct_Merchant_ApplicationID =>
$::Variable->{MV_IV_MERCHANTID},
Direct_AutoInvoice_Ext => "INV",
Ecom_TransactionComplete => "False",
Direct_Order_LineItems_Product_3 => "Shipping
Charge",
Direct_Order_LineItems_Quantity_3 => "1",
Direct_Order_LineItems_Amount_3 => $shipping,
Direct_Order_LineItems_Product_1 => "Order
Subtotal",
Direct_Order_LineItems_Quantity_1 => "1",
Direct_Order_LineItems_Amount_1 => $subtotal,
Direct_Order_LineItems_Product_2 => "Sales Tax
Charge",
Direct_Order_LineItems_Quantity_2 => "1",
Direct_Order_LineItems_Amount_2 => $salestax,
Ecom_ConsumerOrderID => $orderid,
Direct_Order_Amount => $totalamount,
Ecom_BillTo_Online_Email => $actual{email},
Ecom_Payment_Card_Number =>
$actual{mv_credit_card_number},
Ecom_Payment_Card_ExpDate_Month =>
$actual{mv_credit_card_exp_month},
Ecom_Payment_Card_ExpDate_Year =>
$actual{mv_credit_card_exp_year},
Ecom_Payment_Card_StartDate_Year => "1999",
Ecom_Payment_Card_StartDate_Month => "07",
Ecom_Payment_Card_Protocols => "Iveri"
);
my $submit_url = "https://www.iveri.co.za/Direct/Authorise.asp";
use LWP::UserAgent;
use HTTP::Request::Common qw(POST);
my $ua = LWP::UserAgent->new();
my $req = POST $submit_url, \%values;
my $resp = $ua->request($req);
my %result;
## check for errors
my $error;
unless ($resp->as_string() =~ m/Location: success/) {
my $content = $resp->content();
if ($content =~ m/BEGIN ERROR DESCRIPTION --\>(.*)\<\!-- END ERROR
DESCRIPTION/s) {
$error = $1;
$error =~ s/\<.*?\>//g;
$error =~ s/[^-A-Za-z_0-9 ]//g;
} else {
## something very bad happened
$error = "something bad happened--we don't know what is is.";
}
::logError("iVeri Error: " . $error);
$result{MStatus} = 'denied';
$result{ErrMsg} = $error;
return %result;
}
## at this point, we assume everything worked just fine
$result{MStatus} = 'success';
$result{'order-id'} = "1";
return %result;
}
EOS
I've added the #include globalsubs/iVeri to interchange.cfg, and here are
some excerpts from my catalog.cfg :
### These reflect the initial settings set above;
### if you uncomment them they will override it.
#
#Variable SERVER_NAME test.assetsco.co.za
#Variable CGI_URL /cgi-bin/assetsco
#Variable SECURE_SERVER http://test.assetsco.co.za
#Variable ORDERS_TO market
#Variable IMAGE_DIR /images
#Variable DOCROOT /var/www/websites/assetsco/htdocs
#Variable SAMPLEHTML /var/www/websites/assetsco/htdocs
#Variable SAMPLEURL http://test.assetsco.co.za/
#
#Variable COMPANY The Assets Holding Co.
#Variable ENCRYPTOR none
#
#Variable SOMESQL 1
#Variable MYSQL 1
#Variable PGSQL
#Variable ORACLE
#Variable SQLDSN dbi:mysql:assetsco
#Variable SQLDB assetsco
#Variable SQLUSER market
#Variable SQLPASS saidar
Variable MV_IV_BACK_URL
http://test.assetsco.co.za/cgi-bin/assetsco/process.html
Variable MV_IV_MERCHANTID ***********************************
#i've blocked this for mail list security reasons
## END SITE CONFIGURATION
Variable MV_PAYMENT_MODE custom iVeri
# Uncomment to use creditCardAuto if you want, now handled better in
# order profiles with "&credit_card=standard".
#CreditCardAuto Yes
# These are usually all you need for CyberCash 3
# Uncomment and edit to suit; make sure you remove CreditCardAuto somehow
#
#Variable CYBER_CONFIGFILE
/home/you/yourid75/mck-cgi/merchant_conf
#Variable CYBER_VERSION 3.2
#Variable CYBER_MODE mauthonly
#ifdef CYBER_MODE
#Variable MV_PAYMENT_MODE mauthonly
CreditCardAuto No
#endif
EncryptProgram __ENCRYPTOR__
# Here you can set up fatal errors if a necessary sub or usertag
# doesn't exist, uncomment one of next lines to test
#
#Require globalsub nevairbe
#Require usertag nevairbe
Require usertag email
Require usertag email_raw
Require usertag var
Require usertag loc
Require usertag summary
Require usertag button
As far as I can figure, this side is OK. However upon restart I get an
error message of :
Sending debug to /tmp/icdebug.
Low traffic settings.
Calling UI....
...UI is loaded....
Bad GlobalSub 'iVeri'
In line 107 of the configuration file 'globalsubs/iVeri':
GlobalSub <<EOS
Bad GlobalSub 'iVeri'
In line 107 of the configuration file 'globalsubs/iVeri':
GlobalSub <<EOS
Line 107 is the EOS at the end of my globalsub. I've checked the syntax,
the permissions are all set to market (the ic user), and I'm convinced the
error has nothing to do with the actual contents of the sub - it seems
there's a general problem with how I've tried to incorporate the globalsub.
The userdocs are really unhelpful, it would be nice if there was a gentle
kind of demo of the full process of writing a globalsub.
Anyhow, sorry to moan, but I really could use some guidance here, I need to
get this thing working asap. Any help would be most welcome, especially if
you consider the globalsub could maybe be added to the ic distribution to
help future hapless SA users like me.
Thanks in advance, and Mike and the Akopia guys keep the great IC work up.
Regards
Paul Du Bois
East Coast Access
Durban, South Africa