Closed karansnarula closed 6 years ago
Steps:
This is basic knowledge you need to get this library to work. Once you have done that we can help you.
Hi, thank you for your helpful response, I am currently trying to make my app work on android before going to iOS. I have successfully integrated in-app purchase in my app using https://github.com/libgdx/gdx-pay/wiki/Integration-example-with-resolvers as an example. The issue I am having are the CONSUMABLE products in my game, whenever I buy a product and buy it again my app crashes. I tried reinstalling the game several times and tried buying the product but the game crashes even before the payment bill shows up. Is there something I am doing wrong? Should I show my code?
Actually consumables was contributed by someone else (@junkdog). Does he have this problem to?
What error do you see in logcat?
I have actually (magically I guess) fixed the issue, maybe it was because I didn't call the 'request purchase restore' method so I made a button that will explicitly call the 'request purchase restore' method and for some reason I am able to buy the consumable items multiple times but I do need click the restore button to actually get those items . Later I decided to add ENTITILEMENT item and I could successfully purchase the item but if I click it again after purchasing the app crashes. I will show my Logcat in my next comment.
Here is my logcat when I click on an already purchased ENTITLEMENT product. Is there any way to fix this?
FATAL EXCEPTION: Thread-17143 Process: com.karangames.game, PID: 20766 com.badlogic.gdx.utils.GdxRuntimeException: com.badlogic.gdx.pay.android.googleplay.GdxPayException: startPurchaseRequest failed at getBuyIntent() for product: product_4 at com.karangames.game.Store$1.handlePurchaseError(Store.java:70) at com.badlogic.gdx.pay.android.googleplay.AndroidGooglePlayPurchaseManager$2.purchaseError(AndroidGooglePlayPurchaseManager.java:221) at com.badlogic.gdx.pay.android.googleplay.billing.V3GoogleInAppBillingService.internalStartPurchaseRequest(V3GoogleInAppBillingService.java:216) at com.badlogic.gdx.pay.android.googleplay.billing.V3GoogleInAppBillingService.access$200(V3GoogleInAppBillingService.java:40) at com.badlogic.gdx.pay.android.googleplay.billing.V3GoogleInAppBillingService$1.run(V3GoogleInAppBillingService.java:227) at com.badlogic.gdx.pay.android.googleplay.billing.NewThreadSleepAsyncExecutor$1.run(NewThreadSleepAsyncExecutor.java:15) at java.lang.Thread.run(Thread.java:818) Caused by: com.badlogic.gdx.pay.android.googleplay.GdxPayException: startPurchaseRequest failed at getBuyIntent() for product: product_4 at com.badlogic.gdx.pay.android.googleplay.billing.V3GoogleInAppBillingService.internalStartPurchaseRequest(V3GoogleInAppBillingService.java:216) at com.badlogic.gdx.pay.android.googleplay.billing.V3GoogleInAppBillingService.access$200(V3GoogleInAppBillingService.java:40) at com.badlogic.gdx.pay.android.googleplay.billing.V3GoogleInAppBillingService$1.run(V3GoogleInAppBillingService.java:227) at com.badlogic.gdx.pay.android.googleplay.billing.NewThreadSleepAsyncExecutor$1.run(NewThreadSleepAsyncExecutor.java:15) at java.lang.Thread.run(Thread.java:818) Caused by: com.badlogic.gdx.pay.android.googleplay.GdxPayException: Unexpected getBuyIntent() responseCode: ResponseCode{code=3, message='Billing API version is not supported for the type requested'} with response data: Bundle[{RESPONSE_CODE=3}] at com.badlogic.gdx.pay.android.googleplay.billing.V3GoogleInAppBillingService.fetchPendingIntentFromGetBuyIntentResponse(V3GoogleInAppBillingService.java:299) at com.badlogic.gdx.pay.android.googleplay.billing.V3GoogleInAppBillingService.getBuyIntent(V3GoogleInAppBillingService.java:289) at com.badlogic.gdx.pay.android.googleplay.billing.V3GoogleInAppBillingService.internalStartPurchaseRequest(V3GoogleInAppBillingService.java:208) at com.badlogic.gdx.pay.android.googleplay.billing.V3GoogleInAppBillingService.access$200(V3GoogleInAppBillingService.java:40) at com.badlogic.gdx.pay.android.googleplay.billing.V3GoogleInAppBillingService$1.run(V3GoogleInAppBillingService.java:227) at com.badlogic.gdx.pay.android.googleplay.billing.NewThreadSleepAsyncExecutor$1.run(NewThreadSleepAsyncExecutor.java:15) at java.lang.Thread.run(Thread.java:818)
This is intended behavior.
Javadoc of com.badlogic.gdx.pay.OfferType#ENTITLEMENT
:
An entitlement can only be purchased once (e.g. one time upgrade). Basically a non-consumable.
Existing transactions (including entitlement) are passed to the app on startup via com.badlogic.gdx.pay.PurchaseObserver#handleRestore
. If a product is in the list of Transactions of restore, let the user not buy it again for entitlements.
I used gdx-pay for ios and it works properly. My application has been published in the market and provides purchasing as well as restoring functionality (for non-consumable product).
But in 'App Store Promotions' page I got a message 'These in-app purchases can’t be promoted on the App Store because your latest app binary doesn’t include the SKPaymentTransactionObserver method.
When I asked support engineers they responses that 'it doesn't look like your app has implemented the paymentQueue:shouldAddStorePayment:forProduct method.'
I would appreciate any advise if Is it possible do something to improve the situation?
@Glyfad so far I have not tried to promote in-app purchases, it is on our TODO-list.
The ios implementation does implement SKPaymentTransactionObserver, see: https://github.com/libgdx/gdx-pay/blob/master/gdx-pay-iosrobovm-apple/src/main/java/com/badlogic/gdx/pay/ios/apple/PurchaseManageriOSApple.java#L350
I don't know if there are any special requirements, can you let your engineer look at that code?
Also found this: https://stackoverflow.com/questions/46672653/skpaymenttransactionobserver-in-app-purchases-can-t-be-promoted-on-the-app-stor
Is that useful for you?
I have already attached PurchaseManageriOSApple.java as a file (and AppleTransactionObserver.java ) in my request. Do not understand why they need exactly that 'magic' method.
Will try to give them your second reference as well.
Thanks a lot.
Finally I got an answer as follow:
We can confirm the developer will need to implement “paymentQueue:shouldAddStorePayment:forProduct:” in order for the IAP product to be promoted:
@Glyfad , so to support this, the only thing to do is add this (to existing AppleTransactionObserver class):
private class AppleTransactionObserver extends SKPaymentTransactionObserverAdapter {
@Override // new method added
public boolean shouldAddStorePayment(SKPaymentQueue queue, SKPayment payment, SKProduct product) {
return true;
}
}
If that is only thing to be done to make this work correctly, I can add it. Can you create a new ticket for this? I will commit it on the new ticket.
I have created a new issue. Thanks a lot.
Hi can you please take a look at this link and can you please solve my issue. Thank you :) https://stackoverflow.com/questions/48241019/error-in-app-purchase-libgdx