MCPcopy Create free account
hub / github.com/Acode-Foundation/Acode / Iap

Class Iap

src/plugins/iap/src/com/foxdebug/iap/Iap.java:37–432  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

35import org.json.JSONObject;
36
37public class Iap extends CordovaPlugin {
38
39 private BillingClient billingClient;
40 private WeakReference<Context> contextRef;
41 private WeakReference<Activity> activityRef;
42 private CallbackContext purchaseUpdated;
43
44 public void initialize(CordovaInterface cordova, CordovaWebView webView) {
45 super.initialize(cordova, webView);
46 contextRef = new WeakReference<>(cordova.getContext());
47 activityRef = new WeakReference<>(cordova.getActivity());
48 billingClient = getBillingClient();
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;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected