@akinon/pz-haso

中文文档
2.0.165发布于 2026/11/12MITCommonJS零依赖近 30 天下载 1.3万

HASO (Hemen Al Sonra Öde / Buy Now Pay Later) ödeme entegrasyonu için data aggregation paketi.

原始使用文档
文档目录12 节
  1. Installation
  2. Usage
  3. Customizing the HASO Component
  4. Custom Form Component
  5. Custom Renderer API
  6. Configuration
  7. Data Aggregation Flow
  8. Data Collected
  9. Security
  10. API Routes
  11. Check Availability API
  12. Using checkHasoAvailability Mutation

HASO Payment Gateway Extension

HASO (Hemen Al Sonra Öde / Buy Now Pay Later) ödeme entegrasyonu için data aggregation paketi.

Installation

You can use the following command to install the extension with the latest plugins:

npx @akinon/projectzero@latest --plugins

Usage

Once the extension is installed, you can easily integrate the HASO payment gateway into your application. Here's an example of how to use it.

  1. Navigate to the src/app/[commerce]/[locale]/[currency]/payment-gateway/haso/ directory.

  2. Create a file named page.tsx and include the following code:

import { HasoPaymentGateway } from '@akinon/pz-haso';

const HasoGateway = async ({
  searchParams: { sessionId },
  params: { currency, locale }
}: {
  searchParams: Record<string, string>;
  params: { currency: string; locale: string };
}) => {
  return (
    <HasoPaymentGateway
      sessionId={sessionId}
      currency={currency}
      locale={locale}
      extensionUrl={process.env.HASO_EXTENSION_URL}
      hashKey={process.env.HASO_HASH_KEY}
    />
  );
};

export default HasoGateway;

Customizing the HASO Component

You can customize the appearance of the HASO payment gateway using the renderer prop. This allows you to provide custom rendering functions for different parts of the component.

Custom Form Component

import { HasoPaymentGateway } from '@akinon/pz-haso';

const HasoGateway = async ({
  searchParams: { sessionId },
  params: { currency, locale }
}: {
  searchParams: Record<string, string>;
  params: { currency: string; locale: string };
}) => {
  return (
    <HasoPaymentGateway
      sessionId={sessionId}
      currency={currency}
      locale={locale}
      extensionUrl={process.env.HASO_EXTENSION_URL}
      hashKey={process.env.HASO_HASH_KEY}
      renderer={{
        formComponent: {
          renderForm: ({
            extensionUrl,
            sessionId,
            context,
            csrfToken,
            autoSubmit
          }) => (
            <div className="custom-haso-form-wrapper">
              <h3 className="text-lg font-semibold mb-4">HASO Ödeme</h3>
              <p className="mb-4">
                HASO ödeme sayfasına yönlendiriliyorsunuz...
              </p>
              <form
                action={`${extensionUrl}/form-page/?sessionId=${sessionId}`}
                method="post"
                encType="multipart/form-data"
                id="haso-custom-form"
                className="hidden"
              >
                <input type="hidden" name="csrf_token" value={csrfToken} />
                <input
                  type="hidden"
                  name="data"
                  value={JSON.stringify(context)}
                />
                {autoSubmit && (
                  <script
                    dangerouslySetInnerHTML={{
                      __html:
                        "document.getElementById('haso-custom-form').submit()"
                    }}
                  />
                )}
              </form>
              <div className="loader w-12 h-12 border-4 border-t-4 border-gray-200 border-t-blue-500 rounded-full animate-spin"></div>
            </div>
          )
        },
        paymentGateway: {
          renderContainer: ({ children }) => (
            <div className="p-8 max-w-lg mx-auto bg-white rounded-lg shadow-md">
              {children}
            </div>
          )
        }
      }}
    />
  );
};

export default HasoGateway;

Custom Renderer API

The renderer prop accepts an object with the following structure:

interface HasoRendererProps {
  formComponent?: {
    renderForm?: (props: {
      extensionUrl: string;
      sessionId: string;
      context: any;
      csrfToken: string;
      autoSubmit: boolean;
    }) => React.ReactNode;
    renderLoading?: () => React.ReactNode;
    renderError?: (error: string) => React.ReactNode;
  };
  paymentGateway?: {
    renderContainer?: (props: { children: React.ReactNode }) => React.ReactNode;
  };
}

Configuration

Add these variables to your .env file:

HASO_EXTENSION_URL=<your_extension_url>
HASO_HASH_KEY=<your_hash_key>

Data Aggregation Flow

This package implements the data aggregation pattern for HASO payments:

1. start-session → redirectUrl: /payment-gateway/haso/?sessionId=XXX
2. HasoPaymentGateway → Collects data (preOrder, addresses, basket)
3. FormComponent → POST → Extension /form-page/?sessionId=XXX (with SHA-512 hash)
4. Extension → Creates Provider URL → Payment screen
5. Payment completed → return-url → Merchant Store

Data Collected

The package collects the following data from the checkout:

  • Order Items: Product name, SKU, quantity, unit price, total amount
  • Billing Address: City, country, name, address line, phone, email, postal code
  • Shipping Address: City, country, name, address line, phone, email, postal code
  • Customer Info: Name, phone, email, identity number
  • Amounts: Total amount, shipping amount, currency

Security

All data is sent with a SHA-512 hash for validation:

  • Hash is generated using: salt | sessionId | hashKey
  • Extension validates the hash before processing

API Routes

Check Availability API

To enable HASO payment availability checks, you need to create an API route. Create a file at src/app/api/haso-check-availability/route.ts with the following content:

import { POST } from '@akinon/pz-haso/src/pages/api/check-availability';

export { POST };

This API endpoint handles checking the availability of HASO payment for a given:

  • Phone number
  • Order amount
  • Email (optional)
  • Identity number (optional)

The endpoint automatically validates the request and response using hash-based security measures.

Using checkHasoAvailability Mutation

The extension provides a Redux mutation hook that you can use to check HASO payment availability. Here's an example of how to implement it:

import { useCheckHasoAvailabilityMutation } from '@akinon/pz-haso';

const YourComponent = () => {
  const [checkHasoAvailability] = useCheckHasoAvailabilityMutation();
  const [isHasoAvailable, setIsHasoAvailable] = useState(false);

  useEffect(() => {
    const checkAvailability = async () => {
      try {
        const response = await checkHasoAvailability({
          amount: '1000.00',
          phone: '+905551234567',
          email: '[email protected]',
          identity_number: '12345678901' // TC Kimlik No (optional)
        }).unwrap();

        setIsHasoAvailable(response.is_available);
      } catch (error) {
        console.error('Error checking HASO availability:', error);
        setIsHasoAvailable(false);
      }
    };

    checkAvailability();
  }, [checkHasoAvailability]);

  return (
    // Your component JSX
  );
};

The mutation returns an object with the following properties:

  • is_available: boolean indicating if HASO payment is available
  • limit: number indicating the available credit limit (optional)
  • salt: string used for hash verification
  • hash: string for response validation

版本与发布记录

@akinon/pz-haso 共发布 710 个版本,首次发布于 2025/11/26;过去 12 个月发布了 710 个版本。

版本发布日期距今
2.0.165latest2026/11/12今天
2.0.165-beta.0beta2026/11/092 天前
2.0.165-rc.0rc2026/11/092 天前
2.0.1642026/11/092 天前
1.126.29-v1-rc.36v1-rc2026/11/093 天前
2.0.164-rc.12026/11/093 天前

其他发布通道:snapshot → 1.126.4-snapshot-ZERO-5318-occasion-20261019202720,v1-latest → 1.126.28,v1-rc → 1.126.29-v1-rc.36,rc → 2.0.165-rc.0,beta → 2.0.165-beta.0。

关于 @akinon/pz-haso 的常见问题

@akinon/pz-haso 是什么?

HASO (Hemen Al Sonra Öde / Buy Now Pay Later) ödeme entegrasyonu için data aggregation paketi.

如何安装 @akinon/pz-haso?

在项目目录运行 npm install @akinon/pz-haso,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:react(^18.0.0 || ^19.0.0)、react-dom(^18.0.0 || ^19.0.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@akinon/pz-haso 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/akinon__pz-haso 是否存在。

@akinon/pz-haso 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@akinon/pz-haso 可以商用吗?

@akinon/pz-haso 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@akinon/pz-haso 的下载量有多少?

根据 npm 官方下载统计,@akinon/pz-haso 在 2026/10/06 – 2026/11/04 这 30 天内被下载 13,484 次,日均约 449 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@akinon/pz-haso 还在维护吗?

最新版本 2.0.165 发布于 2026/11/12(今天);至今共发布 710 个版本,其中过去 12 个月发布了 710 个;首次发布于 2025/11/26。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。