What’s IAPHelper
IAPHelper simply wraps the API of Apple’s In-App Purchase using Swift. Very lightweight and easy to use.
IAPHelper opens source and welcome to improve it.
IAPHelper Usage
Request Product List
|
|
Purchase Product
|
|
Restore
|
|
Validate Receipt
|
|
Note: IAPHelper directly validate with Apple’s server. It’s simple, but has risk. You decide use your own server or not as Apple suggested:
Use a trusted server to communicate with the App Store. Using your own server lets you design your app to recognize and trust only your server, and lets you ensure that your server connects with the App Store server. It is not possible to build a trusted connection between a user’s device and the App Store directly because you don’t control either end of that connection.
Integrate IAPHelper in Your Project
Just copy IAPHelper.swift to your project, and use it as the demo shows.
IAPHelper Demo
NOTE: You need to change the app bundle id and product id to your own. And also set your shared secret in Constants.swift.
Note
This library can’t help you understand the basic concepts for IAP. For it, please refer to these documents.
- In-App Purchase Programming Guide
- In-App Purchase Configuration Guide for iTunes Connect
- In-App Purchase Best Practices
- Receipt Validation Programming Guide
- Adding In-App Purchase to your iOS and macOS Applications
What’s Test
It’s mainly test on macOS 10.10 with auto-renew subscription. Now it’s used by my app of iPic.