Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Alternative TypeScript SDK #129

Open
codingwithmanny opened this issue Apr 30, 2024 · 1 comment
Open

Alternative TypeScript SDK #129

codingwithmanny opened this issue Apr 30, 2024 · 1 comment

Comments

@codingwithmanny
Copy link

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
Copy link
Author

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 protected]',
      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 }));
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant