npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

samsung-iap

v1.0.0

Published

A package to integrate Samsung in-app purchases in your application

Readme

samsung-iap

A package to integrate Samsung in-app purchases in your application.

Installation

npm install samsung-iap

SDK Setup

This package is a TypeScript wrapper around the Samsung IAP SDK. The actual Samsung IAP SDK aar file must be provided by your application.

Setting Up the Samsung IAP SDK

  1. Download the Samsung IAP SDK AAR file from the Samsung Developers website

  2. In your application's Android project:

    • Create a libs directory in your app's root directory if it doesn't exist
    • Place the Samsung IAP SDK AAR file in the libs directory
    • The file structure should look like this:
      your-app/
      ├── android/
      │   ├── libs/
      │   │   └── samsung-iap-6.4.0.aar  // Your SDK file
      │   └── build.gradle
      └── ...
  3. Add the following to your app's build.gradle:

    repositories {
        flatDir {
            dirs 'libs'
        }
    }
    
    dependencies {
        implementation(name: 'samsung-iap-6.4.0', ext: 'aar')  // Replace with your actual aar file name
    }
  4. Sync your project with Gradle files:

    • In Android Studio: Click "Sync Project with Gradle Files"
    • Or run: ./gradlew clean build

Verification

To verify that the SDK is properly integrated:

  1. Check the build output for any errors
  2. Try to import the SDK classes in your Java/Kotlin code:
    import com.samsung.android.sdk.iap.lib.helper.IapHelper;
    If there are no import errors, the SDK is properly integrated.

Expo Setup

Development Build

To use this package in an Expo project, you need to create a development build:

  1. Install EAS CLI:
npm install -g eas-cli
  1. Configure your project for development builds:
eas build:configure
  1. Add the following to your app.json:
{
  "expo": {
    "plugins": [
      [
        "expo-build-properties",
        {
          "android": {
            "compileSdkVersion": 33,
            "targetSdkVersion": 33,
            "buildToolsVersion": "33.0.0"
          }
        }
      ]
    ]
  }
}
  1. Install the required dependencies:
npx expo install expo-build-properties
  1. Create a development build:
eas build --profile development --platform android

Config Plugin

Add the following to your app.json to configure the Samsung IAP SDK:

{
  "expo": {
    "plugins": [
      [
        "samsung-iap",
        {
          "sdkVersion": "6.0.0"  // Specify your Samsung IAP SDK version
        }
      ]
    ]
  }
}

Native Module Setup

  1. Create a plugins directory in your project root
  2. Create samsung-iap.js in the plugins directory:
const { withPlugins } = require('@expo/config-plugins');

const withSamsungIap = (config) => {
  return withPlugins(config, [
    // Add any additional plugins if needed
  ]);
};

module.exports = withSamsungIap;
  1. Update your app.config.js:
const { withPlugins } = require('@expo/config-plugins');
const withSamsungIap = require('./plugins/samsung-iap');

module.exports = ({ config }) => {
  return withPlugins(config, [
    withSamsungIap,
    // Add other plugins as needed
  ]);
};

Usage in Expo

import SamsungIap from 'samsung-iap';
import { Platform } from 'react-native';

// Check if running on a Samsung device
const isSamsungDevice = Platform.OS === 'android' && 
  Platform.constants.Manufacturer.toLowerCase().includes('samsung');

// Initialize Samsung IAP
const initSamsungIap = async () => {
  if (!isSamsungDevice) {
    console.log('Not a Samsung device, Samsung IAP will not work');
    return;
  }

  try {
    // Set operation mode (0 for test, 1 for production)
    await SamsungIap.setOperationMode(0);
    console.log('Samsung IAP initialized successfully');
  } catch (error) {
    console.error('Failed to initialize Samsung IAP:', error);
  }
};

// Purchase an item
const purchaseItem = async (itemId) => {
  if (!isSamsungDevice) {
    throw new Error('Samsung IAP is only available on Samsung devices');
  }

  try {
    const result = await SamsungIap.startPayment(itemId);
    console.log('Purchase successful:', result);
    return result;
  } catch (error) {
    console.error('Purchase failed:', error);
    throw error;
  }
};

// Get product details
const getProducts = async (itemIds) => {
  if (!isSamsungDevice) {
    throw new Error('Samsung IAP is only available on Samsung devices');
  }

  try {
    const products = await SamsungIap.getProductsDetails(itemIds);
    console.log('Products:', products);
    return products;
  } catch (error) {
    console.error('Failed to get products:', error);
    throw error;
  }
};

// Example usage in a component
const MyComponent = () => {
  useEffect(() => {
    initSamsungIap();
  }, []);

  const handlePurchase = async () => {
    try {
      const result = await purchaseItem('your_item_id');
      // Handle successful purchase
    } catch (error) {
      // Handle purchase error
    }
  };

  return (
    <View>
      <Button title="Purchase Item" onPress={handlePurchase} />
    </View>
  );
};

Error Handling

The package provides specific error codes for different scenarios:

const handleError = (error) => {
  switch (error.code) {
    case 'SET_OPERATION_MODE_ERROR':
      console.error('Failed to set operation mode');
      break;
    case 'PAYMENT_ERROR':
      console.error('Payment failed:', error.message);
      break;
    case 'GET_PRODUCTS_ERROR':
      console.error('Failed to get products:', error.message);
      break;
    case 'GET_OWNED_LIST_ERROR':
      console.error('Failed to get owned items:', error.message);
      break;
    case 'CONSUME_ITEMS_ERROR':
      console.error('Failed to consume items:', error.message);
      break;
    case 'ACKNOWLEDGE_PURCHASES_ERROR':
      console.error('Failed to acknowledge purchases:', error.message);
      break;
    case 'CHANGE_SUBSCRIPTION_PLAN_ERROR':
      console.error('Failed to change subscription plan:', error.message);
      break;
    case 'GET_PROMOTION_ELIGIBILITY_ERROR':
      console.error('Failed to get promotion eligibility:', error.message);
      break;
    default:
      console.error('Unknown error:', error);
  }
};

Testing

For testing purposes, you can use the test mode:

// Set test mode
await SamsungIap.setOperationMode(0);  // 0 for test mode

// Test purchase flow
try {
  const result = await SamsungIap.startPayment('test_item_id');
  console.log('Test purchase successful:', result);
} catch (error) {
  console.error('Test purchase failed:', error);
}

Troubleshooting

  1. SDK not found error

    • Make sure the Samsung IAP SDK aar file is in the correct location
    • Check that the build.gradle file is properly configured
  2. Device compatibility

    • Samsung IAP only works on Samsung devices
    • Check device compatibility before making API calls
  3. Network issues

    • Ensure the device has a stable internet connection
    • Check if the Samsung account is properly logged in
  4. Test mode issues

    • Make sure you're using the correct test item IDs
    • Verify that the test mode is properly set

License

MIT