Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Continue to improve error reporting.

  • Loading branch information...
commit 9f452511bb9116e0b30b0be6708b1df9664bcfb1 1 parent c34027f
@lxcid authored
Showing with 16 additions and 4 deletions.
  1. +2 −0  CargoBay/CargoBay.h
  2. +14 −4 CargoBay/CargoBay.m
View
2  CargoBay/CargoBay.h
@@ -51,6 +51,8 @@ typedef NS_ENUM(NSInteger, CBErrorCode) {
CBErrorPurchaseInfoDoesNotMatchReceipt = 1,
CBErrorTransactionDoesNotMatchesPurchaseInfo = 2,
CBErrorCannotExtractPurchaseInfoFromTransactionReceipt = 3,
+ CBErrorTransactionNotInPurchasedOrRestoredState = 4,
+ CBErrorTransactionNotValid = 5,
// Error codes derived from status codes for auto-renewable subscriptions
CBErrorCannotParseJSON = CBStatusCannotParseJSON,
View
18 CargoBay/CargoBay.m
@@ -867,16 +867,18 @@ - (void)verifyTransaction:(SKPaymentTransaction *)transaction
{
if ((transaction.transactionState != SKPaymentTransactionStatePurchased) && (transaction.transactionState != SKPaymentTransactionStateRestored)) {
if (failure) {
- failure([[NSError alloc] initWithDomain:SKErrorDomain code:-1 userInfo:nil]);
+ NSDictionary *userInfo =
+ [NSDictionary dictionaryWithObjectsAndKeys:
+ [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]);
}
return;
}
NSError *error = nil;
if (![self isTransactionAndItsReceiptValid:transaction error:&error]) {
if (failure) {
- if (!error) {
- error = [[NSError alloc] initWithDomain:SKErrorDomain code:-1 userInfo:nil];
- }
failure(error);
}
return;
@@ -914,6 +916,14 @@ - (void)setPaymentQueueRestoreCompletedTransactionsWithSuccess:(void (^)(SKPayme
- (BOOL)isTransactionAndItsReceiptValid:(SKPaymentTransaction *)theTransaction error:(NSError * __autoreleasing *)theError {
if (!((theTransaction) && (theTransaction.transactionReceipt) && (theTransaction.transactionReceipt.length > 0))) {
// Transaction is not valid.
+ if (theError != NULL) {
+ NSDictionary *theUserInfo =
+ [NSDictionary dictionaryWithObjectsAndKeys:
+ @"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];
+ }
return NO;
}
Please sign in to comment.
Something went wrong with that request. Please try again.