# テナントショップ 決済手段追加申請

`POST /v1/contracts/examinations/tenants/{id}/providers/reserve`

- operationId: `reserveProvider`
- tags: テナント申請管理

`id`で指定したテナントショップの決済手段の追加申請を行います。  
※ 申請状況の管理画面への反映には最大24時間程度のタイムラグがあります


## コードサンプル

### cURL

```bash
curl \
    -X POST \
    -H "Authorization:Bearer <Secret API Key>" \
    -H "Content-Type: application/json" \
    -H "Tenant-Shop-Id: <Tenant Shop ID>" \
    -d '{
    "provider": ["PAYPAY"]
}' \
'https://api.test.fincode.jp/v1/contracts/examinations/tenants/{Tenant Shop ID}/providers/reserve'
```

### Node.js

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

const BASE_URL = "https://api.test.fincode.jp";

const API_KEY = "<Secret API Key>";

(async () => {
    const tenantShopId = "<Tenant Shop ID>";

    const endpoint = `${BASE_URL}/v1/contracts/examinations/tenants/${tenantShopId}/providers/reserve`;

    const response = await fetch(endpoint, {
        method: "POST",
        headers: {
            Authorization: `Bearer ${API_KEY}`,
            "Content-Type": "application/json",
            "Tenant-Shop-Id": tenantShopId,
        },
        body: JSON.stringify({
            provider: ["PAYSLE", "PAYPAY"],
        }),
    });
    const reservingResult = await response.json();
})();
```

### Go

```go
package main

import (
	"bytes"
	"encoding/json"
	"fmt"
	"log"
	"net/http"
)

func main() {

	apiKey := "<Secret API Key>"

	tenantShopID := "<Tenant Shop ID>"

	body := ReservingTenantProviderRequest{
		Provider: []Provider{
			PAYPAY,
		},
	}

	marshalledBody, _ := json.Marshal(body)

	// リクエストの作成
	req, _ := http.NewRequest("POST", fmt.Sprintf("https://api.test.fincode.jp/v1/contracts/examinations/tenants/%s/providers/reserve", tenantShopID), bytes.NewBuffer(marshalledBody))
	req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", apiKey))
	req.Header.Set("Content-Type", "application/json")
	req.Header.Set("Tenant-Shop-Id", tenantShopID)

	// リクエストの送信
	client := &http.Client{}
	res, err := client.Do(req)
	if err != nil {
		log.Fatal(err)
	}
	defer res.Body.Close()

}

type ReservingTenantProviderRequest struct {
	Provider []Provider `json:"provider"`
}

type Provider string

const (
	PAYSLE        Provider = "PAYSLE"
	PAYPAY        Provider = "PAYPAY"
	APPLE_PAY_UC  Provider = "APPLE_PAY_UC"
	APPLE_PAY_JCB_AMEX Provider = "APPLE_PAY_JCB_AMEX"
	DIRECT_DEBIT  Provider = "DIRECT_DEBIT"
)
```

### PHP

```php
<?php

$apiKey = '<Secret API Key>';

$tenantShopId = '<Tenant Shop ID>';

$baseUrl = "https://api.test.fincode.jp";
$endpoint = "/v1/contracts/examinations/tenants/{$tenantShopId}/providers/reserve";
$headers = [
    "Authorization: Bearer " . $apiKey,
    "Content-Type: application/json",
    "Tenant-Shop-Id: " . $tenantShopId,
];

$data = json_encode([
    "provider" => [
        "PAYSLE",
        "PAYPAY"
    ]
]);

$session = curl_init();
curl_setopt($session, CURLOPT_URL, $baseUrl . $endpoint);
curl_setopt($session, CURLOPT_HTTPHEADER, $headers);
curl_setopt($session, CURLOPT_POST, true);
curl_setopt($session, CURLOPT_POSTFIELDS, $data);
curl_setopt($session, CURLOPT_RETURNTRANSFER, true);
// curl_setopt($session, CURLOPT_SSL_VERIFYPEER, );
// curl_setopt($session, CURLOPT_SSL_VERIFYHOST, );

$response = curl_exec($session);

if ($response === false) {
    # エラー処理
    echo "cURL Error: " . curl_error($session);
} else {
    # APIからのデータを処理
    var_dump($response);
}

curl_close($session);
```

### Python 3

```python
import requests

api_key = '<Secret API Key>'

tenant_shop_id = '<Tenant Shop ID>'

url = f'https://api.test.fincode.jp/v1/contracts/examinations/tenants/{tenant_shop_id}/providers/reserve'

# ヘッダーを設定
headers = {
    'Authorization': f'Bearer {api_key}',
    'Content-Type': 'application/json',
    'Tenant-Shop-Id': tenant_shop_id,
}

data = {
    'provider': [ "PAYSLE", "PAYPAY" ]
}

# HTTP POSTリクエストの送信
try:
    response = requests.post(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"Request error: {e}")
```

### Ruby

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

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

def main
    tenant_shop_id = '<Tenant Shop ID>'
    endpoint = "/v1/contracts/examinations/tenants/#{tenant_shop_id}/providers/reserve"
    uri = URI.parse(BASE_URL + endpoint)

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

    data = {
        provider: ["PAYSLE", "PAYPAY"],
    }

    # リクエストの作成
    request = Net::HTTP::Post.new(uri.request_uri)
    request['Authorization'] = "Bearer #{API_KEY}"
    request['Content-Type'] = 'application/json'
    request['Tenant-Shop-Id'] = tenant_shop_id

    request.body = data.to_json

    # リクエストの送信
    response = http.request(request)

    case response
    when Net::HTTPSuccess
        puts 'SUCCESS'
    else
        puts 'ERROR'
    end

    # レスポンスの表示
    puts response.body
end

main
```

## パラメータ

| 名前 | 位置 | 必須 | 型 | 説明 |
| --- | --- | --- | --- | --- |
| `id` | path | ✓ | schema | 指定したテナントショップに対して決済手段を追加申請します。`Tenant-Shop-Id`ヘッダーも併せて指定してください。 |
| `Tenant-Shop-Id` | header | ✓ | schema | <span class="smallText color--red-400">※ プラットフォームのメインショップのみ指定可</span> |

## リクエストボディ

Content-Type: `multipart/form-data`

| パラメータ | 型 | 必須 | 説明 |
| --- | --- | --- | --- |
| `provider` | provider | ✓ |  |

## レスポンス

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

| パラメータ | 型 | 必須 | 説明 |
| --- | --- | --- | --- |
| `reservation_list` | array<object> |  | 決済手段追加 申請リスト |

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

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

