iyzico / iyzipay-node

iyzipay api node.js client
MIT License
199 stars 60 forks source link

Alternative TypeScript SDK #129

Open codingwithmanny opened 2 months ago

codingwithmanny commented 2 months ago

TR: Yardım etmek isteyen varsa şu anda NextJS ve ReactNative gibi ortamlar ve çerçevelerle yerel olarak çalışacak alternatif bir TypeScript Iyzico SDK üzerinde çalışıyorum. Şu anda devam eden bir çalışmadır, ancak burada bulabilirsiniz.

EN: If anyone is interested in helping, I'm currently working on an alternative TypeScript Iyzico SDK to work natively with environments and frameworks like NextJS and ReactNative. It is currently a work in progress, but you can find it here.

https://github.com/codingwithmanny/iyzipay-js

codingwithmanny commented 2 months ago

The package is published here, but it's still a work in progress:

https://www.npmjs.com/package/@codingwithmanny/iyzipay-js

You can also see how it works currently with NextJS App Router API Router.

Example:

File: ./app/api/test/route.ts

// Imports
import Iyzipay from "@codingwithmanny/iyzipay-js";

// Config
const client = Iyzipay({
  apiKey: `${process.env.IYZICO_API_KEY}`,
  secretKey: `${process.env.IYZICO_SECRET_KEY}`,
});

// Route
export async function GET(_request: Request) {
  const response = await client.payment.checkoutForm.create({
    locale: 'tr',
    conversationId: '023456789',
    price: '1.0',
    basketId: 'B67832',
    paymentGroup: 'PRODUCT',
    buyer: {
      id: 'BY789',
      name: 'John',
      surname: 'Doe',
      identityNumber: '74300864791',
      email: 'email@email.com',
      gsmNumber: '+905350000000',
      registrationDate: '2013-04-21 15:12:09',
      lastLoginDate: '2015-10-05 12:43:35',
      registrationAddress: 'Nidakule Göztepe, Merdivenköy Mah. Bora Sok. No:1',
      city: 'Istanbul',
      country: 'Turkey',
      zipCode: '34732',
      ip: '85.34.78.112'
    },
    shippingAddress: {
      address: 'Nidakule Göztepe, Merdivenköy Mah. Bora Sok. No:1',
      zipCode: '34742',
      contactName: 'Jane Doe',
      city: 'Istanbul',
      country: 'Turkey'
    },
    billingAddress: {
      address: 'Nidakule Göztepe, Merdivenköy Mah. Bora Sok. No:1',
      zipCode: '34742',
      contactName: 'Jane Doe',
      city: 'Istanbul',
      country: 'Turkey'
    },
    basketItems: [
      {
        id: 'BI101',
        price: '0.3',
        name: 'Binocular',
        category1: 'Collectibles',
        category2: 'Accessories',
        itemType: 'PHYSICAL'
      },
      {
        id: 'BI102',
        price: '0.5',
        name: 'Game code',
        category1: 'Game',
        category2: 'Online Game Items',
        itemType: 'VIRTUAL'
      },
      {
        id: 'BI103',
        name: 'Usb',
        price: '0.2',
        category1: 'Electronics',
        category2: 'Usb / Cable',
        itemType: 'PHYSICAL'
      }
    ],
    enabledInstallments: [ 1, 2, 3, 6, 9 ],
    callbackUrl: 'https://www.merchant.com/callback',
    currency: 'TRY',
    paidPrice: '1.2'
  });

  return new Response(JSON.stringify({ data: response }));
}