Adding Simple Payment Processing to Drupal Site

2011-04-14

Pramod Jain

Adding Simple Payment Processing to Drupal Site

How to integrate PayPal payment processing into a Drupal website using LM_Paypal module.

I had a need to add simple payment processing to a Drupal website; I did not want to useUbercartor any other eCommerce modules, orCiviCRM.Here were my basic requirements:

  • Users register for a course using a web form page
  • After registration user is taken to a payment page
  • Payment is then processed by Paypal
  • After payment is processed, user is directed back to the site

In this simple payment processing example, I did not want any payment confirmation.For example, if a user registers and then does not complete payment then in this simple method, there would be no automated check or flag; the admin would have to manually check and match the registration and payment records. In order to accomplish this, I looked at two modules:Simple_PaypalandLM_Paypal.Simple_Paypal is till in test mode for Drupal 6, so it is not ready for deployment.LM_Paypal was used for this example.Following steps were used:

  1. Install lm_paypal module in normal location (/sites/all/modules/)

  2. Enable the module at http://mysite…/admin/build/modules

  3. Configure the module at http://mysite…/admin/settings/lm_paypal/settings

  4. The first field is LM PayPal Business/Premier Email:

    Create an account with Paypal and use the email address registered with Paypal

  5. Use default values for the next 2 fields.  Use the sandbox address while testing

  6. While testing check on the two checkboxes

  7. Last step in configuration is to go to http://mysite…/admin/settings/lm_paypal/donations_settings.  Here enter a URL; this URL is used by Paypal after the payment processing is complete.

  8. Next, we need to put a “Pay” link on a webpage.  Here is the code:

'; // The amount is a one element array so an text input with the one value as // default // print 'Write your own amount to give, we suggest $5' . // lm_paypal_donate(array(5), 'USD', 'donation to example.com') . ' '; // The amount is a multi element array so a select will be used. Note if one // of the elements is itself an array that will be the default selection // The final two parameters are an alternative button (here we use the default) // and a replacement label before the amount // print 'We would really like a $10, or more, donation ' . // lm_paypal_donate(array(5,array(10),15), 'USD', 'donation to example.com', '', 'Donation') .' '; } ?>

This completes the setup of simple payment processing.