Refund API関数
返金を作成する
既に作成され、まだ返金されていない支払いに対して返金を作成します。返金する金額を指定することも、金額を指定せずに支払い全額を返金することもできます。返金は、支払いと同じ通貨で、支払いと同じ支払い方法に対して作成されます。
1つの支払いに対して複数回返金することはできません。 既に返金済みの支払いに対して返金を試みると、エラーが返されます。これは、元の支払い金額を超える金額を返金しようとした場合にも発生します。
エンドポイント: https://api.stripe.com/v1/refunds
操作: POST
例
cURLの例:
curl -X POST https://api.stripe.com/v1/refunds \
-u <YOUR_SECRET_KEY>: \
-d "charge=ch_1NirD82eZvKYlo2CIvbtLWuY"
レスポンス
レスポンスは標準コードを返します。
200: OK
{
"id": "re_1Nispe2eZvKYlo2Cd31jOCgZ",
"object": "refund",
"amount": 212,
"balance_transaction": "txn_1Nispe2eZvKYlo2CYezqFhEx",
"charge": "ch_1NirD82eZvKYlo2CIvbtLWuY",
"created": 1692942318,
"currency": "usd",
"destination_details": {
"card": {
"reference": "123456789012",
"reference_status": "available",
"reference_type": "acquirer_reference_number",
"type": "refund"
},
"type": "card"
},
"metadata": {},
"payment_intent": "pi_1GszsK2eZvKYlo2CfhZyoZLp",
"reason": null,
"receipt_number": null,
"source_transfer_reversal": null,
"status": "succeeded",
"transfer_reversal": null
}
400: Bad Request
{
"error": {
"code": "parameter_invalid_integer",
"doc_url": "https://stripe.com/docs/error-codes/parameter-invalid-integer",
"message": "Invalid integer: <integer>",
"param": "amount",
"request_log_url": "https://dashboard.stripe.com/test/logs/req_UQf6XBwBl9yk66?t=1734829676",
"type": "invalid_request_error"
}
}
401: Unauthorized
{
"error": {
"type": "invalid_request_error",
"message": "Invalid API Key provided: sk_test_********************1234"
}
}
パラメーター
ボディパラメーター
| パラメーター | 型 | 説明 |
|---|---|---|
amount | 整数 | 返金する金額(セント単位)。指定しない場合、支払い全額が返金されます。 |
charge | 文字列 | (必須) 返金する支払いのID。 |
currency | 文字列 | 3文字のISO通貨コード(小文字)。サポートされている通貨である必要があります。指定しない場合、支払いの通貨が使用されます。 |
expand[] | 文字列の配列 | レスポンス内のどのフィールドを展開するかを指定します。 |
customer | 文字列 | 支払いが属するカスタマーのID。 |
reason | 文字列 | 返金の理由。設定する場合、可能な値は duplicate(重複)、fraudulent(不正)、または requested_by_customer(カスタマーによるリクエスト)です。 fraudulent として設定すると、その支払いに関連付けられたカードとメールアドレスがブロックリストに追加され、Stripeの不正検出の向上に役立ちます。 |
payment_intent | 文字列 | 返金するPaymentIntentのID。 |
refund_application_fee | boolean | アプリケーション手数料を返金するかどうかを示します。全額返金される場合は、アプリケーション手数料も返金されます。それ以外の場合は、返金額に比例してアプリケーション手数料が返金されます。アプリケーション手数料は、支払いを作成したアプリケーションのみが対象となります。 |
origin | 文字列 | 返金の起点。 |
reverse_transfer | boolean | 送金を逆仕訳するかどうかを示します。送金は返金額(全額または一部返金)に比例して逆仕訳されます。 |
instructions_email | 文字列 | 返金をサポートしていない支払い方法が使用された場合に、返金手順の送信先としてカスタマーのメールアドレスを使用します。 |
返金を更新する
渡されたパラメーターの値を設定することで、指定された返金を更新します。提供されなかったパラメーターは変更されません。これは、返金に関する追加情報を保存するのに便利です。
エンドポイント: https://api.stripe.com/v1/refunds/{id}
操作: POST
例
cURLの例:
curl -X POST `https://api.stripe.com/v1/refunds/{id}` \
-u <YOUR_SECRET_KEY>: \
-d "metadata[order_id]=6735"
レスポンス
レスポンスは標準コードを返します。
200: OK
{
"id": "re_1Nispe2eZvKYlo2Cd31jOCgZ",
"object": "refund",
"amount": 1000,
"balance_transaction": "txn_1Nispe2eZvKYlo2CYezqFhEx",
"charge": "ch_1NirD82eZvKYlo2CIvbtLWuY",
"created": 1692942318,
"currency": "usd",
"destination_details": {
"card": {
"reference": "123456789012",
"reference_status": "available",
"reference_type": "acquirer_reference_number",
"type": "refund"
},
"type": "card"
},
"metadata": {
"order_id": "6735"
},
"payment_intent": "pi_1GszsK2eZvKYlo2CfhZyoZLp",
"reason": null,
"receipt_number": null,
"source_transfer_reversal": null,
"status": "succeeded",
"transfer_reversal": null
}
400: Bad Request
{
"error": {
"code": "parameter_invalid_integer",
"doc_url": "https://stripe.com/docs/error-codes/parameter-invalid-integer",
"message": "Invalid integer: <integer>",
"param": "amount",
"request_log_url": "https://dashboard.stripe.com/test/logs/req_UQf6XBwBl9yk66?t=1734829676",
"type": "invalid_request_error"
}
}
401: Unauthorized
{
"error": {
"type": "invalid_request_error",
"message": "Invalid API Key provided: sk_test_********************1234"
}
}
パラメーター
ボディパラメーター
| パラメーター | 型 | 説明 |
|---|---|---|
metadata | オブジェクト | オブジェクトに添付できるキーと値のペア。構造化された形式でオブジェクトに関する追加情報を保存するのに役立ちます。 |
expand[] | 文字列の配列 | レスポンス内のどのフィールドを展開するかを指定します。 |
パス変数
| 名前 | 型 | 必須 | 説明 |
|---|---|---|---|
id | 文字列 | 必須 | 更新する返金のID。 |
返金を取得する
特定の返金の詳細を取得します。
エンドポイント: https://api.stripe.com/v1/refunds/{id}
操作: GET
例
cURLの例:
curl -X GET https://api.stripe.com/v1/refunds/re_1Nispe2eZvKYlo2Cd31jOCgZ \
-u <YOUR_SECRET_KEY>:
レスポンス
レスポンスは標準コードを返します。
200: OK
{
"id": "re_1Nispe2eZvKYlo2Cd31jOCgZ",
"object": "refund",
"amount": 212,
"balance_transaction": "txn_1Nispe2eZvKYlo2CYezqFhEx",
"charge": "ch_1NirD82eZvKYlo2CIvbtLWuY",
"created": 1692942318,
"currency": "usd",
"destination_details": {
"card": {
"reference": "123456789012",
"reference_status": "available",
"reference_type": "acquirer_reference_number",
"type": "refund"
},
"type": "card"
},
"metadata": {},
"payment_intent": "pi_1GszsK2eZvKYlo2CfhZyoZLp",
"reason": null,
"receipt_number": null,
"source_transfer_reversal": null,
"status": "succeeded",
"transfer_reversal": null
}
400: Bad Request
{
"error": {
"code": "parameter_invalid_integer",
"doc_url": "https://stripe.com/docs/error-codes/parameter-invalid-integer",
"message": "Invalid integer: <integer>",
"param": "amount",
"request_log_url": "https://dashboard.stripe.com/test/logs/req_UQf6XBwBl9yk66?t=1734829676",
"type": "invalid_request_error"
}
}
401: Unauthorized
{
"error": {
"type": "invalid_request_error",
"message": "Invalid API Key provided: sk_test_********************1234"
}
}
パラメーター
クエリパラメーター
| パラメーター | 型 | 説明 |
|---|---|---|
expand[] | 文字列の配列 | レスポンス内のどのフィールドを展開するかを指定します。 |
パス変数
| 名前 | 型 | 必須 | 説明 |
|---|---|---|---|
id | 文字列 | 必須 | 取得する返金のID。 |
すべての返金をリスト表示する
既存の返金のリストを返します。返金はソートされた順序で返され、最新の返金が最初に表示されます。デフォルトでは、最新の10件の返金が返されます。
エンドポイント: https://api.stripe.com/v1/refunds
操作: GET
例
cURLの例:
curl -X GET https://api.stripe.com/v1/refunds \
-u <YOUR_SECRET_KEY>:
レスポンス
レスポンスは標準コードを返します。
200: OK
{
"object": "list",
"url": "/v1/refunds",
"has_more": false,
"data": [
{
"id": "re_1Nispe2eZvKYlo2Cd31jOCgZ",
"object": "refund",
"amount": 212,
"balance_transaction": "txn_1Nispe2eZvKYlo2CYezqFhEx",
"charge": "ch_1NirD82eZvKYlo2CIvbtLWuY",
"created": 1692942318,
"currency": "usd",
"destination_details": {
"card": {
"reference": "123456789012",
"reference_status": "available",
"reference_type": "acquirer_reference_number",
"type": "refund"
},
"type": "card"
},
"metadata": {},
"payment_intent": "pi_1GszsK2eZvKYlo2CfhZyoZLp",
"reason": null,
"receipt_number": null,
"source_transfer_reversal": null,
"status": "succeeded",
"transfer_reversal": null
}
]
}
400: Bad Request
{
"error": {
"code": "resource_missing",
"doc_url": "https://stripe.com/docs/error-codes/resource-missing",
"message": "No such charge: 'ch_1NirD82eZvKYlo2CIvbtLWuY'",
"param": "charge",
"request_log_url": "https://dashboard.stripe.com/test/logs/req_HIH2jWkJGecwCk?t=1754504399",
"type": "invalid_request_error"
}
}
401: Unauthorized
{
"error": {
"type": "invalid_request_error",
"message": "Invalid API Key provided: sk_test_********************1234"
}
}
パラメーター
| パラメーター | 型 | 説明 |
|---|---|---|
charge | 文字列 | 返金を取得する支払いのID。指定しない場合、すべての返金が返されます。 |
created | 辞書 | 指定された日付の間隔に作成された返金のみを返します。これは、gt、gte、lt、lte というキーを持つ辞書にすることができます。 |
ending_before | 文字列 | ページネーションに使用するカーソル。リスト内での位置を定義するために、オブジェクトID ending_before を使用します。リストリクエストを行って obj_bar から始まる100件の結果を受け取った場合、後続の呼び出しに ending_before=obj_bar を含めることで、リストの前のページを取得できます。 |
limit | 整数 | 返されるオブジェクトの数の制限。制限は1から100の間で、デフォルトは10です。 |
payment_intent | 文字列 | 返金を取得するPaymentIntentのID。指定しない場合、すべての返金が返されます。 |
starting_after | 文字列 | ページネーションに使用するカーソル。リスト内での位置を定義するために、オブジェクトID starting_after を使用します。リストリクエストを行って obj_foo で終わる100件の結果を受け取った場合、後続の呼び出しに starting_after=obj_foo を含めることで、リストの次のページを取得できます。 |
expand[] | 文字列の配列 | レスポンス内のどのフィールドを展開するかを指定します。 |