Skip to content

l4u/CargoBay

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CargoBay

The Essential StoreKit Companion

StoreKit is the Apple framework for making In-App Purchases. It's pretty good, but it has a few rough edges.

CargoBay smooths out those rough parts by providing:

  • Block-based interface for requesting product information
  • Ability to request product information for identifiers asynchronously from a remote web service
  • Block-based callbacks for payment queue observation delegate methods
  • One-step receipt verification

Usage

Product Requests

NSArray *identifiers = @[
  @"com.example.myapp.apple",
  @"com.example.myapp.pear",
  @"com.example.myapp.banana"
];

[[CargoBay sharedManager] productsWithIdentifiers:[NSSet setWithArray:identifiers]
success:^(NSArray *products, NSArray *invalidIdentifiers) {
  NSLog(@"Products: %@", products);
  NSLog(@"Invalid Identifiers: %@", invalidIdentifiers);
} failure:^(NSError *error) {
  NSLog(@"Error: %@", error);
}];

Getting Product Identifiers From Server

NSURL *URL = [NSURL URLWithString:@"http://example.com/products"];
[[CargoBay sharedManager] productsWithURLRequest:[NSURLRequest requestWithURL:URL]
success:^(NSArray *products, NSArray *invalidIdentifiers) {
  // ...
} failure:^(NSError *error) {
  // ...
}];

Payment Queue Observation

AppDelegate.m

- (void)application:(UIApplication *)application didFinishLoadingWithOptions:(NSDictionary *)options {
  [[CargoBay sharedManager] setPaymentQueueUpdatedTransactionsBlock:^(SKPaymentQueue *queue, NSArray *transactions) {
    NSLog(@"Updated Transactions: %@", transactions);
  }];

  [[SKPaymentQueue defaultQueue] addTransactionObserver:[CargoBay sharedManager]];

  // ...
}

Verifying Receipts

[[CargoBay sharedManager] verifyTransaction:(SKPaymentTransaction *) success:^(NSDictionary *receipt) {
  NSLog(@"Receipt: %@", receipt);
} failure:^(NSError *error) {
    NSLog(@"Error %d (%@)", [error code], [error localizedDescription]);
}];

Contact

Mattt Thompson
@mattt

License

CargoBay is available under the MIT license. See the LICENSE file for more info.

About

The Essential StoreKit Companion

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Objective-C 84.5%
  • C 13.1%
  • Ruby 2.4%