How to use Apple Pay API with Electron-like program

Hello!

I would like to a deploy a program (more on which later) to the Apple Store, and I have a couple of questions regarding Apple Pay API usage. My product will be a paid program, and I have some problems with the Apple Pay API due to technical reasons.

My program is an "Electron-like" application, it consists of two parts, backend, and UI. The "Backend" runs directly in the user's computer, it's written in Python and Flask. The "UI" is actually a browser that opens a webpage from the "Backend", and interacts with it using AJAX.

The issue here is that I don't understand how in-app payments can be implemented. As far as I understand, the only option to deploy a paid application and the Apple Store is to use Apple Pay API, which is only available from Swift or Objective-C. I don't understand how can I use Apple Pay API, how I can check for a valid payment, etc. Can you please send me some kind of guide, tutorial, or instruction that can help me to use Apple Pay in my program?

Thank you very much, Alex.

There is a lot going on here so I am going to attempt to advise from a high level based on what I usually see done from applications supporting Apple Pay. Typically, if a service already has a web based presence, meaning that Apple Pay is already supported in a web application for a storefront, then a native application can take advantage of this web workflow in their app using WKWebView, but would have to bridge the final payment request to the native app. See the guide for Bridging from Web-Based Interfaces. Now, if their is no web presence for Apple Pay, then PassKit would be an option to make payments directly to the Apple Pay infrastructure via the PassKit APIs.

Also, Apple Pay is not the only API for making purchases. I will throw out StoreKit as an option too. I am not versed in `StoreKit``, but you may want to take a look at this as this is also an option for processing In-App Purchases.

Finally, if you go the web based route you may have some issues with your current architecture because you are running a local server, so check out the requirements for Apple Pay on the web before deciding on an option.

Matt Eaton
DTS Engineering, CoreOS
meaton3@apple.com

Thank you for a fast reply. I investigated the web based route and found out that it's impossible to use with my current infrastructure because of the SSL certificates on a localhost. As I understand, the only option left is to use the StoreKit API. In theory, is it possible to use the StoreKit API from Python with the help of PyObjc (pyobjc-framework-StoreKit)?

Thank you, Alex.

and found out that it's impossible to use with my current infrastructure because of the SSL certificates on a localhost.

I suspected that this may be the case based upon what you had described and that's why I wanted to call out local server piece.

Regarding:

As I understand, the only option left is to use the StoreKit API. In theory, is it possible to use the StoreKit API from Python with the help of PyObjc (pyobjc-framework-StoreKit)?

You could use either the native StoreKit or PassKit APIs as both of them have a native APIs set. Note that StoreKit is typically used for In-App Purchases and PassKit is used for either Apple Pay or Wallet interactions. Now, where using these APIs lands you with an external language like Python, I really have no idea. I suspect that if you wanted to use these APIs on your client side app, from what I understand to be as the JavaScript side of your project, then you could build the native components in either StoreKit or PassKit and then you would just need a way to integrate your 3rd party code (JavaScript) with these native APIs. That however, is something you will need to take on as I cannot provide assistance with that piece.

Matt Eaton
DTS Engineering, CoreOS
meaton3@apple.com

Thank you, Matt. After reading your answer, I got a new idea. What if, I write a program in objective-c using the StoreKit API, for example I will define functions like get_products, request_payment, etc using the StoreKit API. Then, I will compile it and write a wrapper around it using Python's built-in ctypes module, and call it when necessary, for example after user presses "Buy button" or something like this. If I'm not wrong, it may be easier to use this method in order to add in-app purchases, rather than using pyobjc. What do you think?

A native component to your program that uses the StoreKit APIs for purchasing sounds like it would work as long as it can be configured with the necessary requirements needed when setting up StoreKit.

Matt Eaton
DTS Engineering, CoreOS
meaton3@apple.com
How to use Apple Pay API with Electron-like program
 
 
Q