# 返金の取引 Stripe Terminal の支払いをキャンセルまたは返金します。 Stripe Terminal は、*自動* (Automatically capture funds when a charge is authorized)と*手動* (Manually capture funds separately from an authorization)の両方のキャプチャーをサポートしています。 SDK が確定済みの PaymentIntent をアプリに返す時点で、支払いはオーソリされていますが、[キャプチャー](https://docs.stripe.com/terminal/payments/collect-card-payment.md#capture-payment)されていません。オーソリされてもキャプチャーされていない支払いは[キャンセル](https://docs.stripe.com/terminal/features/refunds.md#canceling-payments)できます。PaymentIntent がすでにキャプチャーされている場合は、その PaymentIntent によって作成された基になる支払いを [Refund API](https://docs.stripe.com/api.md#create_refund) または[ダッシュボード](https://docs.stripe.com/refunds.md?dashboard-or-api=dashboard)を使用して[返金](https://docs.stripe.com/terminal/features/refunds.md#refunds)する必要があります。 意図しないオーソリや売上の未収を防ぐため、1 日の終わりにバックエンドで[支払いを照合](https://docs.stripe.com/terminal/payments/collect-card-payment.md#reconciling)することをお勧めします。 ## 利用状況 **支払いのキャンセル**は、Visa、Mastercard、アメリカン・エキスプレス、Discover、girocard で利用できます。[Interac](https://docs.stripe.com/terminal/payments/regional.md?integration-country=CA#interac-payments)、[eftpos](https://docs.stripe.com/terminal/payments/regional.md?integration-country=AU#eftpos-payments) などの単一メッセージの支払い方法では、PaymentIntents が自動的にキャプチャーされます。PaymentIntents をキャンセルする代わりに、お客様のアプリケーションで、決済フローの最後に返金の開始を許可するようにしてください。 **オンラインの返金**は、Interac を除くすべてのカードネットワークで利用できます。 [対面での返金](https://docs.stripe.com/terminal/payments/regional.md?integration-country=CA#refund-an-interac-payment)は、Interac でのみ利用できます。 ## 支払いをキャンセルする (クライアント側)(サーバー側) - [cancelPaymentIntent (iOS)](https://stripe.dev/stripe-terminal-ios/docs/Classes/SCPTerminal.html#/c:objc\(cs\)SCPTerminal\(im\)cancelPaymentIntent:completion:) - [cancelPaymentIntent (Android)](https://stripe.dev/stripe-terminal-android/core/com.stripe.stripeterminal/-terminal/cancel-payment-intent.html) - [cancelPaymentIntent (React Native)](https://stripe.dev/stripe-terminal-react-native/api-reference/interfaces/StripeTerminalSdkType.html#cancelPaymentIntent) - [cancelPaymentIntent (Java)](https://stripe.dev/stripe-terminal-java/core/com.stripe.stripeterminal/-terminal/cancel-payment-intent.html) `card_present` PaymentIntent はキャプチャーされる前であれば、いつでも[キャンセル](https://docs.stripe.com/api.md#cancel_payment_intent)できます。PaymentIntent をキャンセルすると、キャプチャーされていないすべての売上がリリースされ、キャンセルされた PaymentIntent は支払いの実行に使用できなくなります。 これは例えば、支払いが処理された後で、顧客が別の決済手段を使用したり、現金で支払うことを決めた場合に行います。アプリケーションの UI で、ユーザーが[支払いを確定](https://docs.stripe.com/terminal/payments/collect-card-payment.md#confirm-payment)した後にキャンセルできるように、支払いの確定とバックエンドへの[キャプチャー](https://docs.stripe.com/terminal/payments/collect-card-payment.md#capture-payment)の通知を遅らせることを検討してください。 #### クライアント側 iOS、Android、または React Native SDK を使用して、クライアントから `PaymentIntent` をキャンセルします。 # サーバー主導型 > This is a サーバー主導型 for when terminal-sdk-platform is server-driven. View the full page at https://docs.stripe.com/terminal/features/refunds?terminal-sdk-platform=server-driven. > クライアント側での `PaymentIntent` のキャンセルは、iOS、Android、React Native の SDK を使用して実行できます。サーバー主導で連携している場合は、サーバー側で `PaymentIntent` をキャンセルします。 # JavaScript > This is a JavaScript for when terminal-sdk-platform is js. View the full page at https://docs.stripe.com/terminal/features/refunds?terminal-sdk-platform=js. > クライアント側での `PaymentIntent` のキャンセルは、その他のクライアント SDK を使用して実行できます。Stripe Terminal に JavaScript SDK を使用している場合は、サーバー側で `PaymentIntent` をキャンセルします。 # iOS > This is a iOS for when terminal-sdk-platform is ios. View the full page at https://docs.stripe.com/terminal/features/refunds?terminal-sdk-platform=ios. #### Swift ```swift // Action for a "Cancel" button func cancelAction() { if let paymentIntent = self.paymentIntent { Terminal.shared.cancelPaymentIntent(paymentIntent) { cancelResult, cancelError in if let error = cancelError { print("cancelPaymentIntent failed: \(error)") } else { print("cancelPaymentIntent succeeded") } } } } ``` # Android > This is a Android for when terminal-sdk-platform is android. View the full page at https://docs.stripe.com/terminal/features/refunds?terminal-sdk-platform=android. #### Kotlin ```kotlin Terminal.getInstance().cancelPaymentIntent(paymentIntent, object : PaymentIntentCallback { override fun onSuccess(paymentIntent: PaymentIntent) { // Placeholder for handling successful operation } override fun onFailure(e: TerminalException) { // Placeholder for handling exception } } ) ``` # React Native > This is a React Native for when terminal-sdk-platform is react-native. View the full page at https://docs.stripe.com/terminal/features/refunds?terminal-sdk-platform=react-native. ```js const { cancelPaymentIntent } = useStripeTerminal(); const { paymentIntent, error } = await cancelPaymentIntent(paymentIntent); if (error) { // Placeholder for handling exception return; } // Placeholder for handling successful operation ``` #### サーバー側 - [PaymentIntent をキャンセルする](https://docs.stripe.com/api/payment_intents/cancel.md) JavaScript SDK とサーバー主導型の連携では、サーバーで `PaymentIntent` をキャンセルする必要があります。その他のクライアント SDK で、アプリですぐに支払いの開始に必要な情報を利用できないときは、サーバーで `PaymentIntent` をキャンセルできます。 ```curl curl -X POST https://api.stripe.com/v1/payment_intents/pi_ANipwO3zNfjeWODtRPIg/cancel \ -u "<>:" ``` ## 返金を実行する (Server-side) 顧客からの支払いの回収に PaymentIntent を使用するときに、Stripe は [Charge (支払い)](https://docs.stripe.com/api/charges/object.md) をバックグラウンドで作成します。PaymentIntent が正常に完了した後に顧客の支払いを返金するには、PaymentIntent ID または支払い ID を渡して[返金を作成](https://docs.stripe.com/api.md#create_refund)します。必要に応じて、金額を指定して支払いの一部を返金することもできます。 返金は、[API](https://docs.stripe.com/refunds.md?dashboard-or-api=api) でも[ダッシュボード](https://docs.stripe.com/refunds.md?dashboard-or-api=dashboard)でも実行できます。カナダの Interac 取引では、BBPOS WisePad 3、BBPOS WisePOS E、Stripe Reader S700/S710、iPhone のタッチ決済、または Android のタッチ決済での[対面返金](https://docs.stripe.com/terminal/payments/regional.md?integration-country=CA#refund-an-interac-payment)が可能です。 オンラインの返金では、カード保有者が店舗で再度カードを提示する必要はありません。以下の例は、PaymentIntent ID を渡して全額の返金を作成する方法を示したものです。 ```curl curl https://api.stripe.com/v1/refunds \ -u "<>:" \ -d payment_intent=pi_Aabcxyz01aDfoo ``` PaymentIntent の一部を返金するには、セント単位の整数で (または支払い通貨の最小単位で)、`amount` パラメーターを指定します。 ```curl curl https://api.stripe.com/v1/refunds \ -u "<>:" \ -d payment_intent=pi_Aabcxyz01aDfoo \ -d amount=1000 ``` ## See also - [カートの表示](https://docs.stripe.com/terminal/features/display.md) - [領収書](https://docs.stripe.com/terminal/features/receipts.md)