Skip to content

Commit

Permalink
Merge d672bbb into 2dbf3ed
Browse files Browse the repository at this point in the history
  • Loading branch information
psipaylo committed Nov 22, 2019
2 parents 2dbf3ed + d672bbb commit 6b794b2
Showing 1 changed file with 6 additions and 0 deletions.
Expand Up @@ -72,6 +72,8 @@ else if (call.method.equals("initConnection")) {
.enablePendingPurchases()
.build();
billingClient.startConnection(new BillingClientStateListener() {
private boolean alreadyFinished = false;

@Override
public void onBillingSetupFinished(BillingResult billingResult) {
try {
Expand All @@ -81,11 +83,15 @@ public void onBillingSetupFinished(BillingResult billingResult) {
JSONObject item = new JSONObject();
item.put("connected", true);
channel.invokeMethod("connection-updated", item.toString());
if (alreadyFinished) return;
alreadyFinished = true;
result.success("Billing client ready");
} else {
JSONObject item = new JSONObject();
item.put("connected", false);
channel.invokeMethod("connection-updated", item.toString());
if (alreadyFinished) return;
alreadyFinished = true;
result.error(call.method, "responseCode: " + responseCode, "");
}
} catch (JSONException je) {
Expand Down

0 comments on commit 6b794b2

Please sign in to comment.