メインコンテンツへスキップ

設定

Settings APIを使用すると、PaymentKit内のさまざまな設定を管理できます。例えば、寄付ウィジェットの作成や通知ハンドラーの設定などです。各設定は、そのtypeとmountLocationによって識別される設定可能なリソースです。

Settings APIを使用すると、PaymentKit内のさまざまな設定を管理できます。例えば、寄付ウィジェットの作成や通知ハンドラーの設定などです。各設定は、そのtypemountLocationによって識別される設定可能なリソースです。

Settingオブジェクト

Settingオブジェクトには、特定の機能の設定が含まれています。

属性説明
idstring設定オブジェクトの一意の識別子。
typestring設定のタイプ。例:'donate''notification'
mount_locationstring設定が使用される場所の一意の識別子。多くの場合、URLパスまたはコンポーネント名です。
descriptionstring人間が読める形式の設定の説明。
settingsobjectこの設定タイプに固有の設定を含むオブジェクト。詳細は以下を参照してください。
activeboolean設定が現在アクティブかどうか。
livemodebooleanオブジェクトがライブモードに存在する場合はtrue、テストモードに存在する場合はfalse
component_didstringこの設定を作成したコンポーネントのDID。
created_atstring設定が作成されたときのタイムスタンプ。
updated_atstring設定が最後に更新されたときのタイムスタンプ。

donateのsettingsオブジェクト

属性説明
amountobject寄付金額の設定。
btnTextstring寄付ボタンに表示されるテキスト。デフォルト:'Donate'
historyType'table' | 'avatar'寄付履歴の表示スタイル。デフォルト:'avatar'

amountオブジェクトのプロパティ

属性説明
presetsstring[]事前定義された寄付金額の配列。customfalseの場合に必須です。
presetstringプリセットからデフォルトで選択される金額。
custombooleanカスタム寄付金額を許可するかどうか。
minimumstringカスタム寄付で許可される最小金額。customtrueの場合に必須です。
maximumstringカスタム寄付で許可される最大金額。customtrueの場合に必須です。

notificationのsettingsオブジェクト

属性説明
self_handlebooleantrueの場合、コンポーネントが通知イベントを自身で処理することを示します。
include_eventsstring[]通知に含めるイベントタイプの配列。
exclude_eventsstring[]通知から除外するイベントタイプの配列。

設定の作成

新しい設定オブジェクトを作成します。

新しい設定を作成する

javascript
const setting = await payment.settings.create({
  type: 'donate',
  mountLocation: '/community/donate',
  description: 'Community Donation Page',
  settings: {
    amount: {
      presets: ['5', '10', '25'],
      preset: '10',
      custom: true,
      minimum: '1',
      maximum: '1000',
    },
    btnText: 'Support Us',
  },
});

パラメータ

名前説明
typestring必須。 作成する設定のタイプ(例:'donate''notification')。
mountLocationstring必須。 設定が使用される場所の一意の識別子。
descriptionstring必須。 設定の説明。
settingsobjectオプション。typeに固有の設定を持つオブジェクト。
activebooleanオプション。設定がアクティブかどうか。デフォルトはtrueです。
livemodebooleanオプション。モードを指定します。デフォルトはtrueです。
componentDidstringオプション。設定を作成するコンポーネントのDID。

戻り値

新しく作成された設定オブジェクト。

レスポンス

json
{
  "id": "set_1a2b3c4d5e6f7g8h",
  "type": "donate",
  "mount_location": "/community/donate",
  "description": "Community Donation Page",
  "settings": {
    "amount": {
      "presets": ["5", "10", "25"],
      "preset": "10",
      "custom": true,
      "minimum": "1",
      "maximum": "1000"
    },
    "btnText": "Support Us",
    "historyType": "avatar"
  },
  "active": true,
  "livemode": true,
  "component_did": "z1...",
  "created_at": "2023-10-27T10:00:00.000Z",
  "updated_at": "2023-10-27T10:00:00.000Z"
}

設定の取得

IDまたはmountLocationによって既存の設定の詳細を取得します。

設定を取得する

javascript
const settingId = 'set_1a2b3c4d5e6f7g8h';
const setting = await payment.settings.retrieve(settingId);

パラメータ

名前説明
idstring必須。 取得する設定の一意の識別子またはmountLocation

戻り値

設定オブジェクトが見つかった場合はそのオブジェクト。見つからない場合はエラーがスローされます。

レスポンス

json
{
  "id": "set_1a2b3c4d5e6f7g8h",
  "type": "donate",
  "mount_location": "/community/donate",
  "description": "Community Donation Page",
  "settings": {
    "amount": {
      "presets": ["5", "10", "25"],
      "preset": "10",
      "custom": true,
      "minimum": "1",
      "maximum": "1000"
    },
    "btnText": "Support Us",
    "historyType": "avatar"
  },
  "active": true,
  "livemode": true,
  "component_did": "z1...",
  "created_at": "2023-10-27T10:00:00.000Z",
  "updated_at": "2023-10-27T10:00:00.000Z"
}

設定の更新

渡されたパラメータの値を設定して、指定された設定を更新します。提供されなかったパラメータは変更されません。

設定を更新する

javascript
const settingId = 'set_1a2b3c4d5e6f7g8h';
const updatedSetting = await payment.settings.update(settingId, {
  description: 'Updated Community Donation Page',
  active: false,
  settings: {
    btnText: 'Donate Now',
  },
});

パラメータ

名前説明
idstring必須。 更新する設定の一意の識別子またはmountLocation
dataobject必須。 更新するフィールドを含むオブジェクト。

dataオブジェクトのプロパティ

名前説明
descriptionstringオプション。設定の更新された説明。
activebooleanオプション。設定がアクティブかどうか。
settingsobjectオプション。更新する設定固有のフィールドを持つオブジェクト。これは既存の設定とマージされます。

戻り値

更新された設定オブジェクト。

レスポンス

json
{
  "id": "set_1a2b3c4d5e6f7g8h",
  "type": "donate",
  "mount_location": "/community/donate",
  "description": "Updated Community Donation Page",
  "settings": {
    "amount": {
      "presets": ["5", "10", "25"],
      "preset": "10",
      "custom": true,
      "minimum": "1",
      "maximum": "1000"
    },
    "btnText": "Donate Now",
    "historyType": "avatar"
  },
  "active": false,
  "livemode": true,
  "component_did": "z1...",
  "created_at": "2023-10-27T10:00:00.000Z",
  "updated_at": "2023-10-27T10:05:00.000Z"
}

設定の削除

設定を完全に削除します。この操作は元に戻すことはできません。

設定を削除する

javascript
const settingId = 'set_1a2b3c4d5e6f7g8h';
const response = await payment.settings.del(settingId);

パラメータ

名前説明
idstring必須。 削除する設定の一意の識別子またはmountLocation

戻り値

確認メッセージ。

レスポンス

json
{
  "message": "設定 set_1a2b3c4d5e6f7g8h は削除されました"
}