Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

adding paypal to existing cgi script

Posted on 2004-04-22
6
215 Views
Last Modified: 2013-12-25
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
0
Comment
Question by:hummerrecord
  • 3
  • 3
6 Comments
 
LVL 3

Expert Comment

by:cjmos
ID: 10895374
Hi, take a look at
Business::PayPal::IPN

http://search.cpan.org/~sherzodr/Business-PayPal-IPN-1.94/IPN.pm
0
 

Author Comment

by:hummerrecord
ID: 10895759
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.

0
 

Author Comment

by:hummerrecord
ID: 10922572
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.....
0
How Do You Stack Up Against Your Peers?

With today’s modern enterprise so dependent on digital infrastructures, the impact of major incidents has increased dramatically. Grab the report now to gain insight into how your organization ranks against your peers and learn best-in-class strategies to resolve incidents.

 
LVL 3

Expert Comment

by:cjmos
ID: 10930058


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";
0
 
LVL 3

Accepted Solution

by:
cjmos earned 500 total points
ID: 10930090
In case you can't see any difference,

notice the use of $i int the lines

 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";
0
 

Author Comment

by:hummerrecord
ID: 10930341
Hi cjmos

You are right....I figured it out yesterday...but thank you for you input....

take care

hummer
0

Featured Post

Space-Age Communications Transitions to DevOps

ViaSat, a global provider of satellite and wireless communications, securely connects businesses, governments, and organizations to the Internet. Learn how ViaSat’s Network Solutions Engineer, drove the transition from a traditional network support to a DevOps-centric model.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Example unit tests with AngularJS 3 47
Recursively Delete Files 5 93
Powershell File Sort 8 41
PowerShell logging 1 13
Recently I have been answering a lot of questions like this in IT forums that I frequent. The question posed is usually something along the lines of "We have software X installed and need to uninstall it for reason Y" or some other variant of the sa…
Batch, VBS, and scripts in general are incredibly useful for repetitive tasks.  Some tasks can take a while to complete and it can be annoying to check back only to discover that your script finished 5 minutes ago.  Some scripts may complete nearly …
Viewers will get an overview of the benefits and risks of using Bitcoin to accept payments. What Bitcoin is: Legality: Risks: Benefits: Which businesses are best suited?: Other things you should know: How to get started:
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question