3

Background Information

Square recently released SquareSDK.

Firebase has compatibility with StripeSDK.

Questions

Does Firebase have compatibility with Square?

Is there support that allows for integration?

I've gone through the preliminaries for Square and i've noticed in their sample application which has a walkthrough, in specific, their sample code allows us to replace the charge server, can I replace this with firebase hosting?

Sample Code

Square Cookie Demo, code for setting charge server in "take" payments guide:

private static final String CHARGE_SERVER_HOST = "REPLACE_ME";
private static final String CHARGE_SERVER_URL = 
"https://" + CHARGE_SERVER_HOST + "/";

Firebase Stripe Demo, code for setting key in "process" payments guide:

firebase.initializeApp({
    apiKey: "your-web-api-key",
    authDomain: "your-firebase-project-id.firebaseapp.com",
    databaseURL: "https://your-firebase-project-id.firebaseio.com",
    storageBucket: "your-firebase-project-id.appspot.com",
    messagingSenderId: "your-cloud-messaging-sender-id"
  });
  Stripe.setPublishableKey('your-stripe-publishable-key');

Some Thoughts

From the walkthrough on Square cookie demo,

(1) sign up with square to gain an access key, for the purpose of communicating with their api through the app., [✓]

(2) sign up with heroku, for the purpose of deploying the app. and hosting the charge server, [✓]

(3) placing the key we got from square in the heroku account. [✓]

I'd imagine .setPublishableKey(...) is similar to this process?

(1) sign up with square to gain access key, [✓]

(2) sign up with firebase to gain hosting capabilities for the app., [✓]

(3) placing the key we got from square in the firebase account (through the CLI). [???]

mate00
  • 2,727
  • 5
  • 26
  • 34
EvOlaNdLuPiZ
  • 600
  • 1
  • 4
  • 21
  • Please note, I am aware `Stripe.setPublishableKey(...)` is a method being called from Stripe class, so essentially what I'm asking is there `Square.setPublishableKey(...)`? – EvOlaNdLuPiZ Feb 26 '19 at 18:49

1 Answers1

4

Square does not have an official integration with Firebase, but is certainly compatible with Square.

You wouldn't be able to replace the Charge server with Firebase hosting, unless you were configuring specific Firebase hosting routes to point to Firebase Cloud functions that are processing your charges.

You'll see in the source code of Firestripe that they are creating a cloud function for processing the charge on the "backend".

As for the publishable key, that would be the equivalent in Square as your Application ID. That is used for identifying your payment form, which is used for generating the nonces that you pass to your backend for creating customer cards or directly for processing transactions.

Since it seems you're referencing the In-App Payments SDK, you can reference the backend server quickstart to see what a charge looks like. It should be fairly easy to refactor that into a cloud function.

Some additional reading:

mootrichard
  • 3,581
  • 13
  • 25
  • 1
    your response is amazing, no pun intended, full of wonderful information. thank you. now, what i've seen firestripe does the following: (1) when a user is created they register them to their database `createStripeCustomer(...)`, (2) they capture their users payment information using `addPaymentSource(...)`, (3) then they create a dynamic charge (on the fly) using `createStripeCharge(...)`, lastly of course, they clean up and error handle. Am I understanding it correctly? It's all JavaScript being called from the client application. – EvOlaNdLuPiZ Feb 26 '19 at 19:47
  • 1
    Thanks! Yes, it is creating a Stripe customer to associate with the logged in user, storing the card details for the user on the customer that was created in Stripe, then charging the card that was created for that customer. The equivalent of this is the Square Card on File (which I linked the documentation on). I'm looking at internally whether a Square integration with Firebase could be explored, to help simplify these kinds of implementation, particularly for In-App Payments. – mootrichard Feb 26 '19 at 19:50
  • I'll do my best at taking a shot at this approach with my I application and I'll close out this post as answered, Thank you @mootrichard. Lastly, please if you find any further information into this topic, let us know through this post, if you can. – EvOlaNdLuPiZ Feb 26 '19 at 19:54
  • 1
    You can feel free to message me in the Square slack community at squ.re/slack or on Twitter. Under @wootmoot I happen to have used firebase a lot and would be interested in find out out how you got it going – mootrichard Feb 26 '19 at 20:21
  • after working on this project as of recently, i was able to accomplish what i needed. i processed a square payment from my android application using the GCP. attached is a reference link to another SO question where i show how to do this: [link](https://stackoverflow.com/questions/59105378/get-data-from-object-promise/59113909#59113909) – EvOlaNdLuPiZ Nov 30 '19 at 06:52
  • cant we use Square without server side for in-app payment ? please let me know if there is a any way to do payment only using mobile app (without server side coding ) – YodagamaHeshan Apr 28 '20 at 16:15
  • There is not. You really don't want to do a mobile-only solution since it would require you storing sensitive credentials on untrusted devices. – mootrichard Apr 28 '20 at 16:36