PayPal Integration (REST API)

RSVPMaker now integrates with PayPal via its REST application programming interface (API).

If you previously set up integration with the older Express Checkout / NVP API method, RSVPMaker still supports it. PayPal also still supports it but is not adding new features to that version. You probably want to switch to the new method anyway because the user experience is better and more tightly integrated with your website.

The pay by PayPal / pay by credit card buttons will appear as part of the confirmation message when someone registers for one of your events.

PayPal payment buttons

Attendees who click on the PayPal button will get a pop up prompt inviting them to log in and pay.

PayPal login prompt

Those who prefer to pay by credit card can click one of the credit card icons (or the button on the screen above that says Pay with Debit of Credit Card) and be prompted for credit card information.

To obtain the required credentials for the REST API, go to developer.paypal.com and log in with your PayPal password. The developer’s dashboard allows you to register multiple sandbox accounts for testing and create an app for your integration. Creating an app just means you are generating the API access keys required for the integration with RSVPMaker. Just give your app a name, associate it with a sandbox account for testing, and click the Create App button.

Creating an App

Then copy the keys (the client id and client secret) for both the Sandbox (test) and Live versions of the app.

Copying the client id and client secret.

Once you have copied and pasted all the credentials, into the Payments Tab of the RSVPMaker settings, it’s a good idea to toggle the Operating Mode setting from Production to Sandbox. Create a sample event with sample pricing and test the integration. For testing, you can make payments using one of the sandbox accounts associated with your developer account on PayPal, which is funded by imaginary money.

Once you are satisfied that everything is working properly, go to the Payments tab in RSVPMaker settings and toggle the integration from Sandbox to Production to accept live payments.

Here is a quick video demo:

Developer Functions for Extending RSVPMaker

If you are creating a custom events website for which RSVPMaker is the foundation but you want to add your own flourishes, you should be aware of several utilities functions.

I created these for my own selfish purposes. As someone who customizes events for specific purposes, I have gradually gotten to the point where I don’t want to deal with the internal complexities of my own plugin. And from studying the APIs of other software I’ve had occasion to modify or extend, I’ve started to figure out what that ought to look like for RSVPMaker.

Here are a few basic functions that are useful if you are trying to get events data out of the system and display it in some custom manner, for example in a widget or a shortcode different from the ones RSVPMaker includes.

To get a listing of future events use get_future_events:

The variable $events will be an array of objects, each of which represents an event post. The event post objects include all the usual blog post fields such as post_title, post_author, post_content, with the additional fields datetime (the SQL timestamp for the date and time of the event) and date (date formatted as Month Day, Year as in July 6, 2017). You can add where and limit parameters to the query. You then loop through the results like in this example using a shortcode.

The full function signature is

Changing the $output parameter from OBJECT, the default, to ARRAY_A, would give you an associative array for each event. The fourth parameter, $offset_hours is used to prevent events from expiring off the list the moment their start time is past. I’ve come across a number of situations where it’s preferable to have an event displayed several hours past the start time, for example so people who are arriving late or are in the middle of the meeting can still look up details such as the agenda or location.

There is also get_past_events function, which works almost the same way (no $offset_hours parameter) but lists past events starting with the most recent and counting backwards.

Here’s an example that would pull in all the past events since the start of 2017.

You can retrieve a single event using get_rsvp_event. It accepts 2 parameters, $where and $output (defaults to OBJECT)

or

Here are a few others that might come in handy.

Use get_events_by_template to retrieve all the events associated with a specific template, in ascending date order by default and as row objects by default.

Count of future events (no parameters)

Get the date associated with an event, based on ID, with get_rsvp_date. SQL date will be returned. To format, you might use strtotime as in this example.

Because a single event can span multiple dates, there is also a get_rsvp_dates function that returns an array of timestamps. This is also the version you would have to use if you also want to retrieve the event duration. Look at the rsvp_date_block function in rsvpmaker-pluggable.php for an example of how RSVPMaker uses this internally to display the date or dates at the top of an event post.

To test whether an event is in the future, use:

The $event_id is the post ID, while $offset_hours (default = 0) is the number of hours past the start time where this will return true. For example, you wouldn’t necessarily want it to evaluate to false for an all-day event.

To retrieve the same values you would get from the rsvpmaker_upcoming shortcode (or the comparable Gutenberg block), you can use:

This returns an array of rows that you can feed into your own display function.

$atts is an array of the same attributes you would use with the shortcode. Examples: $atts[‘posts_per_page’] (default: 10) or $atts[‘days’] (days worth of results to include (default: 365). The stricter of the two limits will be applied.

To check whether an event is based on a template, this function will return either the ID of the template or false if there is none.

Can I Help?

If you would like help creating custom events websites, I am available as a consultant. Drop me a note at david@rsvpmaker.com. Some of the customizations I’ve worked on over the past couple of years include:

  • Signups for volunteer roles at a rifle range, with a reporting back end to show which roles are filled versus open for each shift.
  • A network of membership-based event websites for a nonprofit organization (Toastmasters), set up as subdomains using WordPress multisite. Chapter officers can sign up to get a free site, using a custom user and site registration process. They can then manage their own events and create accounts for their own members. They can collect event registrations via RSVPMaker but also sign members up to fill specific roles using the WordPress for Toastmasters extensions.
  • In a couple of cases, I’ve made signing up for MailChimp a prerequisite for creating a user account. The MailChimp confirmation message directs people back to a website page with a coded url that includes their email address. Before the signup form will display, their subscription must be verified via the MailChimp API.

Toward a Proper API

Going back to 2010, RSVPMaker has included a mechanism for developers to override pluggable functions with their own versions. The functions documented above represent the beginnings of a cleaner API.