Skip to content

iyzico/iyzipay-node

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

44 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

iyzipay-node

Build Status NPM version

You can sign up for an iyzico account at https://iyzico.com

Installation

npm install iyzipay

Usage

Initialization

var Iyzipay = require('iyzipay');

var iyzipay = new Iyzipay({
    apiKey: 'your api key',
    secretKey: 'your secret key',
    uri: 'https://stg.iyzipay.com'
});

As you can see, credentials information provided while creating new instance of Iyzipay class. If you do not provide iyzipay credentials, default values will be fetched from environment variables by following names.

   IYZIPAY_URI
   IYZIPAY_API_KEY
   IYZIPAY_SECRET_KEY

In other words, you can initialize Iyzipay object like following:

var iyzipay = new Iyzipay();

Sample Usage

var Iyzipay = require('iyzipay');

var iyzipay = new Iyzipay({
    apiKey: 'your api key',
    secretKey: 'your secret key',
    uri: 'https://stg.iyzipay.com'
});

var paymentAuth = {
    locale: Iyzipay.LOCALE.TR,
    conversationId: '123456789',
    price: '1.0',
    paidPrice: '1.1',
    installment: 1,
    paymentChannel: Iyzipay.PAYMENT_CHANNEL.WEB,
    basketId: 'B67832',
    paymentGroup: Iyzipay.PAYMENT_GROUP.PRODUCT,
    paymentCard: {
        cardHolderName: 'John Doe',
        cardNumber: '5528790000000008',
        expireYear: '2030',
        expireMonth: '12',
        cvc: '123',
        registerCard: 0
    },
    buyer: {
        id: 'BY789',
        name: 'John',
        surname: 'Doe',
        identityNumber: '74300864791',
        email: '[email protected]',
        gsmNumber: '+905350000000',
        registrationDate: '2013-04-21 15:12:09',
        lastLoginDate: '2015-10-05 12:43:35',
        registrationAddress: 'Address',
        city: 'Istanbul',
        country: 'Turkey',
        zipCode: '34732',
        ip: '85.34.78.112'
    },
    shippingAddress: {
        address: 'Address',
        zipCode: '34742',
        contactName: 'Jane Doe',
        city: 'Istanbul',
        country: 'Turkey'
    },
    billingAddress: {
        address: 'Address',
        zipCode: '34742',
        contactName: 'Jane Doe',
        city: 'Istanbul',
        country: 'Turkey'
    },
    basketItems: [
        {
            id: 'BI101',
            price: '0.3',
            name: 'Binocular',
            category1: 'Collectibles',
            category2: 'Accessories',
            itemType: Iyzipay.BASKET_ITEM_TYPE.PHYSICAL
        },
        {
            id: 'BI102',
            price: '0.5',
            name: 'Game code',
            category1: 'Game',
            category2: 'Online Game Items',
            itemType: Iyzipay.BASKET_ITEM_TYPE.VIRTUAL
        },
        {
            id: 'BI103',
            price: '0.2',
            name: 'Usb',
            category1: 'Electronics',
            category2: 'Usb / Cable',
            itemType: Iyzipay.BASKET_ITEM_TYPE.PHYSICAL
        }
    ]
};

iyzipay.paymentAuth.create(paymentAuth, function (err, result) {
    console.log(err, result);
    done();
});

You can see further examples in test/samples folder, and run them by npm run-script samples

Testing

You need to have mocha installed on your machine in order to run tests.

npm test

Available Resources and Methods

Author

Originally by Huseyin Babal ([email protected]). Now officially maintained by iyzico.