Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Could not use CBError* because it is used by Core Bluetooth. Rename t…

…o CargoBayError*. Also rename CBStatus* to CargoBayStatus*.
  • Loading branch information...
commit 209473f66da57ed73d26066edb4764afd60a325a 1 parent d104cd8
@lxcid authored
Showing with 39 additions and 39 deletions.
  1. +23 −23 CargoBay/CargoBay.h
  2. +16 −16 CargoBay/CargoBay.m
View
46 CargoBay/CargoBay.h
@@ -29,37 +29,37 @@
@class AFHTTPClient;
-extern NSString * const CBErrorDomain;
+extern NSString * const CargoBayErrorDomain;
-typedef NS_ENUM(NSInteger, CBStatusCode) {
- CBStatusOK = 0,
+typedef NS_ENUM(NSInteger, CargoBayStatusCode) {
+ CargoBayStatusOK = 0,
// Status codes for auto-renewable subscriptions
- CBStatusCannotParseJSON = 21000,
- CBStatusMalformedReceiptData = 21002,
- CBStatusCannotAuthenticateReceiptData = 21003,
- CBStatusSharedSecretDoesNotMatch = 21004,
- CBStatusReceiptServerUnavailable = 21005,
- CBStatusReceiptValidButSubscriptionExpired = 21006,
- CBStatusSandboxReceiptSentToProduction = 21007,
- CBStatusProductionReceiptSentToSandbox = 21008
+ CargoBayStatusCannotParseJSON = 21000,
+ CargoBayStatusMalformedReceiptData = 21002,
+ CargoBayStatusCannotAuthenticateReceiptData = 21003,
+ CargoBayStatusSharedSecretDoesNotMatch = 21004,
+ CargoBayStatusReceiptServerUnavailable = 21005,
+ CargoBayStatusReceiptValidButSubscriptionExpired = 21006,
+ CargoBayStatusSandboxReceiptSentToProduction = 21007,
+ CargoBayStatusProductionReceiptSentToSandbox = 21008
};
-typedef NS_ENUM(NSInteger, CBErrorCode) {
- CBErrorUnknown = -1,
+typedef NS_ENUM(NSInteger, CargoBayErrorCode) {
+ CargoBayErrorUnknown = -1,
- CBErrorPurchaseInfoDoesNotMatchReceipt = 1,
- CBErrorTransactionDoesNotMatchesPurchaseInfo = 2,
- CBErrorCannotExtractPurchaseInfoFromTransactionReceipt = 3,
- CBErrorTransactionNotInPurchasedOrRestoredState = 4,
- CBErrorTransactionNotValid = 5,
+ CargoBayErrorPurchaseInfoDoesNotMatchReceipt = 1,
+ CargoBayErrorTransactionDoesNotMatchesPurchaseInfo = 2,
+ CargoBayErrorCannotExtractPurchaseInfoFromTransactionReceipt = 3,
+ CargoBayErrorTransactionNotInPurchasedOrRestoredState = 4,
+ CargoBayErrorTransactionNotValid = 5,
// Error codes derived from status codes for auto-renewable subscriptions
- CBErrorCannotParseJSON = CBStatusCannotParseJSON,
- CBErrorMalformedReceiptData = CBStatusMalformedReceiptData,
- CBErrorCannotAuthenticateReceiptData = CBStatusCannotAuthenticateReceiptData,
- CBErrorSharedSecretDoesNotMatch = CBStatusSharedSecretDoesNotMatch,
- CBErrorReceiptServerUnavailable = CBStatusReceiptServerUnavailable
+ CargoBayErrorCannotParseJSON = CargoBayStatusCannotParseJSON,
+ CargoBayErrorMalformedReceiptData = CargoBayStatusMalformedReceiptData,
+ CargoBayErrorCannotAuthenticateReceiptData = CargoBayStatusCannotAuthenticateReceiptData,
+ CargoBayErrorSharedSecretDoesNotMatch = CargoBayStatusSharedSecretDoesNotMatch,
+ CargoBayErrorReceiptServerUnavailable = CargoBayStatusReceiptServerUnavailable
};
@interface CargoBay : NSObject <SKPaymentTransactionObserver>
View
32 CargoBay/CargoBay.m
@@ -27,7 +27,7 @@
#import "AFHTTPClient.h"
#import "AFJSONRequestOperation.h"
-NSString * const CBErrorDomain = @"me.mattt.CargoBay.ErrorDomain";
+NSString * const CargoBayErrorDomain = @"me.mattt.CargoBay.ErrorDomain";
static NSString * const kCargoBaySandboxReceiptVerificationBaseURLString = @"https://sandbox.itunes.apple.com/";
static NSString * const kCargoBayProductionReceiptVerificationBaseURLString = @"https://buy.itunes.apple.com/";
@@ -165,7 +165,7 @@ static BOOL CBValidatePurchaseInfoMatchesReceipt(NSDictionary *purchaseInfo, NSD
[NSString stringWithFormat:@"Purchase info does not match receipt because purchase info's bundle ID (%@) does not match receipt's bundle ID (%@).", [purchaseInfo objectForKey:@"bid"], [receipt objectForKey:@"bid"]], NSLocalizedDescriptionKey,
[NSString stringWithFormat:@"Purchase info's bundle ID (%@) does not match receipt's bundle ID (%@).", [purchaseInfo objectForKey:@"bid"], [receipt objectForKey:@"bid"]], NSLocalizedFailureReasonErrorKey,
nil];
- *error = [NSError errorWithDomain:CBErrorDomain code:CBErrorPurchaseInfoDoesNotMatchReceipt userInfo:userInfo];
+ *error = [NSError errorWithDomain:CargoBayErrorDomain code:CargoBayErrorPurchaseInfoDoesNotMatchReceipt userInfo:userInfo];
}
return NO;
} else if (![[receipt objectForKey:@"product_id"] isEqual:[purchaseInfo objectForKey:@"product-id"]]) {
@@ -175,7 +175,7 @@ static BOOL CBValidatePurchaseInfoMatchesReceipt(NSDictionary *purchaseInfo, NSD
[NSString stringWithFormat:@"Purchase info does not match receipt because purchase info's product ID (%@) does not match receipt's product ID (%@).", [purchaseInfo objectForKey:@"product-id"], [receipt objectForKey:@"product_id"]], NSLocalizedDescriptionKey,
[NSString stringWithFormat:@"Purchase info's product ID (%@) does not match receipt's product ID (%@).", [purchaseInfo objectForKey:@"product-id"], [receipt objectForKey:@"product_id"]], NSLocalizedFailureReasonErrorKey,
nil];
- *error = [NSError errorWithDomain:CBErrorDomain code:CBErrorPurchaseInfoDoesNotMatchReceipt userInfo:userInfo];
+ *error = [NSError errorWithDomain:CargoBayErrorDomain code:CargoBayErrorPurchaseInfoDoesNotMatchReceipt userInfo:userInfo];
}
return NO;
} else if (![[receipt objectForKey:@"quantity"] isEqual:[purchaseInfo objectForKey:@"quantity"]]) {
@@ -185,7 +185,7 @@ static BOOL CBValidatePurchaseInfoMatchesReceipt(NSDictionary *purchaseInfo, NSD
[NSString stringWithFormat:@"Purchase info does not match receipt because purchase info's quantity (%@) does not match receipt's quantity (%@).", [purchaseInfo objectForKey:@"quantity"], [receipt objectForKey:@"quantity"]], NSLocalizedDescriptionKey,
[NSString stringWithFormat:@"Purchase info's quantity (%@) does not match receipt's quantity (%@).", [purchaseInfo objectForKey:@"quantity"], [receipt objectForKey:@"quantity"]], NSLocalizedFailureReasonErrorKey,
nil];
- *error = [NSError errorWithDomain:CBErrorDomain code:CBErrorPurchaseInfoDoesNotMatchReceipt userInfo:userInfo];
+ *error = [NSError errorWithDomain:CargoBayErrorDomain code:CargoBayErrorPurchaseInfoDoesNotMatchReceipt userInfo:userInfo];
}
return NO;
} else if (![[receipt objectForKey:@"item_id"] isEqual:[purchaseInfo objectForKey:@"item-id"]]) {
@@ -195,7 +195,7 @@ static BOOL CBValidatePurchaseInfoMatchesReceipt(NSDictionary *purchaseInfo, NSD
[NSString stringWithFormat:@"Purchase info does not match receipt because purchase info's item ID (%@) does not match receipt's item ID (%@).", [purchaseInfo objectForKey:@"item-id"], [receipt objectForKey:@"item_id"]], NSLocalizedDescriptionKey,
[NSString stringWithFormat:@"Purchase info's item ID (%@) does not match receipt's item ID (%@).", [purchaseInfo objectForKey:@"item-id"], [receipt objectForKey:@"item_id"]], NSLocalizedFailureReasonErrorKey,
nil];
- *error = [NSError errorWithDomain:CBErrorDomain code:CBErrorPurchaseInfoDoesNotMatchReceipt userInfo:userInfo];
+ *error = [NSError errorWithDomain:CargoBayErrorDomain code:CargoBayErrorPurchaseInfoDoesNotMatchReceipt userInfo:userInfo];
}
return NO;
}
@@ -216,7 +216,7 @@ static BOOL CBValidatePurchaseInfoMatchesReceipt(NSDictionary *purchaseInfo, NSD
[NSString stringWithFormat:@"Purchase info does not match receipt because device's identifier for vendor (%@) does not match purchase info's (%@) and receipt's unique vendor identifier (%@).", deviceIdentifier, transactionUniqueVendorIdentifier, receiptVendorIdentifier], NSLocalizedDescriptionKey,
[NSString stringWithFormat:@"Device's identifier for vendor (%@) does not match purchase info's (%@) and receipt's unique vendor identifier (%@).", deviceIdentifier, transactionUniqueVendorIdentifier, receiptVendorIdentifier], NSLocalizedFailureReasonErrorKey,
nil];
- *error = [NSError errorWithDomain:CBErrorDomain code:CBErrorPurchaseInfoDoesNotMatchReceipt userInfo:userInfo];
+ *error = [NSError errorWithDomain:CargoBayErrorDomain code:CargoBayErrorPurchaseInfoDoesNotMatchReceipt userInfo:userInfo];
}
return NO;
#endif
@@ -238,7 +238,7 @@ static BOOL CBValidatePurchaseInfoMatchesReceipt(NSDictionary *purchaseInfo, NSD
[NSString stringWithFormat:@"Purchase info does not match receipt because device's unique identifier (%@) does not match purchase info's (%@) and receipt's unique identifier (%@).", deviceIdentifier, transactionUniqueIdentifier, receiptUniqueIdentifier], NSLocalizedDescriptionKey,
[NSString stringWithFormat:@"Device's unique identifier (%@) does not match purchase info's (%@) and receipt's unique identifier (%@).", deviceIdentifier, transactionUniqueIdentifier, receiptUniqueIdentifier], NSLocalizedFailureReasonErrorKey,
nil];
- *error = [NSError errorWithDomain:CBErrorDomain code:CBErrorPurchaseInfoDoesNotMatchReceipt userInfo:userInfo];
+ *error = [NSError errorWithDomain:CargoBayErrorDomain code:CargoBayErrorPurchaseInfoDoesNotMatchReceipt userInfo:userInfo];
}
return NO;
}
@@ -591,7 +591,7 @@ calculating SHA1(version|purchaseinfo)
@"Cannot extract purchase info from transaction receipt because purchase info failed to validate against its signature.", NSLocalizedDescriptionKey,
@"Purchase info failed to validate against its signature.", NSLocalizedFailureReasonErrorKey,
nil];
- *theError = [NSError errorWithDomain:CBErrorDomain code:CBErrorCannotExtractPurchaseInfoFromTransactionReceipt userInfo:theUserInfo];
+ *theError = [NSError errorWithDomain:CargoBayErrorDomain code:CargoBayErrorCannotExtractPurchaseInfoFromTransactionReceipt userInfo:theUserInfo];
}
return nil;
}
@@ -728,8 +728,8 @@ - (void)verifyTransactionReceipt:(NSData *)transactionReceipt
NSInteger status = [responseObject valueForKey:@"status"] ? [[responseObject valueForKey:@"status"] integerValue] : NSNotFound;
switch (status) {
- case CBStatusOK: // Status 0: The receipt is valid.
- case CBStatusReceiptValidButSubscriptionExpired: { // Status 21006: This receipt is valid but the subscription has expired.
+ case CargoBayStatusOK: // Status 0: The receipt is valid.
+ case CargoBayStatusReceiptValidButSubscriptionExpired: { // Status 21006: This receipt is valid but the subscription has expired.
NSDictionary *receipt = [responseObject valueForKey:@"receipt"];
NSError *error = nil;
@@ -782,14 +782,14 @@ - (void)verifyTransactionReceipt:(NSData *)transactionReceipt
}
}
} break;
- case CBStatusSandboxReceiptSentToProduction: { // Status 21007: This receipt is a sandbox receipt, but it was sent to the production service for verification.
+ case CargoBayStatusSandboxReceiptSentToProduction: { // Status 21007: This receipt is a sandbox receipt, but it was sent to the production service for verification.
[self verifyTransactionReceipt:transactionReceipt
client:[self sandboxReceiptVerificationClient]
password:password
success:success
failure:failure];
} break;
- case CBStatusProductionReceiptSentToSandbox: { // Status 21008: This receipt is a production receipt, but it was sent to the sandbox service for verification.
+ case CargoBayStatusProductionReceiptSentToSandbox: { // Status 21008: This receipt is a production receipt, but it was sent to the sandbox service for verification.
[self verifyTransactionReceipt:transactionReceipt
client:[self productionReceiptVerificationClient]
password:password
@@ -801,7 +801,7 @@ - (void)verifyTransactionReceipt:(NSData *)transactionReceipt
NSString *exception = [responseObject valueForKey:@"exception"];
NSDictionary *userInfo = exception ? [NSDictionary dictionaryWithObject:exception forKey:NSLocalizedFailureReasonErrorKey] : nil;
- NSError *error = [[NSError alloc] initWithDomain:CBErrorDomain code:status userInfo:userInfo];
+ NSError *error = [[NSError alloc] initWithDomain:CargoBayErrorDomain code:status userInfo:userInfo];
failure(error);
}
} break;
@@ -880,7 +880,7 @@ - (void)verifyTransaction:(SKPaymentTransaction *)transaction
[NSString stringWithFormat:@"Cannot verify transaction because transaction (%@) not in purchased or restored state.", transaction.transactionIdentifier], NSLocalizedDescriptionKey,
[NSString stringWithFormat:@"Transaction (%@) not in purchased or restored state.", transaction.transactionIdentifier], NSLocalizedFailureReasonErrorKey,
nil];
- failure([NSError errorWithDomain:CBErrorDomain code:CBErrorTransactionNotInPurchasedOrRestoredState userInfo:userInfo]);
+ failure([NSError errorWithDomain:CargoBayErrorDomain code:CargoBayErrorTransactionNotInPurchasedOrRestoredState userInfo:userInfo]);
}
return;
}
@@ -931,7 +931,7 @@ - (BOOL)isTransactionAndItsReceiptValid:(SKPaymentTransaction *)theTransaction e
@"Transaction and its receipt is not valid because transaction object is not valid.", NSLocalizedDescriptionKey,
@"Transaction object is not valid.", NSLocalizedDescriptionKey,
nil];
- *theError = [NSError errorWithDomain:CBErrorDomain code:CBErrorTransactionNotValid userInfo:theUserInfo];
+ *theError = [NSError errorWithDomain:CargoBayErrorDomain code:CargoBayErrorTransactionNotValid userInfo:theUserInfo];
}
return NO;
}
@@ -964,7 +964,7 @@ - (BOOL)isTransactionAndItsReceiptValid:(SKPaymentTransaction *)theTransaction e
[NSDictionary dictionaryWithObjectsAndKeys:
@"Transaction does not match purchase info", NSLocalizedDescriptionKey,
nil];
- *theError = [NSError errorWithDomain:CBErrorDomain code:CBErrorTransactionDoesNotMatchesPurchaseInfo userInfo:theUserInfo];
+ *theError = [NSError errorWithDomain:CargoBayErrorDomain code:CargoBayErrorTransactionDoesNotMatchesPurchaseInfo userInfo:theUserInfo];
}
return NO;
}
Please sign in to comment.
Something went wrong with that request. Please try again.