Search Unity

ProcessPurchase called even if purchase was not completed

Discussion in 'Unity IAP' started by Loris2222, Jul 15, 2020.

  1. domonyiv

    domonyiv

    Joined:
    Oct 1, 2016
    Posts:
    76
    Thank you!
     
  2. NoPants_

    NoPants_

    Joined:
    Apr 23, 2014
    Posts:
    59
    Awesome thanks for the help!
     
  3. tessellation

    tessellation

    Joined:
    Aug 11, 2015
    Posts:
    390
    I'm still seeing this in IAP 1.23.5. In this log example, we already had one non-consumable item purchased and then attempted to purchase another after reinstalling but then hit the back button (cancelled) before making the purchase. Our own IAP_Fulfillment class logs the OnPurchaseFailed event, followed by the ProcessPurchase event on the same product.

    08-18 18:19:11.926 27597 27641 I Unity : UnityIAP Version: 1.23.5
    08-18 18:19:13.294 27597 27641 I Unity : Already recorded transaction GPA.XXXX-XXXX-XXXX-XXXXX
    08-18 18:19:13.297 27597 27641 I Unity : UnityIAP: Promo interface is available for 8 items
    08-18 18:19:24.875 27597 27641 I Unity : purchase({0}): infinity_recharge
    08-18 18:19:35.441 27597 27641 I Unity : onPurchaseFailedEvent({0}): infinity_recharge

    08-18 18:19:35.453 27597 27641 W Unity : [IAP_Fulfillment] infinity_recharge purchase FAILED: UserCancelled
    08-18 18:19:35.453 27597 27641 W Unity : IAP_Fulfillment:OnPurchaseFailed(Product, PurchaseFailureReason)
    08-18 18:19:35.453 27597 27641 W Unity : IAP_Store:OnPurchaseFailed(Product, PurchaseFailureReason)
    08-18 18:19:35.453 27597 27641 W Unity : UnityEngine.Purchasing.Extension.UnityUtil:Update()
    08-18 18:19:35.453 27597 27641 W Unity : (Filename: ./Runtime/Export/Debug.bindings.h Line: 45)

    08-18 18:19:36.295 27597 27641 W Unity : [IAP_Fulfillment] infinity_recharge purchased
    08-18 18:19:36.295 27597 27641 W Unity : IAP_Fulfillment:OnPurchase(Product)
    08-18 18:19:36.295 27597 27641 W Unity : IAP_Store:processPurchase(PurchaseEventArgs)
    08-18 18:19:36.295 27597 27641 W Unity : UnityEngine.Purchasing.PurchasingManager:processPurchaseIfNew(Product)
    08-18 18:19:36.295 27597 27641 W Unity : UnityEngine.Purchasing.JSONStore:OnPurchaseSucceeded(String, String, String)
    08-18 18:19:36.295 27597 27641 W Unity : UnityEngine.Purchasing.Extension.UnityUtil:Update()
    08-18 18:19:36.295 27597 27641 W Unity : (Filename: ./Runtime/Export/Debug.bindings.h Line: 45)

    08-18 18:19:36.448 27597 27641 I Unity : UnityIAP: Promo interface is available for 7 items
     
  4. tessellation

    tessellation

    Joined:
    Aug 11, 2015
    Posts:
    390
    Would a safe temporary work-around for this problem be to validate the transactionID on Google Play builds to make sure that it begins with "GPA." ?

    We're already doing the following bits of validation on the GooglePlayReceipt but these are resulting in a valid purchase for these cancelled transactions:
    1. Calling Validate() using the unity client-side validator.
    2. Checking that productID matches the storeSpecificId for the product.
    3. Checking that purchaseState == GooglePurchaseState.Purchased
    4. Checking that the purchaseData is within a valid range.
     
  5. SamOYUnity3D

    SamOYUnity3D

    Unity Technologies

    Joined:
    May 12, 2019
    Posts:
    626
    OK, we will investigate this. Could you provide the full logs here? Thanks.
     
  6. tessellation

    tessellation

    Joined:
    Aug 11, 2015
    Posts:
    390
    Sure, here's the beginning of the log:

    08-18 19:21:20.241 31375 31419 I Unity : SystemInfo CPU = ARM64 FP ASIMD AES, Cores = 4, Memory = 3765mb
    08-18 19:21:20.242 31375 31419 I Unity : SystemInfo ARM big.LITTLE configuration: 2 big (mask: 0xc), 2 little (mask: 0x3)
    08-18 19:21:20.247 31375 31419 I Unity : ApplicationInfo com.pinestreetcodeworks.TinyBubbles version 1.10.5 build e7696a35-03b5-4de0-99fe-092bd8d39f0e
    08-18 19:21:20.247 31375 31419 I Unity : Built from '2018.4/staging' branch, Version '2018.4.24f1 (3071911a89e9)', Build type 'Release', Scripting Backend 'il2cpp', CPU 'arm64-v8a'
    08-18 19:21:20.874 31375 31419 D Unity : GL_OES_EGL_image GL_OES_EGL_image_external GL_OES_EGL_sync GL_OES_vertex_half_float GL_OES_framebuffer_object GL_OES_rgb8_rgba8 GL_OES_compressed_ETC1_RGB8_texture GL_AMD_compressed_ATC_texture GL_KHR_texture_compression_astc_ldr GL_KHR_texture_compression_astc_hdr GL_OES_texture_compression_astc GL_OES_texture_npot GL_EXT_texture_filter_anisotropic GL_EXT_texture_format_BGRA8888 GL_EXT_read_format_bgra GL_OES_texture_3D GL_EXT_color_buffer_float GL_EXT_color_buffer_half_float GL_QCOM_alpha_test GL_OES_depth24 GL_OES_packed_depth_stencil GL_OES_depth_texture GL_OES_depth_texture_cube_map GL_EXT_sRGB GL_OES_texture_float GL_OES_texture_float_linear GL_OES_texture_half_float GL_OES_texture_half_float_linear GL_EXT_texture_type_2_10_10_10_REV GL_EXT_texture_sRGB_decode GL_EXT_texture_format_sRGB_override GL_OES_element_index_uint GL_EXT_copy_image GL_EXT_geometry_shader GL_EXT_tessellation_shader GL_OES_texture_stencil8 GL_EXT_shader_io_blocks GL_OES_shader_image_atomic GL_OES_sample_variables GL_EXT_texture_b
    08-18 19:21:20.874 31375 31419 D Unity : order_clamp GL_EXT_EGL_image_external_wrap_modes GL_EXT_multisampled_render_to_texture GL_EXT_multisampled_render_to_texture2 GL_OES_shader_multisample_interpolation GL_EXT_texture_cube_map_array GL_EXT_draw_buffers_indexed GL_EXT_gpu_shader5 GL_EXT_robustness GL_EXT_texture_buffer GL_EXT_shader_framebuffer_fetch GL_ARM_shader_framebuffer_fetch_depth_stencil GL_OES_texture_storage_multisample_2d_array GL_OES_sample_shading GL_OES_get_program_binary GL_EXT_debug_label GL_KHR_blend_equation_advanced GL_KHR_blend_equation_advanced_coherent GL_QCOM_tiled_rendering GL_ANDROID_extension_pack_es31a GL_EXT_primitive_bounding_box GL_OES_standard_derivatives GL_OES_vertex_array_object GL_EXT_disjoint_timer_query GL_KHR_debug GL_EXT_YUV_target GL_EXT_sRGB_write_control GL_EXT_texture_norm16 GL_EXT_discard_framebuffer GL_OES_surfaceless_context GL_OVR_multiview GL_OVR_multiview2 GL_EXT_texture_sRGB_R8 GL_KHR_no_error GL_EXT_debug_marker GL_OES_EGL_image_external_essl3 GL_OVR_multiview_multisampled_render_to_texture GL_E
    08-18 19:21:20.874 31375 31419 D Unity : XT_buffer_storage GL_EXT_external_buffer GL_EXT_blit_framebuffer_params GL_EXT_clip_cull_distance GL_EXT_protected_textures GL_EXT_shader_non_constant_global_initializers GL_QCOM_texture_foveated GL_QCOM_shader_framebuffer_fetch_noncoherent GL_QCOM_shader_framebuffer_fetch_rate GL_EXT_memory_object GL_EXT_memory_object_fd GL_EXT_EGL_image_array GL_NV_shader_noperspective_interpolation GL_KHR_robust_buffer_access_behavior GL_EXT_EGL_image_storage GL_EXT_blend_func_extended GL_EXT_clip_control GL_OES_texture_view GL_EXT_fragment_invocation_density
    08-18 19:21:30.145 31375 31419 I Unity : [IAP_Store] Found 9 IAP_Products for sale...
    08-18 19:21:30.146 31375 31419 I Unity : UnityIAP Version: 1.23.5
     
  7. SamOYUnity3D

    SamOYUnity3D

    Unity Technologies

    Joined:
    May 12, 2019
    Posts:
    626
    Could you print the product ID so
    Could you print the product ID so we can confirm whether the product is the right one? What you said might be expected behavior, Unity IAP automatically restores any products the user owns during the first initialization following reinstallation; the ProcessPurchase method of your IStoreListener will be called for each owned item.
    https://docs.unity3d.com/Manual/UnityIAPRestoringTransactions.html
     
  8. tessellation

    tessellation

    Joined:
    Aug 11, 2015
    Posts:
    390
    The productID (infinity_recharge) was displayed in the part of the log that I included. When the user cancelled the purchase of "infinity_recharge" a failed event (cancelled) and a purchase event was sent for the same product "infinity_recharge". The one listed as "Already recorded transaction" on startup is a completely different product ID, I'm 100% sure of this.
     
  9. tessellation

    tessellation

    Joined:
    Aug 11, 2015
    Posts:
    390
    I've published a new build version that now validates that transactionID.StartsWith("GPA.") and this seems to be working for legitimate purchases and ignores the invalid purchase callbacks on user purchase cancellation. In summary, this is a work-around for what I consider a bug in UnityIAP 1.23
     
  10. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    Have you had a chance to test with 1.23.5?
     
  11. tessellation

    tessellation

    Joined:
    Aug 11, 2015
    Posts:
    390
    Yes, see my original post above from August 18th: "I'm still seeing this in IAP 1.23.5"
     
    JeffDUnity3D likes this.
  12. tessellation

    tessellation

    Joined:
    Aug 11, 2015
    Posts:
    390
  13. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    No updates, still on the radar. Have you tried the aggressivelyRecoverLostPurchases flag in 1.23.5 or 2.0?
     
  14. tessellation

    tessellation

    Joined:
    Aug 11, 2015
    Posts:
    390
    Yes, we're using aggressivelyRecoverLostPurchases = true with 1.23.5. This was the scenario under which cancelling the non-consumable purchase caused a ProcessPurchase() callback to fire on the Android device under Google Play.
     
  15. Seraphim-Whiteless

    Seraphim-Whiteless

    Joined:
    Jun 23, 2014
    Posts:
    197
    am ..
    Looks like a something new in 2020
    Unity3d 2020.4.9
    Android IL2CPP
    Having some message afetr update to Unity IAP 2.1.0
    after purchasing

    Code (CSharp):
    1. 09-03 15:15:45.506: I/Unity(17038): UnityIAP Version: 2.0.0
    Code (CSharp):
    1. 09-03 15:16:37.051: E/UnityIAP(17038): Unrecoverable consumption failure, transaction status will not be automatically handled further
     
    Last edited: Sep 3, 2020
  16. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    Can you elaborate? How does this affect the purchase flow for you?
     
  17. Seraphim-Whiteless

    Seraphim-Whiteless

    Joined:
    Jun 23, 2014
    Posts:
    197
    it message. it worries me.
    application should not have error messages.
     
  18. tessellation

    tessellation

    Joined:
    Aug 11, 2015
    Posts:
    390
    I'm confused, is this error message related to the this thread's subject, which is a bug in UnityIAP where the ProcessPurchase() callback is called when the user cancels the purchase? If not, then please Post A New Thread.
     
  19. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    That is an information message only, we need to consider different wording.
     
    Seraphim-Whiteless likes this.
  20. Storyfied

    Storyfied

    Joined:
    Sep 19, 2020
    Posts:
    1
    I have this issue too but instead of restarting the application, the players get awarded with their purchases immediately. After clicking the buy button, there is a small pause before failing and then rewarding the player afterwards.

    I know that it failed because I have 2 different audio that plays for purchase failure and success respectively. The purchase failed audio plays followed by the success audio shortly after. Purchases are also credited to the players.
     
  21. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    What is causing the pause? Please debug, reproduce and provide the device logs.