Search code examples
iosin-app-purchasestorekit

StoreKit 2: Custom purchase option isn't recorded


The StoreKit 2 function for purchasing a product takes an array of options. One option is for setting an app account id, and another is for setting a custom key/value pair.

Setting the app account id seems to work great in that the id can be seen in the transaction after making the purchase, and is persisted indefinitely. Setting a custom key/value pair, however, doesn't seem to do anything. The key/value pair doesn't seem to appear anywhere in the transaction or purchase at any time, even immediately after purchase() is called.

The documentation on PurchaseOptions is very limited, and there doesn't seem to be any explanation as to why this happens. All I've found is this thread from 2 years ago where an Apple engineer states that purchase options are "not necessarily returned in the Transaction for the purchase". Does this mean that they are sometimes included? And if so, how can I guarantee that? Has anyone found any solutions, or even an answer as to why Apple would include a feature that works like this?

Docs:


Solution

  • The documentation states:

    Custom purchase options don’t have any effect and are reserved for future use.

    So, it looks like the behaviour you are seeing is expected.