Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unfinished transactions are not removed #1535

Open
selcukbeyhan opened this issue Feb 21, 2024 · 1 comment
Open

Unfinished transactions are not removed #1535

selcukbeyhan opened this issue Feb 21, 2024 · 1 comment

Comments

@selcukbeyhan
Copy link

I was reading the source code for iOS and came across a situation in the code of "InAppPurchase".
This function is called in the app startup:

- (void) processTransactionUpdate:(SKPaymentTransaction*)transaction withArgs:(NSArray*)callbackArgs {

    DLog(@"processTransactionUpdate:withArgs: transactionIdentifier=%@", callbackArgs[PT_INDEX_TRANSACTION_IDENTIFIER]);
    NSString *js = [NSString
        stringWithFormat:@"window.storekit.transactionUpdated.apply(window.storekit, %@)",
        [callbackArgs JSONSerialize]];
    [self.commandDelegate evalJs:js];

    SKPaymentTransactionState state = transaction.transactionState;
    BOOL canFinish = state == SKPaymentTransactionStateRestored
        || state == SKPaymentTransactionStateFailed
        || state == SKPaymentTransactionStatePurchased;

    if (g_autoFinishEnabled && canFinish) {
        [[SKPaymentQueue defaultQueue] finishTransaction:transaction];
        [self transactionFinished:transaction];
    }
    else {
        [self.unfinishedTransactions setObject:transaction forKey:callbackArgs[PT_INDEX_TRANSACTION_IDENTIFIER]];
    }
}

If a transaction is not finished (due to any reason), it is added to the set of "self.unfinishedTransactions". However, this set is never cleaned up.

There is only one section where this set is processed, it is within "- (void) finishTransaction: (CDVInvokedUrlCommand*)command".
However, to call this successfully, you need the transactionID.
You cannot provide the transactionID of those unfinishedTransactions because simply there is no get for that to process them.

It seems to be processed only if the flag "g_autoFinishEnabled" is activated.

There should be a way of processing those unfinishedTransactions too.

Thanks

@AlexandrDegteari
Copy link

same problem

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants