PayPal integration framework and admin interface as well as IPN listener.
This plugins gives you a great framework to use for integrating with PayPal.
It stores both live and sandbox API credentials and allows you to switch back
and forth easily. All NVP API calls are passed through the framework and
default values such as API version, API credentials, and even currency code are
added to the request based on settings from the admin panel.
It also has a built in IPN listener that validates messages as coming from
PayPal then throws WordPress actions based on messages received. For example it
throws “paypal-recurring_payment_profile_cancel” when someone cancels a
recurring payment that they had set up with you. It passes along all the info
that PayPal sent to the action, so it’s simple to create other plugins that use
this one.
Requires PHP5.
You may also be interested in WordPress tips and tricks at WordPress Informer or gerneral Web Developer News
To send a request to PayPal, simply build the request as an associative array and pass it to the hashCall helper function like this:
$ppParams = array( 'METHOD' => 'doDirectPayment', 'PAYMENTACTION' => 'Sale', 'IPADDRESS' => '123.123.123.123', 'AMT' => '222.22', 'DESC' => 'some product', 'CREDITCARDTYPE' => 'VISA', 'ACCT' => '4111111111111111', 'EXPDATE' => '112011', 'CVV2' => '123', 'FIRSTNAME' => 'Aaron', 'LASTNAME' => 'Campbell', 'EMAIL' => '[email protected]', 'STREET' => '123 some pl', 'STREET2' => '', 'CITY' => 'San Diego', 'STATE' => 'CA', 'ZIP' => '92101', 'COUNTRYCODE' => 'US', 'INVNUM' => '12345', ); $response = hashCall($ppParams);
First you have to tell PayPal to send message to the correct URL. Go to the
PayPal Framework settings page and click the “PayPal IPN Listener URL” link to
see instructions on how to use the URL that’s listed there. Once your PayPal
account has been set up the listener will automatically process all IPN messages
and turn them into WordPress actions that you can hook into. You can use the
‘paypal-ipn’ action to look at every message you ever get, or hook directly into
a ‘paypal-{transaction-type}’ hook to process a specific type of message:
add_action('paypal-ipn', 'my_process_ipn'); function my_process_ipn( $data ) { echo 'Processing IPN Message:<pre>'; var_dump( $data ); echo '</pre>'; } add_action('paypal-recurring_payment_failed', 'my_process_ipn_recurring_payment_failed'); function my_process_ipn_recurring_payment_failed( $data ) { echo 'A recurring payment has failed. Here is the data I have to process this:<pre>'; var_dump( $data ); echo '</pre>'; }
Many servers have out of date certificate lists, so this is necessary to be as
portable as possible. However, if your server is set up right you can force
sslverify like this:
add_filter( 'paypal_framework_sslverify', '__return_true' );