How to use API Online Giving Service to Track Single Gifts

Have you ever wanted to insert SINGLE online giving gifts into Church Community Builder (CCB) but not process payments?

Let’s say your church hosts a conference or event that doesn’t utilize CCB’s registration, event management and payment processing capabilities.

However, you want to track the online giving gifts associated with conference or event within CCB.

Today’s tutorial shares exactly how to successfully do just that.

This tutorial is not to be confused with a tutorial delivered a month or so ago: How to Import Online Gifts Using CCB’s API.

The difference in the aforementioned tutorial and today’s tutorial is this tutorial today focuses on singular entry (one) where as the last month’s tutorial focused on batching multiple gifts at one time (more than one).

The same principles apply, yet only for single gift entry instead of bulk import. Also, worth stating that this tutorial and API service DOES NOT process payments.

Without further ado, let’s get started!

Service, Required and Optional Variables

Much of this tutorial is built upon the aforementioned tutorial, so I won’t spend much time diving into the details (read the previous tutorial).

For now, open a text editor of your choice, naming and saving the following PHP file: online-giving-insert-gift.php.

Be sure to include necessary files and comments as previous tutorials contain.

Next, define the apiService variable to have the following value: online_giving_insert_gift.

To learn more about this service,  please read CCB’s Public Web API Documentation.

Speaking of CCB API documentation, you’ll want to read up a bit on the required and optional parameters.

Although I list both required and optional parameters with a few simple usage comments and instructions to adhere too, I’m only using the required parameters to execute this tutorial.

Making the API Call

Once service, required, and optional parameter variables have been accurately defined, you’re ready to bind defined variables to their respective API service labels in preparation of making the CCB API call.

To do so, create a urlData variable, setting it equal to an encapsulated key-value pair array using PHP’s built-in array_filter method.

It’s now time to make the call or instantiate the CCB API call. To do so, create a rss variable to capture the CCB API response data, setting the rss variable equal to the ccbDetails function, which does all the heavy-lifting to send and receive API data.

Don’t forget to pass get as the first argument and the urlData variable as the second argument for the ccbDetails function.

Capturing API’s XML Response Data

You’re now ready to parse and display CCB API’s XML response data since instantiating the CCB API call.

To parse and prep XML response data for the web browser, use PHP’s built-in XPATH query method, applying the following expression: //items/item.

Define a nodes variable and have it’s value be the rss variable pointing to the aforementioned path query expression.

Once the response data has been appropriately transformed, the nodes variable can be printed to the web browser using PHP’s built-in print_r method.

This method allows arrays to be printed and displayed to the screen. Check previous tutorials for how to access each data point, or review the list of commented out variables I’ve listed found in CCB’s Public Web API Documentation.

Time to test online giving insert code

And believe it or not, the time has come for you to test your technical prowess.

By now, your code in its entirety should look like the following:

And PLEASE DO NOT FORGET to update required and optional parameter variables with appropriate values.

Save your file and open it using a web browser. You should view a multi-dimensional array of data for the newly imported single online gift for the person you specified.

If you didn’t, and are receiving an error or blank screen, then do feel free to contact me.

That’s it for this tutorial. I look forward to seeing you back hear next week. Same bat time, same bat channel. 🙂


Please comment if this tutorial has helped you.