saturngod/IAPHelper
saturngod/IAPHelper has 1,548 GitHub stars and 272 forks. GitHot measured 0 stars in 24 hours. Last checked 2026-11-08 04:18 UTC. Last push 2020-10-31.
No more maintenance for this repo. Please use the https://github.com/bizz84/SwiftyStoreKit
Measured star growth
- in 24h
- 0
- in 7 days
- Collecting history
- in 15 days
- Collecting history
- in 1 month
- Collecting history
Net star changes over overlapping periods, not daily totals. Missing measurements are left blank. Stars measure attention, not software quality.
README.md
OriginalIAP helper for Apple in app purchases. It uses ARC and blocks for ease of use. Ready to use with newsstand subscriptions.
##Require
- StoreKit
- iOS 5 or later
- ARC
##How to use
- Add IAPHelper folder to your project.
- Add Storekit framework
Cocoapod
pod 'IAPHelper'
Initialize
if(![IAPShare sharedHelper].iap) {
NSSet* dataSet = [[NSSet alloc] initWithObjects:@"com.comquas.iap.test", nil];
[IAPShare sharedHelper].iap = [[IAPHelper alloc] initWithProductIdentifiers:dataSet];
}
Production Mode On/Off
[IAPShare sharedHelper].iap.production = NO;
Request Products
[[IAPShare sharedHelper].iap requestProductsWithCompletion:^(SKProductsRequest* request,SKProductsResponse* response)
{
}];
Get Locale Price and Title
SKProduct* product =[[IAPShare sharedHelper].iap.products objectAtIndex:0];
NSLog(@"Price: %@",[[IAPShare sharedHelper].iap getLocalePrice:product]);
NSLog(@"Title: %@",product.localizedTitle);
Purchase
[[IAPShare sharedHelper].iap buyProduct:product
onCompletion:^(SKPaymentTransaction* trans){
}];
Check Receipt with shared secret
For checking receipt , recommend to use only for server side. I am not recommend to use from client side directly check it. However, sometime we want to use only on client side for some reason. Use with your own risk.
Please check Apple guide .
[[IAPShare sharedHelper].iap checkReceipt:[NSData dataWithContentsOfURL:[[NSBundle mainBundle] appStoreReceiptURL]] AndSharedSecret:@"your sharesecret" onCompletion:^(NSString *response, NSError *error) {
}];
Check Receipt without shared secret
For checking receipt , recommend to use only for server side. I am not recommend to use from client side directly check it. However, sometime we want to use only on client side for some reason. Use with your own risk.
Please check Apple guide .
[[IAPShare sharedHelper].iap checkReceipt:[NSData dataWithContentsOfURL:[[NSBundle mainBundle] appStoreReceiptURL]] onCompletion:^(NSString *response, NSError *error) {
}];
Saving Product Identifier
[[IAPShare sharedHelper].iap provideContentWithTransaction:transaction];
Check for Previous Purchase
if([[IAPShare sharedHelper].iap isPurchasedProductsIdentifier:@"com.comquas.iap.test"]
{
// require saving product identifier first
}
Purchased Products
NSLog(@"%@",[IAPShare sharedHelper].iap.purchasedProducts);
Clear Purchases
[[IAPShare sharedHelper].iap clearSavedPurchasedProducts];
[[IAPShare sharedHelper].iap clearSavedPurchasedProductByID:@"com.myproduct.id"];
Restore Purchase
[[IAPShare sharedHelper].iap restoreProductsWithCompletion:^(SKPaymentQueue *payment, NSError *error) {
//check with SKPaymentQueue
// number of restore count
int numberOfTransactions = payment.transactions.count;
for (SKPaymentTransaction *transaction in payment.transactions)
{
NSString *purchased = transaction.payment.productIdentifier;
if([purchased isEqualToString:@"com.myproductType.product"])
{
//enable the prodcut here
}
}
}];
Example
if(![IAPShare sharedHelper].iap) {
NSSet* dataSet = [[NSSet alloc] initWithObjects:@"com.comquas.iap.test", nil];
[IAPShare sharedHelper].iap = [[IAPHelper alloc] initWithProductIdentifiers:dataSet];
}
[IAPShare sharedHelper].iap.production = NO;
[[IAPShare sharedHelper].iap requestProductsWithCompletion:^(SKProductsRequest* request,SKProductsResponse* response)
{
if(response > 0 ) {
SKProduct* product =[[IAPShare sharedHelper].iap.products objectAtIndex:0];
NSLog(@"Price: %@",[[IAPShare sharedHelper].iap getLocalePrice:product]);
NSLog(@"Title: %@",product.localizedTitle);
[[IAPShare sharedHelper].iap buyProduct:product
onCompletion:^(SKPaymentTransaction* trans){
if(trans.error)
{
NSLog(@"Fail %@",[trans.error localizedDescription]);
}
else if(trans.transactionState == SKPaymentTransactionStatePurchased) {
[[IAPShare sharedHelper].iap checkReceipt:[NSData dataWithContentsOfURL:[[NSBundle mainBundle] appStoreReceiptURL]] AndSharedSecret:@"your sharesecret" onCompletion:^(NSString *response, NSError *error) {
//Convert JSON String to NSDictionary
NSDictionary* rec = [IAPShare toJSON:response];
if([rec[@"status"] integerValue]==0)
{
[[IAPShare sharedHelper].iap provideContentWithTransaction:trans];
NSLog(@"SUCCESS %@",response);
NSLog(@"Pruchases %@",[IAPShare sharedHelper].iap.purchasedProducts);
}
else {
NSLog(@"Fail");
}
}];
}
else if(trans.transactionState == SKPaymentTransactionStateFailed) {
NSLog(@"Fail");
}
}];//end of buy product
}
}];
Explore related projects
codecrafters-io/build-your-own-x
Master programming by recreating your favorite technologies from scratch.
560,836 starspublic-apis/public-apis
A collective list of free APIs
497,082 starsmorluto/rea
Reverse engineer anything with agents, from app behavior down to native binaries.
441,526 starsopenclaw/openclaw
The AI that really does things. Any OS. Any Platform. The lobster way. 🦞
394,157 stars