FileMaker tips, techniques, and news.

By Kiyan Allaei  Posted on  April 3rd, 2019  in  FileMaker, Free Downloads

FileMaker Square Integration

Square is one of the most popular in-person credit card processing systems available with over 2 million sellers using square today. Using the Point of Sale API, Square allows you to easily integrate with their Point of Sale app to quickly process in-person payments from your FileMaker application on mobile devices.

What You Need

You must have a Square account and a Square Reader for all mobile devices you want to accept payment on. You will also need to have your FileMaker application hosted on a FileMaker Server, have the FileMaker Data API enabled on FileMaker Server, and enable the fmurlscript “Allow URLs to perform FileMaker scripts” and fmrest “Access via FileMaker Data API” extended privileges for all users pushing charges to Square.

FileMaker Square Process Flow source:https://docs.connect.squareup.com/payments/pos/overview

How It Works

Your FileMaker application will determine the total charge to the customer and pass the transaction information to the Square POS app. The mobile device automatically opens the POS app and the charge amount is pre-populated in the transaction presented to the customer. Once the transaction is completed, the results are sent via a callback URL, which references PHP code to open your FileMaker application and pass in the results of the transaction from Square.

Creating Your Square Application

First install the Square Point of Sale app from the App Store (available on iOS and Android). Then create a Square application on your Square developer dashboard. To do this, sign in to your developer portal online and click “New Application”.

FileMaker Square Developer Portal

Next enter your web callback URL by clicking into the application you created, selecting the “Point of Sale API” tab, and entering your Web Callback URL. Square requires that we use an HTTPS URL and not an FMP URL. This URL will be a link to a PHP script that acts as an FMP URL and will reopen your FileMaker application after the Square transaction completes. It needs to include parameters to reference your FileMaker file and call the FileMaker script that will handle the response data from Square.

FileMaker Square Callback URL

Keep in mind you will have to purchase an SSL certificate for the domain you use to host your PHP code as Square requires HTTPS for Web Callback URLs.

Pushing a Transaction to Square

Now that you’ve configured your Square application in the developer portal and have hosted your PHP script on a secure web server, you can start pushing transactions to Square from FileMaker. To push the transaction to Square, you will need to call the Square app with the Square URI scheme and pass information to prepopulate the transaction in the form of a JSON object. Here is an example of the JSON object.

{
    "amount_money" : 
    {
        "amount" : "0",
        "currency_code" : "USD"
    },
    "callback_url" : "https://api.dbservices.com/Test/SquareArticle/LaunchFMPURL.php?host=cloud.dbservices.com&database=DB_Services_FileMaker_Square_Integration&script=Square_Process_Payment",
    "client_id" : "sq0idp-mRVxvaQDqPVVacCJDPn2zg",
    "notes" : "",
    "options" : 
    {
        "supported_tender_types" : [ "CREDIT_CARD", "CASH" ]
    },
    "version" : "1.3"
}

Make sure to URL encode the JSON object and append it to the end of the URL “square-commerce-v1://payment/create?data=”. Use the Open URL script step to open the Square POS app.

One important note to remember is that Square reads the transaction amount in cents, so if you’re passing dollar values, you need to multiply them by 100 before passing them through the API.

Passing Back Transaction Results with PHP

Included in the demo file is a PHP file used to pass the Square transaction results back to your FileMaker application. This PHP code handles the JSON data passed from Square and essentially builds an FMP URL used to re-open your FileMaker application and call a script. This is how we retrieve our result data in the FileMaker script that is called by Square. An example of the result data is shown below.

{
    "client_transaction_id" : "C33DC0BB-98B4-4E7E-BB0E-9764C46E5A15",
    "status" : "ok",
    "transaction_id" : "WO873ceEC5bOO4KtzCFtaNzeV"
}

The only catch to this, is that on iOS devices, Safari will always be the browser that handles the FMP URL sent by the PHP code. Unfortunately Safari always prompts the user to open FileMaker Go and there is no way to disable this. So users will have to click “Open” or the FileMaker application won’t open. This can cause issues because the transaction could have completed or canceled and your FileMaker application wouldn’t know the difference.

Processing Payment in FileMaker

This is the easiest part of the integration. Once the PHP code opens your FileMaker application it will run the specified script. You will want to grab the data from Square and tie it to your charge record. In the demo file, we store the entire result in the response field and store the transaction ID in a transaction ID field.

Conclusion

The Square Point of Sale API allows you to quickly and easily process in-person payments on mobile devices, while linking your Square transactions with your FileMaker records. This eliminates the risk of human error while taking payment with Square. Contact us if you need help integrating your FileMaker application with Square!

Did you know we are an authorized reseller for FileMaker Licensing?
Contact us to discuss upgrading your FileMaker software.

Download
Download the FileMaker Square Integration File
Please complete the form below to download your FREE FileMaker file.
FileMaker Experience *
Terms of Use *
OPT-IN: I agree that I am downloading a completely free FileMaker application file with no strings attached. This file is unlocked, and I may use it for my business or organization as I see fit. Because I am downloading a free file, I agree that I should receive occasional marketing. I understand that I can OPT-OUT of these emails at anytime.
Kiyan Allaei thumbnail
Kiyan Allaei

Kiyan is an outgoing and energetic certified FileMaker developer whose technical passion is the world of databases. His collaborative and positive attitude creates a natural draw for clients seeking solutions to meet their database needs.

FileMaker 18 Certified Developer
FileMaker 17 Certified Developer
FileMaker 16 Certified Developer
FileMaker 15 Certified Developer
FileMaker 14 Certified Developer
FileMaker 13 Certified Developer
FileMaker 12 Certified Developer
FileMaker 11 Certified Developer
"We were actually able to add more features than we thought would be possible within our budget. We always experienced a ‘can do’ attitude and DB Services was incredibly patient and easy to work with."
Courtney Hartman
Art Director
"The new FileMaker custom website interface is very user-friendly and easy to follow for our clients. In addition, it is much faster than the old Instant Web Publishing (IWP) interface. Thank you and all the others who have helped us out at DB Services. I am very grateful for the excellent service you provide us. Its nice to know we can call you for help if we have an issue."
Wayne Capek
President
"We needed a solution that would simplify the administration of our responsibilities under our contract with the State of Indiana. We have seen a dramatic increase across the state in the number of potential foster and adoptive parents that have begun the preparation and training process. This increase has resulted in a significant opportunity for children available for adoption. That’s a big win for everyone! And it’s all because we can refer potential parents to the proper state contacts efficiently and quickly."
Chris Morrison
Executive Director
"Thank you for all of your expertise and valuable help. I am so grateful to have found DB Services."
Linda Findlay
Owner
"Thank you for our new database system. We transitioned from a carbon copy paper based system to a digital database. The software has saved us time and money. We used to archive all our jobs in cabinets, now we can look up a job in seconds from anywhere. The software allows us to easily email estimates to our customers in pdf format. In a year there was a return on investment just from eliminating the purchasing of our carbon forms."
Todd Cartmel
Owner
"The new system allows us to create and track jobs for customers along with inventory, something we had been doing with separate word and spreadsheet files. Because it’s now so intuitive, new staff members are able to begin using the database immediately without our usual training session and ‘cheat sheets’ for getting around within the file."
Tom Andrews
President