# Custom Integration

Recustomer API for Return and Cancel v2
## Introduction
Custom Integration は、Recustomer を利用するために必要な各種データを、マーチャントのシステムと Recustomer の間で連携するための API です。
通信の向きによって、次の 3 種類に分かれます。
<table>
  <tr>
    <th>種類</th>
    <th>向き</th>
    <th>エンドポイントを用意する側</th>
    <th>認証</th>
  </tr>
  <tr>
    <td>Recustomer API</td>
    <td>マーチャント → Recustomer</td>
    <td>Recustomer</td>
    <td>管理画面で発行した API トークンを、マーチャントが送る</td>
  </tr>
  <tr>
    <td>マーチャントが用意する API</td>
    <td>Recustomer → マーチャント</td>
    <td>マーチャント</td>
    <td>マーチャントが用意したトークンを、Recustomer が送る</td>
  </tr>
  <tr>
    <td>Webhook</td>
    <td>Recustomer → マーチャント（通知）</td>
    <td>マーチャント</td>
    <td>Recustomer が通知に署名する（X-Recustomer-Signature-256）</td>
  </tr>
</table>

それぞれの説明と認証の方法は、各区切りの「概要」のページにあります。

### 機能ごとに使う API
どの機能も、注文情報が Recustomer に入っていることが前提です。Import Order で注文情報を送ってください。
マーチャントが用意する API と Webhook は、使う機能のぶんだけ用意します。Recustomer は、管理画面で設定したものだけを呼び出します。
<table>
  <tr>
    <th>機能</th>
    <th>マーチャントが用意する API</th>
    <th>Webhook</th>
  </tr>
  <tr>
    <td>返品</td>
    <td>なし</td>
    <td>Return Order Webhook</td>
  </tr>
  <tr>
    <td>交換</td>
    <td>Get Product Variants：交換先の商品のバリエーションと在庫を取得する。用意しない場合、交換は同じバリエーションへの交換だけになる
Create Exchange Order：交換商品の受注伝票を作成する。交換伝票を Recustomer から作成する場合に用意する</td>
    <td>Return Order Webhook</td>
  </tr>
  <tr>
    <td>キャンセル</td>
    <td>Cancel Order：Recustomer がキャンセルを承認した注文の出荷を止める</td>
    <td>なし</td>
  </tr>
  <tr>
    <td>配送追跡</td>
    <td>なし</td>
    <td>Shipping Status Webhook</td>
  </tr>
</table>

### データフォーマット
<ul>
  <li>country_code(国コード) : <a href="https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2">https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2</a></li>
</ul>

## エンドポイント一覧

### [Recustomer API](https://docs.public.rcmr.io/ja/api/recustomer-api/overview.md)

向き: マーチャント → Recustomer

- [Import Order](https://docs.public.rcmr.io/ja/api/order-importer/import-orders.md): `POST /api/v1/orders/import`

### [マーチャントが用意する API](https://docs.public.rcmr.io/ja/api/merchant-hosted-api/overview.md)

向き: Recustomer → マーチャント

- [Get Product Variants](https://docs.public.rcmr.io/ja/api/exchange/get-product-variants.md): `GET /products/{product_id}`
- [Create Exchange Order](https://docs.public.rcmr.io/ja/api/exchange/create-exchange-order.md): `POST /orders`
- [Cancel Order](https://docs.public.rcmr.io/ja/api/cancel/cancel-order.md): `POST /orders/cancel`

### [Webhook](https://docs.public.rcmr.io/ja/api/webhooks/overview.md)

向き: Recustomer → マーチャント（通知）

- [Shipping Status Webhook](https://docs.public.rcmr.io/ja/api/webhooks/shipping-status.md): `POST /{your_shipping_endpoint}`
- [Return Order Webhook](https://docs.public.rcmr.io/ja/api/webhooks/return-order.md): `POST /{your_return_order_endpoint}`

