expo-iap 2.2.3 → 2.2.4-rc.2

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.
@@ -76,7 +76,7 @@ class ExpoIapModule :
76
76
  "transactionId" to purchase.orderId,
77
77
  "transactionDate" to purchase.purchaseTime.toDouble(),
78
78
  "transactionReceipt" to purchase.originalJson,
79
- "purchaseToken" to purchase.purchaseToken,
79
+ "purchaseTokenAndroid" to purchase.purchaseToken,
80
80
  "dataAndroid" to purchase.originalJson,
81
81
  "signatureAndroid" to purchase.signature,
82
82
  "autoRenewingAndroid" to purchase.isAutoRenewing,
@@ -227,7 +227,7 @@ class ExpoIapModule :
227
227
  "transactionDate" to purchase.purchaseTime.toDouble(),
228
228
  "transactionReceipt" to purchase.originalJson,
229
229
  "orderId" to purchase.orderId,
230
- "purchaseToken" to purchase.purchaseToken,
230
+ "purchaseTokenAndroid" to purchase.purchaseToken,
231
231
  "developerPayloadAndroid" to purchase.developerPayload,
232
232
  "signatureAndroid" to purchase.signature,
233
233
  "purchaseStateAndroid" to purchase.purchaseState,
@@ -273,7 +273,7 @@ class ExpoIapModule :
273
273
  "ids" to purchase.products,
274
274
  "transactionDate" to purchase.purchaseTime.toDouble(),
275
275
  "transactionReceipt" to purchase.originalJson,
276
- "purchaseToken" to purchase.purchaseToken,
276
+ "purchaseTokenAndroid" to purchase.purchaseToken,
277
277
  "dataAndroid" to purchase.originalJson,
278
278
  "signatureAndroid" to purchase.signature,
279
279
  "developerPayload" to purchase.developerPayload,
@@ -455,7 +455,7 @@ class ExpoIapModule :
455
455
  val errorData = PlayUtils.getBillingResponseData(billingResult.responseCode)
456
456
  map["code"] = errorData.code
457
457
  map["message"] = errorData.message
458
- map["purchaseToken"] = purchaseToken
458
+ map["purchaseTokenAndroid"] = purchaseToken
459
459
  promise.resolve(map)
460
460
  }
461
461
  }
@@ -31,7 +31,6 @@ export type PurchaseBase = {
31
31
  transactionId?: string;
32
32
  transactionDate: number;
33
33
  transactionReceipt: string;
34
- purchaseToken?: string;
35
34
  };
36
35
  export type Product = (ProductAndroid & AndroidPlatform) | (ProductIos & IosPlatform);
37
36
  export type ProductPurchase = (ProductPurchaseAndroid & AndroidPlatform) | (ProductPurchaseIos & IosPlatform);
@@ -47,7 +46,7 @@ export type PurchaseResult = {
47
46
  debugMessage?: string;
48
47
  code?: string;
49
48
  message?: string;
50
- purchaseToken?: string;
49
+ purchaseTokenAndroid?: string;
51
50
  };
52
51
  export declare enum ErrorCode {
53
52
  E_UNKNOWN = "E_UNKNOWN",
@@ -1 +1 @@
1
- {"version":3,"file":"ExpoIap.types.d.ts","sourceRoot":"","sources":["../src/ExpoIap.types.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,sBAAsB,EACtB,2BAA2B,EAC3B,+BAA+B,EAC/B,0BAA0B,EAC3B,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACL,UAAU,EACV,kBAAkB,EAClB,uBAAuB,EACvB,2BAA2B,EAC3B,sBAAsB,EACvB,MAAM,0BAA0B,CAAC;AAElC,MAAM,MAAM,kBAAkB,GAAG;IAC/B,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,WAAW,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAGF,MAAM,MAAM,WAAW,GAAG;IAAC,QAAQ,EAAE,KAAK,CAAA;CAAC,CAAC;AAC5C,MAAM,MAAM,eAAe,GAAG;IAAC,QAAQ,EAAE,SAAS,CAAA;CAAC,CAAC;AAEpD,oBAAY,WAAW;IACrB,aAA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nC,kDAAqC,CAAA;IACrC,oEAAuD,CAAA;IACvD,8CAAiC,CAAA;IACjC,wCAA2B,CAAA;IAC3B,gDAAmC,CAAA;IACnC,oDAAuC,CAAA;IACvC,wFAA2E,CAAA;IAC3E,sDAAyC,CAAA;IACzC,4CAA+B,CAAA;IAC/B,wDAA2C,CAAA;AAC7C,CAAC,EAlBW,SAAS,KAAT,SAAS,QAkBpB;AAED,MAAM,OAAO,aAAa;IAEf;IACA;IACA;IACA;IACA;IACA;IANT,YACS,IAAY,EACZ,OAAe,EACf,YAAqB,EACrB,YAAqB,EACrB,IAAgB,EAChB,SAAkB;QALlB,SAAI,GAAJ,IAAI,CAAQ;QACZ,YAAO,GAAP,OAAO,CAAQ;QACf,iBAAY,GAAZ,YAAY,CAAS;QACrB,iBAAY,GAAZ,YAAY,CAAS;QACrB,SAAI,GAAJ,IAAI,CAAY;QAChB,cAAS,GAAT,SAAS,CAAS;QAEzB,IAAI,CAAC,IAAI,GAAG,2BAA2B,CAAC;QACxC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAC7B,CAAC;CACF","sourcesContent":["import {\n ProductAndroid,\n ProductPurchaseAndroid,\n RequestPurchaseAndroidProps,\n RequestSubscriptionAndroidProps,\n SubscriptionProductAndroid,\n} from './types/ExpoIapAndroid.types';\nimport {\n ProductIos,\n ProductPurchaseIos,\n RequestPurchaseIosProps,\n RequestSubscriptionIosProps,\n SubscriptionProductIos,\n} from './types/ExpoIapIos.types';\n\nexport type ChangeEventPayload = {\n value: string;\n};\n\n/**\n * Base product type with common properties shared between iOS and Android\n */\nexport type ProductBase = {\n id: string;\n title: string;\n description: string;\n type: ProductType;\n displayName?: string;\n displayPrice?: string;\n price?: number;\n currency?: string;\n};\n\n// Define literal platform types for better type discrimination\nexport type IosPlatform = {platform: 'ios'};\nexport type AndroidPlatform = {platform: 'android'};\n\nexport enum ProductType {\n InAppPurchase = 'inapp',\n Subscription = 'subs',\n}\n\n// Common base purchase type\nexport type PurchaseBase = {\n id: string;\n transactionId?: string;\n transactionDate: number;\n transactionReceipt: string;\n purchaseToken?: string;\n};\n\n// Union type for platform-specific product types with proper discriminators\nexport type Product =\n | (ProductAndroid & AndroidPlatform)\n | (ProductIos & IosPlatform);\n\n// Union type for platform-specific purchase types with proper discriminators\nexport type ProductPurchase =\n | (ProductPurchaseAndroid & AndroidPlatform)\n | (ProductPurchaseIos & IosPlatform);\n\n// Union type for platform-specific subscription purchase types with proper discriminators\nexport type SubscriptionPurchase =\n | (ProductPurchaseAndroid & AndroidPlatform & {autoRenewingAndroid: boolean})\n | (ProductPurchaseIos & IosPlatform);\n\nexport type Purchase = ProductPurchase | SubscriptionPurchase;\n\nexport type RequestPurchaseProps =\n | RequestPurchaseIosProps\n | RequestPurchaseAndroidProps;\n\nexport type SubscriptionProduct =\n | (SubscriptionProductAndroid & AndroidPlatform)\n | (SubscriptionProductIos & IosPlatform);\n\nexport type RequestSubscriptionProps =\n | RequestSubscriptionAndroidProps\n | RequestSubscriptionIosProps;\n\nexport type PurchaseResult = {\n responseCode?: number;\n debugMessage?: string;\n code?: string;\n message?: string;\n purchaseToken?: string;\n};\n\nexport enum ErrorCode {\n E_UNKNOWN = 'E_UNKNOWN',\n E_USER_CANCELLED = 'E_USER_CANCELLED',\n E_USER_ERROR = 'E_USER_ERROR',\n E_ITEM_UNAVAILABLE = 'E_ITEM_UNAVAILABLE',\n E_REMOTE_ERROR = 'E_REMOTE_ERROR',\n E_NETWORK_ERROR = 'E_NETWORK_ERROR',\n E_SERVICE_ERROR = 'E_SERVICE_ERROR',\n E_RECEIPT_FAILED = 'E_RECEIPT_FAILED',\n E_RECEIPT_FINISHED_FAILED = 'E_RECEIPT_FINISHED_FAILED',\n E_NOT_PREPARED = 'E_NOT_PREPARED',\n E_NOT_ENDED = 'E_NOT_ENDED',\n E_ALREADY_OWNED = 'E_ALREADY_OWNED',\n E_DEVELOPER_ERROR = 'E_DEVELOPER_ERROR',\n E_BILLING_RESPONSE_JSON_PARSE_ERROR = 'E_BILLING_RESPONSE_JSON_PARSE_ERROR',\n E_DEFERRED_PAYMENT = 'E_DEFERRED_PAYMENT',\n E_INTERRUPTED = 'E_INTERRUPTED',\n E_IAP_NOT_AVAILABLE = 'E_IAP_NOT_AVAILABLE',\n}\n\nexport class PurchaseError implements Error {\n constructor(\n public name: string,\n public message: string,\n public responseCode?: number,\n public debugMessage?: string,\n public code?: ErrorCode,\n public productId?: string,\n ) {\n this.name = '[expo-iap]: PurchaseError';\n this.message = message;\n this.responseCode = responseCode;\n this.debugMessage = debugMessage;\n this.code = code;\n this.productId = productId;\n }\n}\n"]}
1
+ {"version":3,"file":"ExpoIap.types.js","sourceRoot":"","sources":["../src/ExpoIap.types.ts"],"names":[],"mappings":"AAqCA,MAAM,CAAN,IAAY,WAGX;AAHD,WAAY,WAAW;IACrB,sCAAuB,CAAA;IACvB,oCAAqB,CAAA;AACvB,CAAC,EAHW,WAAW,KAAX,WAAW,QAGtB;AA+CD,MAAM,CAAN,IAAY,SAkBX;AAlBD,WAAY,SAAS;IACnB,oCAAuB,CAAA;IACvB,kDAAqC,CAAA;IACrC,0CAA6B,CAAA;IAC7B,sDAAyC,CAAA;IACzC,8CAAiC,CAAA;IACjC,gDAAmC,CAAA;IACnC,gDAAmC,CAAA;IACnC,kDAAqC,CAAA;IACrC,oEAAuD,CAAA;IACvD,8CAAiC,CAAA;IACjC,wCAA2B,CAAA;IAC3B,gDAAmC,CAAA;IACnC,oDAAuC,CAAA;IACvC,wFAA2E,CAAA;IAC3E,sDAAyC,CAAA;IACzC,4CAA+B,CAAA;IAC/B,wDAA2C,CAAA;AAC7C,CAAC,EAlBW,SAAS,KAAT,SAAS,QAkBpB;AAED,MAAM,OAAO,aAAa;IAEf;IACA;IACA;IACA;IACA;IACA;IANT,YACS,IAAY,EACZ,OAAe,EACf,YAAqB,EACrB,YAAqB,EACrB,IAAgB,EAChB,SAAkB;QALlB,SAAI,GAAJ,IAAI,CAAQ;QACZ,YAAO,GAAP,OAAO,CAAQ;QACf,iBAAY,GAAZ,YAAY,CAAS;QACrB,iBAAY,GAAZ,YAAY,CAAS;QACrB,SAAI,GAAJ,IAAI,CAAY;QAChB,cAAS,GAAT,SAAS,CAAS;QAEzB,IAAI,CAAC,IAAI,GAAG,2BAA2B,CAAC;QACxC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAC7B,CAAC;CACF","sourcesContent":["import {\n ProductAndroid,\n ProductPurchaseAndroid,\n RequestPurchaseAndroidProps,\n RequestSubscriptionAndroidProps,\n SubscriptionProductAndroid,\n} from './types/ExpoIapAndroid.types';\nimport {\n ProductIos,\n ProductPurchaseIos,\n RequestPurchaseIosProps,\n RequestSubscriptionIosProps,\n SubscriptionProductIos,\n} from './types/ExpoIapIos.types';\n\nexport type ChangeEventPayload = {\n value: string;\n};\n\n/**\n * Base product type with common properties shared between iOS and Android\n */\nexport type ProductBase = {\n id: string;\n title: string;\n description: string;\n type: ProductType;\n displayName?: string;\n displayPrice?: string;\n price?: number;\n currency?: string;\n};\n\n// Define literal platform types for better type discrimination\nexport type IosPlatform = {platform: 'ios'};\nexport type AndroidPlatform = {platform: 'android'};\n\nexport enum ProductType {\n InAppPurchase = 'inapp',\n Subscription = 'subs',\n}\n\n// Common base purchase type\nexport type PurchaseBase = {\n id: string;\n transactionId?: string;\n transactionDate: number;\n transactionReceipt: string;\n};\n\n// Union type for platform-specific product types with proper discriminators\nexport type Product =\n | (ProductAndroid & AndroidPlatform)\n | (ProductIos & IosPlatform);\n\n// Union type for platform-specific purchase types with proper discriminators\nexport type ProductPurchase =\n | (ProductPurchaseAndroid & AndroidPlatform)\n | (ProductPurchaseIos & IosPlatform);\n\n// Union type for platform-specific subscription purchase types with proper discriminators\nexport type SubscriptionPurchase =\n | (ProductPurchaseAndroid & AndroidPlatform & {autoRenewingAndroid: boolean})\n | (ProductPurchaseIos & IosPlatform);\n\nexport type Purchase = ProductPurchase | SubscriptionPurchase;\n\nexport type RequestPurchaseProps =\n | RequestPurchaseIosProps\n | RequestPurchaseAndroidProps;\n\nexport type SubscriptionProduct =\n | (SubscriptionProductAndroid & AndroidPlatform)\n | (SubscriptionProductIos & IosPlatform);\n\nexport type RequestSubscriptionProps =\n | RequestSubscriptionAndroidProps\n | RequestSubscriptionIosProps;\n\nexport type PurchaseResult = {\n responseCode?: number;\n debugMessage?: string;\n code?: string;\n message?: string;\n purchaseTokenAndroid?: string;\n};\n\nexport enum ErrorCode {\n E_UNKNOWN = 'E_UNKNOWN',\n E_USER_CANCELLED = 'E_USER_CANCELLED',\n E_USER_ERROR = 'E_USER_ERROR',\n E_ITEM_UNAVAILABLE = 'E_ITEM_UNAVAILABLE',\n E_REMOTE_ERROR = 'E_REMOTE_ERROR',\n E_NETWORK_ERROR = 'E_NETWORK_ERROR',\n E_SERVICE_ERROR = 'E_SERVICE_ERROR',\n E_RECEIPT_FAILED = 'E_RECEIPT_FAILED',\n E_RECEIPT_FINISHED_FAILED = 'E_RECEIPT_FINISHED_FAILED',\n E_NOT_PREPARED = 'E_NOT_PREPARED',\n E_NOT_ENDED = 'E_NOT_ENDED',\n E_ALREADY_OWNED = 'E_ALREADY_OWNED',\n E_DEVELOPER_ERROR = 'E_DEVELOPER_ERROR',\n E_BILLING_RESPONSE_JSON_PARSE_ERROR = 'E_BILLING_RESPONSE_JSON_PARSE_ERROR',\n E_DEFERRED_PAYMENT = 'E_DEFERRED_PAYMENT',\n E_INTERRUPTED = 'E_INTERRUPTED',\n E_IAP_NOT_AVAILABLE = 'E_IAP_NOT_AVAILABLE',\n}\n\nexport class PurchaseError implements Error {\n constructor(\n public name: string,\n public message: string,\n public responseCode?: number,\n public debugMessage?: string,\n public code?: ErrorCode,\n public productId?: string,\n ) {\n this.name = '[expo-iap]: PurchaseError';\n this.message = message;\n this.responseCode = responseCode;\n this.debugMessage = debugMessage;\n this.code = code;\n this.productId = productId;\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAqB,YAAY,EAAC,MAAM,mBAAmB,CAAC;AAEnE,OAAO,EACL,OAAO,EACP,eAAe,EAEf,QAAQ,EACR,aAAa,EACb,cAAc,EACd,wBAAwB,EACxB,mBAAmB,EACnB,oBAAoB,EACrB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EACL,2BAA2B,EAE5B,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAEL,uBAAuB,EAExB,MAAM,0BAA0B,CAAC;AAOlC,cAAc,mBAAmB,CAAC;AAClC,cAAc,eAAe,CAAC;AAG9B,eAAO,MAAM,EAAE,KAAmB,CAAC;AAEnC,oBAAY,QAAQ;IAClB,eAAe,qBAAqB;IACpC,aAAa,mBAAmB;IAChC,qBAAqB,4BAA4B;CAClD;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,OAE1C;AAED,eAAO,MAAM,OAAO,cAEnB,CAAC;AAEF,eAAO,MAAM,uBAAuB,aACxB,CAAC,KAAK,EAAE,QAAQ,KAAK,IAAI,6CAOpC,CAAC;AAEF,eAAO,MAAM,qBAAqB,aACtB,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,6CAGzC,CAAC;AAEF,wBAAgB,cAAc,QAE7B;AAED,eAAO,MAAM,WAAW,SAAgB,MAAM,EAAE,KAAG,QAAQ,OAAO,EAAE,CAsBnE,CAAC;AAEF,eAAO,MAAM,gBAAgB,SACrB,MAAM,EAAE,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,gCAG3B;IACD,QAAQ,EAAE,QAAQ,CAAC;IACnB,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB,KAAG,QAAQ,cAAc,GAAG,OAAO,CAiCnC,CAAC;AAEF,cAAc,UAAU,CAAC"}
package/build/index.js CHANGED
@@ -173,14 +173,16 @@ export const finishTransaction = ({ purchase, isConsumable, }) => {
173
173
  return Promise.resolve(true);
174
174
  },
175
175
  android: async () => {
176
- if (!purchase?.purchaseToken) {
177
- return Promise.reject(new Error('purchaseToken is required to finish transaction'));
176
+ // Check if the purchase is from Android by checking the platform property
177
+ if (purchase.platform !== 'android' ||
178
+ !('purchaseTokenAndroid' in purchase)) {
179
+ return Promise.reject(new Error('purchaseTokenAndroid is required to finish transaction'));
178
180
  }
179
181
  if (isConsumable) {
180
- return ExpoIapModule.consumeProduct(purchase.purchaseToken);
182
+ return ExpoIapModule.consumeProduct(purchase.purchaseTokenAndroid);
181
183
  }
182
184
  else {
183
- return ExpoIapModule.acknowledgePurchase(purchase.purchaseToken);
185
+ return ExpoIapModule.acknowledgePurchase(purchase.purchaseTokenAndroid);
184
186
  }
185
187
  },
186
188
  }) || (() => Promise.reject(new Error('Unsupported Platform'))))();
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,wCAAwC;AACxC,OAAO,EAAC,kBAAkB,EAAE,YAAY,EAAC,MAAM,mBAAmB,CAAC;AACnE,OAAO,EAAC,QAAQ,EAAC,MAAM,cAAc,CAAC;AACtC,OAAO,EAGL,WAAW,GAOZ,MAAM,iBAAiB,CAAC;AACzB,OAAO,aAAa,MAAM,iBAAiB,CAAC;AAU5C,OAAO,EAAC,YAAY,EAAE,wBAAwB,EAAC,MAAM,eAAe,CAAC;AACrE,OAAO,EACL,gBAAgB,EAChB,4BAA4B,GAC7B,MAAM,mBAAmB,CAAC;AAE3B,cAAc,mBAAmB,CAAC;AAClC,cAAc,eAAe,CAAC;A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AAG,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CACpC,EAAE,CAAC;AAEN,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,EAChC,QAAQ,EACR,YAAY,GAIb,EAAqC,EAAE;IACtC,OAAO,CACL,QAAQ,CAAC,MAAM,CAAC;QACd,GAAG,EAAE,KAAK,IAAI,EAAE;YACd,MAAM,aAAa,GAAG,QAAQ,CAAC,aAAa,CAAC;YAC7C,IAAI,CAAC,aAAa,EAAE,CAAC;gBACnB,OAAO,OAAO,CAAC,MAAM,CACnB,IAAI,KAAK,CAAC,kDAAkD,CAAC,CAC9D,CAAC;YACJ,CAAC;YACD,MAAM,aAAa,CAAC,iBAAiB,CAAC,aAAa,CAAC,CAAC;YACrD,OAAO,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QAC/B,CAAC;QACD,OAAO,EAAE,KAAK,IAAI,EAAE;YAClB,IAAI,CAAC,QAAQ,EAAE,aAAa,EAAE,CAAC;gBAC7B,OAAO,OAAO,CAAC,MAAM,CACnB,IAAI,KAAK,CAAC,iDAAiD,CAAC,CAC7D,CAAC;YACJ,CAAC;YACD,IAAI,YAAY,EAAE,CAAC;gBACjB,OAAO,aAAa,CAAC,cAAc,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC;YAC9D,CAAC;iBAAM,CAAC;gBACN,OAAO,aAAa,CAAC,mBAAmB,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC;YACnE,CAAC;QACH,CAAC;KACF,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC,CAAC,CAChE,EAAE,CAAC;AACN,CAAC,CAAC;AAEF,cAAc,UAAU,CAAC","sourcesContent":["// Import the native module. On web, it will be resolved to ExpoIap.web.ts\n// and on native platforms to ExpoIap.ts\nimport {NativeModulesProxy, EventEmitter} from 'expo-modules-core';\nimport {Platform} from 'react-native';\nimport {\n Product,\n ProductPurchase,\n ProductType,\n Purchase,\n PurchaseError,\n PurchaseResult,\n RequestSubscriptionProps,\n SubscriptionProduct,\n SubscriptionPurchase,\n} from './ExpoIap.types';\nimport ExpoIapModule from './ExpoIapModule';\nimport {\n RequestPurchaseAndroidProps,\n RequestSubscriptionAndroidProps,\n} from './types/ExpoIapAndroid.types';\nimport {\n PaymentDiscount,\n RequestPurchaseIosProps,\n RequestSubscriptionIosProps,\n} from './types/ExpoIapIos.types';\nimport {isProductIos, isSubscriptionProductIos} from './modules/ios';\nimport {\n isProductAndroid,\n isSubscriptionProductAndroid,\n} from './modules/android';\n\nexport * from './modules/android';\nexport * from './modules/ios';\n\n// Get the native constant value.\nexport const PI = ExpoIapModule.PI;\n\nexport enum IapEvent {\n PurchaseUpdated = 'purchase-updated',\n PurchaseError = 'purchase-error',\n TransactionIapUpdated = 'iap-transaction-updated',\n}\n\nexport function setValueAsync(value: string) {\n return ExpoIapModule.setValueAsync(value);\n}\n\nexport const emitter = new EventEmitter(\n ExpoIapModule || NativeModulesProxy.ExpoIap,\n);\n\nexport const purchaseUpdatedListener = (\n listener: (event: Purchase) => void,\n) => {\n const emitterSubscription = emitter.addListener(\n IapEvent.PurchaseUpdated,\n listener,\n );\n return emitterSubscription;\n};\n\nexport const purchaseErrorListener = (\n listener: (error: PurchaseError) => void,\n) => {\n return emitter.addListener<PurchaseError>(IapEvent.PurchaseError, listener);\n};\n\nexport function initConnection() {\n return ExpoIapModule.initConnection();\n}\n\nexport const getProducts = async (skus: string[]): Promise<Product[]> => {\n if (!skus?.length) {\n return Promise.reject(new Error('\"skus\" is required'));\n }\n\n return Platform.select({\n ios: async () => {\n const items = await ExpoIapModule.getItems(skus);\n return items.filter((item: unknown) => isProductIos<Product>(item));\n },\n android: async () => {\n const products = await ExpoIapModule.getItemsByType(\n ProductType.InAppPurchase,\n skus,\n );\n\n return products.filter((product: unknown) =>\n isProductAndroid<Product>(product),\n );\n },\n default: () => Promise.reject(new Error('Unsupported Platform')),\n })();\n};\n\nexport const getSubscriptions = async (\n skus: string[],\n): Promise<SubscriptionProduct[]> => {\n if (!skus?.length) {\n return Promise.reject(new Error('\"skus\" is required'));\n }\n\n return Platform.select({\n ios: async () => {\n const rawItems = await ExpoIapModule.getItems(skus);\n return rawItems.filter((item: unknown) => {\n if (!isSubscriptionProductIos(item)) return false;\n return (\n typeof item === 'object' &&\n item !== null &&\n 'id' in item &&\n typeof item.id === 'string' &&\n skus.includes(item.id)\n );\n }) as SubscriptionProduct[];\n },\n android: async () => {\n const rawItems = await ExpoIapModule.getItemsByType('subs', skus);\n return rawItems.filter((item: unknown) => {\n if (!isSubscriptionProductAndroid(item)) return false;\n return (\n typeof item === 'object' &&\n item !== null &&\n 'id' in item &&\n typeof item.id === 'string' &&\n skus.includes(item.id)\n );\n }) as SubscriptionProduct[];\n },\n default: () => Promise.reject(new Error('Unsupported Platform')),\n })();\n};\n\nexport async function endConnection(): Promise<boolean> {\n return ExpoIapModule.endConnection();\n}\n\nexport const getPurchaseHistory = ({\n alsoPublishToEventListener = false,\n onlyIncludeActiveItems = false,\n}: {\n alsoPublishToEventListener?: boolean;\n onlyIncludeActiveItems?: boolean;\n} = {}): Promise<ProductPurchase[]> =>\n (\n Platform.select({\n ios: async () => {\n return ExpoIapModule.getAvailableItems(\n alsoPublishToEventListener,\n onlyIncludeActiveItems,\n );\n },\n android: async () => {\n const products = await ExpoIapModule.getPurchaseHistoryByType(\n ProductType.InAppPurchase,\n );\n const subscriptions = await ExpoIapModule.getPurchaseHistoryByType(\n ProductType.Subscription,\n );\n return products.concat(subscriptions);\n },\n }) || (() => Promise.resolve([]))\n )();\n\nexport const getAvailablePurchases = ({\n alsoPublishToEventListener = false,\n onlyIncludeActiveItems = true,\n}: {\n alsoPublishToEventListener?: boolean;\n onlyIncludeActiveItems?: boolean;\n} = {}): Promise<ProductPurchase[]> =>\n (\n Platform.select({\n ios: () =>\n ExpoIapModule.getAvailableItems(\n alsoPublishToEventListener,\n onlyIncludeActiveItems,\n ),\n android: async () => {\n const products = await ExpoIapModule.getAvailableItemsByType(\n ProductType.InAppPurchase,\n );\n const subscriptions = await ExpoIapModule.getAvailableItemsByType(\n ProductType.Subscription,\n );\n return products.concat(subscriptions);\n },\n }) || (() => Promise.resolve([]))\n )();\n\nconst offerToRecordIos = (\n offer: PaymentDiscount | undefined,\n): Record<keyof PaymentDiscount, string> | undefined => {\n if (!offer) {\n return undefined;\n }\n return {\n identifier: offer.identifier,\n keyIdentifier: offer.keyIdentifier,\n nonce: offer.nonce,\n signature: offer.signature,\n timestamp: offer.timestamp.toString(),\n };\n};\n\nexport const requestPurchase = (\n request: RequestPurchaseIosProps | RequestPurchaseAndroidProps,\n): Promise<ProductPurchase | ProductPurchase[] | void> =>\n (\n Platform.select({\n ios: async () => {\n if (!('sku' in request)) {\n throw new Error('sku is required for iOS purchase');\n }\n const {\n sku,\n andDangerouslyFinishTransactionAutomaticallyIOS = false,\n appAccountToken,\n quantity,\n withOffer,\n } = request;\n const offer = offerToRecordIos(withOffer);\n const purchase = await ExpoIapModule.buyProduct(\n sku,\n andDangerouslyFinishTransactionAutomaticallyIOS,\n appAccountToken,\n quantity ?? -1,\n offer,\n );\n return Promise.resolve(purchase);\n },\n android: async () => {\n if (!('skus' in request) || !request.skus.length) {\n throw new Error('skus is required for Android purchase');\n }\n const {\n skus,\n obfuscatedAccountIdAndroid,\n obfuscatedProfileIdAndroid,\n isOfferPersonalized,\n } = request;\n return ExpoIapModule.buyItemByType({\n type: ProductType.InAppPurchase,\n skuArr: skus,\n purchaseToken: undefined,\n replacementMode: -1,\n obfuscatedAccountId: obfuscatedAccountIdAndroid,\n obfuscatedProfileId: obfuscatedProfileIdAndroid,\n offerTokenArr: [],\n isOfferPersonalized: isOfferPersonalized ?? false,\n });\n },\n }) || Promise.resolve\n )();\n\nexport const requestSubscription = (\n request: RequestSubscriptionProps,\n): Promise<SubscriptionPurchase | SubscriptionPurchase[] | null | void> =>\n (\n Platform.select({\n ios: async () => {\n if (!('sku' in request)) {\n throw new Error('sku is required for iOS subscriptions');\n }\n const {\n sku,\n andDangerouslyFinishTransactionAutomaticallyIOS = false,\n appAccountToken,\n quantity,\n withOffer,\n } = request as RequestSubscriptionIosProps;\n const offer = offerToRecordIos(withOffer);\n const purchase = await ExpoIapModule.buyProduct(\n sku,\n andDangerouslyFinishTransactionAutomaticallyIOS,\n appAccountToken,\n quantity ?? -1,\n offer,\n );\n return Promise.resolve(purchase as SubscriptionPurchase);\n },\n android: async () => {\n const {\n skus,\n isOfferPersonalized,\n obfuscatedAccountIdAndroid,\n obfuscatedProfileIdAndroid,\n subscriptionOffers,\n replacementModeAndroid,\n purchaseTokenAndroid,\n } = request as RequestSubscriptionAndroidProps;\n return ExpoIapModule.buyItemByType({\n type: ProductType.Subscription,\n skuArr: skus.map((so) => so),\n purchaseToken: purchaseTokenAndroid,\n replacementMode: replacementModeAndroid,\n obfuscatedAccountId: obfuscatedAccountIdAndroid,\n obfuscatedProfileId: obfuscatedProfileIdAndroid,\n offerTokenArr: subscriptionOffers.map((so) => so.offerToken),\n isOfferPersonalized: isOfferPersonalized ?? false,\n });\n },\n }) || (() => Promise.resolve(null))\n )();\n\nexport const finishTransaction = ({\n purchase,\n isConsumable,\n}: {\n purchase: Purchase;\n isConsumable?: boolean;\n}): Promise<PurchaseResult | boolean> => {\n return (\n Platform.select({\n ios: async () => {\n const transactionId = purchase.transactionId;\n if (!transactionId) {\n return Promise.reject(\n new Error('transactionId required to finish iOS transaction'),\n );\n }\n await ExpoIapModule.finishTransaction(transactionId);\n return Promise.resolve(true);\n },\n android: async () => {\n if (!purchase?.purchaseToken) {\n return Promise.reject(\n new Error('purchaseToken is required to finish transaction'),\n );\n }\n if (isConsumable) {\n return ExpoIapModule.consumeProduct(purchase.purchaseToken);\n } else {\n return ExpoIapModule.acknowledgePurchase(purchase.purchaseToken);\n }\n },\n }) || (() => Promise.reject(new Error('Unsupported Platform')))\n )();\n};\n\nexport * from './useIap';\n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CAAC,wDAAwD,CAAC,CACpE,CAAC;YACJ,CAAC;YACD,IAAI,YAAY,EAAE,CAAC;gBACjB,OAAO,aAAa,CAAC,cAAc,CAAC,QAAQ,CAAC,oBAAoB,CAAC,CAAC;YACrE,CAAC;iBAAM,CAAC;gBACN,OAAO,aAAa,CAAC,mBAAmB,CACtC,QAAQ,CAAC,oBAAoB,CAC9B,CAAC;YACJ,CAAC;QACH,CAAC;KACF,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC,CAAC,CAChE,EAAE,CAAC;AACN,CAAC,CAAC;AAEF,cAAc,UAAU,CAAC","sourcesContent":["// Import the native module. On web, it will be resolved to ExpoIap.web.ts\n// and on native platforms to ExpoIap.ts\nimport {NativeModulesProxy, EventEmitter} from 'expo-modules-core';\nimport {Platform} from 'react-native';\nimport {\n Product,\n ProductPurchase,\n ProductType,\n Purchase,\n PurchaseError,\n PurchaseResult,\n RequestSubscriptionProps,\n SubscriptionProduct,\n SubscriptionPurchase,\n} from './ExpoIap.types';\nimport ExpoIapModule from './ExpoIapModule';\nimport {\n RequestPurchaseAndroidProps,\n RequestSubscriptionAndroidProps,\n} from './types/ExpoIapAndroid.types';\nimport {\n PaymentDiscount,\n RequestPurchaseIosProps,\n RequestSubscriptionIosProps,\n} from './types/ExpoIapIos.types';\nimport {isProductIos, isSubscriptionProductIos} from './modules/ios';\nimport {\n isProductAndroid,\n isSubscriptionProductAndroid,\n} from './modules/android';\n\nexport * from './modules/android';\nexport * from './modules/ios';\n\n// Get the native constant value.\nexport const PI = ExpoIapModule.PI;\n\nexport enum IapEvent {\n PurchaseUpdated = 'purchase-updated',\n PurchaseError = 'purchase-error',\n TransactionIapUpdated = 'iap-transaction-updated',\n}\n\nexport function setValueAsync(value: string) {\n return ExpoIapModule.setValueAsync(value);\n}\n\nexport const emitter = new EventEmitter(\n ExpoIapModule || NativeModulesProxy.ExpoIap,\n);\n\nexport const purchaseUpdatedListener = (\n listener: (event: Purchase) => void,\n) => {\n const emitterSubscription = emitter.addListener(\n IapEvent.PurchaseUpdated,\n listener,\n );\n return emitterSubscription;\n};\n\nexport const purchaseErrorListener = (\n listener: (error: PurchaseError) => void,\n) => {\n return emitter.addListener<PurchaseError>(IapEvent.PurchaseError, listener);\n};\n\nexport function initConnection() {\n return ExpoIapModule.initConnection();\n}\n\nexport const getProducts = async (skus: string[]): Promise<Product[]> => {\n if (!skus?.length) {\n return Promise.reject(new Error('\"skus\" is required'));\n }\n\n return Platform.select({\n ios: async () => {\n const items = await ExpoIapModule.getItems(skus);\n return items.filter((item: unknown) => isProductIos<Product>(item));\n },\n android: async () => {\n const products = await ExpoIapModule.getItemsByType(\n ProductType.InAppPurchase,\n skus,\n );\n\n return products.filter((product: unknown) =>\n isProductAndroid<Product>(product),\n );\n },\n default: () => Promise.reject(new Error('Unsupported Platform')),\n })();\n};\n\nexport const getSubscriptions = async (\n skus: string[],\n): Promise<SubscriptionProduct[]> => {\n if (!skus?.length) {\n return Promise.reject(new Error('\"skus\" is required'));\n }\n\n return Platform.select({\n ios: async () => {\n const rawItems = await ExpoIapModule.getItems(skus);\n return rawItems.filter((item: unknown) => {\n if (!isSubscriptionProductIos(item)) return false;\n return (\n typeof item === 'object' &&\n item !== null &&\n 'id' in item &&\n typeof item.id === 'string' &&\n skus.includes(item.id)\n );\n }) as SubscriptionProduct[];\n },\n android: async () => {\n const rawItems = await ExpoIapModule.getItemsByType('subs', skus);\n return rawItems.filter((item: unknown) => {\n if (!isSubscriptionProductAndroid(item)) return false;\n return (\n typeof item === 'object' &&\n item !== null &&\n 'id' in item &&\n typeof item.id === 'string' &&\n skus.includes(item.id)\n );\n }) as SubscriptionProduct[];\n },\n default: () => Promise.reject(new Error('Unsupported Platform')),\n })();\n};\n\nexport async function endConnection(): Promise<boolean> {\n return ExpoIapModule.endConnection();\n}\n\nexport const getPurchaseHistory = ({\n alsoPublishToEventListener = false,\n onlyIncludeActiveItems = false,\n}: {\n alsoPublishToEventListener?: boolean;\n onlyIncludeActiveItems?: boolean;\n} = {}): Promise<ProductPurchase[]> =>\n (\n Platform.select({\n ios: async () => {\n return ExpoIapModule.getAvailableItems(\n alsoPublishToEventListener,\n onlyIncludeActiveItems,\n );\n },\n android: async () => {\n const products = await ExpoIapModule.getPurchaseHistoryByType(\n ProductType.InAppPurchase,\n );\n const subscriptions = await ExpoIapModule.getPurchaseHistoryByType(\n ProductType.Subscription,\n );\n return products.concat(subscriptions);\n },\n }) || (() => Promise.resolve([]))\n )();\n\nexport const getAvailablePurchases = ({\n alsoPublishToEventListener = false,\n onlyIncludeActiveItems = true,\n}: {\n alsoPublishToEventListener?: boolean;\n onlyIncludeActiveItems?: boolean;\n} = {}): Promise<ProductPurchase[]> =>\n (\n Platform.select({\n ios: () =>\n ExpoIapModule.getAvailableItems(\n alsoPublishToEventListener,\n onlyIncludeActiveItems,\n ),\n android: async () => {\n const products = await ExpoIapModule.getAvailableItemsByType(\n ProductType.InAppPurchase,\n );\n const subscriptions = await ExpoIapModule.getAvailableItemsByType(\n ProductType.Subscription,\n );\n return products.concat(subscriptions);\n },\n }) || (() => Promise.resolve([]))\n )();\n\nconst offerToRecordIos = (\n offer: PaymentDiscount | undefined,\n): Record<keyof PaymentDiscount, string> | undefined => {\n if (!offer) {\n return undefined;\n }\n return {\n identifier: offer.identifier,\n keyIdentifier: offer.keyIdentifier,\n nonce: offer.nonce,\n signature: offer.signature,\n timestamp: offer.timestamp.toString(),\n };\n};\n\nexport const requestPurchase = (\n request: RequestPurchaseIosProps | RequestPurchaseAndroidProps,\n): Promise<ProductPurchase | ProductPurchase[] | void> =>\n (\n Platform.select({\n ios: async () => {\n if (!('sku' in request)) {\n throw new Error('sku is required for iOS purchase');\n }\n const {\n sku,\n andDangerouslyFinishTransactionAutomaticallyIOS = false,\n appAccountToken,\n quantity,\n withOffer,\n } = request;\n const offer = offerToRecordIos(withOffer);\n const purchase = await ExpoIapModule.buyProduct(\n sku,\n andDangerouslyFinishTransactionAutomaticallyIOS,\n appAccountToken,\n quantity ?? -1,\n offer,\n );\n return Promise.resolve(purchase);\n },\n android: async () => {\n if (!('skus' in request) || !request.skus.length) {\n throw new Error('skus is required for Android purchase');\n }\n const {\n skus,\n obfuscatedAccountIdAndroid,\n obfuscatedProfileIdAndroid,\n isOfferPersonalized,\n } = request;\n return ExpoIapModule.buyItemByType({\n type: ProductType.InAppPurchase,\n skuArr: skus,\n purchaseToken: undefined,\n replacementMode: -1,\n obfuscatedAccountId: obfuscatedAccountIdAndroid,\n obfuscatedProfileId: obfuscatedProfileIdAndroid,\n offerTokenArr: [],\n isOfferPersonalized: isOfferPersonalized ?? false,\n });\n },\n }) || Promise.resolve\n )();\n\nexport const requestSubscription = (\n request: RequestSubscriptionProps,\n): Promise<SubscriptionPurchase | SubscriptionPurchase[] | null | void> =>\n (\n Platform.select({\n ios: async () => {\n if (!('sku' in request)) {\n throw new Error('sku is required for iOS subscriptions');\n }\n const {\n sku,\n andDangerouslyFinishTransactionAutomaticallyIOS = false,\n appAccountToken,\n quantity,\n withOffer,\n } = request as RequestSubscriptionIosProps;\n const offer = offerToRecordIos(withOffer);\n const purchase = await ExpoIapModule.buyProduct(\n sku,\n andDangerouslyFinishTransactionAutomaticallyIOS,\n appAccountToken,\n quantity ?? -1,\n offer,\n );\n return Promise.resolve(purchase as SubscriptionPurchase);\n },\n android: async () => {\n const {\n skus,\n isOfferPersonalized,\n obfuscatedAccountIdAndroid,\n obfuscatedProfileIdAndroid,\n subscriptionOffers,\n replacementModeAndroid,\n purchaseTokenAndroid,\n } = request as RequestSubscriptionAndroidProps;\n return ExpoIapModule.buyItemByType({\n type: ProductType.Subscription,\n skuArr: skus.map((so) => so),\n purchaseToken: purchaseTokenAndroid,\n replacementMode: replacementModeAndroid,\n obfuscatedAccountId: obfuscatedAccountIdAndroid,\n obfuscatedProfileId: obfuscatedProfileIdAndroid,\n offerTokenArr: subscriptionOffers.map((so) => so.offerToken),\n isOfferPersonalized: isOfferPersonalized ?? false,\n });\n },\n }) || (() => Promise.resolve(null))\n )();\n\nexport const finishTransaction = ({\n purchase,\n isConsumable,\n}: {\n purchase: Purchase;\n isConsumable?: boolean;\n}): Promise<PurchaseResult | boolean> => {\n return (\n Platform.select({\n ios: async () => {\n const transactionId = purchase.transactionId;\n if (!transactionId) {\n return Promise.reject(\n new Error('transactionId required to finish iOS transaction'),\n );\n }\n await ExpoIapModule.finishTransaction(transactionId);\n return Promise.resolve(true);\n },\n android: async () => {\n // Check if the purchase is from Android by checking the platform property\n if (\n purchase.platform !== 'android' ||\n !('purchaseTokenAndroid' in purchase)\n ) {\n return Promise.reject(\n new Error('purchaseTokenAndroid is required to finish transaction'),\n );\n }\n if (isConsumable) {\n return ExpoIapModule.consumeProduct(purchase.purchaseTokenAndroid);\n } else {\n return ExpoIapModule.acknowledgePurchase(\n purchase.purchaseTokenAndroid,\n );\n }\n },\n }) || (() => Promise.reject(new Error('Unsupported Platform')))\n )();\n};\n\nexport * from './useIap';\n"]}
@@ -99,6 +99,7 @@ export declare enum PurchaseStateAndroid {
99
99
  }
100
100
  export type ProductPurchaseAndroid = PurchaseBase & {
101
101
  ids?: string[];
102
+ purchaseTokenAndroid?: string;
102
103
  dataAndroid?: string;
103
104
  signatureAndroid?: string;
104
105
  autoRenewingAndroid?: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"ExpoIapAndroid.types.d.ts","sourceRoot":"","sources":["../../src/types/ExpoIapAndroid.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAE,WAAW,EAAC,MAAM,kBAAkB,CAAC;AAE3D,KAAK,2BAA2B,GAAG;IACjC,iBAAiB,EAAE,MAAM,CAAC;IAC1B,cAAc,EAAE,MAAM,CAAC;IACvB,iBAAiB,EAAE,MAAM,CAAC;CAC3B,CAAC;AAEF,KAAK,mBAAmB,GAAG;IACzB,cAAc,EAAE,MAAM,CAAC;IACvB,iBAAiB,EAAE,MAAM,CAAC;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,EAAE,MAAM,CAAC;IACpC,0BAA0B,CAAC,EAAE,MAAM,CAAC;CACrC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"ExpoIapAndroid.types.js","sourceRoot":"","sources":["../../src/types/ExpoIapAndroid.types.ts"],"names":[],"mappings":"AAuDA,IAAK,uBAOJ;AAPD,WAAK,uBAAuB;IAC1B,6GAA4B,CAAA;IAC5B,mGAAuB,CAAA;IACvB,uGAAyB,CAAA;IACzB,+FAAqB,CAAA;IACrB,+FAAqB,CAAA;IACrB,6EAAY,CAAA;AACd,CAAC,EAPI,uBAAuB,KAAvB,uBAAuB,QAO3B;AAkCD,MAAM,CAAN,IAAY,kBAWX;AAXD,WAAY,kBAAkB;IAC5B,0EAA0E;IAC1E,2DAAqC,CAAA;IACrC,+CAA+C;IAC/C,6EAAuD,CAAA;IACvD,oFAAoF;IACpF,yDAAmC,CAAA;IACnC,wCAAwC;IACxC,qDAA+B,CAAA;IAC/B,oCAAoC;IACpC,mEAA6C,CAAA;AAC/C,CAAC,EAXW,kBAAkB,KAAlB,kBAAkB,QAW7B;AAED,MAAM,CAAN,IAAY,oBAIX;AAJD,WAAY,oBAAoB;IAC9B,yFAAqB,CAAA;IACrB,yEAAa,CAAA;IACb,qEAAW,CAAA;AACb,CAAC,EAJW,oBAAoB,KAApB,oBAAoB,QAI/B","sourcesContent":["import {PurchaseBase, ProductBase} from '../ExpoIap.types';\n\ntype OneTimePurchaseOfferDetails = {\n priceCurrencyCode: string;\n formattedPrice: string;\n priceAmountMicros: string;\n};\n\ntype PricingPhaseAndroid = {\n formattedPrice: string;\n priceCurrencyCode: string;\n // P1W, P1M, P1Y\n billingPeriod: string;\n billingCycleCount: number;\n priceAmountMicros: string;\n recurrenceMode: number;\n};\n\ntype PricingPhasesAndroid = {\n pricingPhaseList: PricingPhaseAndroid[];\n};\n\ntype SubscriptionOfferDetail = {\n basePlanId: string;\n offerId: string;\n offerToken: string;\n offerTags: string[];\n pricingPhases: PricingPhasesAndroid;\n};\n\nexport type ProductAndroid = ProductBase & {\n name: string;\n oneTimePurchaseOfferDetails?: OneTimePurchaseOfferDetails;\n subscriptionOfferDetails?: SubscriptionOfferDetail[];\n};\n\ntype SubscriptionOfferAndroid = {\n basePlanId: string;\n offerId: string | null;\n offerToken: string;\n pricingPhases: PricingPhasesAndroid;\n offerTags: string[];\n};\n\nexport type SubscriptionProductAndroid = ProductAndroid & {\n subscriptionOfferDetails: SubscriptionOfferAndroid[];\n};\n\nexport type RequestPurchaseAndroidProps = {\n skus: string[];\n obfuscatedAccountIdAndroid?: string;\n obfuscatedProfileIdAndroid?: string;\n isOfferPersonalized?: boolean; // For AndroidBilling V5 https://developer.android.com/google/play/billing/integrate#personalized-price\n};\n\nenum ReplacementModesAndroid {\n UNKNOWN_REPLACEMENT_MODE = 0,\n WITH_TIME_PRORATION = 1,\n CHARGE_PRORATED_PRICE = 2,\n WITHOUT_PRORATION = 3,\n CHARGE_FULL_PRICE = 5,\n DEFERRED = 6,\n}\n\ntype SubscriptionOffer = {\n sku: string;\n offerToken: string;\n};\n\nexport type RequestSubscriptionAndroidProps = RequestPurchaseAndroidProps & {\n purchaseTokenAndroid?: string;\n replacementModeAndroid?: ReplacementModesAndroid;\n subscriptionOffers: SubscriptionOffer[];\n};\n\nexport type ReceiptAndroid = {\n autoRenewing: boolean;\n betaProduct: boolean;\n cancelDate: number | null;\n cancelReason: string;\n deferredDate: number | null;\n deferredSku: number | null;\n freeTrialEndDate: number;\n gracePeriodEndDate: number;\n parentProductId: string;\n productId: string;\n productType: string;\n purchaseDate: number;\n quantity: number;\n receiptId: string;\n renewalDate: number;\n term: string;\n termSku: string;\n testTransaction: boolean;\n};\n\nexport enum FeatureTypeAndroid {\n /** Show in-app messages. Included in documentation by the annotations: */\n IN_APP_MESSAGING = 'IN_APP_MESSAGING',\n /** Launch a price change confirmation flow. */\n PRICE_CHANGE_CONFIRMATION = 'PRICE_CHANGE_CONFIRMATION',\n /** Play billing library support for querying and purchasing with ProductDetails. */\n PRODUCT_DETAILS = 'PRODUCT_DETAILS',\n /** Purchase/query for subscriptions. */\n SUBSCRIPTIONS = 'SUBSCRIPTIONS',\n /** Subscriptions update/replace. */\n SUBSCRIPTIONS_UPDATE = 'SUBSCRIPTIONS_UPDATE',\n}\n\nexport enum PurchaseStateAndroid {\n UNSPECIFIED_STATE = 0,\n PURCHASED = 1,\n PENDING = 2,\n}\n\nexport type ProductPurchaseAndroid = PurchaseBase & {\n ids?: string[];\n dataAndroid?: string;\n signatureAndroid?: string;\n autoRenewingAndroid?: boolean;\n purchaseStateAndroid?: PurchaseStateAndroid;\n isAcknowledgedAndroid?: boolean;\n packageNameAndroid?: string;\n developerPayloadAndroid?: string;\n obfuscatedAccountIdAndroid?: string;\n obfuscatedProfileIdAndroid?: string;\n};\n"]}
1
+ {"version":3,"file":"ExpoIapAndroid.types.js","sourceRoot":"","sources":["../../src/types/ExpoIapAndroid.types.ts"],"names":[],"mappings":"AAuDA,IAAK,uBAOJ;AAPD,WAAK,uBAAuB;IAC1B,6GAA4B,CAAA;IAC5B,mGAAuB,CAAA;IACvB,uGAAyB,CAAA;IACzB,+FAAqB,CAAA;IACrB,+FAAqB,CAAA;IACrB,6EAAY,CAAA;AACd,CAAC,EAPI,uBAAuB,KAAvB,uBAAuB,QAO3B;AAkCD,MAAM,CAAN,IAAY,kBAWX;AAXD,WAAY,kBAAkB;IAC5B,0EAA0E;IAC1E,2DAAqC,CAAA;IACrC,+CAA+C;IAC/C,6EAAuD,CAAA;IACvD,oFAAoF;IACpF,yDAAmC,CAAA;IACnC,wCAAwC;IACxC,qDAA+B,CAAA;IAC/B,oCAAoC;IACpC,mEAA6C,CAAA;AAC/C,CAAC,EAXW,kBAAkB,KAAlB,kBAAkB,QAW7B;AAED,MAAM,CAAN,IAAY,oBAIX;AAJD,WAAY,oBAAoB;IAC9B,yFAAqB,CAAA;IACrB,yEAAa,CAAA;IACb,qEAAW,CAAA;AACb,CAAC,EAJW,oBAAoB,KAApB,oBAAoB,QAI/B","sourcesContent":["import {PurchaseBase, ProductBase} from '../ExpoIap.types';\n\ntype OneTimePurchaseOfferDetails = {\n priceCurrencyCode: string;\n formattedPrice: string;\n priceAmountMicros: string;\n};\n\ntype PricingPhaseAndroid = {\n formattedPrice: string;\n priceCurrencyCode: string;\n // P1W, P1M, P1Y\n billingPeriod: string;\n billingCycleCount: number;\n priceAmountMicros: string;\n recurrenceMode: number;\n};\n\ntype PricingPhasesAndroid = {\n pricingPhaseList: PricingPhaseAndroid[];\n};\n\ntype SubscriptionOfferDetail = {\n basePlanId: string;\n offerId: string;\n offerToken: string;\n offerTags: string[];\n pricingPhases: PricingPhasesAndroid;\n};\n\nexport type ProductAndroid = ProductBase & {\n name: string;\n oneTimePurchaseOfferDetails?: OneTimePurchaseOfferDetails;\n subscriptionOfferDetails?: SubscriptionOfferDetail[];\n};\n\ntype SubscriptionOfferAndroid = {\n basePlanId: string;\n offerId: string | null;\n offerToken: string;\n pricingPhases: PricingPhasesAndroid;\n offerTags: string[];\n};\n\nexport type SubscriptionProductAndroid = ProductAndroid & {\n subscriptionOfferDetails: SubscriptionOfferAndroid[];\n};\n\nexport type RequestPurchaseAndroidProps = {\n skus: string[];\n obfuscatedAccountIdAndroid?: string;\n obfuscatedProfileIdAndroid?: string;\n isOfferPersonalized?: boolean; // For AndroidBilling V5 https://developer.android.com/google/play/billing/integrate#personalized-price\n};\n\nenum ReplacementModesAndroid {\n UNKNOWN_REPLACEMENT_MODE = 0,\n WITH_TIME_PRORATION = 1,\n CHARGE_PRORATED_PRICE = 2,\n WITHOUT_PRORATION = 3,\n CHARGE_FULL_PRICE = 5,\n DEFERRED = 6,\n}\n\ntype SubscriptionOffer = {\n sku: string;\n offerToken: string;\n};\n\nexport type RequestSubscriptionAndroidProps = RequestPurchaseAndroidProps & {\n purchaseTokenAndroid?: string;\n replacementModeAndroid?: ReplacementModesAndroid;\n subscriptionOffers: SubscriptionOffer[];\n};\n\nexport type ReceiptAndroid = {\n autoRenewing: boolean;\n betaProduct: boolean;\n cancelDate: number | null;\n cancelReason: string;\n deferredDate: number | null;\n deferredSku: number | null;\n freeTrialEndDate: number;\n gracePeriodEndDate: number;\n parentProductId: string;\n productId: string;\n productType: string;\n purchaseDate: number;\n quantity: number;\n receiptId: string;\n renewalDate: number;\n term: string;\n termSku: string;\n testTransaction: boolean;\n};\n\nexport enum FeatureTypeAndroid {\n /** Show in-app messages. Included in documentation by the annotations: */\n IN_APP_MESSAGING = 'IN_APP_MESSAGING',\n /** Launch a price change confirmation flow. */\n PRICE_CHANGE_CONFIRMATION = 'PRICE_CHANGE_CONFIRMATION',\n /** Play billing library support for querying and purchasing with ProductDetails. */\n PRODUCT_DETAILS = 'PRODUCT_DETAILS',\n /** Purchase/query for subscriptions. */\n SUBSCRIPTIONS = 'SUBSCRIPTIONS',\n /** Subscriptions update/replace. */\n SUBSCRIPTIONS_UPDATE = 'SUBSCRIPTIONS_UPDATE',\n}\n\nexport enum PurchaseStateAndroid {\n UNSPECIFIED_STATE = 0,\n PURCHASED = 1,\n PENDING = 2,\n}\n\nexport type ProductPurchaseAndroid = PurchaseBase & {\n ids?: string[];\n purchaseTokenAndroid?: string;\n dataAndroid?: string;\n signatureAndroid?: string;\n autoRenewingAndroid?: boolean;\n purchaseStateAndroid?: PurchaseStateAndroid;\n isAcknowledgedAndroid?: boolean;\n packageNameAndroid?: string;\n developerPayloadAndroid?: string;\n obfuscatedAccountIdAndroid?: string;\n obfuscatedProfileIdAndroid?: string;\n};\n"]}
package/iap.md CHANGED
@@ -142,8 +142,7 @@ This section describes purchase properties in `expo-iap`.
142
142
  | `id` | `string` | Purchased product ID |
143
143
  | `transactionId` | `string?` | Transaction ID (optional) |
144
144
  | `transactionDate` | `number` | Unix timestamp |
145
- | `transactionReceipt` | `string` | Receipt data |
146
- | `purchaseToken` | `string?` | Purchase token (optional) |
145
+ | `purchaseTokenAndroid` | `string?` | Purchase token (optional) |
147
146
 
148
147
  ### Android-Only Purchase Types
149
148
 
@@ -200,7 +199,7 @@ export default function SimpleIAP() {
200
199
 
201
200
  // Handle purchase updates
202
201
  const purchaseListener = purchaseUpdatedListener(async (purchase) => {
203
- if (purchase.transactionReceipt) {
202
+ if (purchase) {
204
203
  await finishTransaction({purchase, isConsumable: true});
205
204
  alert('Purchase completed!');
206
205
  }
@@ -327,7 +326,7 @@ export default function IAPWithHook() {
327
326
 
328
327
  // Handle purchase updates and errors
329
328
  useEffect(() => {
330
- if (currentPurchase?.transactionReceipt) {
329
+ if (currentPurchase) {
331
330
  InteractionManager.runAfterInteractions(async () => {
332
331
  try {
333
332
  await finishTransaction({
@@ -1,11 +1,11 @@
1
1
  import ExpoModulesCore
2
2
  import StoreKit
3
3
 
4
- func serializeDebug (_ s: String) -> String? {
4
+ func serializeDebug(_ s: String) -> String? {
5
5
  #if DEBUG
6
- return s
6
+ return s
7
7
  #else
8
- return nil
8
+ return nil
9
9
  #endif
10
10
  }
11
11
 
@@ -18,16 +18,20 @@ struct IapEvent {
18
18
  @available(iOS 15.0, *)
19
19
  func serializeTransaction(_ transaction: Transaction) -> [String: Any?] {
20
20
  // Determine if this is a subscription by productType or expirationDate
21
- let isSubscription = transaction.productType.rawValue.lowercased().contains("renewable") || transaction.expirationDate != nil
22
-
21
+ let isSubscription =
22
+ transaction.productType.rawValue.lowercased().contains("renewable")
23
+ || transaction.expirationDate != nil
24
+
23
25
  // Parse transaction reason from jsonRepresentation if available
24
26
  var transactionReasonIos: String? = nil
25
27
  var webOrderLineItemId: Int? = nil
26
28
  var jsonData: [String: Any]? = nil
27
-
28
- // JSON representation handling
29
+
30
+ // JSON representation handling (JWS 데이터)
31
+ var jwsReceipt: String
29
32
  do {
30
33
  let jsonRep = transaction.jsonRepresentation
34
+ jwsReceipt = String(data: jsonRep, encoding: .utf8) ?? "" // JWS 형식으로 변환
31
35
  let jsonObj = try JSONSerialization.jsonObject(with: jsonRep) as! [String: Any]
32
36
  jsonData = jsonObj
33
37
  if let reason = jsonObj["transactionReason"] as? String {
@@ -38,6 +42,7 @@ func serializeTransaction(_ transaction: Transaction) -> [String: Any?] {
38
42
  }
39
43
  } catch {
40
44
  print("Error parsing JSON representation: \(error)")
45
+ jwsReceipt = ""
41
46
  }
42
47
 
43
48
  // Create base purchase object that matches Purchase type in TypeScript
@@ -47,74 +52,72 @@ func serializeTransaction(_ transaction: Transaction) -> [String: Any?] {
47
52
  "ids": [transaction.productID],
48
53
  "transactionId": String(transaction.id),
49
54
  "transactionDate": transaction.purchaseDate.timeIntervalSince1970 * 1000,
50
- "transactionReceipt": "", // Not available in StoreKit 2
51
- "purchaseToken": "", // Not applicable on iOS
52
-
55
+ "transactionReceipt": jwsReceipt, // JWS 데이터를 transactionReceipt에 담음
56
+
53
57
  // iOS specific fields - basic info
54
58
  "quantityIos": transaction.purchasedQuantity,
55
59
  "originalTransactionDateIos": transaction.originalPurchaseDate.timeIntervalSince1970 * 1000,
56
60
  "originalTransactionIdentifierIos": transaction.originalID,
57
61
  "appAccountToken": transaction.appAccountToken?.uuidString,
58
-
62
+
59
63
  // App and Product Identifiers
60
64
  "appBundleIdIos": transaction.appBundleID,
61
65
  "productTypeIos": transaction.productType.rawValue,
62
66
  "subscriptionGroupIdIos": transaction.subscriptionGroupID,
63
-
67
+
64
68
  // Transaction Identifiers
65
69
  "webOrderLineItemIdIos": webOrderLineItemId,
66
-
70
+
67
71
  // Purchase and Expiration Dates
68
72
  "expirationDateIos": transaction.expirationDate.map { $0.timeIntervalSince1970 * 1000 },
69
-
73
+
70
74
  // Purchase Details
71
75
  "isUpgradedIos": transaction.isUpgraded,
72
76
  "ownershipTypeIos": transaction.ownershipType.rawValue,
73
-
77
+
74
78
  // Revocation Status
75
79
  "revocationDateIos": transaction.revocationDate.map { $0.timeIntervalSince1970 * 1000 },
76
- "revocationReasonIos": transaction.revocationReason?.rawValue
80
+ "revocationReasonIos": transaction.revocationReason?.rawValue,
77
81
  ]
78
-
82
+
79
83
  // Environment (iOS 16.0+)
80
84
  if #available(iOS 16.0, *) {
81
85
  purchaseMap["environmentIos"] = transaction.environment.rawValue
82
86
  }
83
-
87
+
84
88
  // Storefront (iOS 17.0+)
85
89
  if #available(iOS 17.0, *) {
86
90
  purchaseMap["storefrontCountryCodeIos"] = transaction.storefront.countryCode
87
91
  }
88
-
92
+
89
93
  // Transaction Reason (iOS 17.0+)
90
94
  if #available(iOS 17.0, *) {
91
95
  purchaseMap["reasonIos"] = transaction.reason.rawValue
92
96
  }
93
-
94
- // reasonStringRepresentation transactionReasonIos는 명시적 타입 처리
95
- purchaseMap["reasonStringRepresentationIos"] = transaction.reasonStringRepresentation
97
+
98
+ // reasonStringRepresentation Transaction에 없으므로 제거
96
99
  purchaseMap["transactionReasonIos"] = transactionReasonIos
97
-
100
+
98
101
  // Add offer information if available with proper availability check
99
102
  if #available(iOS 17.2, *) {
100
103
  if let offer = transaction.offer {
101
104
  purchaseMap["offerIos"] = [
102
105
  "id": offer.id as Any,
103
106
  "type": offer.type.rawValue,
104
- "paymentMode": offer.paymentMode?.rawValue ?? ""
107
+ "paymentMode": offer.paymentMode?.rawValue ?? "",
105
108
  ]
106
109
  }
107
110
  }
108
-
111
+
109
112
  // Add additional pricing info if available
110
113
  if #available(iOS 15.4, *), let priceInfo = jsonData?["price"] as? NSNumber {
111
114
  purchaseMap["priceIos"] = priceInfo.doubleValue
112
115
  }
113
-
116
+
114
117
  if #available(iOS 15.4, *), let currencyInfo = jsonData?["currency"] as? String {
115
118
  purchaseMap["currencyIos"] = currencyInfo
116
119
  }
117
-
120
+
118
121
  return purchaseMap
119
122
  }
120
123
 
@@ -128,12 +131,13 @@ func serializeProduct(_ p: Product) -> [String: Any?] {
128
131
  "id": p.id,
129
132
  "title": p.displayName,
130
133
  "isFamilyShareable": p.isFamilyShareable,
131
- "jsonRepresentation": serializeDebug(String(data: p.jsonRepresentation, encoding: .utf8) ?? ""),
134
+ "jsonRepresentation": serializeDebug(
135
+ String(data: p.jsonRepresentation, encoding: .utf8) ?? ""),
132
136
  "price": p.price,
133
137
  "subscription": p.subscription,
134
138
  "type": p.type,
135
139
  "currency": p.priceFormatStyle.currencyCode,
136
- "platform": "ios" // Add platform identifier
140
+ "platform": "ios",
137
141
  ]
138
142
  }
139
143
 
@@ -152,16 +156,17 @@ func serializeProduct(_ p: Product) -> [String: Any?] {
152
156
  func serializeSubscriptionStatus(_ status: Product.SubscriptionInfo.Status) -> [String: Any?] {
153
157
  return [
154
158
  "state": status.state.rawValue,
155
- "renewalInfo": serializeRenewalInfo(status.renewalInfo)
159
+ "renewalInfo": serializeRenewalInfo(status.renewalInfo),
156
160
  ]
157
161
  }
158
162
 
159
163
  @available(iOS 15.0, *)
160
- func serializeRenewalInfo(_ renewalInfo: VerificationResult<Product.SubscriptionInfo.RenewalInfo>) -> [String: Any?]? {
164
+ func serializeRenewalInfo(_ renewalInfo: VerificationResult<Product.SubscriptionInfo.RenewalInfo>)
165
+ -> [String: Any?]?
166
+ {
161
167
  switch renewalInfo {
162
168
  case .unverified:
163
169
  return nil
164
-
165
170
  case .verified(let info):
166
171
  return [
167
172
  "autoRenewStatus": info.willAutoRenew,
@@ -170,7 +175,7 @@ func serializeRenewalInfo(_ renewalInfo: VerificationResult<Product.Subscription
170
175
  "deviceVerification": info.deviceVerification,
171
176
  "currentProductID": info.currentProductID,
172
177
  "debugDescription": info.debugDescription,
173
- "gracePeriodExpirationDate": info.gracePeriodExpirationDate
178
+ "gracePeriodExpirationDate": info.gracePeriodExpirationDate,
174
179
  ]
175
180
  }
176
181
  }
@@ -208,23 +213,20 @@ public class ExpoIapModule: Module {
208
213
 
209
214
  AsyncFunction("getItems") { (skus: [String]) -> [[String: Any?]?] in
210
215
  guard let productStore = self.productStore else {
211
- throw NSError(domain: "ExpoIapModule", code: 1, userInfo: [NSLocalizedDescriptionKey: "Connection not initialized"])
216
+ throw NSError(
217
+ domain: "ExpoIapModule", code: 1,
218
+ userInfo: [NSLocalizedDescriptionKey: "Connection not initialized"])
212
219
  }
213
220
 
214
221
  do {
215
222
  let fetchedProducts = try await Product.products(for: skus)
216
-
217
223
  await productStore.performOnActor { isolatedStore in
218
- fetchedProducts.forEach({ product in
224
+ fetchedProducts.forEach { product in
219
225
  isolatedStore.addProduct(product)
220
- })
226
+ }
221
227
  }
222
-
223
228
  let products = await productStore.getAllProducts()
224
-
225
- return products.map { (prod: Product) -> [String: Any?]? in
226
- return serializeProduct(prod)
227
- }.compactMap { $0 }
229
+ return products.map { serializeProduct($0) }.compactMap { $0 }
228
230
  } catch {
229
231
  print("Error fetching items: \(error)")
230
232
  throw error
@@ -235,7 +237,6 @@ public class ExpoIapModule: Module {
235
237
  guard let productStore = self.productStore else {
236
238
  return false
237
239
  }
238
-
239
240
  await productStore.removeAll()
240
241
  self.transactions.removeAll()
241
242
  self.productStore = nil
@@ -243,7 +244,8 @@ public class ExpoIapModule: Module {
243
244
  return true
244
245
  }
245
246
 
246
- AsyncFunction("getAvailableItems") { (alsoPublishToEventListener: Bool, onlyIncludeActiveItems: Bool) -> [[String: Any?]?] in
247
+ AsyncFunction("getAvailableItems") {
248
+ (alsoPublishToEventListener: Bool, onlyIncludeActiveItems: Bool) -> [[String: Any?]?] in
247
249
  var purchasedItems: [Transaction] = []
248
250
 
249
251
  func addTransaction(transaction: Transaction) {
@@ -259,7 +261,9 @@ public class ExpoIapModule: Module {
259
261
  }
260
262
  }
261
263
 
262
- for await result in onlyIncludeActiveItems ? Transaction.currentEntitlements : Transaction.all {
264
+ for await result in onlyIncludeActiveItems
265
+ ? Transaction.currentEntitlements : Transaction.all
266
+ {
263
267
  do {
264
268
  let transaction = try self.checkVerified(result)
265
269
  if !onlyIncludeActiveItems {
@@ -268,19 +272,22 @@ public class ExpoIapModule: Module {
268
272
  }
269
273
  switch transaction.productType {
270
274
  case .nonConsumable, .autoRenewable, .consumable:
271
- if await self.productStore?.getProduct(productID: transaction.productID) != nil {
275
+ if await self.productStore?.getProduct(productID: transaction.productID)
276
+ != nil
277
+ {
272
278
  addTransaction(transaction: transaction)
273
279
  }
274
-
275
280
  case .nonRenewable:
276
- if await self.productStore?.getProduct(productID: transaction.productID) != nil {
281
+ if await self.productStore?.getProduct(productID: transaction.productID)
282
+ != nil
283
+ {
277
284
  let currentDate = Date()
278
- let expirationDate = Calendar(identifier: .gregorian).date(byAdding: DateComponents(year: 1), to: transaction.purchaseDate)!
285
+ let expirationDate = Calendar(identifier: .gregorian).date(
286
+ byAdding: DateComponents(year: 1), to: transaction.purchaseDate)!
279
287
  if currentDate < expirationDate {
280
288
  addTransaction(transaction: transaction)
281
289
  }
282
290
  }
283
-
284
291
  default:
285
292
  break
286
293
  }
@@ -290,7 +297,7 @@ public class ExpoIapModule: Module {
290
297
  "debugMessage": StoreError.failedVerification.localizedDescription,
291
298
  "code": IapErrors.E_TRANSACTION_VALIDATION_FAILED.rawValue,
292
299
  "message": StoreError.failedVerification.localizedDescription,
293
- "productId": "unknown"
300
+ "productId": "unknown",
294
301
  ]
295
302
  addError(error: StoreError.failedVerification, errorDict: err)
296
303
  } catch {
@@ -299,7 +306,7 @@ public class ExpoIapModule: Module {
299
306
  "debugMessage": error.localizedDescription,
300
307
  "code": IapErrors.E_UNKNOWN.rawValue,
301
308
  "message": error.localizedDescription,
302
- "productId": "unknown"
309
+ "productId": "unknown",
303
310
  ]
304
311
  addError(error: error, errorDict: err)
305
312
  }
@@ -308,9 +315,15 @@ public class ExpoIapModule: Module {
308
315
  return purchasedItems.map { serializeTransaction($0) }
309
316
  }
310
317
 
311
- AsyncFunction("buyProduct") { (sku: String, andDangerouslyFinishTransactionAutomatically: Bool, appAccountToken: String?, quantity: Int, discountOffer: [String: String]?) -> [String: Any?]? in
318
+ AsyncFunction("buyProduct") {
319
+ (
320
+ sku: String, andDangerouslyFinishTransactionAutomatically: Bool,
321
+ appAccountToken: String?, quantity: Int, discountOffer: [String: String]?
322
+ ) -> [String: Any?]? in
312
323
  guard let productStore = self.productStore else {
313
- throw NSError(domain: "ExpoIapModule", code: 1, userInfo: [NSLocalizedDescriptionKey: "Connection not initialized"])
324
+ throw NSError(
325
+ domain: "ExpoIapModule", code: 1,
326
+ userInfo: [NSLocalizedDescriptionKey: "Connection not initialized"])
314
327
  }
315
328
 
316
329
  let product: Product? = await productStore.getProduct(productID: sku)
@@ -320,26 +333,42 @@ public class ExpoIapModule: Module {
320
333
  if quantity > -1 {
321
334
  options.insert(.quantity(quantity))
322
335
  }
323
- if let offerID = discountOffer?["identifier"], let keyID = discountOffer?["keyIdentifier"], let nonce = discountOffer?["nonce"], let signature = discountOffer?["signature"], let timestamp = discountOffer?["timestamp"], let uuidNonce = UUID(uuidString: nonce), let signatureData = signature.data(using: .utf8), let timestampInt = Int(timestamp) {
324
- options.insert(.promotionalOffer(offerID: offerID, keyID: keyID, nonce: uuidNonce, signature: signatureData, timestamp: timestampInt))
336
+ if let offerID = discountOffer?["identifier"],
337
+ let keyID = discountOffer?["keyIdentifier"],
338
+ let nonce = discountOffer?["nonce"],
339
+ let signature = discountOffer?["signature"],
340
+ let timestamp = discountOffer?["timestamp"],
341
+ let uuidNonce = UUID(uuidString: nonce),
342
+ let signatureData = signature.data(using: .utf8),
343
+ let timestampInt = Int(timestamp)
344
+ {
345
+ options.insert(
346
+ .promotionalOffer(
347
+ offerID: offerID, keyID: keyID, nonce: uuidNonce,
348
+ signature: signatureData, timestamp: timestampInt))
325
349
  }
326
- if let appAccountToken = appAccountToken, let appAccountUUID = UUID(uuidString: appAccountToken) {
350
+ if let appAccountToken = appAccountToken,
351
+ let appAccountUUID = UUID(uuidString: appAccountToken)
352
+ {
327
353
  options.insert(.appAccountToken(appAccountUUID))
328
354
  }
329
355
  guard let windowScene = await self.currentWindowScene() else {
330
- throw NSError(domain: "ExpoIapModule", code: 2, userInfo: [NSLocalizedDescriptionKey: "Could not find window scene"])
356
+ throw NSError(
357
+ domain: "ExpoIapModule", code: 2,
358
+ userInfo: [NSLocalizedDescriptionKey: "Could not find window scene"])
331
359
  }
332
360
  let result: Product.PurchaseResult
333
361
  #if swift(>=5.9)
334
- if #available(iOS 17.0, tvOS 17.0, *) {
335
- result = try await product.purchase(confirmIn: windowScene, options: options)
336
- } else {
337
- #if !os(visionOS)
338
- result = try await product.purchase(options: options)
339
- #endif
340
- }
362
+ if #available(iOS 17.0, tvOS 17.0, *) {
363
+ result = try await product.purchase(
364
+ confirmIn: windowScene, options: options)
365
+ } else {
366
+ #if !os(visionOS)
367
+ result = try await product.purchase(options: options)
368
+ #endif
369
+ }
341
370
  #elseif !os(visionOS)
342
- result = try await product.purchase(options: options)
371
+ result = try await product.purchase(options: options)
343
372
  #endif
344
373
 
345
374
  switch result {
@@ -350,23 +379,35 @@ public class ExpoIapModule: Module {
350
379
  return nil
351
380
  } else {
352
381
  self.transactions[String(transaction.id)] = transaction
353
- self.sendEvent(IapEvent.PurchaseUpdated, serializeTransaction(transaction))
354
- return serializeTransaction(transaction)
382
+ let serialized = serializeTransaction(transaction)
383
+ self.sendEvent(IapEvent.PurchaseUpdated, serialized)
384
+ return serialized
355
385
  }
356
-
357
386
  case .userCancelled:
358
- throw NSError(domain: "ExpoIapModule", code: 3, userInfo: [NSLocalizedDescriptionKey: "User cancelled the purchase"])
359
-
387
+ throw NSError(
388
+ domain: "ExpoIapModule", code: 3,
389
+ userInfo: [NSLocalizedDescriptionKey: "User cancelled the purchase"])
360
390
  case .pending:
361
- throw NSError(domain: "ExpoIapModule", code: 4, userInfo: [NSLocalizedDescriptionKey: "The payment was deferred"])
391
+ throw NSError(
392
+ domain: "ExpoIapModule", code: 4,
393
+ userInfo: [NSLocalizedDescriptionKey: "The payment was deferred"])
362
394
  @unknown default:
363
- throw NSError(domain: "ExpoIapModule", code: 5, userInfo: [NSLocalizedDescriptionKey: "Unknown purchase result"])
395
+ throw NSError(
396
+ domain: "ExpoIapModule", code: 5,
397
+ userInfo: [NSLocalizedDescriptionKey: "Unknown purchase result"])
364
398
  }
365
399
  } catch {
366
- throw NSError(domain: "ExpoIapModule", code: 6, userInfo: [NSLocalizedDescriptionKey: "Purchase failed: \(error.localizedDescription)"])
400
+ throw NSError(
401
+ domain: "ExpoIapModule", code: 6,
402
+ userInfo: [
403
+ NSLocalizedDescriptionKey:
404
+ "Purchase failed: \(error.localizedDescription)"
405
+ ])
367
406
  }
368
407
  } else {
369
- throw NSError(domain: "ExpoIapModule", code: 7, userInfo: [NSLocalizedDescriptionKey: "Invalid product ID"])
408
+ throw NSError(
409
+ domain: "ExpoIapModule", code: 7,
410
+ userInfo: [NSLocalizedDescriptionKey: "Invalid product ID"])
370
411
  }
371
412
  }
372
413
 
@@ -376,24 +417,34 @@ public class ExpoIapModule: Module {
376
417
 
377
418
  AsyncFunction("subscriptionStatus") { (sku: String) -> [[String: Any?]?]? in
378
419
  guard let productStore = self.productStore else {
379
- throw NSError(domain: "ExpoIapModule", code: 1, userInfo: [NSLocalizedDescriptionKey: "Connection not initialized"])
420
+ throw NSError(
421
+ domain: "ExpoIapModule", code: 1,
422
+ userInfo: [NSLocalizedDescriptionKey: "Connection not initialized"])
380
423
  }
381
424
 
382
425
  do {
383
426
  let product = await productStore.getProduct(productID: sku)
384
- let status: [Product.SubscriptionInfo.Status]? = try await product?.subscription?.status
427
+ let status: [Product.SubscriptionInfo.Status]? = try await product?.subscription?
428
+ .status
385
429
  guard let status = status else {
386
430
  return nil
387
431
  }
388
432
  return status.map { serializeSubscriptionStatus($0) }
389
433
  } catch {
390
- throw NSError(domain: "ExpoIapModule", code: 2, userInfo: [NSLocalizedDescriptionKey: "Error getting subscription status: \(error.localizedDescription)"])
434
+ throw NSError(
435
+ domain: "ExpoIapModule", code: 2,
436
+ userInfo: [
437
+ NSLocalizedDescriptionKey:
438
+ "Error getting subscription status: \(error.localizedDescription)"
439
+ ])
391
440
  }
392
441
  }
393
442
 
394
443
  AsyncFunction("currentEntitlement") { (sku: String) -> [String: Any?]? in
395
444
  guard let productStore = self.productStore else {
396
- throw NSError(domain: "ExpoIapModule", code: 1, userInfo: [NSLocalizedDescriptionKey: "Connection not initialized"])
445
+ throw NSError(
446
+ domain: "ExpoIapModule", code: 1,
447
+ userInfo: [NSLocalizedDescriptionKey: "Connection not initialized"])
397
448
  }
398
449
 
399
450
  if let product = await productStore.getProduct(productID: sku) {
@@ -402,21 +453,39 @@ public class ExpoIapModule: Module {
402
453
  let transaction = try self.checkVerified(result)
403
454
  return serializeTransaction(transaction)
404
455
  } catch StoreError.failedVerification {
405
- throw NSError(domain: "ExpoIapModule", code: 2, userInfo: [NSLocalizedDescriptionKey: "Failed to verify transaction for sku \(sku)"])
456
+ throw NSError(
457
+ domain: "ExpoIapModule", code: 2,
458
+ userInfo: [
459
+ NSLocalizedDescriptionKey:
460
+ "Failed to verify transaction for sku \(sku)"
461
+ ])
406
462
  } catch {
407
- throw NSError(domain: "ExpoIapModule", code: 3, userInfo: [NSLocalizedDescriptionKey: "Error fetching entitlement for sku \(sku): \(error.localizedDescription)"])
463
+ throw NSError(
464
+ domain: "ExpoIapModule", code: 3,
465
+ userInfo: [
466
+ NSLocalizedDescriptionKey:
467
+ "Error fetching entitlement for sku \(sku): \(error.localizedDescription)"
468
+ ])
408
469
  }
409
470
  } else {
410
- throw NSError(domain: "ExpoIapModule", code: 4, userInfo: [NSLocalizedDescriptionKey: "Can't find entitlement for sku \(sku)"])
471
+ throw NSError(
472
+ domain: "ExpoIapModule", code: 4,
473
+ userInfo: [
474
+ NSLocalizedDescriptionKey: "Can't find entitlement for sku \(sku)"
475
+ ])
411
476
  }
412
477
  } else {
413
- throw NSError(domain: "ExpoIapModule", code: 5, userInfo: [NSLocalizedDescriptionKey: "Can't find product for sku \(sku)"])
478
+ throw NSError(
479
+ domain: "ExpoIapModule", code: 5,
480
+ userInfo: [NSLocalizedDescriptionKey: "Can't find product for sku \(sku)"])
414
481
  }
415
482
  }
416
483
 
417
484
  AsyncFunction("latestTransaction") { (sku: String) -> [String: Any?]? in
418
485
  guard let productStore = self.productStore else {
419
- throw NSError(domain: "ExpoIapModule", code: 1, userInfo: [NSLocalizedDescriptionKey: "Connection not initialized"])
486
+ throw NSError(
487
+ domain: "ExpoIapModule", code: 1,
488
+ userInfo: [NSLocalizedDescriptionKey: "Connection not initialized"])
420
489
  }
421
490
 
422
491
  if let product = await productStore.getProduct(productID: sku) {
@@ -425,15 +494,32 @@ public class ExpoIapModule: Module {
425
494
  let transaction = try self.checkVerified(result)
426
495
  return serializeTransaction(transaction)
427
496
  } catch StoreError.failedVerification {
428
- throw NSError(domain: "ExpoIapModule", code: 2, userInfo: [NSLocalizedDescriptionKey: "Failed to verify transaction for sku \(sku)"])
497
+ throw NSError(
498
+ domain: "ExpoIapModule", code: 2,
499
+ userInfo: [
500
+ NSLocalizedDescriptionKey:
501
+ "Failed to verify transaction for sku \(sku)"
502
+ ])
429
503
  } catch {
430
- throw NSError(domain: "ExpoIapModule", code: 3, userInfo: [NSLocalizedDescriptionKey: "Error fetching latest transaction for sku \(sku): \(error.localizedDescription)"])
504
+ throw NSError(
505
+ domain: "ExpoIapModule", code: 3,
506
+ userInfo: [
507
+ NSLocalizedDescriptionKey:
508
+ "Error fetching latest transaction for sku \(sku): \(error.localizedDescription)"
509
+ ])
431
510
  }
432
511
  } else {
433
- throw NSError(domain: "ExpoIapModule", code: 4, userInfo: [NSLocalizedDescriptionKey: "Can't find latest transaction for sku \(sku)"])
512
+ throw NSError(
513
+ domain: "ExpoIapModule", code: 4,
514
+ userInfo: [
515
+ NSLocalizedDescriptionKey:
516
+ "Can't find latest transaction for sku \(sku)"
517
+ ])
434
518
  }
435
519
  } else {
436
- throw NSError(domain: "ExpoIapModule", code: 5, userInfo: [NSLocalizedDescriptionKey: "Can't find product for sku \(sku)"])
520
+ throw NSError(
521
+ domain: "ExpoIapModule", code: 5,
522
+ userInfo: [NSLocalizedDescriptionKey: "Can't find product for sku \(sku)"])
437
523
  }
438
524
  }
439
525
 
@@ -443,7 +529,9 @@ public class ExpoIapModule: Module {
443
529
  self.transactions.removeValue(forKey: transactionIdentifier)
444
530
  return true
445
531
  } else {
446
- throw NSError(domain: "ExpoIapModule", code: 8, userInfo: [NSLocalizedDescriptionKey: "Invalid transaction ID"])
532
+ throw NSError(
533
+ domain: "ExpoIapModule", code: 8,
534
+ userInfo: [NSLocalizedDescriptionKey: "Invalid transaction ID"])
447
535
  }
448
536
  }
449
537
 
@@ -456,28 +544,42 @@ public class ExpoIapModule: Module {
456
544
  try await AppStore.sync()
457
545
  return true
458
546
  } catch {
459
- throw NSError(domain: "ExpoIapModule", code: 9, userInfo: [NSLocalizedDescriptionKey: "Error synchronizing with the AppStore: \(error.localizedDescription)"])
547
+ throw NSError(
548
+ domain: "ExpoIapModule", code: 9,
549
+ userInfo: [
550
+ NSLocalizedDescriptionKey:
551
+ "Error synchronizing with the AppStore: \(error.localizedDescription)"
552
+ ])
460
553
  }
461
554
  }
462
555
 
463
556
  AsyncFunction("presentCodeRedemptionSheet") { () -> Bool in
464
557
  #if !os(tvOS)
465
- SKPaymentQueue.default().presentCodeRedemptionSheet()
466
- return true
558
+ SKPaymentQueue.default().presentCodeRedemptionSheet()
559
+ return true
467
560
  #else
468
- throw NSError(domain: "ExpoIapModule", code: 10, userInfo: [NSLocalizedDescriptionKey: "This method is not available on tvOS"])
561
+ throw NSError(
562
+ domain: "ExpoIapModule", code: 10,
563
+ userInfo: [NSLocalizedDescriptionKey: "This method is not available on tvOS"])
469
564
  #endif
470
565
  }
471
566
 
472
567
  AsyncFunction("showManageSubscriptions") { () -> Bool in
473
568
  #if !os(tvOS)
474
- guard let windowScene = await self.currentWindowScene() else {
475
- throw NSError(domain: "ExpoIapModule", code: 11, userInfo: [NSLocalizedDescriptionKey: "Cannot find window scene or not available on macOS"])
476
- }
477
- try await AppStore.showManageSubscriptions(in: windowScene)
478
- return true
569
+ guard let windowScene = await self.currentWindowScene() else {
570
+ throw NSError(
571
+ domain: "ExpoIapModule", code: 11,
572
+ userInfo: [
573
+ NSLocalizedDescriptionKey:
574
+ "Cannot find window scene or not available on macOS"
575
+ ])
576
+ }
577
+ try await AppStore.showManageSubscriptions(in: windowScene)
578
+ return true
479
579
  #else
480
- throw NSError(domain: "ExpoIapModule", code: 12, userInfo: [NSLocalizedDescriptionKey: "This method is not available on tvOS"])
580
+ throw NSError(
581
+ domain: "ExpoIapModule", code: 12,
582
+ userInfo: [NSLocalizedDescriptionKey: "This method is not available on tvOS"])
481
583
  #endif
482
584
  }
483
585
 
@@ -497,25 +599,47 @@ public class ExpoIapModule: Module {
497
599
 
498
600
  AsyncFunction("beginRefundRequest") { (sku: String) -> String? in
499
601
  #if !os(tvOS)
500
- guard let product = await self.productStore?.getProduct(productID: sku),
501
- let result = await product.latestTransaction else {
502
- throw NSError(domain: "ExpoIapModule", code: 5, userInfo: [NSLocalizedDescriptionKey: "Can't find product or transaction for sku \(sku)"])
503
- }
602
+ guard let product = await self.productStore?.getProduct(productID: sku),
603
+ let result = await product.latestTransaction
604
+ else {
605
+ throw NSError(
606
+ domain: "ExpoIapModule", code: 5,
607
+ userInfo: [
608
+ NSLocalizedDescriptionKey:
609
+ "Can't find product or transaction for sku \(sku)"
610
+ ])
611
+ }
504
612
 
505
- do {
506
- let transaction = try self.checkVerified(result)
507
- guard let windowScene = await self.currentWindowScene() else {
508
- throw NSError(domain: "ExpoIapModule", code: 11, userInfo: [NSLocalizedDescriptionKey: "Cannot find window scene or not available on macOS"])
613
+ do {
614
+ let transaction = try self.checkVerified(result)
615
+ guard let windowScene = await self.currentWindowScene() else {
616
+ throw NSError(
617
+ domain: "ExpoIapModule", code: 11,
618
+ userInfo: [
619
+ NSLocalizedDescriptionKey:
620
+ "Cannot find window scene or not available on macOS"
621
+ ])
622
+ }
623
+ let refundStatus = try await transaction.beginRefundRequest(in: windowScene)
624
+ return serialize(refundStatus)
625
+ } catch StoreError.failedVerification {
626
+ throw NSError(
627
+ domain: "ExpoIapModule", code: 2,
628
+ userInfo: [
629
+ NSLocalizedDescriptionKey: "Failed to verify transaction for sku \(sku)"
630
+ ])
631
+ } catch {
632
+ throw NSError(
633
+ domain: "ExpoIapModule", code: 3,
634
+ userInfo: [
635
+ NSLocalizedDescriptionKey:
636
+ "Failed to refund purchase: \(error.localizedDescription)"
637
+ ])
509
638
  }
510
- let refundStatus = try await transaction.beginRefundRequest(in: windowScene)
511
- return serialize(refundStatus)
512
- } catch StoreError.failedVerification {
513
- throw NSError(domain: "ExpoIapModule", code: 2, userInfo: [NSLocalizedDescriptionKey: "Failed to verify transaction for sku \(sku)"])
514
- } catch {
515
- throw NSError(domain: "ExpoIapModule", code: 3, userInfo: [NSLocalizedDescriptionKey: "Failed to refund purchase: \(error.localizedDescription)"])
516
- }
517
639
  #else
518
- throw NSError(domain: "ExpoIapModule", code: 12, userInfo: [NSLocalizedDescriptionKey: "This method is not available on tvOS"])
640
+ throw NSError(
641
+ domain: "ExpoIapModule", code: 12,
642
+ userInfo: [NSLocalizedDescriptionKey: "This method is not available on tvOS"])
519
643
  #endif
520
644
  }
521
645
 
@@ -544,8 +668,9 @@ public class ExpoIapModule: Module {
544
668
  let transaction = try self.checkVerified(result)
545
669
  self.transactions[String(transaction.id)] = transaction
546
670
  if self.hasListeners {
547
- self.sendEvent(IapEvent.PurchaseUpdated, serializeTransaction(transaction))
548
- self.sendEvent(IapEvent.TransactionIapUpdated, ["transaction": serializeTransaction(transaction)])
671
+ let serialized = serializeTransaction(transaction)
672
+ self.sendEvent(IapEvent.PurchaseUpdated, serialized)
673
+ self.sendEvent(IapEvent.TransactionIapUpdated, ["transaction": serialized])
549
674
  }
550
675
  } catch {
551
676
  if self.hasListeners {
@@ -553,7 +678,7 @@ public class ExpoIapModule: Module {
553
678
  "responseCode": IapErrors.E_TRANSACTION_VALIDATION_FAILED.rawValue,
554
679
  "debugMessage": error.localizedDescription,
555
680
  "code": IapErrors.E_TRANSACTION_VALIDATION_FAILED.rawValue,
556
- "message": error.localizedDescription
681
+ "message": error.localizedDescription,
557
682
  ]
558
683
  self.sendEvent(IapEvent.PurchaseError, err)
559
684
  self.sendEvent(IapEvent.TransactionIapUpdated, ["error": err])
@@ -583,7 +708,6 @@ public class ExpoIapModule: Module {
583
708
  switch result {
584
709
  case .unverified(_, let error):
585
710
  throw error
586
-
587
711
  case .verified(let item):
588
712
  return item
589
713
  }
package/ios/Types.swift CHANGED
@@ -14,6 +14,7 @@ public enum StoreError: Error {
14
14
 
15
15
  enum IapErrors: String, CaseIterable {
16
16
  case E_UNKNOWN = "E_UNKNOWN"
17
+ case E_NOT_INITIALIZED = "E_NOT_INITIALIZED"
17
18
  case E_SERVICE_ERROR = "E_SERVICE_ERROR"
18
19
  case E_USER_CANCELLED = "E_USER_CANCELLED"
19
20
  case E_USER_ERROR = "E_USER_ERROR"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "expo-iap",
3
- "version": "2.2.3",
3
+ "version": "2.2.4-rc.2",
4
4
  "description": "In App Purchase module in Expo",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",
@@ -46,7 +46,6 @@ export type PurchaseBase = {
46
46
  transactionId?: string;
47
47
  transactionDate: number;
48
48
  transactionReceipt: string;
49
- purchaseToken?: string;
50
49
  };
51
50
 
52
51
  // Union type for platform-specific product types with proper discriminators
@@ -83,7 +82,7 @@ export type PurchaseResult = {
83
82
  debugMessage?: string;
84
83
  code?: string;
85
84
  message?: string;
86
- purchaseToken?: string;
85
+ purchaseTokenAndroid?: string;
87
86
  };
88
87
 
89
88
  export enum ErrorCode {
package/src/index.ts CHANGED
@@ -323,15 +323,21 @@ export const finishTransaction = ({
323
323
  return Promise.resolve(true);
324
324
  },
325
325
  android: async () => {
326
- if (!purchase?.purchaseToken) {
326
+ // Check if the purchase is from Android by checking the platform property
327
+ if (
328
+ purchase.platform !== 'android' ||
329
+ !('purchaseTokenAndroid' in purchase)
330
+ ) {
327
331
  return Promise.reject(
328
- new Error('purchaseToken is required to finish transaction'),
332
+ new Error('purchaseTokenAndroid is required to finish transaction'),
329
333
  );
330
334
  }
331
335
  if (isConsumable) {
332
- return ExpoIapModule.consumeProduct(purchase.purchaseToken);
336
+ return ExpoIapModule.consumeProduct(purchase.purchaseTokenAndroid);
333
337
  } else {
334
- return ExpoIapModule.acknowledgePurchase(purchase.purchaseToken);
338
+ return ExpoIapModule.acknowledgePurchase(
339
+ purchase.purchaseTokenAndroid,
340
+ );
335
341
  }
336
342
  },
337
343
  }) || (() => Promise.reject(new Error('Unsupported Platform')))
@@ -115,6 +115,7 @@ export enum PurchaseStateAndroid {
115
115
 
116
116
  export type ProductPurchaseAndroid = PurchaseBase & {
117
117
  ids?: string[];
118
+ purchaseTokenAndroid?: string;
118
119
  dataAndroid?: string;
119
120
  signatureAndroid?: string;
120
121
  autoRenewingAndroid?: boolean;