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.
Iyzipay
✓ const Iyzipay = require('iyzipay');
✗ import Iyzipay from 'iyzipay';
This package is CommonJS only; ES module import will fail.
Iyzipay (instance)
✓ const iyzipay = new Iyzipay({ apiKey: '...', secretKey: '...', uri: 'https://sandbox-api.iyzipay.com' });
✗ new Iyzipay(); // without env vars, credentials will be undefined
If no options are passed, defaults are read from environment variables IYZIPAY_API_KEY, IYZIPAY_SECRET_KEY, IYZIPAY_URI.
Iyzipay.LOCALE.TR
✓ locale: Iyzipay.LOCALE.TR
✗ locale: 'TR'
Use the constants from the Iyzipay constructor; raw strings may not be accepted by all API versions.
Initializes the client with environment variables and creates a payment request using test card information.
const Iyzipay = require('iyzipay');
const iyzipay = new Iyzipay({
apiKey: process.env.IYZIPAY_API_KEY ?? 'your api key',
secretKey: process.env.IYZIPAY_SECRET_KEY ?? 'your secret key',
uri: process.env.IYZIPAY_URI ?? 'https://sandbox-api.iyzipay.com'
});
const request = {
locale: Iyzipay.LOCALE.TR,
conversationId: '123456789',
price: '1',
paidPrice: '1.2',
currency: Iyzipay.CURRENCY.TRY,
installment: '1',
basketId: 'B67832',
paymentChannel: Iyzipay.PAYMENT_CHANNEL.WEB,
paymentGroup: Iyzipay.PAYMENT_GROUP.PRODUCT,
paymentCard: {
cardHolderName: 'John Doe',
cardNumber: '5528790000000008',
expireMonth: '12',
expireYear: '2030',
cvc: '123',
registerCard: '0'
},
buyer: {
id: 'BY789',
name: 'John',
surname: 'Doe',
gsmNumber: '+905350000000',
email: 'email@email.com',
identityNumber: '74300864791',
lastLoginDate: '2015-10-05 12:43:35',
registrationDate: '2013-04-21 15:12:09',
registrationAddress: 'Nidakule Göztepe, Merdivenköy Mah. Bora Sok. No:1',
ip: '85.34.78.112',
city: 'Istanbul',
country: 'Turkey',
zipCode: '34732'
},
shippingAddress: {
contactName: 'Jane Doe',
city: 'Istanbul',
country: 'Turkey',
address: 'Nidakule Göztepe, Merdivenköy Mah. Bora Sok. No:1',
zipCode: '34742'
},
billingAddress: {
contactName: 'Jane Doe',
city: 'Istanbul',
country: 'Turkey',
address: 'Nidakule Göztepe, Merdivenköy Mah. Bora Sok. No:1',
zipCode: '34742'
},
basketItems: [
{ id: 'BI101', name: 'Binocular', category1: 'Collectibles', category2: 'Accessories', itemType: Iyzipay.BASKET_ITEM_TYPE.PHYSICAL, price: '0.3' },
{ id: 'BI102', name: 'Game code', category1: 'Game', category2: 'Online Game Items', itemType: Iyzipay.BASKET_ITEM_TYPE.VIRTUAL, price: '0.5' },
{ id: 'BI103', name: 'Usb', category1: 'Electronics', category2: 'Usb / Cable', itemType: Iyzipay.BASKET_ITEM_TYPE.PHYSICAL, price: '0.2' }
]
};
iyzipay.payment.create(request, function (err, result) {
if (err) console.error(err);
else console.log(result);
});
Errors
Common errors & fixes
Error: Cannot find module 'iyzipay'
Package not installed or require path wrong.
fixRun 'npm install iyzipay' and ensure no type in the require statement.
TypeError: iyzipay.payment.create is not a function
Forgot to call 'new Iyzipay()' before using the instance.
fixCorrect initialization: const iyzipay = new Iyzipay({...}); Error: Unauthorized. Check your API key and secret key.
Credentials are invalid or missing.
fixDouble-check apiKey and secretKey in constructor or environment variables.
RequestError: getaddrinfo ENOTFOUND sandbox-api.iyzipay.com
Invalid URI or network issue.
fixEnsure uri exactly is 'https://sandbox-api.iyzipay.com' or correct production URL.
Audit
Dependencies
mochaoptionalUsed for running tests; dev dependency but required to run sample/test scripts.