hummerrecord
asked on
adding paypal to existing cgi script
Hi
I have an existing shopping cart on my site. I would like to add Paypal as an option for payment. Right now the choices for payment are credit card on line, credit card through fax and cheque by mail. I would like to subsitute both credit card options with the paypal option but keep the cheque by mail.
I know this is a very vague question but is there a sub that I can add to my existing cgi script? This is an older Webgenie script by the way and I don't want to spend anymore money on buying a new cart.
any help would be appreciated.
Thanks
hummer
I have an existing shopping cart on my site. I would like to add Paypal as an option for payment. Right now the choices for payment are credit card on line, credit card through fax and cheque by mail. I would like to subsitute both credit card options with the paypal option but keep the cheque by mail.
I know this is a very vague question but is there a sub that I can add to my existing cgi script? This is an older Webgenie script by the way and I don't want to spend anymore money on buying a new cart.
any help would be appreciated.
Thanks
hummer
ASKER
Hi cjmos
Thanks for the redirect....however...I must admit I am a know just enought to be dangerous.....so although I understand some of this....I am still not sure how to implement it into the shopping cart script.
Thanks for the redirect....however...I must admit I am a know just enought to be dangerous.....so although I understand some of this....I am still not sure how to implement it into the shopping cart script.
ASKER
okay
well I am a step closer and actually have figured out how to add the paypal code to my existing cgi script....the code is as follows
$i = 0; # Just a number to define form elements
foreach $item (@items)
{
if ($item)
{
if ($item =~ /,/)
{
$i++;
@components = split (/,/, "$item");
$qty = @components[1];
$price = @components[2];
$product = @components[3];
$catNo = @components[4];
$weight = @components[5]*$qty;
$totWeight += $weight;
$tot = $qty*$price;
$gtot += $tot;
$tot = &Monify ($tot);
$price = &Monify ($price);
print "<input type=hidden name=item_name_1 value=\"$product\">\n";
print "<input type=hidden name=item_number_1 value=\"$catNo\">\n";
print "<input type=hidden name=amount_1 value=\"$price\">\n";
print "<input type=hidden name=quantity_1 value=\"$qty\">\n";
}
}
}
print "<input type=image src=\"http://images.paypal.com/images/x-clickbut01.gif\" name=submit alt=\"Make payments with PayPal - it?s fast,free and secure\">\n";
print "</form>\n";
the problem is only the 1st item is being passed to paypal....I need to increment the name values....for example
item_number_1, item_number_2, item_number_3 etc....for eachof the names in the form inputs.....
well I am a step closer and actually have figured out how to add the paypal code to my existing cgi script....the code is as follows
$i = 0; # Just a number to define form elements
foreach $item (@items)
{
if ($item)
{
if ($item =~ /,/)
{
$i++;
@components = split (/,/, "$item");
$qty = @components[1];
$price = @components[2];
$product = @components[3];
$catNo = @components[4];
$weight = @components[5]*$qty;
$totWeight += $weight;
$tot = $qty*$price;
$gtot += $tot;
$tot = &Monify ($tot);
$price = &Monify ($price);
print "<input type=hidden name=item_name_1 value=\"$product\">\n";
print "<input type=hidden name=item_number_1 value=\"$catNo\">\n";
print "<input type=hidden name=amount_1 value=\"$price\">\n";
print "<input type=hidden name=quantity_1 value=\"$qty\">\n";
}
}
}
print "<input type=image src=\"http://images.paypal.com/images/x-clickbut01.gif\" name=submit alt=\"Make payments with PayPal - it?s fast,free and secure\">\n";
print "</form>\n";
the problem is only the 1st item is being passed to paypal....I need to increment the name values....for example
item_number_1, item_number_2, item_number_3 etc....for eachof the names in the form inputs.....
hummerrecord, the $i variable is used to increment item_numer for each item. Replace your code with.
$i = 0; # Just a number to define form elements
foreach $item (@items)
{
if ($item)
{
if ($item =~ /,/)
{
$i++;
@components = split (/,/, "$item");
$qty = @components[1];
$price = @components[2];
$product = @components[3];
$catNo = @components[4];
$weight = @components[5]*$qty;
$totWeight += $weight;
$tot = $qty*$price;
$gtot += $tot;
$tot = &Monify ($tot);
$price = &Monify ($price);
print "<input type=hidden name=item_name_$i value=\"$product\">\n";
print "<input type=hidden name=item_number_$i value=\"$catNo\">\n";
print "<input type=hidden name=amount_$i value=\"$price\">\n";
print "<input type=hidden name=quantity_$i value=\"$qty\">\n";
}
}
}
print "<input type=image src=\"http://images.paypal.com/images/x-clickbut01.gif\" name=submit alt=\"Make payments with PayPal - it?s fast,free and secure\">\n";
print "</form>\n";
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi cjmos
You are right....I figured it out yesterday...but thank you for you input....
take care
hummer
You are right....I figured it out yesterday...but thank you for you input....
take care
hummer
Business::PayPal::IPN
http://search.cpan.org/~sherzodr/Business-PayPal-IPN-1.94/IPN.pm