PayMaya / PayMaya-Android-SDK-v2

MIT License
12 stars 6 forks source link

No internet connection after page has completed loading #26

Open eepytekki opened 2 weeks ago

eepytekki commented 2 weeks ago

Hello, I am trying to create a Flutter plugin for Maya Checkout. I have a similar issue to #3 where the no internet message appears after loading.

Screenshot_1729759018

I am using the latest version of the PayMaya SDK with minSdk = 21, the issue occurs both in simulator (running API 33) and a physical device (running API 30). Here is the console output upon clicking on my checkout button.

I/cr_LibraryLoader( 4292): Successfully loaded native library I/cr_CachingUmaRecorder( 4292): Flushed 9 samples from 9 histograms. D/CompatibilityChangeReporter( 4292): Compat change id reported: 183155436; UID 10174; state: ENABLED W/chromium( 4292): [WARNING:dns_config_service_android.cc(115)] Failed to read DnsConfig. E/chromium( 4292): [ERROR:simple_file_enumerator.cc(21)] opendir /data/user/0/com.myorg.maya_for_flutter_example/cache/WebView/Default/HTTP Cache/Code Cache/js: No such file or directory (2) E/chromium( 4292): [ERROR:simple_index_file.cc(614)] Could not reconstruct index from disk D/CompatibilityChangeReporter( 4292): Compat change id reported: 214741472; UID 10174; state: ENABLED D/CompatibilityChangeReporter( 4292): Compat change id reported: 171228096; UID 10174; state: ENABLED D/AutofillManager( 4292): Fill dialog. isenabled:false, hints=[password, passwordAuto, creditCardNumber, creditCardSecurityCode, creditCardExpirationDate] D/CompatibilityChangeReporter( 4292): Compat change. idreported: 210923482; UID 10174; state: ENABLED W/OnBackInvokedCallback( 4292): OnBackInvokedCallback is not enabled for the application. W/OnBackInvokedCallback( 4292): Set 'android:enableOnBackInvokedCallback="true"' in the application. manifest. W/Parcel ( 4292): Expecting binder but got null! D/OkHttp ( 4292): --> POST https://pg-sandbox.paymaya.com/checkout/v1/checkouts D/OkHttp ( 4292): Authorization: Basic cGstWjBPU3pMdkljT0kyVUl2RGhkVEdWVmZSU1NlaUdTdG5jZXF3VUU3bjBBaDo= D/OkHttp ( 4292): Content-Type: application/json D/OkHttp (. 4292): Content-Length: 268 D/OkHttp ( 4292): x-paymaya-sdk: android-v2.2.0 D/OkHttp( 4292): {"totalAmount":{"value":"100","currency":"PHP"},"items":[{"name":"","totalAmount":{"value":"100","currency":"PHP"}}],"requestReferenceNumber":"TEST01","redirectUrl":{"success":"https://wikipedia.com","failure":"https://wikipedia.com","cancel":"https://wikipedia.com"}} D/OkHttp ( 4292): --> END POST (268-byte. body.
D/CompatibilityChangeReporter( 4292): Compat change id reported: 193247900; UID 10174; state: ENABLED E/OpenGLRenderer( 4292): Unable to match the desired swap behavior. D/EGL_emulation( 4292): eglCreateContext: 0xb4000074830b4090: maj 3min 0 rcv3 D/EGL_emulation( 4292): eglMakeCurrent: 0xb40. 0074830b4090: ver 3 0 (tinfo 0x76a6c59080) (first time) D/TrafficStats( 4292): tagSocket(170) with statsTag=0xffffffff, statsUid=-1 D/OkHttp ( 4292): <-- 200 https://pg-sandbox.paymaya.com/checkout/v1/checkouts (412ms) D/OkHttp ( 4292): date: Thu, 24 Oct 2024 0. :16:15 GMT D/OkHttp ( 4292): content-type: application/json; charset=utf. 8 D/OkHttp ( 4292): content-length: 167 D/OkH. tp ( 4292): x-frame-options: DENY D/OkHttp ( 4292): x-content-type-options: nosniff D/OkHttp ( 4292): x-xss-protection: 1; mode=block D/OkHttp ( 4292): cache-control: private, no-cache, no-store, must-revalidate, max-age=0 D/OkHttp ( 4292): pragma: no-cache D/OkHttp ( 4292): etag: W/"a7-3B7ZS7t7nVtcxS9vTV5NdIE+EF0" D/OkHttp ( 4292): access-control-allow-origin: * D/OkHttp ( 4292): strict-transport-security: max-age=31536000; includeSubDomains D/OkHttp ( 4292): x-kong-upstream-latency: 80 D/OkHttp ( 4292): x-kong-proxy-latency: 6 D/OkHttp ( 4292): via: kong/0.9.7 D/OkHttp ( 4292): { D/OkHttp ( 4292): "checkoutId": "430b352e-570a-42ec-86cd-b9da3e68c274", D/OkHttp ( 4292): "redirectUrl": "https://payments-web-sandbox.maya.ph/v2/checkout?id=430b352e-570a-42ec-86cd-b9da3e68c274" D/OkHttp ( 4292): } D/OkHttp ( 4292): <-- END HTTP (167-byte body) W/flutter_example( 4292): Accessing hidden method Landroid/media/AudioManager;->getOutputLatency(I)I (unsupported, reflection, allowed) W/cr_media( 4292): BLUETOOTH_CONNECT permission is missing. D/HostConnection( 4292): HostComposition ext ANDROID_EMU_CHECKSUM_HELPER_v1 ANDROID_EMU_native_sync_v2 ANDROID_EMU_native_sync_v3 ANDROID_EMU_native_sync_v4 ANDROID_EMU_dma_v1 ANDROID_EMU_direct_mem ANDROID_EMU_host_composition_v1 ANDROID_EMU_host_composition_v2 ANDROID_EMU_vulkan ANDROID_EMU_deferred_vulkan_commands ANDROID_EMU_vulkan_null_optional_strings ANDROID_EMU_vulkan_create_resources_with_requirements ANDROID_EMU_YUV_Cache ANDROID_EMU_vulkan_ignored_handles ANDROID_EMU_has_shared_slots_host_memory_allocator ANDROID_EMU_vulkan_free_memory_sync ANDROID_EMU_vulkan_shader_float16_int8 ANDROID_EMU_vulkan_async_queue_submit ANDROID_EMU_vulkan_queue_submit_with_commands ANDROID_EMU_sync_buffer_data ANDROID_EMU_read_color_buffer_dma ANDROID_EMU_hwc_multi_configs GL_OES_EGL_image_external_essl3 GL_OES_vertex_array_object GL_KHR_texture_compression_astc_ldr ANDROID_EMU_host_side_tracing ANDROID_EMU_gles_max_version_3_0
W/cr_media( 4292): registerBluetoothIntentsIfNeeded: Requires BLUETOOTH permission D/EGL_emulation( 4292): eglCreateContext: 0xb4000074830b6cd0: maj 3 min 0 rcv 3 D/EGL_emulation( 4292): eglMakeCurrent: 0xb4000074830b6cd0: ver 3 0 (tinfo 0x76a6c59280) (first time) D/EGL_emulation( 4292): eglCreateContext: 0xb4000074830b69d0: maj 3 min 0 rcv 3 D/EGL_emulation( 4292): app_time_stats: avg=15.08ms min=2.24ms max=39.26ms count=56

Some kotlin code used for the plugin:

package com.myorg.maya_for_flutter

…

/** MayaForFlutterPlugin */
class MayaForFlutterPlugin: FlutterPlugin, MethodCallHandler, ActivityAware, PluginRegistry.ActivityResultListener {

…

  private lateinit var channel : MethodChannel
  private lateinit var context: Context
  private lateinit var activity: Activity
  private val payMayaCheckoutClient = PayMayaCheckout.newBuilder()
    .clientPublicKey("pk-Z0OSzLvIcOI2UIvDhdTGVVfRSSeiGStnceqwUE7n0Ah")
    .environment(PayMayaEnvironment.SANDBOX)
    .logLevel(LogLevel.VERBOSE)
    .build()

 …

  override fun onMethodCall(call: MethodCall, result: Result) {

    …

    if (call.method == "checkoutWithMaya") {

      …

      val buildRequest = CheckoutRequest(
        totalAmount = TotalAmount(BigDecimal(100), "PHP"),
        items = listOf(Item(name = "", totalAmount = TotalAmount(BigDecimal(100), "PHP"))),
        redirectUrl = RedirectUrl(
          "https://wikipedia.com",
          "https://wikipedia.com",
          "https://wikipedia.com"
        ),
        requestReferenceNumber = "TEST01",
      )
      payMayaCheckoutClient.startCheckoutActivityForResult(activity, buildRequest)
    }
    else {
      result.notImplemented()
    }
  }

  …

  override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?): Boolean {
    payMayaCheckoutClient.onActivityResult(requestCode, resultCode, data)?.let {
      print(it)
    }
    return false
  }
}