chargebee / chargebee-flutter

MIT License
5 stars 8 forks source link

Chargebee.configure never finishes on error #23

Closed RobertHeim closed 1 year ago

RobertHeim commented 2 years ago

Running the following code, I would expect to always see the log output for either done or Could not configure chargebee. Using a wrong applicationId logs an error (I think from the android SDK) but the expected log output on the flutter end is never shown, because the Chargebee.configure method seems to never finish.

print('before');
try {
  await Chargebee.configure(
    appConfig.chargebeeSite,
    appConfig.chargebeeSdkKey,
    appConfig.chargebeeIosSdkKey,
    appConfig.chargebeeAndroidSdkKey,
  );
  print('done');
} catch (e, s) {
  print('Could not configure chargebee');
}
print('after');

output:

before
I/Chargebee( 8608): Exception from server :{"message":"Provided Application id - a.b.c.dev doesnt match with existing id","type":"invalid_request","api_error_code":"invalid_request","error_code":"operation_not_supported","error_msg":"Provided Application id - a.b.c.dev doesnt match with existing id","http_status_code":400}
(end of output)

We would expect to see Could not configure chargebee and after in the log output. We also expect that the configure method propagates errors via exceptions, so we can catch them.

RobertHeim commented 1 year ago

Actually the same method does also not finish if there is no error:

I/ChargebeeFlutterSdkPlugin(17449):  some-test, test_ABCDEF, cb-abcdef, package Name: some.domain
I/LoggerResource(17449): logData :{key=cb.logging, ref_module=cb_flutter_android_sdk, site=some-test, action=Authenticate SDK Key, log_data_type=info, device_model=null, platform=null, os_version=null, sdk_version=null}
I/AuthResource(17449):  Response :Response{protocol=h2, code=200, message=, url=https://some-test.chargebee.com/api/v2/in_app_details/cb-abcdef/verify_app_detail/}
I/Chargebee(17449): Environment Setup Completed
I/Chargebee(17449):  Response :CBAuthResponse(in_app_detail=CBAuthentication(resource_id=cb-abcdef, app_id=some.domain, app_name=Some Name, webhook_url=, status=active, product_catalog_version=v2))
I/Chargebee(17449): Note: pre-requisites configuration is mandatory for SDK to work. Learn more - https://www.chargebee.com/docs/2.0/mobile-playstore-connect.html 

The configure method does never return but hangs.