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 Android SDK はオープンソースであり、詳細なドキュメントが提供されています。
To install the SDK, add stripe-android
to the dependencies
block of your app/build.gradle file:
注
SDK の最新リリースおよび過去バージョンの詳細については、GitHub の Releases ページをご覧ください。新しいリリースの公開時に通知を受け取るには、リポジトリのリリースを確認してください。
Stripe の公開可能キーを使用して SDK を設定し、 Application
サブクラスなどで、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.
クライアント側
返される PaymentIntent には client secret が含まれています。これは、PaymentIntent オブジェクト全体を渡すことなく安全に決済を完了するために、クライアント側で使用されます。クライアント側で、サーバーに PaymentIntent をリクエストし、その client secret を保存します。
Stripe に支払いを送信するクライアント側
ステップ 2 で作成した PaymentIntent から client secret を取得し、PaymentLauncher confirm メソッドを呼び出します。これにより、Webview が表示され、顧客は支払いを完了できます。完了後、支払い結果とともに、onActivityResult が呼び出されます。
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 を使用しようとしたときに予期しないエラーが発生しました |