In Development, Free Downloads, Mobile, Web Development

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.

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://fm.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 FileMaker Square IntegrationDownload FileMaker Square Integration Database

Please complete the form below to download your FREE FileMaker database file.

FileMaker While Function