# インボイス 入金登録（銀行振込（指定口座））

`PUT /v1/invoices/{id}/amount_register/payee_account`

- operationId: `amountRegisterInvoicePayeeAccount`
- tags: インボイス機能

指定したIDを持つ発行済みのインボイスに対し、銀行振込（指定口座）による入金額を登録します。\
登録した入金情報は、後続の[インボイス 支払い完了（銀行振込（指定口座））API](#operation/captureInvoicePayeeAccount) によって支払完了として確定できます。


## コードサンプル

### cURL

```bash
curl \
    -X PUT \
    -H "Authorization:Bearer <Secret API Key>" \
    -H "Content-Type: application/json" \
    -d '{
    "amount": "1000"
}' \
    'https://api.test.fincode.jp/v1/invoices/{id}/amount_register/payee_account'
```

### Node.js

```javascript
import fetch from "node-fetch";

const BASE_URL = "https://api.test.fincode.jp";
const API_KEY = "<Secret API Key>";

(async () => {
    const invoiceID = "<Invoice ID>";
    const endpoint = `${BASE_URL}/v1/invoices/${invoiceID}/amount_register/payee_account`;

    const response = await fetch(endpoint, {
        method: "PUT",
        headers: {
            Authorization: `Bearer ${API_KEY}`,
            "Content-Type": "application/json",
        },
        body: JSON.stringify({
            amount: "1000",
        }),
    });

    if (!response.ok) {
        console.error(`Error: ${response.statusText}`);
        return;
    }

    const data = await response.json();
    console.log(data);
})();
```

### Go

```go
package main

import (
	"bytes"
	"fmt"
	"io"
	"log"
	"net/http"
)

func main() {
	apiKey := "<Secret API Key>"
	invoiceID := "<Invoice ID>"

	url := fmt.Sprintf("https://api.test.fincode.jp/v1/invoices/%s/amount_register/payee_account", invoiceID)

	reqBody := bytes.NewBufferString(`{
		"amount": "1000"
	}`)

	req, err := http.NewRequest("PUT", url, reqBody)
	if err != nil {
		log.Fatalf("リクエスト作成エラー: %v", err)
	}
	req.Header.Set("Authorization", "Bearer "+apiKey)
	req.Header.Set("Content-Type", "application/json")

	resp, err := http.DefaultClient.Do(req)
	if err != nil {
		log.Fatalf("リクエスト送信エラー: %v", err)
	}
	defer resp.Body.Close()

	respBody, _ := io.ReadAll(resp.Body)
	fmt.Println(string(respBody))
}
```

### PHP

```php
<?php

$apiKey = '<Secret API Key>';
$invoiceID = "<Invoice ID>";
$baseUrl = "https://api.test.fincode.jp";
$endpoint = "/v1/invoices/{$invoiceID}/amount_register/payee_account";
$headers = [
    "Authorization: Bearer " . $apiKey,
    "Content-Type: application/json"
];

$data = json_encode([
    "amount" => "1000"
]);

$session = curl_init();
curl_setopt($session, CURLOPT_URL, $baseUrl . $endpoint);
curl_setopt($session, CURLOPT_HTTPHEADER, $headers);
curl_setopt($session, CURLOPT_CUSTOMREQUEST, "PUT");
curl_setopt($session, CURLOPT_POSTFIELDS, $data);
curl_setopt($session, CURLOPT_RETURNTRANSFER, true);

$response = curl_exec($session);
if ($response === false) {
    echo "cURL Error: " . curl_error($session);
} else {
    var_dump($response);
}
curl_close($session);
```

### Python 3

```python
import requests

api_key = '<Secret API Key>'
invoice_id = '<Invoice ID>'
url = f'https://api.test.fincode.jp/v1/invoices/{invoice_id}/amount_register/payee_account'

headers = {
    'Authorization': f'Bearer {api_key}',
    'Content-Type': 'application/json'
}

data = {
    "amount": "1000"
}

try:
    response = requests.put(url, headers=headers, json=data)
    if response.status_code == 200:
        print(f"Success: {response.json()}")
    else:
        print(f"Error: {response.json()}")
except requests.RequestException as e:
    print(f"通信エラー: {e}")
```

### Ruby

```ruby
require 'net/http'
require 'uri'
require 'json'

API_KEY = '<Secret API Key>'
BASE_URL = 'https://api.test.fincode.jp'

def main
  invoice_id = '<Invoice ID>'
  endpoint = "/v1/invoices/#{invoice_id}/amount_register/payee_account"
  uri = URI.parse(BASE_URL + endpoint)

  http = Net::HTTP.new(uri.host, uri.port)
  http.use_ssl = true

  data = {
    amount: "1000"
  }

  request = Net::HTTP::Put.new(uri.request_uri)
  request['Authorization'] = "Bearer #{API_KEY}"
  request['Content-Type'] = 'application/json'
  request.body = data.to_json

  response = http.request(request)
  puts response.body
end

main
```

## パラメータ

| 名前 | 位置 | 必須 | 型 | 説明 |
| --- | --- | --- | --- | --- |
| `id` | path | ✓ | string | インボイスID |
| `Tenant-Shop-Id` | header |  | schema | <span class="smallText color--red-400">※ プラットフォームのメインショップのみ指定可</span> |

## リクエストボディ

Content-Type: `application/json`

| パラメータ | 型 | 必須 | 説明 |
| --- | --- | --- | --- |
| `amount` | string | ✓ | 入金額（[インボイス 支払い完了（銀行振込（指定口座））API](#operation/captureInvoicePayeeAccount)を実行するまでは更新可能） |

## レスポンス

### 200 リクエストに成功

| パラメータ | 型 | 必須 | 説明 |
| --- | --- | --- | --- |
| `id` | string |  | インボイスID |
| `status` | string |  | インボイス請求書のステータス |
| `invoice_url` | string |  | インボイス 請求ページURL |
| `bill_mail_send_flag` | enum(0 | 1) |  | 請求書メール送信フラグ (0: メールを送信しない 1: メールを送信する) |
| `bill_pdf_url` | string |  | [非推奨] インボイス請求書PDFダウンロードURL |
| `receipt_mail_send_flag` | enum(0 | 1) |  | 領収書メール送信フラグ (0: メールを送信しない 1: メールを送信する) |
| `underpayment_mail_send_flag` | enum(0 | 1) |  | 差額請求メール送信フラグ (0: メールを送信しない 1: メールを送信する) |
| `receipt_pdf_url` | string |  | [非推奨] インボイス領収書PDFダウンロードURL |
| `invoice_number` | string |  | 請求番号 |
| `customer_id` | string |  | 顧客（請求先）ID |
| `customer_honorific` | string |  | 顧客（請求先）敬称 |
| `customer` | object |  | 顧客（請求先）情報 |
| `customer_overwrite` | object |  | 上書き顧客（請求先）情報 |
| `issuer` | object |  | 発行元事業者情報 |
| `issuer_overwrite` | object |  | 上書き発行元事業者情報 |
| `issue_date` | string |  | 発行年月日 |
| `lines` | array<object> |  | 取引内容レコード |
| `total_amount` | number |  | 合計金額 |
| `billing_total_amount` | number |  | 請求金額合計 |
| `pay_types` | array<string> |  | 利用可能な決済種別リスト |
| `input_type` | enum(amount) |  | 取引金額の入力方式 |
| `card` | object |  | カード決済情報 |
| `virtual_account` | object |  | 銀行振込（バーチャル口座）情報 |
| `embedded_virtual_account` | object |  | このインボイス情報に対して発行されたバーチャル口座情報 |
| `is_tax_included` | boolean |  | 内税表記有無 |
| `due_date` | string |  | 支払期日 |
| `memo` | string |  | 備考 |
| `client_field_1` | string |  | 加盟店自由項目1 |
| `client_field_2` | string |  | 加盟店自由項目2 |
| `client_field_3` | string |  | 加盟店自由項目3 |
| `is_uncollectible` | boolean |  | 回収困難フラグ |
| `is_paid_externally` | boolean |  | M's PayBridge外支払フラグ |
| `transaction_date` | string |  | 支払完了日 |
| `bill_id` | string |  | 請求ID |
| `directdebit` | object |  | 口座振替情報 |
| `payee_account` | object |  | 銀行振込（指定口座）情報 |
| `embedded_directdebit` | object |  | このインボイス情報に対する口座振替の口座情報 この口座から引き落とし完了することでインボイスによる請求に対して支払いできます。 |
| `embedded_payee_accounts` | array<object> |  | このインボイス情報に対する銀行振込（指定口座）口座情報 この口座情報に対して振込を行うことでインボイスによる請求に対して支払いできます。 |
| `billing_file_import_entry_id` | string |  | 請求インポートファイル読み込みエントリーID |
| `trade_client_field_1` | string |  | 決済情報自由項目 1 |
| `trade_client_field_2` | string |  | 決済情報自由項目 2 |
| `trade_client_field_3` | string |  | 決済情報自由項目 3 |
| `invoice_backfill` | object |  | 後付け請求情報 |
| `created` | string |  | 作成日時 |
| `updated` | string |  | 更新日時 |

### 400 不正なリクエスト

| パラメータ | 型 | 必須 | 説明 |
| --- | --- | --- | --- |
| `errors` | array<FincodeAPIError> |  |  |

