The PayPal for FileMaker solution file loads a set of custom functions in FileMaker to make integrating PayPal APIs quick and easy.
The FileMaker PayPal custom functions work like any other function you would use in FileMaker, so all you have to do is load the function, fill in the parameters with dynamic FileMaker data or static values, and the function will handle the rest.
- Downloading the PayPal for FileMaker solution file.
- Installing the Scodigo SmatPill plugin to your FileMaker install directory.
- Open the solution file and enter PayPal API credentials.
See our PayPal for FileMaker Install and Setup Guide for more details on this if you have not followed that guide already.
FileMaker PayPal Custom Functions
As you can see, there are separate functions available for each individual PayPal API.
The sample here focuses on the GetBalance API, which simply pulls your current balance from your PayPal account and has only a few parameters. Other functions will have many more parameters, however, the procedure is the same for any of the functions you would like to use.
Like any other function in FileMaker, these parameters can be populated from dynamic FileMaker data or with static values.
How to Include Order Items
To send itemized order details in a PayPal request you will need to generate a string of order items to pass into the “order_items” parameter in PayPal functions (ie. DoDirectPayment).
The data that can be passed for an individual item includes:
- Item ID
- Tax Amount
- eBay Item Number
- eBay Transaction ID
- eBay Order ID
If you have more than one item being included on the order this data would be repeated, of course.
The data needs to be passed into the “order_items” parameter of the PayPal function in a specific format in order to be processed correctly. Assuming you are passing two items, that format would be:
If you do not need a parameter you can leave it blank, but you still need to include it in the string. Here is a populated sample:
Test Widget 1|This is the first test widget|5.00|123-ABC|1||||~~~Test Widget 2| This is the second test widget.|5.00|555-ZZZ|1||||
- Create a new FileMaker Script to run your PayPal API request.
- Clear out any data that might be in the global response fields using the ClearGlobalFields script provided by the solution file.
- Set a FileMaker variable called $PayPalResult which runs the calculation which triggers the FileMaker PayPal function.
- Set FileMaker variables for any response data you need access to using the global fields that would now be populated with response data from the previous request.
- Use the FileMaker variables to populate your FileMaker tables accordingly.
Here is a sample of the Set Variable script step which performs a calculation to run the PHPx_AE_PayPal_GetBalance() function.
You’ll notice that the API credential values are populated from the configuration data that is covered in our PayPal for FileMaker Install and Setup Guide.
A static value of “USD” was used for the currency_code while the api_subject and related_record_id parameters were left blank.
NOTE: If you do not need a particular parameter it must be left in place, but you can use double quotes ( “” ) to make it an empty text value. Empty values will be ignored in the PayPal API request.
When this function is run within a script calculation in FileMaker, the PayPal API request is generated from the data passed in, the communication with PayPal takes place, and the response data back from PayPal is parsed and placed into individual global fields within the PayPal for FileMaker solution file so that you may easily access it for your own needs.
PayPal Response Global Fields
The table/layout includes global fields for every possible response parameter that PayPal might return. As such, in many cases they will not all be populated. They are simply available at any time from any FileMaker script or calculation if you need to pull the current value.
Here is example of what the global fields layout would look like after using the AE_PayPal_GetTransactionDetails function.
With the data available in the global fields you may easily place it into your own FileMaker data tables, load it in variables, calculations, scripts, etc.
For more samples you can take a look at our video demonstrations for various PayPal calls from FileMaker.
FileMaker PayPal Script Templates
These scripts include sample data which may need adjustments to work with your own PayPal account, but they are a great reference for the steps you should take to make PayPal API calls from within FileMaker.