# 認証コンバージョンのクエリー

Stripe Sigma で、使用されている認証、コンバージョン、 SCA 免除に関する情報を取得します。

Sigma スキーマの **Analytics Tables (分析テーブル)** セクションの `authentication_report_attempts` テーブルをご確認ください。`authentication_report_attempts` テーブルの各行は、個々の試行オブジェクトに関するデータを表しています。Stripe の[ドキュメントページ](https://dashboard.stripe.com/stripe-schema?tableName=authentication_report_attempts)には、分割表示形式のスキーマも示されています。

## 試行コンバージョンに関する情報

複数回の試行を含む可能性のある [PaymentIntent](https://docs.stripe.com/api/payment_intents.md) または [SetupIntent](https://docs.stripe.com/api/payment_intents.md) のそれぞれから、すべての試行に関するレポートを取得できます。

> 拒否された支払いが再試行された場合など、単一の取引に対して複数回の試行が行われることがあります。特定の取引にフィルタリングするには、`is_final_attempt` 列を使用します。この列は数日後に最終的に構成されます。

次のクエリー例では、`authentication_report_attempts`テーブルを使用して、チャレンジフローで正常に認証された PaymentIntents のリストを取得します。

```sql
select
  attempt_id,
  intent_id,
  payment_method,
  threeds_reason as step_up_reason,
  charge_outcome
from authentication_report_attempts
where intent_type = 'payment'
  and threeds_outcome_result = 'authenticated'
  and authentication_flow = 'challenge'
  and is_final_attempt
limit 5
```

| attempt_id | intent_id | payment_method | step_up_reason | charge_outcome |
| --- | --- | --- | --- | --- |
| payatt_1IRdZ9F… | pi_1Hn8d… | card_charge | requested_by_radar_rule | authorized |
| payatt_1I4AFxF… | pi_1J8Ljt… | card_charge | requested_by_radar_rule | authorized |
| payatt_1HvmxU… | pi_1HhsH… | card_charge | requested_by_radar_rule | authorized |
| payatt_1I5npGF… | pi_1IdKak… | card_charge | requested_by_radar_rule | authorized |
| payatt_1HcbWZ… | pi_1IAhBh… | card_charge | requested_by_radar_rule | authorized |

## SCA 免除の情報

Stripe または発行会社/銀行が使用している *SCA 免除* (Some transactions that are deemed low risk, based on the volume of fraud rates associated with the payment provider or bank, may be exempt from Europe's Strong Customer Authentication requirements)に関する情報もクエリーできます。[強力な顧客認証の免除](https://stripe.com/guides/strong-customer-authentication#exemptions-to-strong-customer-authentication)をご覧ください。

次のクエリーは、リクエストされた免除とは関係のない理由で拒否された低リスクの*オーソリへの転送* (Where Stripe requests an SCA exemption as part of the authorization message)が使用された  SCA 免除の支払いを示しています。

```sql
select
  attempt_id,
  intent_id,
  charge_outcome,
  charge_outcome_reason
from authentication_report_attempts
where intent_type = 'payment'
  and sca_exemption_requested = 'low_risk'
  and sca_exemption_mechanism = 'authorization' -- direct to authorization
  and sca_exemption_status = 'non_sca_decline'
  and is_final_attempt
limit 5
```

| attempt_id | intent_id | charge_outcome | charge_outcome_reason |
| --- | --- | --- | --- |
| payatt_3JeL… | pi_3JeL… | issuer_declined | insufficient_funds |
| payatt_1Itw… | pi_1Itw… | issuer_declined | do_not_honor |
| payatt_1Ini3… | pi_1Ini3… | issuer_declined | do_not_honor |
| payatt_1IiO7… | pi_1IiO7… | issuer_declined | do_not_honor |
| payatt_1I0hGm… | pi_1I0hGk… | issuer_declined | insufficient_funds |

## 重複排除の影響

次のクエリは、`is_final_attempt` によって重複を排除すると設定の認証率の計算にどのような影響が生じるかを示しています。

> Stripe の重複排除ロジックでは、同じ `customer_id`、`currency`、`amount` で拒否された支払いのグループ (場合によっては最後のものを除く) が時間的に近くに表示されていないか確認します。このようなグループは、コンバージョン計算で単一の単位として扱われます。Sigma テーブルには、すべての未加工データが含まれていますが、各グループの代表的な取引にフィルタリングするために使用できる `is_final_attempt` 列も含まれています。

```sql
with setup_attempts as (
  select
    created,
    is_final_attempt,
    threeds_outcome_result in (
      'attempt_acknowledged',
      'authenticated',
      'delegated',
      'exempted'
    ) as threeds_succeeded
  from authentication_report_attempts
  where created between date'2021-10-29' and date'2021-11-03'
    and intent_type = 'setup'
    and is_threeds_triggered
)
select
  date_trunc('day', created) as day,
  1.0 * count_if(threeds_succeeded)
    / count(*) as authentication_rate__raw,
  2.0 * count_if(threeds_succeeded and is_final_attempt)
    / nullif(count_if(is_final_attempt), 0) as authentication_rate__deduped
from setup_attempts
group by 1
order by 1
```

| day | authentication_rate__raw | authentication_rate__deduped |
| --- | --- | --- |
| 2021-10-29 | 0.59 | 0.80 |
| 2021-10-30 | 0.60 | 0.81 |
| 2021-10-31 | 0.59 | 0.81 |
| 2021-11-01 | 0.61 | 0.83 |
| 2021-11-02 | 0.62 | 0.83 |
