From 151ff2159d7969611e13a9bb8852b41b4ebe3b56 Mon Sep 17 00:00:00 2001 From: Olof Date: Tue, 29 Mar 2016 14:35:26 +0200 Subject: [PATCH 1/9] work --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 62fa551d..16fab8da 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ #RMStore +I have changed this. + [![CocoaPods Version](https://cocoapod-badges.herokuapp.com/v/RMStore/badge.png)](http://cocoadocs.org/docsets/RMStore) [![Platform](https://cocoapod-badges.herokuapp.com/p/RMStore/badge.png)](http://cocoadocs.org/docsets/RMStore) [![Build Status](https://travis-ci.org/robotmedia/RMStore.png)](https://travis-ci.org/robotmedia/RMStore) [![Join the chat at https://gitter.im/robotmedia/RMStore](https://badges.gitter.im/robotmedia/RMStore.svg)](https://gitter.im/robotmedia/RMStore?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) From b3af1b5894894cffc7a5bc63628fbccd6a7e6219 Mon Sep 17 00:00:00 2001 From: OlofT Date: Tue, 29 Mar 2016 14:52:17 +0200 Subject: [PATCH 2/9] Removed changes from README --- README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/README.md b/README.md index 16fab8da..62fa551d 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,5 @@ #RMStore -I have changed this. - [![CocoaPods Version](https://cocoapod-badges.herokuapp.com/v/RMStore/badge.png)](http://cocoadocs.org/docsets/RMStore) [![Platform](https://cocoapod-badges.herokuapp.com/p/RMStore/badge.png)](http://cocoadocs.org/docsets/RMStore) [![Build Status](https://travis-ci.org/robotmedia/RMStore.png)](https://travis-ci.org/robotmedia/RMStore) [![Join the chat at https://gitter.im/robotmedia/RMStore](https://badges.gitter.im/robotmedia/RMStore.svg)](https://gitter.im/robotmedia/RMStore?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) From 2db7e80bcf18c8161772f319aa60347ba8a2cc04 Mon Sep 17 00:00:00 2001 From: Olof Date: Tue, 29 Mar 2016 15:28:01 +0200 Subject: [PATCH 3/9] Added a notification for completed orphan transactions --- RMStore/RMStore.h | 1 + RMStore/RMStore.m | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/RMStore/RMStore.h b/RMStore/RMStore.h index 1a7a6622..7d844e9a 100755 --- a/RMStore/RMStore.h +++ b/RMStore/RMStore.h @@ -30,6 +30,7 @@ extern NSString *const RMStoreErrorDomain; extern NSInteger const RMStoreErrorCodeDownloadCanceled; extern NSInteger const RMStoreErrorCodeUnknownProductIdentifier; extern NSInteger const RMStoreErrorCodeUnableToCompleteVerification; +extern NSString* const RMSKPaymentTransactionOrhanFinished; /** A StoreKit wrapper that adds blocks and notifications, plus optional receipt verification and purchase management. */ diff --git a/RMStore/RMStore.m b/RMStore/RMStore.m index ece43bd9..48fda326 100755 --- a/RMStore/RMStore.m +++ b/RMStore/RMStore.m @@ -39,6 +39,7 @@ NSString* const RMSKRefreshReceiptFinished = @"RMSKRefreshReceiptFinished"; NSString* const RMSKRestoreTransactionsFailed = @"RMSKRestoreTransactionsFailed"; NSString* const RMSKRestoreTransactionsFinished = @"RMSKRestoreTransactionsFinished"; +NSString* const RMSKPaymentTransactionOrhanFinished = @"RMSKPaymentTransactionOrhanFinished"; NSString* const RMStoreNotificationInvalidProductIdentifiers = @"invalidProductIdentifiers"; NSString* const RMStoreNotificationDownloadProgress = @"downloadProgress"; @@ -640,6 +641,14 @@ - (void)finishTransaction:(SKPaymentTransaction *)transaction queue:(SKPaymentQu { wrapper.successBlock(transaction); } + else + { + /* + Nobody has requested this transaction, which would indicate that the app has died after purchase (or at least sometime after beeing added) but before finishTransaction was called. + This regularly happens on older devices if credit cards are denied or old, then the user needs to update their card info and switch away from the app. When coming back the app might have been killed and the success-block is gone (since it was living in RAM). + */ + [self postNotificationWithName:RMSKPaymentTransactionOrhanFinished transaction:transaction userInfoExtras:nil]; + } [self postNotificationWithName:RMSKPaymentTransactionFinished transaction:transaction userInfoExtras:nil]; From f0864654e999b86a7450967042243550ba762546 Mon Sep 17 00:00:00 2001 From: Olof Date: Tue, 29 Mar 2016 15:32:33 +0200 Subject: [PATCH 4/9] Added a notification for failed orphan transactions --- RMStore/RMStore.h | 9 +++++++++ RMStore/RMStore.m | 5 +++++ 2 files changed, 14 insertions(+) diff --git a/RMStore/RMStore.h b/RMStore/RMStore.h index 7d844e9a..620c385b 100755 --- a/RMStore/RMStore.h +++ b/RMStore/RMStore.h @@ -30,8 +30,17 @@ extern NSString *const RMStoreErrorDomain; extern NSInteger const RMStoreErrorCodeDownloadCanceled; extern NSInteger const RMStoreErrorCodeUnknownProductIdentifier; extern NSInteger const RMStoreErrorCodeUnableToCompleteVerification; + +/** + This gets posted globally when: + Nobody has requested this transaction, which would indicate that the app has died after purchase (or at least sometime after beeing added) but before finishTransaction was called. + This regularly happens on older devices if credit cards are denied or old, then the user needs to update their card info and switch away from the app. When coming back the app might have been killed and the success-block is gone (since it was living in RAM). + */ extern NSString* const RMSKPaymentTransactionOrhanFinished; +///Same as RMSKPaymentTransactionOrhanFinished but for failed purchases. +extern NSString* const RMSKPaymentTransactionOrhanFailed; + /** A StoreKit wrapper that adds blocks and notifications, plus optional receipt verification and purchase management. */ @interface RMStore : NSObject diff --git a/RMStore/RMStore.m b/RMStore/RMStore.m index 48fda326..d594b8d9 100755 --- a/RMStore/RMStore.m +++ b/RMStore/RMStore.m @@ -40,6 +40,7 @@ NSString* const RMSKRestoreTransactionsFailed = @"RMSKRestoreTransactionsFailed"; NSString* const RMSKRestoreTransactionsFinished = @"RMSKRestoreTransactionsFinished"; NSString* const RMSKPaymentTransactionOrhanFinished = @"RMSKPaymentTransactionOrhanFinished"; +NSString* const RMSKPaymentTransactionOrhanFailed = @"RMSKPaymentTransactionOrhanFailed"; NSString* const RMStoreNotificationInvalidProductIdentifiers = @"invalidProductIdentifiers"; NSString* const RMStoreNotificationDownloadProgress = @"downloadProgress"; @@ -558,6 +559,10 @@ - (void)didFailTransaction:(SKPaymentTransaction *)transaction queue:(SKPaymentQ { parameters.failureBlock(transaction, error); } + else + { + [self postNotificationWithName:RMSKPaymentTransactionOrhanFailed transaction:transaction userInfoExtras:nil]; + } NSDictionary *extras = error ? @{RMStoreNotificationStoreError : error} : nil; [self postNotificationWithName:RMSKPaymentTransactionFailed transaction:transaction userInfoExtras:extras]; From 4a5bcbd91a00c19d31425b1f41979fc031317205 Mon Sep 17 00:00:00 2001 From: Olof Date: Tue, 29 Mar 2016 17:46:45 +0200 Subject: [PATCH 5/9] Fixed a spelling error --- RMStore/RMStore.m | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/RMStore/RMStore.m b/RMStore/RMStore.m index d594b8d9..3895505b 100755 --- a/RMStore/RMStore.m +++ b/RMStore/RMStore.m @@ -39,8 +39,8 @@ NSString* const RMSKRefreshReceiptFinished = @"RMSKRefreshReceiptFinished"; NSString* const RMSKRestoreTransactionsFailed = @"RMSKRestoreTransactionsFailed"; NSString* const RMSKRestoreTransactionsFinished = @"RMSKRestoreTransactionsFinished"; -NSString* const RMSKPaymentTransactionOrhanFinished = @"RMSKPaymentTransactionOrhanFinished"; -NSString* const RMSKPaymentTransactionOrhanFailed = @"RMSKPaymentTransactionOrhanFailed"; +NSString* const RMSKPaymentTransactionOrphanFinished = @"RMSKPaymentTransactionOrphanFinished"; +NSString* const RMSKPaymentTransactionOrphanFailed = @"RMSKPaymentTransactionOrphanFailed"; NSString* const RMStoreNotificationInvalidProductIdentifiers = @"invalidProductIdentifiers"; NSString* const RMStoreNotificationDownloadProgress = @"downloadProgress"; @@ -561,7 +561,7 @@ - (void)didFailTransaction:(SKPaymentTransaction *)transaction queue:(SKPaymentQ } else { - [self postNotificationWithName:RMSKPaymentTransactionOrhanFailed transaction:transaction userInfoExtras:nil]; + [self postNotificationWithName:RMSKPaymentTransactionOrphanFailed transaction:transaction userInfoExtras:nil]; } NSDictionary *extras = error ? @{RMStoreNotificationStoreError : error} : nil; @@ -652,7 +652,7 @@ - (void)finishTransaction:(SKPaymentTransaction *)transaction queue:(SKPaymentQu Nobody has requested this transaction, which would indicate that the app has died after purchase (or at least sometime after beeing added) but before finishTransaction was called. This regularly happens on older devices if credit cards are denied or old, then the user needs to update their card info and switch away from the app. When coming back the app might have been killed and the success-block is gone (since it was living in RAM). */ - [self postNotificationWithName:RMSKPaymentTransactionOrhanFinished transaction:transaction userInfoExtras:nil]; + [self postNotificationWithName:RMSKPaymentTransactionOrphanFinished transaction:transaction userInfoExtras:nil]; } [self postNotificationWithName:RMSKPaymentTransactionFinished transaction:transaction userInfoExtras:nil]; From e06f1735f3048446d2038d8f05e9d701f011151d Mon Sep 17 00:00:00 2001 From: Olof Date: Tue, 29 Mar 2016 17:49:13 +0200 Subject: [PATCH 6/9] Fixed a spelling error --- RMStore/RMStore.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/RMStore/RMStore.h b/RMStore/RMStore.h index 620c385b..fa32364f 100755 --- a/RMStore/RMStore.h +++ b/RMStore/RMStore.h @@ -36,10 +36,10 @@ extern NSInteger const RMStoreErrorCodeUnableToCompleteVerification; Nobody has requested this transaction, which would indicate that the app has died after purchase (or at least sometime after beeing added) but before finishTransaction was called. This regularly happens on older devices if credit cards are denied or old, then the user needs to update their card info and switch away from the app. When coming back the app might have been killed and the success-block is gone (since it was living in RAM). */ -extern NSString* const RMSKPaymentTransactionOrhanFinished; +extern NSString* const RMSKPaymentTransactionOrphanFinished; -///Same as RMSKPaymentTransactionOrhanFinished but for failed purchases. -extern NSString* const RMSKPaymentTransactionOrhanFailed; +///Same as RMSKPaymentTransactionOrphanFinished but for failed purchases. +extern NSString* const RMSKPaymentTransactionOrphanFailed; /** A StoreKit wrapper that adds blocks and notifications, plus optional receipt verification and purchase management. */ From 8079fb9dc5e5fd04ba685c3adac7063e757c4fbf Mon Sep 17 00:00:00 2001 From: Olof Date: Tue, 29 Mar 2016 18:05:00 +0200 Subject: [PATCH 7/9] Exposing the key for notifications userInfo, so notifications can be used by non-framework classes --- RMStore/RMStore.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/RMStore/RMStore.h b/RMStore/RMStore.h index fa32364f..a2a72753 100755 --- a/RMStore/RMStore.h +++ b/RMStore/RMStore.h @@ -41,6 +41,9 @@ extern NSString* const RMSKPaymentTransactionOrphanFinished; ///Same as RMSKPaymentTransactionOrphanFinished but for failed purchases. extern NSString* const RMSKPaymentTransactionOrphanFailed; +///The key in the userInfo dictionary where the transaction can be found. +extern NSString* const RMStoreNotificationTransaction; + /** A StoreKit wrapper that adds blocks and notifications, plus optional receipt verification and purchase management. */ @interface RMStore : NSObject From 090f4a604b12acf9708090c1575a92a1103c522a Mon Sep 17 00:00:00 2001 From: Olof Date: Tue, 29 Mar 2016 18:41:05 +0200 Subject: [PATCH 8/9] Moved orphan notification into the RMStoreObserver --- RMStore/RMStore.h | 15 ++------------- RMStore/RMStore.m | 5 +++++ 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/RMStore/RMStore.h b/RMStore/RMStore.h index a2a72753..c449999c 100755 --- a/RMStore/RMStore.h +++ b/RMStore/RMStore.h @@ -31,19 +31,6 @@ extern NSInteger const RMStoreErrorCodeDownloadCanceled; extern NSInteger const RMStoreErrorCodeUnknownProductIdentifier; extern NSInteger const RMStoreErrorCodeUnableToCompleteVerification; -/** - This gets posted globally when: - Nobody has requested this transaction, which would indicate that the app has died after purchase (or at least sometime after beeing added) but before finishTransaction was called. - This regularly happens on older devices if credit cards are denied or old, then the user needs to update their card info and switch away from the app. When coming back the app might have been killed and the success-block is gone (since it was living in RAM). - */ -extern NSString* const RMSKPaymentTransactionOrphanFinished; - -///Same as RMSKPaymentTransactionOrphanFinished but for failed purchases. -extern NSString* const RMSKPaymentTransactionOrphanFailed; - -///The key in the userInfo dictionary where the transaction can be found. -extern NSString* const RMStoreNotificationTransaction; - /** A StoreKit wrapper that adds blocks and notifications, plus optional receipt verification and purchase management. */ @interface RMStore : NSObject @@ -274,6 +261,8 @@ extern NSString* const RMStoreNotificationTransaction; - (void)storeRefreshReceiptFinished:(NSNotification*)notification __attribute__((availability(ios,introduced=7.0))); - (void)storeRestoreTransactionsFailed:(NSNotification*)notification; - (void)storeRestoreTransactionsFinished:(NSNotification*)notification; +- (void)storeTransactionsOrphanFinished:(NSNotification*)notification; +- (void)storeTransactionsOrphanFailed:(NSNotification*)notification; @end diff --git a/RMStore/RMStore.m b/RMStore/RMStore.m index 3895505b..2ca13c28 100755 --- a/RMStore/RMStore.m +++ b/RMStore/RMStore.m @@ -334,6 +334,9 @@ - (void)addStoreObserver:(id)observer [self addStoreObserver:observer selector:@selector(storeRefreshReceiptFinished:) notificationName:RMSKRefreshReceiptFinished]; [self addStoreObserver:observer selector:@selector(storeRestoreTransactionsFailed:) notificationName:RMSKRestoreTransactionsFailed]; [self addStoreObserver:observer selector:@selector(storeRestoreTransactionsFinished:) notificationName:RMSKRestoreTransactionsFinished]; + [self addStoreObserver:observer selector:@selector(storeTransactionsOrphanFinished:) notificationName:RMSKPaymentTransactionOrphanFinished]; + [self addStoreObserver:observer selector:@selector(storeTransactionsOrphanFailed:) notificationName:RMSKPaymentTransactionOrphanFailed]; + } - (void)removeStoreObserver:(id)observer @@ -352,6 +355,8 @@ - (void)removeStoreObserver:(id)observer [[NSNotificationCenter defaultCenter] removeObserver:observer name:RMSKRefreshReceiptFinished object:self]; [[NSNotificationCenter defaultCenter] removeObserver:observer name:RMSKRestoreTransactionsFailed object:self]; [[NSNotificationCenter defaultCenter] removeObserver:observer name:RMSKRestoreTransactionsFinished object:self]; + [[NSNotificationCenter defaultCenter] removeObserver:observer name:RMSKPaymentTransactionOrphanFinished object:self]; + [[NSNotificationCenter defaultCenter] removeObserver:observer name:RMSKPaymentTransactionOrphanFailed object:self]; } // Private From 01df54fa8aeee93749ac4caae4020230f8f62b64 Mon Sep 17 00:00:00 2001 From: Olof Date: Fri, 15 Apr 2016 17:38:02 +0200 Subject: [PATCH 9/9] work --- RMStore/RMStore.m | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/RMStore/RMStore.m b/RMStore/RMStore.m index 2ca13c28..01f49762 100755 --- a/RMStore/RMStore.m +++ b/RMStore/RMStore.m @@ -131,7 +131,8 @@ @interface RMStore() @end -@implementation RMStore { +@implementation RMStore +{ NSMutableDictionary *_addPaymentParameters; // HACK: We use a dictionary of product identifiers because the returned SKPayment is different from the one we add to the queue. Bad Apple. NSMutableDictionary *_products; NSMutableSet *_productsRequestDelegates; @@ -295,7 +296,7 @@ - (void)refreshReceiptOnSuccess:(RMStoreSuccessBlock)successBlock { _refreshReceiptFailureBlock = failureBlock; _refreshReceiptSuccessBlock = successBlock; - _refreshReceiptRequest = [[SKReceiptRefreshRequest alloc] initWithReceiptProperties:@{}]; + _refreshReceiptRequest = [[SKReceiptRefreshRequest alloc] initWithReceiptProperties:@{}]; _refreshReceiptRequest.delegate = self; [_refreshReceiptRequest start]; } @@ -770,7 +771,7 @@ - (void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProdu for (SKProduct *product in products) { - RMStoreLog(@"received product with id %@", product.productIdentifier); + //RMStoreLog(@"received product with id %@", product.productIdentifier); [self.store addProduct:product]; }