Install & Compatibility
Where this runs
No compatibility data collected yet for this library.
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
Iamporter
✓ const { Iamporter } = require('iamporter');
✗ import Iamporter from 'iamporter';
CommonJS only; no default export exists.
IamporterError
✓ const { IamporterError } = require('iamporter');
✗ const IamporterError = require('iamporter');
Destructure from the package; it's a named export.
new Iamporter()
✓ const iamporter = new Iamporter({ apiKey: '...', secret: '...' });
✗ const iamporter = new Iamporter('...', '...');
Constructor expects an object, not positional arguments.
Shows how to instantiate Iamporter, create a billing key, and make a subscription payment.
const { Iamporter } = require('iamporter');
const iamporter = new Iamporter({
apiKey: process.env.IAMPORT_API_KEY ?? '',
secret: process.env.IAMPORT_SECRET ?? ''
});
// Create a billing key (subscription)
iamporter.createSubscription({
customer_uid: 'test_customer',
card_number: '1234-1234-1234-1234',
expiry: '2029-12',
birth: '900101',
pwd_2digit: '12'
}).then(result => {
console.log('Billing key created:', result.data);
}).catch(err => {
if (err instanceof IamporterError) {
console.error('Iamporter error:', err.message);
}
});
// Pay with billing key
iamporter.paySubscription({
customer_uid: 'test_customer',
merchant_uid: 'order_123',
amount: 15000
}).then(result => {
console.log('Payment success:', result.data);
}).catch(err => console.error(err));
Errors
Common errors & fixes
TypeError: Iamporter is not a constructor
Incorrect import (default import instead of destructured named export).
fixUse const { Iamporter } = require('iamporter'); Error: getaddrinfo ENOTFOUND api.iamport.kr
Network issue or incorrect API endpoint.
fixCheck internet connectivity and verify the I'mport service status.
IamporterError: {code: -1, message: '인증실패'}
Invalid API key or secret.
fixVerify your IAMPORT_API_KEY and IAMPORT_SECRET environment variables.
Audit
Dependencies
requestrequiredHTTP client for REST API calls