| 49 | } |
| 50 | |
| 51 | @Override |
| 52 | public boolean execute( |
| 53 | String action, |
| 54 | JSONArray args, |
| 55 | CallbackContext callbackContext |
| 56 | ) throws JSONException { |
| 57 | String arg1 = getString(args, 0); |
| 58 | switch (action) { |
| 59 | case "startConnection": |
| 60 | case "getProducts": |
| 61 | case "setPurchaseUpdatedListener": |
| 62 | case "purchase": |
| 63 | case "consume": |
| 64 | case "getPurchases": |
| 65 | case "acknowledgePurchase": |
| 66 | break; |
| 67 | default: |
| 68 | return false; |
| 69 | } |
| 70 | |
| 71 | cordova |
| 72 | .getThreadPool() |
| 73 | .execute( |
| 74 | new Runnable() { |
| 75 | public void run() { |
| 76 | switch (action) { |
| 77 | case "startConnection": |
| 78 | startConnection(callbackContext); |
| 79 | break; |
| 80 | case "getProducts": |
| 81 | getProducts(getStringList(args, 0), callbackContext); |
| 82 | break; |
| 83 | case "setPurchaseUpdatedListener": |
| 84 | setPurchaseUpdatedListener(callbackContext); |
| 85 | break; |
| 86 | case "purchase": |
| 87 | purchase(arg1, callbackContext); |
| 88 | break; |
| 89 | case "consume": |
| 90 | consume(arg1, callbackContext); |
| 91 | break; |
| 92 | case "getPurchases": |
| 93 | getPurchases(callbackContext); |
| 94 | break; |
| 95 | case "acknowledgePurchase": |
| 96 | acknowledgePurchase(arg1, callbackContext); |
| 97 | break; |
| 98 | } |
| 99 | } |
| 100 | } |
| 101 | ); |
| 102 | |
| 103 | return true; |
| 104 | } |
| 105 | |
| 106 | private BillingClient getBillingClient() { |
| 107 | return BillingClient.newBuilder(this.contextRef.get()) |