Skip to content

Commit

Permalink
refactor: merge squareetlabs, fix definitions
Browse files Browse the repository at this point in the history
  • Loading branch information
socialmedialabs committed Aug 27, 2024
1 parent 70da35c commit 82fb93c
Show file tree
Hide file tree
Showing 12 changed files with 1,663 additions and 322 deletions.
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ buildscript {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:8.2.1'
classpath 'com.android.tools.build:gradle:8.2.2'
// classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,24 +1,19 @@
package com.capicitor_subscriptions.capacitor;
package com.squareetlabs.capacitor.subscriptions;

import android.content.Intent;
import android.net.Uri;
import android.util.Log;

import com.android.billingclient.api.AcknowledgePurchaseParams;
import com.android.billingclient.api.BillingClient;
import com.android.billingclient.api.BillingClientStateListener;
import com.android.billingclient.api.BillingResult;
import com.android.billingclient.api.Purchase;
import com.android.billingclient.api.PurchasesUpdatedListener;
import com.getcapacitor.JSObject;
import com.getcapacitor.Plugin;
import com.getcapacitor.PluginCall;
import com.getcapacitor.PluginMethod;
import com.getcapacitor.PluginResult;
import com.getcapacitor.annotation.CapacitorPlugin;

import org.json.JSONObject;

@CapacitorPlugin(name = "Subscriptions")
public class SubscriptionsPlugin extends Plugin {

Expand All @@ -33,7 +28,7 @@ public SubscriptionsPlugin () {
// This listener is fired upon completing the billing flow, it is vital to call the acknowledgePurchase
// method on the billingClient, with the purchase token otherwise Google will automatically cancel the subscription
// shortly after the purchase
private PurchasesUpdatedListener purchasesUpdatedListener = (billingResult, purchases) -> {
private final PurchasesUpdatedListener purchasesUpdatedListener = (billingResult, purchases) -> {

JSObject response = new JSObject();

Expand All @@ -51,7 +46,7 @@ public SubscriptionsPlugin () {
Log.i("Purchase ack", currentPurchase.getOriginalJson());
billingResult1.getResponseCode();

response.put("successful", true);
response.put("successful", billingResult1.getResponseCode());

// WARNING: Changed the notifyListeners method from protected to public in order to get the method call to work
// This may be a security issue in the future - in order to fix it, it may be best to move this listener + the billingClient
Expand Down Expand Up @@ -169,5 +164,4 @@ public void manageSubscriptions(PluginCall call) {
getActivity().startActivity(browserIntent);
}

}

}
14 changes: 11 additions & 3 deletions dist/docs.json
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@
},
{
"name": "addListener",
"signature": "(eventName: 'ANDROID-PURCHASE-RESPONSE', listenerFunc: (response: AndroidPurchasedTrigger) => void) => Promise<PluginListenerHandle> & PluginListenerHandle",
"signature": "(eventName: 'ANDROID-PURCHASE-RESPONSE', listenerFunc: (response: AndroidPurchasedTrigger) => void) => Promise<PluginListenerHandle>",
"parameters": [
{
"name": "eventName",
Expand All @@ -138,7 +138,7 @@
"type": "(response: AndroidPurchasedTrigger) => void"
}
],
"returns": "Promise<PluginListenerHandle> & PluginListenerHandle",
"returns": "Promise<PluginListenerHandle>",
"tags": [],
"docs": "",
"complexTypes": [
Expand Down Expand Up @@ -417,7 +417,15 @@
"docs": "",
"tags": [],
"methods": [],
"properties": []
"properties": [
{
"name": "remove",
"tags": [],
"docs": "",
"complexTypes": [],
"type": "() => Promise<void>"
}
]
},
{
"name": "AndroidPurchasedTrigger",
Expand Down
2 changes: 1 addition & 1 deletion dist/esm/definitions.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export interface SubscriptionsPlugin {
googleVerifyEndpoint: string;
bid: string;
}): void;
addListener(eventName: 'ANDROID-PURCHASE-RESPONSE', listenerFunc: (response: AndroidPurchasedTrigger) => void): Promise<PluginListenerHandle> & PluginListenerHandle;
addListener(eventName: 'ANDROID-PURCHASE-RESPONSE', listenerFunc: (response: AndroidPurchasedTrigger) => void): Promise<PluginListenerHandle>;
}
export interface Product {
productIdentifier: string;
Expand Down
2 changes: 1 addition & 1 deletion dist/esm/definitions.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 82fb93c

Please sign in to comment.