PHP - how to pay using paypal,credit card in an online system

Asked By chandana on 03-Oct-11 01:41 AM
i need to know how to use paypal ,credit card methods for online payment system in php
pls help me..
smr replied to chandana on 03-Oct-11 01:46 AM


You'll have to use Paypal IPN for that. My site runs with Perl, but the way it basically works is as follows:

  1. Customer fills out an order form at my site with their name, address, email.
  2. Customer is being redirected to Paypal
  3. Upon successful payment via Paypal, Paypal calls my IPN-compliant script
  4. My script sends me an e-mail notifying me about the completed order

If the customer does not pay within 30 minutes or so, my database also sends him a reminder with a Paypal payment link for the respective order. 

Follow these links also-

Hope this will help you.

dipa ahuja replied to chandana on 03-Oct-11 01:46 AM
$this_script = 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'];
// if no action variable, set 'process' as default action
if (empty($_GET['action'])) $_GET['action'] = 'process';
switch ($_GET['action']) {
case 'process': // Process and order...
$p->add_field('business', 'PAYPAL EMAIL ADDRESS');
$p->add_field('return', $this_script.'?action=success');
$p->add_field('cancel_return', $this_script.'?action=cancel');
$p->add_field('notify_url', $this_script.'?action=ipn');
$p->add_field('item_name', 'PAYPAL TEST'); // 'ITEM NAME'
$p->add_field('amount', '100'); // 'ITEM AMOUNT'
$p->add_field('currency_code', 'USD');//CURRENCY VALUE USD/EUR…
$p->submit_paypal_post(); // submit the fields to paypal
case 'success': // successful order...
echo "
Thank you for your order!
foreach ($_POST as $key => $value) {
echo "$key: $value";
echo "";
case 'cancel': // Canceled Order...
echo "
The order was canceled.
echo "";
case 'ipn': // For IPN validation...
if ($p->validate_ipn()) {
$subject = 'Instant Payment Notification - Recieved Payment';
$body="An instant payment notification was successfully recieved\n";
$body .= "from ".$p->ipn_data['payer_email']." on ".date('m/d/Y');
$body .= "\n\nDetails:\n";
foreach ($p->ipn_data as $key => $value) {
$body .= "\n$key: $value";
@mail($to, $subject, $body);

Reena Jain replied to chandana on 03-Oct-11 01:51 AM

whenever you need to work with a 3rd party API or a gateway, you’d first search in Google for a possible wrapper for it in PHP. When it comes to supporting payment gateways, you get bunch of libraries in the search results who are fundamentally different. Some of them are old PHP 3/4 ones, some are new, some may need PEAR, etc.

As they were not required together in one single project, I used them whenever needed. But in one project, I needed them all. I thoughts it’s a chance and decided to stop using them and wrote my own ones where I can use the same methods for all the gateways.

So, here is an abstract PaymentGateway library which is being extended to be used for three popular payment gateways (Paypal,, and 2Checkout) in order to provide you with a similar way of using them. Note that the libraries are for basic usage only and do not contain options for recurring payments. Without much babble, let’s see a few examples of how you can use them

PayPal provides the following downloads to help you integrate PayPal into your website.

Lalit M replied to chandana on 03-Oct-11 02:53 AM
Anoop S replied to chandana on 03-Oct-11 03:45 AM
Working with paypal -refer this

Sample Code

Use working sample code and snippets to speed up your PayPal integrations. Download PHP, Java,  and ASP.NET  sample code for a range of PayPal products.

Integration Wizard

The Integration Wizard will generate code for your Express Checkout or Payflow integration:

PayPal APIs

You can also download all the code samples (including supporting property and library files needed) for NVP or SOAP: