修正内购流程中的一些bug
This commit is contained in:
parent
8b7fa5fe0b
commit
eaa77a3a10
@ -19,9 +19,6 @@
|
||||
|
||||
static Utilities *utility = nil;
|
||||
|
||||
@interface UIViewController (Purchase)
|
||||
@property (nonatomic) NSString *currentFunId;
|
||||
@end
|
||||
|
||||
@implementation UIViewController (Purchase)
|
||||
-(void)initPurchaseEnv {
|
||||
@ -124,22 +121,23 @@ static Utilities *utility = nil;
|
||||
return;
|
||||
}
|
||||
// check if currentFunId is empty
|
||||
if (self.currentFunId != nil && ![self.currentFunId isEqualToString:@""]) {
|
||||
NSLog(@"beginBy with currentFunId: %@", self.currentFunId);
|
||||
if ([StoreObserver sharedInstance].funid != nil && ![[StoreObserver sharedInstance].funid isEqualToString:@""]) {
|
||||
NSLog(@"beginBy with currentFunId: %@", [StoreObserver sharedInstance].funid);
|
||||
[self nativeCb:funId hasErr:YES dataStr:@"other purchase is processing"];
|
||||
return;
|
||||
}
|
||||
self.currentFunId = funId;
|
||||
|
||||
[StoreObserver sharedInstance].funid = funId;
|
||||
SKProduct *product = [[StoreManager sharedInstance] productMatchingIdentifier: productId];
|
||||
if (product == nil) {
|
||||
NSLog(@"beginBy with empty product: %@", productId);
|
||||
self.currentFunId = nil;
|
||||
[StoreObserver sharedInstance].funid = nil;
|
||||
[self nativeCb:funId hasErr:YES dataStr:@"beginBy with empty product"];
|
||||
return;
|
||||
}
|
||||
if (orderId == nil || [orderId isEqualToString:@""]) {
|
||||
NSLog(@"beginBy with empty orderId: %@", orderId);
|
||||
self.currentFunId = nil;
|
||||
[StoreObserver sharedInstance].funid = nil;
|
||||
[self nativeCb:funId hasErr:YES dataStr:@"beginBy with empty orderId"];
|
||||
return;
|
||||
}
|
||||
@ -173,10 +171,11 @@ static Utilities *utility = nil;
|
||||
NSDictionary* dic = notification.userInfo;
|
||||
NSNumber *errcode = dic[@"errcode"];
|
||||
NSLog(@"handlePurchaseNotification status: %@", errcode);
|
||||
NSString *funid = [StoreObserver sharedInstance].funid;
|
||||
[StoreObserver sharedInstance].funid = nil;
|
||||
// check if errcode is zero or not
|
||||
self.currentFunId = nil;
|
||||
if (errcode != nil && [errcode intValue] != 0) {
|
||||
[self nativeCb:self.currentFunId hasErr:YES dataStr: [NSString stringWithFormat:@"%@", dic[@"errmsg"]]];
|
||||
[self nativeCb:funid hasErr:YES dataStr: [NSString stringWithFormat:@"%@", dic[@"errmsg"]]];
|
||||
} else {
|
||||
NSString *tid = dic[@"dataid"];
|
||||
NSMutableArray *transactions = [[NSMutableArray alloc] init];
|
||||
@ -184,7 +183,8 @@ static Utilities *utility = nil;
|
||||
NSError *error;
|
||||
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:transactions options:NSJSONWritingPrettyPrinted error:&error];
|
||||
NSString *jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
|
||||
[self nativeCb:self.currentFunId hasErr:NO dataStr: jsonString];
|
||||
[self nativeCb:funid hasErr:NO dataStr: jsonString];
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
Binary file not shown.
@ -270,8 +270,8 @@
|
||||
filePath = "Classes_cocos/UIViewController+Purchase.mm"
|
||||
startingColumnNumber = "9223372036854775807"
|
||||
endingColumnNumber = "9223372036854775807"
|
||||
startingLineNumber = "44"
|
||||
endingLineNumber = "44"
|
||||
startingLineNumber = "41"
|
||||
endingLineNumber = "41"
|
||||
landmarkName = "-queryProducts:products:"
|
||||
landmarkType = "7">
|
||||
</BreakpointContent>
|
||||
@ -286,28 +286,12 @@
|
||||
filePath = "Classes_cocos/UIViewController+Purchase.mm"
|
||||
startingColumnNumber = "9223372036854775807"
|
||||
endingColumnNumber = "9223372036854775807"
|
||||
startingLineNumber = "97"
|
||||
endingLineNumber = "97"
|
||||
startingLineNumber = "94"
|
||||
endingLineNumber = "94"
|
||||
landmarkName = "-queryProducts:products:"
|
||||
landmarkType = "7">
|
||||
</BreakpointContent>
|
||||
</BreakpointProxy>
|
||||
<BreakpointProxy
|
||||
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
|
||||
<BreakpointContent
|
||||
uuid = "4FBF6B08-08A0-4695-995A-211586F5A6CF"
|
||||
shouldBeEnabled = "No"
|
||||
ignoreCount = "0"
|
||||
continueAfterRunningActions = "No"
|
||||
filePath = "Classes_cocos/UIViewController+Purchase.mm"
|
||||
startingColumnNumber = "9223372036854775807"
|
||||
endingColumnNumber = "9223372036854775807"
|
||||
startingLineNumber = "25"
|
||||
endingLineNumber = "25"
|
||||
landmarkName = "unknown"
|
||||
landmarkType = "0">
|
||||
</BreakpointContent>
|
||||
</BreakpointProxy>
|
||||
<BreakpointProxy
|
||||
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
|
||||
<BreakpointContent
|
||||
@ -318,8 +302,8 @@
|
||||
filePath = "Classes_cocos/UIViewController+Purchase.mm"
|
||||
startingColumnNumber = "9223372036854775807"
|
||||
endingColumnNumber = "9223372036854775807"
|
||||
startingLineNumber = "74"
|
||||
endingLineNumber = "74"
|
||||
startingLineNumber = "71"
|
||||
endingLineNumber = "71"
|
||||
landmarkName = "-queryProducts:products:"
|
||||
landmarkType = "7">
|
||||
</BreakpointContent>
|
||||
@ -334,8 +318,8 @@
|
||||
filePath = "Classes_cocos/UIViewController+Purchase.mm"
|
||||
startingColumnNumber = "9223372036854775807"
|
||||
endingColumnNumber = "9223372036854775807"
|
||||
startingLineNumber = "46"
|
||||
endingLineNumber = "46"
|
||||
startingLineNumber = "43"
|
||||
endingLineNumber = "43"
|
||||
landmarkName = "-queryProducts:products:"
|
||||
landmarkType = "7">
|
||||
</BreakpointContent>
|
||||
@ -350,8 +334,8 @@
|
||||
filePath = "Classes_cocos/UIViewController+Purchase.mm"
|
||||
startingColumnNumber = "9223372036854775807"
|
||||
endingColumnNumber = "9223372036854775807"
|
||||
startingLineNumber = "80"
|
||||
endingLineNumber = "80"
|
||||
startingLineNumber = "77"
|
||||
endingLineNumber = "77"
|
||||
landmarkName = "-queryProducts:products:"
|
||||
landmarkType = "7">
|
||||
</BreakpointContent>
|
||||
@ -382,8 +366,8 @@
|
||||
filePath = "purchase/StoreObserver.m"
|
||||
startingColumnNumber = "9223372036854775807"
|
||||
endingColumnNumber = "9223372036854775807"
|
||||
startingLineNumber = "131"
|
||||
endingLineNumber = "131"
|
||||
startingLineNumber = "132"
|
||||
endingLineNumber = "132"
|
||||
landmarkName = "-paymentQueue:updatedTransactions:"
|
||||
landmarkType = "7">
|
||||
</BreakpointContent>
|
||||
@ -392,14 +376,14 @@
|
||||
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
|
||||
<BreakpointContent
|
||||
uuid = "6E8F3D37-5AC6-454A-8526-57B1C343F168"
|
||||
shouldBeEnabled = "No"
|
||||
shouldBeEnabled = "Yes"
|
||||
ignoreCount = "0"
|
||||
continueAfterRunningActions = "No"
|
||||
filePath = "Classes_cocos/UIViewController+Purchase.mm"
|
||||
startingColumnNumber = "9223372036854775807"
|
||||
endingColumnNumber = "9223372036854775807"
|
||||
startingLineNumber = "111"
|
||||
endingLineNumber = "111"
|
||||
startingLineNumber = "108"
|
||||
endingLineNumber = "108"
|
||||
landmarkName = "-queryPurchase:"
|
||||
landmarkType = "7">
|
||||
</BreakpointContent>
|
||||
@ -408,14 +392,14 @@
|
||||
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
|
||||
<BreakpointContent
|
||||
uuid = "298A81F7-4B66-40D1-8EA3-BE7606FB25D2"
|
||||
shouldBeEnabled = "Yes"
|
||||
shouldBeEnabled = "No"
|
||||
ignoreCount = "0"
|
||||
continueAfterRunningActions = "No"
|
||||
filePath = "purchase/StoreObserver.m"
|
||||
startingColumnNumber = "9223372036854775807"
|
||||
endingColumnNumber = "9223372036854775807"
|
||||
startingLineNumber = "190"
|
||||
endingLineNumber = "190"
|
||||
startingLineNumber = "191"
|
||||
endingLineNumber = "191"
|
||||
landmarkName = "-handleTransactionPurchased:"
|
||||
landmarkType = "7">
|
||||
</BreakpointContent>
|
||||
@ -430,8 +414,8 @@
|
||||
filePath = "purchase/StoreObserver.m"
|
||||
startingColumnNumber = "9223372036854775807"
|
||||
endingColumnNumber = "9223372036854775807"
|
||||
startingLineNumber = "50"
|
||||
endingLineNumber = "50"
|
||||
startingLineNumber = "51"
|
||||
endingLineNumber = "51"
|
||||
landmarkName = "-getAppReceipt"
|
||||
landmarkType = "7">
|
||||
</BreakpointContent>
|
||||
@ -446,8 +430,8 @@
|
||||
filePath = "purchase/StoreObserver.m"
|
||||
startingColumnNumber = "9223372036854775807"
|
||||
endingColumnNumber = "9223372036854775807"
|
||||
startingLineNumber = "56"
|
||||
endingLineNumber = "56"
|
||||
startingLineNumber = "57"
|
||||
endingLineNumber = "57"
|
||||
landmarkName = "-getAppReceipt"
|
||||
landmarkType = "7">
|
||||
</BreakpointContent>
|
||||
@ -462,8 +446,8 @@
|
||||
filePath = "Classes_cocos/UIViewController+Purchase.mm"
|
||||
startingColumnNumber = "9223372036854775807"
|
||||
endingColumnNumber = "9223372036854775807"
|
||||
startingLineNumber = "158"
|
||||
endingLineNumber = "158"
|
||||
startingLineNumber = "156"
|
||||
endingLineNumber = "156"
|
||||
landmarkName = "-alertWithTitle:message:"
|
||||
landmarkType = "7">
|
||||
</BreakpointContent>
|
||||
@ -478,8 +462,8 @@
|
||||
filePath = "Classes_cocos/UIViewController+Purchase.mm"
|
||||
startingColumnNumber = "9223372036854775807"
|
||||
endingColumnNumber = "9223372036854775807"
|
||||
startingLineNumber = "159"
|
||||
endingLineNumber = "159"
|
||||
startingLineNumber = "157"
|
||||
endingLineNumber = "157"
|
||||
landmarkName = "-alertWithTitle:message:"
|
||||
landmarkType = "7">
|
||||
</BreakpointContent>
|
||||
@ -494,8 +478,8 @@
|
||||
filePath = "purchase/StoreObserver.m"
|
||||
startingColumnNumber = "9223372036854775807"
|
||||
endingColumnNumber = "9223372036854775807"
|
||||
startingLineNumber = "206"
|
||||
endingLineNumber = "206"
|
||||
startingLineNumber = "207"
|
||||
endingLineNumber = "207"
|
||||
landmarkName = "-handleTransactionFailed:"
|
||||
landmarkType = "7">
|
||||
</BreakpointContent>
|
||||
@ -504,14 +488,14 @@
|
||||
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
|
||||
<BreakpointContent
|
||||
uuid = "15FCA0D4-7E42-43F6-9DC2-FB0643322A2D"
|
||||
shouldBeEnabled = "Yes"
|
||||
shouldBeEnabled = "No"
|
||||
ignoreCount = "0"
|
||||
continueAfterRunningActions = "No"
|
||||
filePath = "purchase/StoreObserver.m"
|
||||
startingColumnNumber = "9223372036854775807"
|
||||
endingColumnNumber = "9223372036854775807"
|
||||
startingLineNumber = "264"
|
||||
endingLineNumber = "264"
|
||||
startingLineNumber = "265"
|
||||
endingLineNumber = "265"
|
||||
landmarkName = "-onPurchaseResult:errorCode:errorDescription:"
|
||||
landmarkType = "7">
|
||||
</BreakpointContent>
|
||||
@ -548,5 +532,85 @@
|
||||
landmarkType = "7">
|
||||
</BreakpointContent>
|
||||
</BreakpointProxy>
|
||||
<BreakpointProxy
|
||||
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
|
||||
<BreakpointContent
|
||||
uuid = "BD2882FC-C072-4CE1-844A-B339C7AF21D9"
|
||||
shouldBeEnabled = "No"
|
||||
ignoreCount = "0"
|
||||
continueAfterRunningActions = "No"
|
||||
filePath = "Classes_cocos/UIViewController+Purchase.mm"
|
||||
startingColumnNumber = "9223372036854775807"
|
||||
endingColumnNumber = "9223372036854775807"
|
||||
startingLineNumber = "115"
|
||||
endingLineNumber = "115"
|
||||
landmarkName = "-beginBuy:productId:orderId:"
|
||||
landmarkType = "7">
|
||||
</BreakpointContent>
|
||||
</BreakpointProxy>
|
||||
<BreakpointProxy
|
||||
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
|
||||
<BreakpointContent
|
||||
uuid = "A6E70BD2-FECB-4683-A170-4830D7CB026B"
|
||||
shouldBeEnabled = "No"
|
||||
ignoreCount = "0"
|
||||
continueAfterRunningActions = "No"
|
||||
filePath = "Classes_cocos/UIViewController+Purchase.mm"
|
||||
startingColumnNumber = "9223372036854775807"
|
||||
endingColumnNumber = "9223372036854775807"
|
||||
startingLineNumber = "124"
|
||||
endingLineNumber = "124"
|
||||
landmarkName = "-beginBuy:productId:orderId:"
|
||||
landmarkType = "7">
|
||||
</BreakpointContent>
|
||||
</BreakpointProxy>
|
||||
<BreakpointProxy
|
||||
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
|
||||
<BreakpointContent
|
||||
uuid = "820583EC-CE7D-4683-BC79-64E9EEBA6287"
|
||||
shouldBeEnabled = "No"
|
||||
ignoreCount = "0"
|
||||
continueAfterRunningActions = "No"
|
||||
filePath = "purchase/StoreObserver.m"
|
||||
startingColumnNumber = "9223372036854775807"
|
||||
endingColumnNumber = "9223372036854775807"
|
||||
startingLineNumber = "266"
|
||||
endingLineNumber = "266"
|
||||
landmarkName = "-onPurchaseResult:errorCode:errorDescription:"
|
||||
landmarkType = "7">
|
||||
</BreakpointContent>
|
||||
</BreakpointProxy>
|
||||
<BreakpointProxy
|
||||
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
|
||||
<BreakpointContent
|
||||
uuid = "F35AF2EC-613F-4489-AD46-ABA9D1D2EFD9"
|
||||
shouldBeEnabled = "No"
|
||||
ignoreCount = "0"
|
||||
continueAfterRunningActions = "No"
|
||||
filePath = "Classes_cocos/UIViewController+Purchase.mm"
|
||||
startingColumnNumber = "9223372036854775807"
|
||||
endingColumnNumber = "9223372036854775807"
|
||||
startingLineNumber = "173"
|
||||
endingLineNumber = "173"
|
||||
landmarkName = "-handlePurchaseNotification:"
|
||||
landmarkType = "7">
|
||||
</BreakpointContent>
|
||||
</BreakpointProxy>
|
||||
<BreakpointProxy
|
||||
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
|
||||
<BreakpointContent
|
||||
uuid = "4E1E964B-B983-4D31-A79F-BEA739EE307B"
|
||||
shouldBeEnabled = "No"
|
||||
ignoreCount = "0"
|
||||
continueAfterRunningActions = "No"
|
||||
filePath = "Classes_cocos/UIViewController+Purchase.mm"
|
||||
startingColumnNumber = "9223372036854775807"
|
||||
endingColumnNumber = "9223372036854775807"
|
||||
startingLineNumber = "180"
|
||||
endingLineNumber = "180"
|
||||
landmarkName = "-handlePurchaseNotification:"
|
||||
landmarkType = "7">
|
||||
</BreakpointContent>
|
||||
</BreakpointProxy>
|
||||
</Breakpoints>
|
||||
</Bucket>
|
||||
|
@ -2,6 +2,14 @@
|
||||
<VariablesViewState
|
||||
version = "1.0">
|
||||
<ContextStates>
|
||||
<ContextState
|
||||
contextName = "-[UIViewController(Purchase) beginBuy:productId:orderId:]:UIViewController+Purchase.mm">
|
||||
<PersistentStrings>
|
||||
<PersistentString
|
||||
value = "self.currentFunId">
|
||||
</PersistentString>
|
||||
</PersistentStrings>
|
||||
</ContextState>
|
||||
<ContextState
|
||||
contextName = "-[StoreObserver handlePurchasedTransaction:]:StoreObserver.m">
|
||||
<PersistentStrings>
|
||||
|
File diff suppressed because one or more lines are too long
@ -20,6 +20,7 @@ Implements the SKPaymentTransactionObserver protocol. Handles purchasing and res
|
||||
|
||||
/// Indicates the cause of the purchase failure.
|
||||
@property(nonatomic, copy) NSString *message;
|
||||
@property(nonatomic, copy) NSString *funid;
|
||||
|
||||
/// Keeps track of all purchases.
|
||||
@property(strong) NSMutableArray *productsPurchased;
|
||||
@ -46,4 +47,7 @@ Implements the SKPaymentTransactionObserver protocol. Handles purchasing and res
|
||||
|
||||
- (NSString *)getAppReceipt;
|
||||
|
||||
- (NSString *)getFunID;
|
||||
- (void) updateFunId: (NSString *) funid;
|
||||
|
||||
@end
|
||||
|
@ -32,6 +32,7 @@
|
||||
_pendingTransactions = [[NSMutableDictionary alloc] init];
|
||||
_finishedTransactions = [[NSMutableSet alloc] init];
|
||||
_status = PCSPurchaseStatusNone;
|
||||
_funid = nil;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
@ -110,7 +111,7 @@
|
||||
// payment.applicationUsername = orderId;
|
||||
// generate UUID for order id
|
||||
NSString *testOrderId = [[NSUUID UUID] UUIDString];
|
||||
[payment performSelector: @selector(setApplicationUsername:) withObject: testOrderId];
|
||||
[payment performSelector: @selector(setApplicationUsername:) withObject: orderId];
|
||||
[[SKPaymentQueue defaultQueue] addPayment:payment];
|
||||
}
|
||||
|
||||
@ -272,5 +273,13 @@
|
||||
});
|
||||
}
|
||||
|
||||
-(void)updateFunId:(NSString *)funid {
|
||||
_funid = funid;
|
||||
}
|
||||
|
||||
-(NSString *) getFunID{
|
||||
return _funid;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user