IAP plugin “This In-App Purchase has already been bought. It will be restored for free.” issue

Ah, even with non-consumable purchases? We are testing on iOS 11 as well. So there is no repro for the issue as shown in the video i sent so far on your side?

I’ve seen the thread. Thread seems to be implying its Apple side issue and we cannot do anything about it.

Here’s a thread discussing handling of the issue by various projects that coded their own IAPs https://stackoverflow.com/questions/34001868/ios-this-in-app-purchase-has-already-been-bought-pop-up

yes, i tried non-consumable purchase.

and i tried consumable purchase. many times. but every time i try to repurchase, it’s a new purchase. the last purchase success, and it’s product have been consumed

how about, you test with https://github.com/sdkbox/sdkbox-sample-iap/cpp. then we are use the same app to test.

this thread (https://stackoverflow.com/questions/34001868/ios-this-in-app-purchase-has-already-been-bought-pop-up). maybe you can try sdkbox::IAP::finishTransaction.

do you have any other analytics SDK such as Firebase? As http://greensopinion.com/2017/03/22/This-In-App-Purchase-Has-Already-Been-Bought.html

These SDK may add its own SKPaymentTransactionObserver.

            // ORDER DEPENDENCY: before analytics
            SKPaymentQueue.default().add(createPaymentTransactionObserver())

            // ORDER DEPENDENCY: do this after store service setup!
            FIRApp.configure()

Trying to build the test project to repro. I think I followed the steps, I’ve run the setup scrip and sdkbox-cocos2d-x-binary is created with the right structure. However, on trying opening and trying to build iap_cpp.xcodeproj, I get multiple errors. Attached here is screenshot:

I got this error, too.
The binary lib seems not support arm64.
The workaround is to build only for arm7 and run it on arm7 devices, not arm64.
I could run it on iPhone 4s, I think iPhone 5 works, too.

Thanks. this made it work, but hard for me to get repro now as I can’t build on iOS11 devices. @htlxyz is there any way to update test project so that it builds on arm64?

@IvanLoo
Glad that works.

I have few questions about how you use the sdkbox:

  1. Do you call IAP::init() when appdidlaunch? Or you call it later?
  2. Do you add listener before IAP::init() or after?

I may find some clues but not really sure for now, so I would like to know your information.

Thanks,
Jo

@joappdev, @IvanLoo

Hi, I upload the lib which support arm64 prebuilt/ios/libcocos2d iOS.a.zip.
You need to unzip the zip and replace it with libcocos2d iOS.a.

steps:

cd sdkbox-cocos2d-x-binary
git pull

## unzip prebuilt/ios/libcocos2d\ iOS.a.zip -d prebuilt/ios/
unzip prebuilt/ios/Archive.zip -d prebuilt/ios/

And then try it on iOS11 device again. Thanks.

P.S: Because Github is not allow file size >= 100M, so the libcocos2d iOS.a in repo only support

  • i386
  • armv7

Hi Jimmy,

Thanks for uploading. I managed to get it to build and run, but the app crashed on launch on iOS11, iPhone 8.

Screenshot of crash:

how about clean, and rebuild?

Same problem. I’ve built on iPhone 5 simulator as well with same result.

regarding your question:

we actually have to code hunt and review a little bit as our project was built over the years with various SDKs. “organic code” haha.

I’m hoping to first verify whether its an SDKBox issue before jumping into to figure out whether its one of the other SDKs or a combination of them that is the problem.

fix steps:

cd sdkbox-cocos2d-x-binary
git pull
unzip prebuilt/ios/Archive.zip -d prebuilt/ios/

The reason is the libcocos2d\ iOS.a file is not match cocos2d’s headers. Our engineer did some modify for GitHub 100M file limit.

I sync up all cocos2d-x 3.8.1 lib now, sorry for above runtime error. It should launch without crash.

BTW, you need to change the sdkbox_config.json with your conf.
Thanks,

Thanks, will try now.

oh hm, how do I set up the sdkbox_config.json? Sorry I actually wasn’t responsible for implementing the SDK into the product.

Managed to test by replacing sdkbox_config.json and renaming app bundle Ids to our own.

No repro so far, I’m going to ask the original issue finder to repro on test project. If no repro, we’ll start looking at our code to figure out whats going on.

@IvanLoo Thanks for your testing.

@kale1 @joappdev Please test this https://github.com/sdkbox/sdkbox-sample-iap repo, because IvanLoo can not reproduce this issue with it.

If you clone sdkbox-cocos2d-x-binary before, plz pull the latest code and unzip the iOS library:

cd sdkbox-cocos2d-x-binary
git pull
unzip prebuilt/ios/Archive.zip -d prebuilt/ios/

Just following up real quick: Can confirm no repro with Test Project from various testers.

Hi

I can reproduce in my app, but not in the sdk-sample.

possible reasons:

  1. I didn’t put IAP::init() in the appdidlaunch because I need to ask server for config json.
  2. I set listener AFTER IAP::init().
  3. I use some third party sdk for statistics, so I guess they might listen to the Payment queue also.

workaround:
set listener BEFORE IAP::init(),
put IAP::init() in the appdidlaunch,
and IAP::init(config.json) again after I got config.json.

If the case happened, I can get the onSuccess callback right after appdidlaunch, and I guess SDK box finish transaction at that time.

Hope this info helpful for other developers.

Jo

1 Like

hey all, just wanted to follow up.

Based on joappdev advice, we managed to confirm that the problem is fixed. We can reasonably conclude the problem to be the following:

IAP::init(config.json) was not complete on app launch, leading to the issue.

Our solution:
Wait for IAP::(config.json) to finish loading before allowing user to enter game.

Hope this helps! Also thanks to the team + joappdev for the suggestions/help!