We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 8b52f99 commit 7b8936dCopy full SHA for 7b8936d
android/src/main/java/IapPlugin.kt
@@ -30,6 +30,8 @@ class PurchaseArgs {
30
var productId: String = ""
31
var productType: String = "subs" // "subs" or "inapp"
32
var offerToken: String? = null
33
+ var obfuscatedAccountId: String? = null
34
+ var obfuscatedProfileId: String? = null
35
}
36
37
@InvokeArg
@@ -232,9 +234,20 @@ class IapPlugin(private val activity: Activity): Plugin(activity), PurchasesUpda
232
234
)
233
235
236
- val billingFlowParams = BillingFlowParams.newBuilder()
237
+ val billingFlowParamsBuilder = BillingFlowParams.newBuilder()
238
.setProductDetailsParamsList(productDetailsParamsList)
- .build()
239
+
240
+ // Add obfuscated account ID if provided
241
+ args.obfuscatedAccountId?.let { accountId ->
242
+ billingFlowParamsBuilder.setObfuscatedAccountId(accountId)
243
+ }
244
245
+ // Add obfuscated profile ID if provided
246
+ args.obfuscatedProfileId?.let { profileId ->
247
+ billingFlowParamsBuilder.setObfuscatedProfileId(profileId)
248
249
250
+ val billingFlowParams = billingFlowParamsBuilder.build()
251
252
val billingResult = billingClient.launchBillingFlow(activity, billingFlowParams)
253
guest-js/index.ts
@@ -87,6 +87,12 @@ export interface ProductStatus {
87
purchaseToken?: string;
88
89
90
+export interface PurchaseOptions {
91
+ offerToken?: string;
92
+ obfuscatedAccountId?: string;
93
+ obfuscatedProfileId?: string;
94
+}
95
96
export async function initialize(): Promise<InitializeResponse> {
97
return await invoke<InitializeResponse>("plugin:iap|initialize");
98
@@ -106,13 +112,13 @@ export async function getProducts(
106
112
export async function purchase(
107
113
productId: string,
108
114
productType: "subs" | "inapp" = "subs",
109
- offerToken?: string,
115
+ options?: PurchaseOptions,
110
116
): Promise<Purchase> {
111
117
return await invoke<Purchase>("plugin:iap|purchase", {
118
payload: {
119
productId,
120
productType,
- offerToken,
121
+ ...options,
122
},
123
});
124
src/commands.rs
@@ -25,7 +25,7 @@ pub(crate) async fn purchase<R: Runtime>(
25
app.iap().purchase(
26
payload.product_id,
27
payload.product_type,
28
- payload.offer_token,
+ payload.options,
29
src/desktop.rs
@@ -34,7 +34,7 @@ impl<R: Runtime> Iap<R> {
&self,
_product_id: String,
_product_type: String,
- _offer_token: Option<String>,
+ _options: Option<PurchaseOptions>,
38
) -> crate::Result<Purchase> {
39
Err(crate::Error::from(std::io::Error::other(
40
"IAP is not supported on this platform",
src/macos.rs
@@ -107,10 +107,11 @@ impl<R: Runtime> Iap<R> {
product_id: String,
product_type: String,
- offer_token: Option<String>,
+ options: Option<PurchaseOptions>,
codesign::is_signature_valid()?;
+ let offer_token = options.and_then(|opts| opts.offer_token);
Self::to_result(ffi::purchase(product_id, product_type, offer_token))
src/mobile.rs
@@ -55,15 +55,15 @@ impl<R: Runtime> Iap<R> {
55
56
57
58
59
60
self.0
61
.run_mobile_plugin(
62
"purchase",
63
PurchaseRequest {
64
product_id,
65
product_type,
66
- offer_token,
+ options,
67
68
69
.map_err(Into::into)
src/models.rs
@@ -65,14 +65,25 @@ pub struct GetProductsResponse {
pub products: Vec<Product>,
+#[derive(Debug, Clone, Deserialize, Serialize)]
+#[serde(rename_all = "camelCase")]
70
+pub struct PurchaseOptions {
71
+ #[serde(skip_serializing_if = "Option::is_none")]
72
+ pub offer_token: Option<String>,
73
74
+ pub obfuscated_account_id: Option<String>,
75
76
+ pub obfuscated_profile_id: Option<String>,
77
78
79
#[derive(Debug, Deserialize, Serialize)]
80
#[serde(rename_all = "camelCase")]
81
pub struct PurchaseRequest {
82
pub product_id: String,
83
#[serde(default = "default_product_type")]
84
pub product_type: String,
- #[serde(skip_serializing_if = "Option::is_none")]
- pub offer_token: Option<String>,
85
+ #[serde(flatten)]
86
+ pub options: Option<PurchaseOptions>,
#[derive(Debug, Clone, Deserialize, Serialize)]
0 commit comments