Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Implementing in-app purchase in an Electron app for the Mac App Store

I've looked around and it seems like several people are having this issue but no-one seems to have solved it:

Adding Apple in-app purchase to Electron HTML/JS app

https://github.com/electron/electron/issues/3745

https://discuss.atom.io/t/osx-in-app-purchases-in-electron/22885

Some people suggest using this Node to Objective-C bridge to do it:

https://github.com/TooTallNate/NodObjC

Other people suggest using this in-app library, but from what I can see, it only validates receipts:

https://github.com/voltrue2/in-app-purchase

Has anyone actually managed to implement in-app purchases in an Electron app for the Mac App Store?

How did you do it?

If no one has done it, is it simply impossible to do?

like image 394
Holger Sindbaek Avatar asked Oct 15 '17 10:10

Holger Sindbaek


1 Answers

Update

Finally, I added in-app purchase directly to Electron.

See https://electronjs.org/docs/tutorial/in-app-purchases


First solution

I have implemented this solution and it works in development (not yet tested in production).

  1. Create a MacOS application (InAppPurchase) with Xcode that performs the in-app purchase (see https://developer.apple.com/library/content/documentation/NetworkingInternet/Conceptual/StoreKitGuide/Introduction.html)
  2. Put the InAppPurchase.app somewhere in your Electron app folder
  3. Use require('electron').shell.openItem or require('child_process').spawn('./InAppPurchase.app/Contents/MacOS/InAppPurchase'); in your Electron app to start the in-app purchase.

This is definitely not a clean solution but it seems to work...

Second solution

I think that it can also be done with NodObjC. However, this lib is very heavy compared to the first solution.

Third solution

Adding in-app purchase directly to Electron.


I will keep you informed if I can release my Electron app on the Mac Apple Store with IAP or if I found another solution.

like image 193
user108828 Avatar answered Sep 21 '22 15:09

user108828