The Recurly PHP Client library is an open source library to interact with Recurly's subscription management from your PHP website. The library interacts with Recurly's REST API.
If you already have git, the easiest way to download the Recurly PHP Client is with the git command:
git clone git://github.com/recurly/recurly-client-php.git /path/to/include/recurly
Alternatively, you may download the PHP files in the library directory and place them within your PHP project.
First, the Recurly classes must be loaded. Next, specify your username and password for your Recurly API user. Note, you must use an API user to connect with the PHP client. Please see the Authentication documentation for more details.
<?php
require_once('recurly/library/recurly.php');
RecurlyClient::SetAuth(RECURLY_API_USERNAME, RECURLY_API_PASSWORD, RECURLY_SUBDOMAIN);
?>
Please see the test code in the unittest/ directory for examples.
Please see the documentation and support forums for more information.
Create a new PHP script to receive the Push Notification:
<?php
require_once('recurly/library/recurly.php');
RecurlyClient::SetAuth(RECURLY_API_USERNAME, RECURLY_API_PASSWORD, RECURLY_SUBDOMAIN);
$post_xml = file_get_contents ("php://input");
$notification = new RecurlyPushNotification($post_xml);
// process based on $notification->type
?>
Be sure to update your Recurly site settings to submit POST Notifications to your new script.
Please see /demo/subscribe.php for an example subscription page.
Please see the Recurly API for more information.