@fincode/node

中文文档
1.1.0发布于 2024/10/02MITTypeScriptESM + CJS近 30 天下载 14.5万

fincode for Node.jsはJavaScript/TypeScriptプロジェクトにおけるfincode APIの呼び出しを支援するAPIラッパーライブラリです。APIの呼び出しを支援するヘルパー関数とTypeScriptの型定義を提供し、型安全性を保ちつつ可読性の高いfincodeの組み込みを可能にします。

原始使用文档
文档目录20 节
  1. Getting Started
  2. Usage
  3. 1. fincodeの管理画面からAPIキーを取得
  4. 2. パッケージマネージャーからインストール
  5. 3. fincodeインスタンスの作成
  6. Call fincode API
  7. クエリパラメーターとヘッダー
  8. Payment API (決済API)
  9. Customer API (顧客API)
  10. Card API (カードAPI)
  11. Plan API (プランAPI)
  12. Subscription API (サブスクリプションAPI)
  13. Session API (リダイレクト型API)
  14. Payment Bulk API (一括決済API)
  15. Platform API (プラットフォームAPI)
  16. Platform Account API (プラットフォーム売上API)
  17. Tenant API (テナントAPI)
  18. Account API (売上入金API)
  19. Webhook Setting API (Webhook設定API)
  20. Requirements

Node.js SDK library for fincode byGMO

fincode for Node.jsはJavaScript/TypeScriptプロジェクトにおけるfincode APIの呼び出しを支援するAPIラッパーライブラリです。APIの呼び出しを支援するヘルパー関数とTypeScriptの型定義を提供し、型安全性を保ちつつ可読性の高いfincodeの組み込みを可能にします。

このライブラリはサーバーサイドNode.jsプロジェクトでの利用を想定しています。ブラウザ上で動作するアプリケーションにおいてfincodeを使用したい場合はfincode for ES Moduleを利用できます。

Getting Started

プロジェクトでnpmを使っている場合、npm経由でfincode for Node.jsをインストールできます。

$ npm i @fincode/node

# yarnやpnpmなど、npmと互換のあるパッケージ管理システムによるインストールも可能です。
$ yarn add @fincode/node

Usage

1. fincodeの管理画面からAPIキーを取得

テスト環境や本番環境の管理画面からAPIキーを取得します。

APIキーはシークレットキーである必要があります。

2. パッケージマネージャーからインストール

Getting Startedの手順に従い @fincode/node をプロジェクトにインストールします。

3. fincodeインスタンスの作成

createFincodeメソッドを呼び出し、fincodeインスタンスを作成します。

import { createFincode } from "@fincode/node"

const fincode = createFincode({
    apiKey: "m_****_**********", // Secret key
    isLiveMode: true,  // fincode Environment. true: Live mode, false: Test mode. default: false
    
    // Optional,
    options: {   
        // API Version
        version: "20211101",
        // Timeout
        timeout: 10000,
        // Proxy
        proxyAgent: "http://url.to.proxy:8080"
    }
})

(async () => {
    
    // Register a payment with idempotent key
    const createdPayment = await fincode.payments.create({
        pay_type: "Card",
        job_code: "CAPTURE",
        amount: "3000"
    }, {
        idempotentKey: "{{idempotent key}}"
    })
    // Execute a payment
    const executedPayment = await fincode.payment.execute(
        payment.id,
        {
            pay_type: createdPayment.pay_type,
            access_id: createdPayment.access_id,
            customer_id: "{{id of customer}}",
            card_id: "{{id of customer's card}}",
        }
    )
    // Retrieve a payment
    const payment = await fincode.payments.retrieve(executedPayment.id, { pay_type : "Card" })

    // Retrieve a list of payments
    const payments = await fincode.payments.retrieveList({
        pay_type: "Card",
        limit: 10,
        page: 1,
        total_amount_min: 1000,
        total_amount_max: 10000,
    })
})()

Call fincode API

fincodeインスタンスを作成することでfincode APIを呼び出すことができます。 fincodeインスタンスが持つメソッドは下記のように各APIと対応しています。

クエリパラメーターとヘッダー

ヘッダーはすべてのAPI呼び出しのオプショナル引数として渡すことができます。 ヘッダー情報は下記のようなオブジェクトに格納します。

{
    // idempotent_key に対応。冪等キー。
    idempotentKey?: string | undefined;
    // Tenant-Shops-Id に対応。テナントショップID。
    tenantShopId?: string | undefined;
    // Content-Type に対応。コンテンツタイプ。
    contentType?: string | undefined;
}

また、一覧取得APIなど一部のAPI呼び出しではオプショナル引数としてクエリパラメーターを渡すことができます。 クエリパラメーターは下記のようなオブジェクトに格納します。

{
    limit?: string | number | null
    page?: string | number | null
    count_only?: boolean | null
    // その他APIによって異なるクエリパラメーター
}

Payment API (決済API)

APIURL呼び出し方
決済登録POST /v1/paymentsfincode.payments.create(requestBody)
実行PUT /v1/payments/{id}fincode.payments.execute(id, requestBody)
一覧取得GET /v1/paymentsfincode.payments.retrieveList({ pay_type: payType})
取得GET /v1/payments/{id}fincode.payments.retrieve(id, { pay_type: payType})
売上確定PUT /v1/payments/{id}/capturefincode.payments.capture(id, requestBody)
キャンセルPUT /v1/payments/{id}/cancelfincode.payments.cancel(id, requestBody)
再オーソリPUT /v1/payments/{id}/authfincode.payments.reauthorize(id, requestBody)
金額変更PUT /v1/payments/{id}/changefincode.payments.changeAmount(id, requestBody)
3Dセキュア2.0認証実行(カード決済)PUT /v1/secure2/{access_id}fincode.payments.execute3DSecureAuth(access_id, requestBody)
3Dセキュア2.0認証実行結果取得(カード決済)GET /v1/secure2/{access_id}fincode.payments.retrieve3DSecureAuthResult(access_id)
認証後決済実行(カード決済)PUT /v1/payments/{id}/securefincode.payments.executeAfter3DSecureAuth(id, requestBody)
バーコード取得(コンビニ決済)PUT /v1/payments/{id}/barcodefincode.payments.generateKonbiniPaymentBarcode(id, requestBody)

Customer API (顧客API)

APIURL呼び出し方
顧客登録POST /v1/customersfincode.customers.create(requestBody)
更新PUT /v1/customers/{id}fincode.customers.update(id, requestBody)
一覧取得GET /v1/customersfincode.customers.retrieveList()
取得GET /v1/customers/{id}fincode.customers.retrieve(id)
削除DELETE /v1/customers/{id}fincode.customers.delete(id)

Card API (カードAPI)

APIURL呼び出し方
カード登録POST /v1/customers/{customer_id}/cardsfincode.cards.create(customerId, requestBody)
更新PUT /v1/customers/{customer_id}/cards/{id}fincode.cards.update(customerId, id, requestBody)
一覧取得GET /v1/customers/{customer_id}/cardsfincode.cards.retrieveList(customerId)
取得GET /v1/customers/{customer_id}/cards/{id}fincode.cards.retrieve(customerId, id)
削除DELETE /v1/customers/{customer_id}/cards/{id}fincode.cards.delete(customerId, id)

Plan API (プランAPI)

APIURL呼び出し方
プラン登録POST /v1/plansfincode.plans.create(requestBody)
更新PUT /v1/plans/{id}fincode.plans.update(id, requestBody)
一覧取得GET /v1/plansfincode.plans.retrieveList()
取得GET /v1/plans/{id}fincode.plans.retrieve(id)
削除DELETE /v1/plans/{id}fincode.plans.delete(id)

Subscription API (サブスクリプションAPI)

APIURL呼び出し方
サブスクリプション登録POST /v1/subscriptionsfincode.subscriptions.create(requestBody)
更新PUT /v1/subscriptions/{id}fincode.subscriptions.update(id, requestBody)
一覧取得GET /v1/subscriptionsfincode.subscriptions.retrieveList()
取得GET /v1/subscriptions/{id}fincode.subscriptions.retrieve(id)
解約DELETE /v1/subscriptions/{id}fincode.subscriptions.cancel(id)
サブスクリプション結果一覧取得GET /v1/subscriptions/{id}/resultfincode.subscriptions.retrieveResultList(id)

Session API (リダイレクト型API)

APIURL呼び出し方
決済URL作成POST /v1/sessionsfincode.paymentSessions.create(requestBody)
カード登録URL作成POST /v1/card_sessionsfincode.cardRegistrationSessions.create(requestBody)

Payment Bulk API (一括決済API)

APIURL呼び出し方
一括決済登録POST /v1/payments/bulkfincode.bulkPayments.create(pay_type, process_plan_date, file, file_name)
一覧取得GET /v1/payments/bulkfincode.bulkPayments.retrieveList()
削除DELETE /v1/payments/bulk/{id}fincode.bulkPayments.delete(id)
一括決済詳細情報一覧取得GET /v1/payments/bulk/{id}fincode.bulkPayments.retrieveDetailList(id)

Platform API (プラットフォームAPI)

APIURL呼び出し方
プラットフォーム一覧取得GET /v1/platformsfincode.platforms.retrieveList()
取得GET /v1/platforms/{id}fincode.platforms.retrieve(id)
更新PUT /v1/platforms/{id}fincode.platforms.update(id, requestBody)

Platform Account API (プラットフォーム売上API)

APIURL呼び出し方
プラットフォーム売上一覧取得GET /v1/platform_accountsfincode.platformAccounts.retrieveList()
取得GET /v1/platform_accounts/{id}fincode.platformAccounts.retrieve(id)
プラットフォーム売上サマリー一覧取得GET /v1/platform_accounts/{id}/summaryfincode.platformAccounts.retrieveSummaryList(id)

Tenant API (テナントAPI)

APIURL呼び出し方
テナント一覧取得GET /v1/tenantsfincode.tenants.retrieveList()
取得GET /v1/tenants/{id}fincode.tenants.retrieve(id)
新規作成(新規ユーザー)POST /v1/tenant_entriesfincode.tenants.createWithNewUser(requestBody)
新規作成(既存ユーザー)POST /v1/tenant_entriesfincode.tenants.createWithExistingUser(requestBody)
テナント本番環境申請情報取得GET /v1/contracts/examinations_v2/tenants/{id}fincode.tenants.retrieveExaminationInfoV2(id)
更新PUT /v1/contracts/examinations_v2/tenants/{id}fincode.tenants.updateExaminationInfoV2(id, requestBody)
テナント契約情報取得GET /v1/contracts/{id}fincode.tenants.retrieveContract(id)
本番環境申請POST /v1/contracts/examinationsfincode.tenants.requestExamination(requestBody)
審査ファイルアップロード
テナント決済手段追加申請

Account API (売上入金API)

APIURL呼び出し方
売上入金一覧取得GET /v1/accountsfincode.accounts.retrieveList()
取得GET /v1/accounts/{id}fincode.accounts.retrieve(id)
売上入金詳細取得GET /v1/accounts/{id}/detailfincode.accounts.retrieveDetailList(id)

Webhook Setting API (Webhook設定API)

APIURL呼び出し方
Webhook設定登録POST /v1/webhook_settingsfincode.webhookSettings.create(requestBody)
一覧取得GET /v1/webhook_settingsfincode.webhookSettings.retrieveList()
取得GET /v1/webhook_settings/{id}fincode.webhookSettings.retrieve(id)
更新PUT /v1/webhook_settings/{id}fincode.webhookSettings.update(id, requestBody)
削除DELETE /v1/webhook_settings/{id}fincode.webhookSettings.delete(id)

Requirements

このSDKは下記の環境で動作します。

環境バージョン
Node.js>=12.0.0

版本与发布记录

@fincode/node 共发布 4 个版本,首次发布于 2024/02/19;过去 12 个月发布了 0 个版本。

版本发布日期距今
1.1.0latest2024/10/022 年前
1.0.22024/06/142 年前
1.0.12024/03/052 年前
1.0.02024/02/192 年前

关于 @fincode/node 的常见问题

@fincode/node 是什么?

fincode for Node.jsはJavaScript/TypeScriptプロジェクトにおけるfincode APIの呼び出しを支援するAPIラッパーライブラリです。APIの呼び出しを支援するヘルパー関数とTypeScriptの型定義を提供し、型安全性を保ちつつ可読性の高いfincodeの組み込みを可能にします。

如何安装 @fincode/node?

在项目目录运行 npm install @fincode/node,或使用 pnpm add / yarn add / bun add。

@fincode/node 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@fincode/node 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@fincode/node 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=12.0.0。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@fincode/node 可以商用吗?

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

@fincode/node 的下载量有多少?

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

@fincode/node 还在维护吗?

最新版本 1.1.0 发布于 2024/10/02(2 年前);至今共发布 4 个版本,其中过去 12 个月发布了 0 个;首次发布于 2024/02/19。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。