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

Method getBillingClient

src/plugins/iap/src/com/foxdebug/iap/Iap.java:106–141  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

104 }
105
106 private BillingClient getBillingClient() {
107 return BillingClient.newBuilder(this.contextRef.get())
108 .enablePendingPurchases(
109 PendingPurchasesParams.newBuilder().enableOneTimeProducts().build()
110 )
111 .setListener(
112 new PurchasesUpdatedListener() {
113 public void onPurchasesUpdated(
114 BillingResult billingResult,
115 List<Purchase> purchases
116 ) {
117 try {
118 int responseCode = billingResult.getResponseCode();
119 if (responseCode == BillingResponseCode.OK) {
120 JSONArray result = new JSONArray();
121 for (Purchase purchase : purchases) {
122 result.put(purchaseToJson(purchase));
123 }
124 sendPurchasePluginResult(
125 new PluginResult(PluginResult.Status.OK, result)
126 );
127 } else {
128 sendPurchasePluginResult(
129 new PluginResult(PluginResult.Status.ERROR, responseCode)
130 );
131 }
132 } catch (JSONException e) {
133 sendPurchasePluginResult(
134 new PluginResult(PluginResult.Status.ERROR, e.getMessage())
135 );
136 }
137 }
138 }
139 )
140 .build();
141 }
142
143 private void setPurchaseUpdatedListener(CallbackContext callbackContext) {
144 purchaseUpdated = callbackContext;

Callers 5

initializeMethod · 0.95
startConnectionMethod · 0.95
getProductsMethod · 0.95
getPurchasesMethod · 0.95
acknowledgePurchaseMethod · 0.95

Calls 1

getMethod · 0.45

Tested by

no test coverage detected