Why is due to platform provide rules. Transfering certain content, is not allowed by Apple in app purchase guidelines:
3.1 Payments
3.1.1 In-App Purchase: If you want to unlock features or functionality within your app, (by way of example: subscriptions, in-game currencies, game levels, access to premium content, or unlocking a full version), you must use in-app purchase. ...
I wasn't able to find anything definitive for Android, but I suspect they have similar restrictions. In general though, any time you have a system that effectively allows real world currency to be moved from one party to another, there tends to be more rules & regulations due to the potential for misuse, such as money laundering. In addition, the platforms don't want to make it easy to do an end run around the % the collect from IAPs.
How to actually transfer the content is a broad question & the specifics will vary somewhat depending on the situation. Generally speaking, you need to:
- generate a code, ideally it should be:
- unique (for instance a GUID) to avoid collisions
- no longer than necessary to avoid frustrating users
- unpredictable to avoid scamming exploits
- associate the code with the source account
- when the code is used by a destination account
- transfer the relevant content between accounts on the server side
- update the clients to reflect the server side changes