expo-iap 3.2.1 → 3.2.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.
package/src/index.ts CHANGED
@@ -808,6 +808,33 @@ export const verifyPurchaseWithProvider: MutationField<
808
808
  'verifyPurchaseWithProvider'
809
809
  > = async (options) => {
810
810
  if (Platform.OS === 'ios' || Platform.OS === 'android') {
811
+ // Auto-fill apiKey from config if not provided and provider is iapkit
812
+ if (
813
+ options.provider === 'iapkit' &&
814
+ options.iapkit &&
815
+ !options.iapkit.apiKey
816
+ ) {
817
+ try {
818
+ // Dynamically import expo-constants to avoid hard dependency
819
+ const {default: Constants} = await import('expo-constants');
820
+ const configApiKey = Constants.expoConfig?.extra?.iapkitApiKey;
821
+ if (configApiKey) {
822
+ options = {
823
+ ...options,
824
+ iapkit: {
825
+ ...options.iapkit,
826
+ apiKey: configApiKey,
827
+ },
828
+ };
829
+ }
830
+ } catch {
831
+ throw new Error(
832
+ 'expo-constants is required for auto-filling iapkitApiKey from config. ' +
833
+ 'Please install it: npx expo install expo-constants\n' +
834
+ 'Or provide apiKey directly in verifyPurchaseWithProvider options.',
835
+ );
836
+ }
837
+ }
811
838
  return ExpoIapModule.verifyPurchaseWithProvider(options);
812
839
  }
813
840