Adding Subscription In-App Purchase to Safari Web Extension

I have created a Safari Web Extension, now I want to add Subscription In-App Purchase into this app.

Since the Safari Web Extension has two parts: the Mac App and the Extension.

I want to ask can I add the IAP codes into the Extension part?
So, the Extension can be programmatically enabled or disabled according to the latest subscription status.
There isn't an extension API to programmatically enable or disable your extension, so it wouldn't work to gate that on IAP.

One thing you could try is using the native messaging API https://developer.apple.com/documentation/safariservices/safari_web_extensions/messaging_a_web_extension_s_native_app?language=objc - and use that to communicate between the JavaScript code in your Web Extension, and native code which could check the IAP state.
Adding Subscription In-App Purchase to Safari Web Extension
 
 
Q