capacitor-plugin-cdv-purchase 13.14.0 → 13.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -8
- package/android/src/main/java/cc/fovea/iap/PurchasePlugin.java +32 -0
- package/dist/esm/definitions.d.ts +10 -0
- package/dist/index.js +360 -53
- package/dist/index.js.map +1 -1
- package/ios/Sources/PurchasePlugin/PurchasePlugin.swift +20 -1
- package/package.json +1 -1
- package/www/store.d.ts +151 -13
- package/www/store.js +357 -52
package/README.md
CHANGED
|
@@ -14,10 +14,7 @@ npx cap sync
|
|
|
14
14
|
## Usage
|
|
15
15
|
|
|
16
16
|
```typescript
|
|
17
|
-
import 'capacitor-plugin-cdv-purchase';
|
|
18
|
-
|
|
19
|
-
const { Store, ProductType, Platform } = CdvPurchase;
|
|
20
|
-
const store = new Store();
|
|
17
|
+
import { store, ProductType, Platform } from 'capacitor-plugin-cdv-purchase';
|
|
21
18
|
|
|
22
19
|
// Register products
|
|
23
20
|
store.register([{
|
|
@@ -40,10 +37,10 @@ await store.initialize();
|
|
|
40
37
|
|
|
41
38
|
If you're using `cordova-plugin-purchase` in a Capacitor app:
|
|
42
39
|
|
|
43
|
-
1. `npm
|
|
44
|
-
2. `
|
|
45
|
-
3.
|
|
46
|
-
4.
|
|
40
|
+
1. `npm uninstall cordova-plugin-purchase` (and `cordova-plugin-purchase-storekit2` if installed)
|
|
41
|
+
2. `npm install capacitor-plugin-cdv-purchase`
|
|
42
|
+
3. `npx cap sync`
|
|
43
|
+
4. Update your import to `import { store, ProductType, Platform } from 'capacitor-plugin-cdv-purchase'` — the API is identical
|
|
47
44
|
|
|
48
45
|
## Platform Support
|
|
49
46
|
|
|
@@ -24,9 +24,12 @@ import com.android.billingclient.api.BillingClient.BillingResponseCode;
|
|
|
24
24
|
import com.android.billingclient.api.BillingClient.FeatureType;
|
|
25
25
|
import com.android.billingclient.api.BillingClient.ProductType;
|
|
26
26
|
import com.android.billingclient.api.BillingClientStateListener;
|
|
27
|
+
import com.android.billingclient.api.BillingConfig;
|
|
28
|
+
import com.android.billingclient.api.BillingConfigResponseListener;
|
|
27
29
|
import com.android.billingclient.api.BillingFlowParams;
|
|
28
30
|
import com.android.billingclient.api.BillingFlowParams.ProductDetailsParams;
|
|
29
31
|
import com.android.billingclient.api.BillingResult;
|
|
32
|
+
import com.android.billingclient.api.GetBillingConfigParams;
|
|
30
33
|
import com.android.billingclient.api.ConsumeParams;
|
|
31
34
|
import com.android.billingclient.api.ConsumeResponseListener;
|
|
32
35
|
import com.android.billingclient.api.PendingPurchasesParams;
|
|
@@ -726,6 +729,35 @@ public class PurchasePlugin extends Plugin implements
|
|
|
726
729
|
call.resolve();
|
|
727
730
|
}
|
|
728
731
|
|
|
732
|
+
/**
|
|
733
|
+
* Retrieve the user's Play Store billing country code (ISO 3166-1 alpha-2).
|
|
734
|
+
*/
|
|
735
|
+
@PluginMethod
|
|
736
|
+
public void getStorefront(final PluginCall call) {
|
|
737
|
+
Log.d(TAG, "getStorefront()");
|
|
738
|
+
executeServiceRequest(() -> {
|
|
739
|
+
GetBillingConfigParams params = GetBillingConfigParams.newBuilder().build();
|
|
740
|
+
mBillingClient.getBillingConfigAsync(params, new BillingConfigResponseListener() {
|
|
741
|
+
@Override
|
|
742
|
+
public void onBillingConfigResponse(
|
|
743
|
+
BillingResult billingResult,
|
|
744
|
+
BillingConfig billingConfig) {
|
|
745
|
+
if (billingResult.getResponseCode() == BillingResponseCode.OK
|
|
746
|
+
&& billingConfig != null) {
|
|
747
|
+
String countryCode = billingConfig.getCountryCode();
|
|
748
|
+
Log.d(TAG, "getStorefront() -> " + countryCode);
|
|
749
|
+
JSObject ret = new JSObject();
|
|
750
|
+
ret.put("countryCode", countryCode);
|
|
751
|
+
call.resolve(ret);
|
|
752
|
+
} else {
|
|
753
|
+
Log.d(TAG, "getStorefront() -> Failed: " + format(billingResult));
|
|
754
|
+
call.reject("Failed to get billing config: " + format(billingResult));
|
|
755
|
+
}
|
|
756
|
+
}
|
|
757
|
+
});
|
|
758
|
+
});
|
|
759
|
+
}
|
|
760
|
+
|
|
729
761
|
// -------------------------------------------------------------------------
|
|
730
762
|
// PurchasesUpdatedListener — called by BillingClient after purchase flow
|
|
731
763
|
// -------------------------------------------------------------------------
|
|
@@ -34,6 +34,16 @@ export interface PurchasePluginPlugin {
|
|
|
34
34
|
manageSubscriptions(): Promise<void>;
|
|
35
35
|
/** Open billing management UI */
|
|
36
36
|
manageBilling(): Promise<void>;
|
|
37
|
+
/**
|
|
38
|
+
* Retrieve the user's storefront country code.
|
|
39
|
+
*
|
|
40
|
+
* iOS returns an ISO 3166-1 alpha-3 code (e.g., "USA"); Android returns
|
|
41
|
+
* an alpha-2 code (e.g., "US"). The TypeScript adapter normalizes iOS
|
|
42
|
+
* responses to alpha-2.
|
|
43
|
+
*/
|
|
44
|
+
getStorefront(): Promise<{
|
|
45
|
+
countryCode: string;
|
|
46
|
+
}>;
|
|
37
47
|
/** Consume a purchase (Android) */
|
|
38
48
|
consumePurchase(options: {
|
|
39
49
|
purchaseToken: string;
|