Klarna による支払い方法を受け付ける
世界で普及している後払いの支払い方法である Klarna を受け付ける方法をご紹介します。
Unified line items with Klarna
To optimize approval rates when you integrate with Klarna, include line_
data to represent what’s in a shopper’s cart. For early access, see Payments line items.
顧客がアプリで Klarna を受け付ける際に、顧客が支払いを認証するための Webview が表示されます。その後、顧客はアプリに戻り、お客様は支払いが成功したか失敗したかをすぐに確認できます。
注
導入を開始する前に、支払い方法の設定に移動して、アカウントで Klarna が使用可能であることを確認してください。
Stripe を設定するサーバ側クライアント側
まず、Stripe アカウントが必要です。今すぐ登録してください。
サーバ側
この組み込みには、サーバ上に Stripe API と通信するエンドポイントが必要です。サーバから Stripe API にアクセスするには、Stripe の公式ライブラリを使用します。
クライアント側
Stripe iOS SDK はオープンソースです。詳細なドキュメントが提供されており、iOS 13 以降をサポートするアプリと互換性があります。
注
For details on the latest SDK release and past versions, see the Releases page on GitHub. To receive notifications when a new release is published, watch releases for the repository.
アプリの起動時に Stripe 公開可能キーを使用して SDK を設定します。これにより、アプリが Stripe API にリクエストを送信できるようになります。
PaymentIntent を作成するサーバー側クライアント側
A PaymentIntent is an object that represents your intent to collect payment from a customer and tracks the lifecycle of the payment process through each stage.
サーバー側
First, create a PaymentIntent
on your server and specify the amount to collect and the currency. If you already have an integration using the Payment Intents API, add klarna
to the list of payment method types for your PaymentIntent
.
クライアント側
返される PaymentIntent には client secret が含まれています。これは、PaymentIntent オブジェクト全体を渡すことなく安全に決済を完了するために、クライアント側で使用されます。クライアント側で、サーバーに PaymentIntent をリクエストし、その client secret を保存します。
Stripe に支払いを送信するクライアント側
ステップ 2 で作成した PaymentIntent から client secret を取得し、STPPaymentHandler confirmPayment: メソッドを呼び出します。これにより WebView が表示され、顧客はここで支払いを完了します。それによって支払い結果を含む完了ブロックの呼び出しが開始されます。
Klarna の組み込みをテストする
Below, we have specially selected test data for the currently supported customer countries. In a sandbox, Klarna approves or denies a transaction based on the supplied email address.
2 段階認証
6 桁の数字であれば、2 段階認証コードとして有効です。999999
を使用すると、認証は失敗します。
返済方法
Klarna のフロー内では、以下のテスト値を使用し、さまざまな返済方法を試すことができます。
タイプ | 値 |
---|---|
口座引き落とし | DE11520513735120710131 |
銀行振込 | デモの銀行 |
クレジットカード |
|
Debit Card |
|
失敗した支払い
Klarna は、取引を受け付けるか拒否するかを決定する際に複数の要因を考慮します (買い手が Klarna を使用している期間、顧客が返済する必要のある未払い額、現在の注文の金額など)。
When the customer selects a deferred payment method, Klarna performs a risk assessment before accepting the transaction. Klarna might decline the transaction due to unsatisfactory risk assessment result, the transaction amount involved, or the customer having a large outstanding debt. As such, we recommend that you present additional payment options such as card
in your checkout flow. In these cases, the PaymentMethod is detached and the PaymentIntent object’s status automatically transitions to requires_
.
Customers are expected to complete the payment within 48 hours after they’re redirected to the Klarna site. If no action is taken after 48 hours, the PaymentMethod is detached and the PaymentIntent object’s status automatically transitions from requires_
to requires_
.
このようなケースでは、決済フローに表示される別の支払いオプションで再試行するように顧客に通知します。
Klarna のレート制限
API requests to Klarna are subject to additional rate limits beyond Stripe’s API-wide rate limits. These limits can differ depending on the shape of the API requests that you make. In general, if you make more than around 360 requests per minute, you may see some rate limiting in the form of responses with HTTP status code 400
or 402
. Please contact us for more details if you’re concerned that your usage may reach these levels, as Klarna may be able to increase these limits on a case by case basis.
エラーメッセージ
Failed Klarna payments normally return one of the following failure codes. These codes show in the last_payment_error API object.
注意
Before the 2023-08-16
API version, every Klarna error reported as payment_intent_authentication_failure. Make sure your API version is up to date to see the detailed errors listed below.
エラーコード | 説明 |
---|---|
payment_method_customer_decline | 顧客が Klarna のページで購入をキャンセルしました |
payment_method_provider_decline | Klarna が顧客の支払いを拒否しました |
payment_intent_payment_attempt_expired | 顧客が Klarna のページで購入を完了しないまま、支払いセッションの有効期限が切れました |
payment_method_not_available | Klarna を使用しようとしたときに予期しないエラーが発生しました |