Skip to content

Chargeback monitoring and merchant risk scoring, in Spark.

Every merchant’s chargeback ratio held against monitoring bands, and every merchant scored for chargeback and fraud risk on the 1st. Saved SQL and one scheduled Spark job over your own storage, on a Kubernetes cluster you operate.

Same merchant.
0.1, then 0.55.

chargeback_risk_score of MCH-00000003 at each run of payments-monthly-risk, from the 90 days before it

merchant_risk_scoresMCH-00000003

chargeback_ratio_90d
0.46%1.13%1.6%1.38%0.88%0.44%
Run of1 Jun1 Jul1 Aug1 Sep1 Oct1 Novchargeback_count_90d410141284chargeback_risk_score0.10.550.550.550.250.1

Merchant risk scoring with a monthly Spark job

At 06:00 on the 1st, payments-monthly-risk reads each active merchant’s 90 days before that morning and writes a chargeback and a fraud score into merchant_risk_scores. A dispute counts while it sits in that window, then drops out.

Run of
Merchant

disputes filed

transactions per day

disputes filed

transactions per day

disputes filed

transactions per day

disputes filed
  • DSP-0000000387 chargeback 13.1 24 Apr
  • DSP-0000001184 chargeback 13.1 21 May
  • DSP-0000000834 chargeback 13.1 27 May
  • DSP-0000001286 chargeback 13.1 31 May
  • DSP-0000001164 chargeback 13.1 5 Jun
  • DSP-0000001346 chargeback 13.1 11 Jun
  • DSP-0000001514 chargeback 13.1 14 Jun
  • DSP-0000001084 chargeback 13.1 16 Jun
  • DSP-0000001369 chargeback 13.1 21 Jun
  • DSP-0000000653 chargeback 13.1 26 Jun
  • DSP-0000001083 chargeback 13.1 3 Jul
  • DSP-0000000104 chargeback 13.1 12 Jul
  • DSP-0000001347 chargeback 13.1 14 Jul
  • DSP-0000000139 chargeback 13.1 16 Jul
  • DSP-0000000109 chargeback 13.1 24 Jul
  • DSP-0000001335 chargeback 13.1 26 Aug
  • DSP-0000000537 chargeback 13.1 2 Sep
  • DSP-0000000021 chargeback 13.1 17 Sep
  • DSP-0000001281 chargeback 10.4 18 Oct
disputes filed
  • DSP-0000001046 chargeback 13.1 21 Mar
  • DSP-0000001126 arbitration 10.4 7 Apr
  • DSP-0000000143 chargeback 10.4 29 Jun
  • DSP-0000000892 chargeback 13.2 18 Jul
  • DSP-0000001317 chargeback 10.5 18 Jul
  • DSP-0000001459 chargeback 10.4 13 Aug
  • DSP-0000001440 chargeback 10.4 18 Aug
  • DSP-0000000461 chargeback 10.4 22 Aug
  • DSP-0000000832 retrieval_request 10.4 24 Aug
  • DSP-0000001071 chargeback 10.4 25 Aug
  • DSP-0000001405 chargeback 10.4 31 Aug
  • DSP-0000001694 chargeback 10.4 7 Sep
  • DSP-0000001304 chargeback 10.4 14 Sep
  • DSP-0000001705 chargeback 10.4 17 Sep
  • DSP-0000001700 chargeback 10.4 20 Sep
  • DSP-0000000199 chargeback 10.4 23 Sep
  • DSP-0000000089 chargeback 10.4 24 Sep
  • DSP-0000001332 chargeback 10.4 26 Sep
  • DSP-0000000520 chargeback 13.3 28 Sep
  • DSP-0000000605 chargeback 10.4 28 Sep
  • DSP-0000001060 chargeback 10.4 29 Sep
  • DSP-0000000155 chargeback 10.4 30 Sep
  • DSP-0000001589 chargeback 10.4 30 Sep
  • DSP-0000000485 chargeback 10.4 2 Oct
  • DSP-0000000569 chargeback 10.4 4 Oct
  • DSP-0000000121 chargeback 10.4 5 Oct
  • DSP-0000001478 retrieval_request 10.4 7 Oct
  • DSP-0000000774 chargeback 13.6 9 Oct
  • DSP-0000000879 chargeback 10.4 10 Oct
  • DSP-0000000138 chargeback 10.4 18 Oct
  • DSP-0000000934 chargeback 10.4 19 Oct
  • DSP-0000000426 chargeback 10.4 22 Oct
  • DSP-0000000166 chargeback 10.4 25 Oct
  • DSP-0000000416 chargeback 10.4 28 Oct
  • DSP-0000000406 chargeback 10.4 30 Oct
  • DSP-0000001732 chargeback 10.4 1 Nov
  • DSP-0000001349 chargeback 10.4 3 Nov
  • DSP-0000000363 chargeback 10.4 6 Nov
  • DSP-0000000967 chargeback 12.2 6 Nov
  • DSP-0000001177 chargeback 10.4 11 Nov
  • DSP-0000001719 pre_arbitration 10.1 12 Nov
  • DSP-0000001025 chargeback 10.4 13 Nov
  • DSP-0000001363 chargeback 10.4 14 Nov
  • DSP-0000000624 chargeback 10.4 21 Nov
  • DSP-0000001334 chargeback 10.4 24 Nov
  • DSP-0000001471 chargeback 10.4 25 Nov
disputes filednone from 3 Mar to 27 Nov

    merchant_risk_scoresscore_date = '2026-06-01'MCH-00000003

    written by the job

    txn_count_90d
    873
    chargeback_count_90d
    4
    chargeback_ratio_90d
    0.004582 (0.46%)
    declined_count_90d
    58
    chargeback_risk_score
    0.1
    fraud_risk_score
    0.11

    counted by the job, not kept

    refund_count_90d
    50
    offhours_txn_count_90d
    21
    ecommerce_count_90d
    377
    fraud_chargeback_count_90d
    0
    • chargeback_risk_score adds when
    • disputes over 1% of transactionsnot met
    • disputes over 0.5% of transactionsnot met
    • more than five fraud disputes (reason 10.4)not met
    • no dispute at all, which lowers the scorenot met
    • fraud_risk_score adds when
    • declined over 10%not met
    • refunds over 5%met
    • off-hours over 15%not met
    • e-commerce over 90%not met

    merchant_risk_scoresscore_date = '2026-07-01'MCH-00000003

    written by the job

    txn_count_90d
    884
    chargeback_count_90d
    10
    chargeback_ratio_90d
    0.011312 (1.13%)
    declined_count_90d
    56
    chargeback_risk_score
    0.55
    fraud_risk_score
    0.11

    counted by the job, not kept

    refund_count_90d
    46
    offhours_txn_count_90d
    18
    ecommerce_count_90d
    387
    fraud_chargeback_count_90d
    0
    • chargeback_risk_score adds when
    • disputes over 1% of transactionsmet
    • disputes over 0.5% of transactionsmet
    • more than five fraud disputes (reason 10.4)not met
    • no dispute at all, which lowers the scorenot met
    • fraud_risk_score adds when
    • declined over 10%not met
    • refunds over 5%met
    • off-hours over 15%not met
    • e-commerce over 90%not met

    merchant_risk_scoresscore_date = '2026-08-01'MCH-00000003

    written by the job

    txn_count_90d
    876
    chargeback_count_90d
    14
    chargeback_ratio_90d
    0.015982 (1.6%)
    declined_count_90d
    59
    chargeback_risk_score
    0.55
    fraud_risk_score
    0.11

    counted by the job, not kept

    refund_count_90d
    48
    offhours_txn_count_90d
    21
    ecommerce_count_90d
    388
    fraud_chargeback_count_90d
    0
    • chargeback_risk_score adds when
    • disputes over 1% of transactionsmet
    • disputes over 0.5% of transactionsmet
    • more than five fraud disputes (reason 10.4)not met
    • no dispute at all, which lowers the scorenot met
    • fraud_risk_score adds when
    • declined over 10%not met
    • refunds over 5%met
    • off-hours over 15%not met
    • e-commerce over 90%not met

    merchant_risk_scoresscore_date = '2026-09-01'MCH-00000003

    written by the job

    txn_count_90d
    872
    chargeback_count_90d
    12
    chargeback_ratio_90d
    0.013761 (1.38%)
    declined_count_90d
    62
    chargeback_risk_score
    0.55
    fraud_risk_score
    0.11

    counted by the job, not kept

    refund_count_90d
    47
    offhours_txn_count_90d
    24
    ecommerce_count_90d
    401
    fraud_chargeback_count_90d
    0
    • chargeback_risk_score adds when
    • disputes over 1% of transactionsmet
    • disputes over 0.5% of transactionsmet
    • more than five fraud disputes (reason 10.4)not met
    • no dispute at all, which lowers the scorenot met
    • fraud_risk_score adds when
    • declined over 10%not met
    • refunds over 5%met
    • off-hours over 15%not met
    • e-commerce over 90%not met

    merchant_risk_scoresscore_date = '2026-10-01'MCH-00000003

    written by the job

    txn_count_90d
    913
    chargeback_count_90d
    8
    chargeback_ratio_90d
    0.008762 (0.88%)
    declined_count_90d
    75
    chargeback_risk_score
    0.25
    fraud_risk_score
    0.11

    counted by the job, not kept

    refund_count_90d
    54
    offhours_txn_count_90d
    23
    ecommerce_count_90d
    406
    fraud_chargeback_count_90d
    0
    • chargeback_risk_score adds when
    • disputes over 1% of transactionsnot met
    • disputes over 0.5% of transactionsmet
    • more than five fraud disputes (reason 10.4)not met
    • no dispute at all, which lowers the scorenot met
    • fraud_risk_score adds when
    • declined over 10%not met
    • refunds over 5%met
    • off-hours over 15%not met
    • e-commerce over 90%not met

    merchant_risk_scoresscore_date = '2026-11-01'MCH-00000003

    written by the job

    txn_count_90d
    904
    chargeback_count_90d
    4
    chargeback_ratio_90d
    0.004425 (0.44%)
    declined_count_90d
    71
    chargeback_risk_score
    0.1
    fraud_risk_score
    0.05

    counted by the job, not kept

    refund_count_90d
    44
    offhours_txn_count_90d
    16
    ecommerce_count_90d
    412
    fraud_chargeback_count_90d
    1
    • chargeback_risk_score adds when
    • disputes over 1% of transactionsnot met
    • disputes over 0.5% of transactionsnot met
    • more than five fraud disputes (reason 10.4)not met
    • no dispute at all, which lowers the scorenot met
    • fraud_risk_score adds when
    • declined over 10%not met
    • refunds over 5%not met
    • off-hours over 15%not met
    • e-commerce over 90%not met

    merchant_risk_scoresscore_date = '2026-06-01'MCH-00000074

    written by the job

    txn_count_90d
    895
    chargeback_count_90d
    2
    chargeback_ratio_90d
    0.002235 (0.22%)
    declined_count_90d
    58
    chargeback_risk_score
    0.1
    fraud_risk_score
    0.11

    counted by the job, not kept

    refund_count_90d
    51
    offhours_txn_count_90d
    19
    ecommerce_count_90d
    382
    fraud_chargeback_count_90d
    1
    • chargeback_risk_score adds when
    • disputes over 1% of transactionsnot met
    • disputes over 0.5% of transactionsnot met
    • more than five fraud disputes (reason 10.4)not met
    • no dispute at all, which lowers the scorenot met
    • fraud_risk_score adds when
    • declined over 10%not met
    • refunds over 5%met
    • off-hours over 15%not met
    • e-commerce over 90%not met

    merchant_risk_scoresscore_date = '2026-07-01'MCH-00000074

    written by the job

    txn_count_90d
    876
    chargeback_count_90d
    2
    chargeback_ratio_90d
    0.002283 (0.23%)
    declined_count_90d
    59
    chargeback_risk_score
    0.1
    fraud_risk_score
    0.11

    counted by the job, not kept

    refund_count_90d
    46
    offhours_txn_count_90d
    20
    ecommerce_count_90d
    374
    fraud_chargeback_count_90d
    2
    • chargeback_risk_score adds when
    • disputes over 1% of transactionsnot met
    • disputes over 0.5% of transactionsnot met
    • more than five fraud disputes (reason 10.4)not met
    • no dispute at all, which lowers the scorenot met
    • fraud_risk_score adds when
    • declined over 10%not met
    • refunds over 5%met
    • off-hours over 15%not met
    • e-commerce over 90%not met

    merchant_risk_scoresscore_date = '2026-08-01'MCH-00000074

    written by the job

    txn_count_90d
    879
    chargeback_count_90d
    3
    chargeback_ratio_90d
    0.003413 (0.34%)
    declined_count_90d
    55
    chargeback_risk_score
    0.1
    fraud_risk_score
    0.11

    counted by the job, not kept

    refund_count_90d
    51
    offhours_txn_count_90d
    20
    ecommerce_count_90d
    399
    fraud_chargeback_count_90d
    1
    • chargeback_risk_score adds when
    • disputes over 1% of transactionsnot met
    • disputes over 0.5% of transactionsnot met
    • more than five fraud disputes (reason 10.4)not met
    • no dispute at all, which lowers the scorenot met
    • fraud_risk_score adds when
    • declined over 10%not met
    • refunds over 5%met
    • off-hours over 15%not met
    • e-commerce over 90%not met

    merchant_risk_scoresscore_date = '2026-09-01'MCH-00000074

    written by the job

    txn_count_90d
    867
    chargeback_count_90d
    9
    chargeback_ratio_90d
    0.010381 (1.04%)
    declined_count_90d
    53
    chargeback_risk_score
    0.67
    fraud_risk_score
    0.11

    counted by the job, not kept

    refund_count_90d
    50
    offhours_txn_count_90d
    20
    ecommerce_count_90d
    390
    fraud_chargeback_count_90d
    7
    • chargeback_risk_score adds when
    • disputes over 1% of transactionsmet
    • disputes over 0.5% of transactionsmet
    • more than five fraud disputes (reason 10.4)met
    • no dispute at all, which lowers the scorenot met
    • fraud_risk_score adds when
    • declined over 10%not met
    • refunds over 5%met
    • off-hours over 15%not met
    • e-commerce over 90%not met

    merchant_risk_scoresscore_date = '2026-10-01'MCH-00000074

    written by the job

    txn_count_90d
    900
    chargeback_count_90d
    20
    chargeback_ratio_90d
    0.022222 (2.22%)
    declined_count_90d
    52
    chargeback_risk_score
    0.67
    fraud_risk_score
    0.11

    counted by the job, not kept

    refund_count_90d
    59
    offhours_txn_count_90d
    23
    ecommerce_count_90d
    400
    fraud_chargeback_count_90d
    17
    • chargeback_risk_score adds when
    • disputes over 1% of transactionsmet
    • disputes over 0.5% of transactionsmet
    • more than five fraud disputes (reason 10.4)met
    • no dispute at all, which lowers the scorenot met
    • fraud_risk_score adds when
    • declined over 10%not met
    • refunds over 5%met
    • off-hours over 15%not met
    • e-commerce over 90%not met

    merchant_risk_scoresscore_date = '2026-11-01'MCH-00000074

    written by the job

    txn_count_90d
    881
    chargeback_count_90d
    30
    chargeback_ratio_90d
    0.034052 (3.41%)
    declined_count_90d
    55
    chargeback_risk_score
    0.67
    fraud_risk_score
    0.11

    counted by the job, not kept

    refund_count_90d
    53
    offhours_txn_count_90d
    20
    ecommerce_count_90d
    384
    fraud_chargeback_count_90d
    28
    • chargeback_risk_score adds when
    • disputes over 1% of transactionsmet
    • disputes over 0.5% of transactionsmet
    • more than five fraud disputes (reason 10.4)met
    • no dispute at all, which lowers the scorenot met
    • fraud_risk_score adds when
    • declined over 10%not met
    • refunds over 5%met
    • off-hours over 15%not met
    • e-commerce over 90%not met

    merchant_risk_scoresscore_date = '2026-06-01'MCH-00000090

    written by the job

    txn_count_90d
    938
    chargeback_count_90d
    0
    chargeback_ratio_90d
    0 (0%)
    declined_count_90d
    74
    chargeback_risk_score
    0.0
    fraud_risk_score
    0.11

    counted by the job, not kept

    refund_count_90d
    52
    offhours_txn_count_90d
    28
    ecommerce_count_90d
    403
    fraud_chargeback_count_90d
    0
    • chargeback_risk_score adds when
    • disputes over 1% of transactionsnot met
    • disputes over 0.5% of transactionsnot met
    • more than five fraud disputes (reason 10.4)not met
    • no dispute at all, which lowers the scoremet
    • fraud_risk_score adds when
    • declined over 10%not met
    • refunds over 5%met
    • off-hours over 15%not met
    • e-commerce over 90%not met

    merchant_risk_scoresscore_date = '2026-07-01'MCH-00000090

    written by the job

    txn_count_90d
    934
    chargeback_count_90d
    0
    chargeback_ratio_90d
    0 (0%)
    declined_count_90d
    75
    chargeback_risk_score
    0.0
    fraud_risk_score
    0.11

    counted by the job, not kept

    refund_count_90d
    60
    offhours_txn_count_90d
    18
    ecommerce_count_90d
    411
    fraud_chargeback_count_90d
    0
    • chargeback_risk_score adds when
    • disputes over 1% of transactionsnot met
    • disputes over 0.5% of transactionsnot met
    • more than five fraud disputes (reason 10.4)not met
    • no dispute at all, which lowers the scoremet
    • fraud_risk_score adds when
    • declined over 10%not met
    • refunds over 5%met
    • off-hours over 15%not met
    • e-commerce over 90%not met

    merchant_risk_scoresscore_date = '2026-08-01'MCH-00000090

    written by the job

    txn_count_90d
    906
    chargeback_count_90d
    0
    chargeback_ratio_90d
    0 (0%)
    declined_count_90d
    72
    chargeback_risk_score
    0.0
    fraud_risk_score
    0.11

    counted by the job, not kept

    refund_count_90d
    50
    offhours_txn_count_90d
    10
    ecommerce_count_90d
    399
    fraud_chargeback_count_90d
    0
    • chargeback_risk_score adds when
    • disputes over 1% of transactionsnot met
    • disputes over 0.5% of transactionsnot met
    • more than five fraud disputes (reason 10.4)not met
    • no dispute at all, which lowers the scoremet
    • fraud_risk_score adds when
    • declined over 10%not met
    • refunds over 5%met
    • off-hours over 15%not met
    • e-commerce over 90%not met

    merchant_risk_scoresscore_date = '2026-09-01'MCH-00000090

    written by the job

    txn_count_90d
    905
    chargeback_count_90d
    0
    chargeback_ratio_90d
    0 (0%)
    declined_count_90d
    68
    chargeback_risk_score
    0.0
    fraud_risk_score
    0.11

    counted by the job, not kept

    refund_count_90d
    55
    offhours_txn_count_90d
    3
    ecommerce_count_90d
    414
    fraud_chargeback_count_90d
    0
    • chargeback_risk_score adds when
    • disputes over 1% of transactionsnot met
    • disputes over 0.5% of transactionsnot met
    • more than five fraud disputes (reason 10.4)not met
    • no dispute at all, which lowers the scoremet
    • fraud_risk_score adds when
    • declined over 10%not met
    • refunds over 5%met
    • off-hours over 15%not met
    • e-commerce over 90%not met

    merchant_risk_scoresscore_date = '2026-10-01'MCH-00000090

    written by the job

    txn_count_90d
    909
    chargeback_count_90d
    0
    chargeback_ratio_90d
    0 (0%)
    declined_count_90d
    61
    chargeback_risk_score
    0.0
    fraud_risk_score
    0.05

    counted by the job, not kept

    refund_count_90d
    45
    offhours_txn_count_90d
    9
    ecommerce_count_90d
    406
    fraud_chargeback_count_90d
    0
    • chargeback_risk_score adds when
    • disputes over 1% of transactionsnot met
    • disputes over 0.5% of transactionsnot met
    • more than five fraud disputes (reason 10.4)not met
    • no dispute at all, which lowers the scoremet
    • fraud_risk_score adds when
    • declined over 10%not met
    • refunds over 5%not met
    • off-hours over 15%not met
    • e-commerce over 90%not met

    merchant_risk_scoresscore_date = '2026-11-01'MCH-00000090

    written by the job

    txn_count_90d
    924
    chargeback_count_90d
    0
    chargeback_ratio_90d
    0 (0%)
    declined_count_90d
    56
    chargeback_risk_score
    0.0
    fraud_risk_score
    0.11

    counted by the job, not kept

    refund_count_90d
    50
    offhours_txn_count_90d
    18
    ecommerce_count_90d
    417
    fraud_chargeback_count_90d
    0
    • chargeback_risk_score adds when
    • disputes over 1% of transactionsnot met
    • disputes over 0.5% of transactionsnot met
    • more than five fraud disputes (reason 10.4)not met
    • no dispute at all, which lowers the scoremet
    • fraud_risk_score adds when
    • declined over 10%not met
    • refunds over 5%met
    • off-hours over 15%not met
    • e-commerce over 90%not met

    Three large merchants through six monthly runs of the job, with every dispute filed against them. Pick a run and watch the window slide: the first one’s disputes reach 1.60% of its transactions on 1 August and are back at 0.44% on 1 November, the second one’s climb from 0.22% to 3.41%, the third has none. The rows are what the job wrote.
    The job and its schedule
    monthly_risk_scoring.py, the featuresSpark job payments-monthly-risk · PySpark
    txn_features = (read_table(spark, "transactions")
        .filter((F.col("event_date") >= lookback) & (F.col("event_date") < score_month))
        .withColumn("rate_date", F.trunc("event_date", "month"))
        .join(F.broadcast(rates), ["currency", "rate_date"], "left")
        .groupBy("merchant_id")
        .agg(
            F.count("*").alias("txn_count_90d"),
            F.sum(F.col("amount") * F.col("inverse_rate")).alias("txn_total_90d"),
            F.avg(F.col("amount") * F.col("inverse_rate")).alias("avg_txn_amount_90d"),
            F.sum(F.when(F.col("status") == "declined", 1).otherwise(0)).alias("declined_count_90d"),
            F.sum(F.when(F.col("transaction_type") == "refund", 1).otherwise(0)).alias("refund_count_90d"),
            F.sum(F.when((F.hour("event_timestamp") < 5) | (F.hour("event_timestamp") > 22), 1).otherwise(0)).alias("offhours_txn_count_90d"),
            F.countDistinct("country").alias("unique_countries_90d"),
            F.sum(F.when(F.col("channel") == "ecommerce", 1).otherwise(0)).alias("ecommerce_count_90d"),
            F.sum(F.col("processing_fee") * F.col("inverse_rate")).alias("total_fees_90d"),
        ))
    
    cb_features = (read_table(spark, "disputes")
        .filter((F.col("filed_date") >= lookback) & (F.col("filed_date") < score_month))
        .withColumn("rate_date", F.trunc("filed_date", "month"))
        .join(F.broadcast(rates), ["currency", "rate_date"], "left")
        .groupBy("merchant_id")
        .agg(
            F.count("*").alias("chargeback_count_90d"),
            F.sum(F.col("dispute_amount") * F.col("inverse_rate")).alias("chargeback_volume_90d"),
            F.sum(F.when(F.col("reason_code") == "10.4", 1).otherwise(0)).alias("fraud_chargeback_count_90d"),
        ))
    The schedule
    FieldValue
    namepayments-monthly-risk
    jobClassmonthly_risk_scoring.py
    cron0 6 1 * *
    maxRetries3
    tagsteam=risk, pipeline=ml-scoring, model=v1.2.0

    Chargeback ratio monitoring in SQL

    The chargeback ratio is the chargebacks of 90 days over the captured and settled purchases of the same 90 days. Chargeback Monitoring measures a merchant from 500 such purchases, where one chargeback moves the ratio by 0.2 points at most.

    monitoring_status

    3 merchants at EXCEEDED - PROGRAM ENTRY

    • MCH-0000007434 chargebacks on 633 purchases5.37%2,767 more clean purchases to fall to 1%
    • MCH-000000068 chargebacks on 558 purchases1.43%242 more clean purchases to fall to 1%
    • MCH-000000299 chargebacks on 669 purchases1.35%231 more clean purchases to fall to 1%

    2 merchants at WARNING

    • MCH-000000686 chargebacks on 621 purchases0.97%
    • MCH-000000525 chargebacks on 659 purchases0.76%

    1 merchant at ELEVATED

    • MCH-000000033 chargebacks on 594 purchases0.51%

    44 merchants at NORMAL

    • MCH-000000183 chargebacks on 616 purchases0.49%
    • MCH-000000813 chargebacks on 634 purchases0.47%
    • MCH-000000873 chargebacks on 636 purchases0.47%
    • MCH-000000992 chargebacks on 602 purchases0.33%
    • MCH-000000172 chargebacks on 606 purchases0.33%
    • MCH-000000762 chargebacks on 612 purchases0.33%
    • MCH-000000212 chargebacks on 617 purchases0.32%
    • MCH-000000232 chargebacks on 627 purchases0.32%

    and 36 more

    The 50 merchants Chargeback Monitoring returns of the 78 it measures, placed by their chargeback rate against the query’s bands. Three are over the 1% line, the highest at 5.37%, 34 chargebacks on 633 purchases, which would need 2,767 more clean purchases in the same 90 days to fall back. Two sit at WARNING, one at ELEVATED, and the other 44 are NORMAL.
    The queries and the tables
    Chargeback MonitoringSaved query Payments/Compliance · Spark SQL
    -- name: Payments/Compliance/Chargeback Monitoring
    -- engine: SPARK_SQL
    -- maxRows: 1000
    -- description: Visa and Mastercard monitoring program thresholds per merchant with chargeback rate classification
    
    WITH merchant_txn_90d AS (
        SELECT
            t.merchant_id,
            COUNT(*) AS txn_count_90d,
            ROUND(SUM(t.amount * COALESCE(er.inverse_rate, 1.0)), 2) AS gross_volume_eur_90d
        FROM payment_processing.transactions t
        LEFT JOIN (
            SELECT currency, base_currency, rate, inverse_rate,
                   ROW_NUMBER() OVER (
                       PARTITION BY currency, base_currency
                       ORDER BY rate_date DESC
                   ) AS rn
            FROM payment_processing.exchange_rates
            WHERE base_currency = 'EUR'
        ) er
            ON t.currency = er.currency
            AND er.rn = 1
        WHERE t.status IN ('captured', 'settled')
          AND t.transaction_type = 'purchase'
          AND t.event_date >= DATE_ADD(CURRENT_DATE, -90)
        GROUP BY t.merchant_id
        -- a ratio is measured from 500 paid purchases in the 90 days: below that one chargeback moves it by 0.2 points or more
        HAVING COUNT(*) >= 500
    ),
    merchant_chargebacks_90d AS (
        SELECT
            d.merchant_id,
            COUNT(*) AS chargeback_count_90d,
            ROUND(SUM(d.dispute_amount), 2) AS chargeback_volume,
            SUM(CASE WHEN d.status = 'merchant_lost' THEN 1 ELSE 0 END) AS lost_count,
            SUM(CASE WHEN d.status = 'merchant_won' THEN 1 ELSE 0 END) AS won_count,
            COUNT(DISTINCT d.reason_code) AS distinct_reason_codes
        FROM payment_processing.disputes d
        WHERE d.dispute_type = 'chargeback'
          AND d.filed_date >= DATE_ADD(CURRENT_DATE, -90)
        GROUP BY d.merchant_id
    ),
    combined AS (
        SELECT
            m.merchant_id,
            m.merchant_name,
            m.country,
            m.mcc_description,
            m.segment,
            m.risk_category,
            mt.txn_count_90d,
            mt.gross_volume_eur_90d,
            COALESCE(mc.chargeback_count_90d, 0) AS chargeback_count_90d,
            COALESCE(mc.chargeback_volume, 0) AS chargeback_volume,
            COALESCE(mc.lost_count, 0) AS lost_count,
            COALESCE(mc.won_count, 0) AS won_count,
            COALESCE(mc.distinct_reason_codes, 0) AS distinct_reason_codes,
            ROUND(COALESCE(mc.chargeback_count_90d, 0) * 100.0 / NULLIF(mt.txn_count_90d, 0), 4) AS chargeback_rate_pct
        FROM payment_processing.merchants m
        INNER JOIN merchant_txn_90d mt
            ON m.merchant_id = mt.merchant_id
        LEFT JOIN merchant_chargebacks_90d mc
            ON m.merchant_id = mc.merchant_id
        WHERE m.status = 'active'
    )
    SELECT
        merchant_id,
        merchant_name,
        country,
        mcc_description,
        segment,
        risk_category,
        txn_count_90d,
        gross_volume_eur_90d,
        chargeback_count_90d,
        chargeback_volume,
        chargeback_rate_pct,
        lost_count,
        won_count,
        distinct_reason_codes,
        CASE
            WHEN chargeback_rate_pct > 1.0 THEN 'EXCEEDED - PROGRAM ENTRY'
            WHEN chargeback_rate_pct > 0.65 THEN 'WARNING'
            WHEN chargeback_rate_pct > 0.5  THEN 'ELEVATED'
            ELSE 'NORMAL'
        END AS monitoring_status,
        CASE
            WHEN chargeback_rate_pct > 1.0 THEN 'Immediate action: enter VDMP/ECM program'
            WHEN chargeback_rate_pct > 0.65 THEN 'Remediation plan required within 30 days'
            WHEN chargeback_rate_pct > 0.5  THEN 'Monitor closely, review fraud controls'
            ELSE 'No action required'
        END AS recommended_action
    FROM combined
    ORDER BY chargeback_rate_pct DESC
    LIMIT 50
    
    Merchant Chargeback Rate & Program ProximityNotebook Payments/Risk/Dispute Lifecycle Analysis · Spark SQL
    -- Merchant Chargeback Rate & Program Proximity
    -- Calculate 90-day chargeback rates and classify merchants by scheme program risk.
    
    WITH merchant_txns AS (
        SELECT
            t.merchant_id,
            m.merchant_name,
            m.country,
            m.segment,
            m.risk_category,
            COUNT(*) AS txn_count_90d,
            ROUND(SUM(t.amount * COALESCE(fx.inverse_rate, 1.0)), 2) AS txn_volume_90d_eur
        FROM payment_processing.transactions t
        INNER JOIN payment_processing.merchants m
            ON t.merchant_id = m.merchant_id
        LEFT JOIN payment_processing.exchange_rates fx
            ON t.currency = fx.currency
            AND fx.base_currency = 'EUR'
            AND fx.rate_date = trunc(t.event_date, 'MM')
        WHERE t.event_date >= date_sub(current_date(), 90)
          AND t.status IN ('captured', 'settled')
        GROUP BY t.merchant_id, m.merchant_name, m.country, m.segment, m.risk_category
        -- as in Chargeback Monitoring: a ratio is measured from 500 paid purchases in the 90 days
        HAVING COUNT(*) >= 500
    ),
    merchant_disputes AS (
        SELECT
            d.merchant_id,
            COUNT(*) AS chargeback_count_90d,
            ROUND(SUM(d.dispute_amount * COALESCE(fx.inverse_rate, 1.0)), 2) AS disputed_amount_eur,
            SUM(CASE WHEN d.status = 'merchant_lost' THEN 1 ELSE 0 END) AS lost_count,
            ROUND(SUM(
                CASE WHEN d.status = 'merchant_lost'
                THEN d.dispute_amount * COALESCE(fx.inverse_rate, 1.0)
                ELSE 0 END
            ), 2) AS net_loss_eur
        FROM payment_processing.disputes d
        LEFT JOIN payment_processing.exchange_rates fx
            ON d.currency = fx.currency
            AND fx.base_currency = 'EUR'
            AND fx.rate_date = trunc(d.filed_date, 'MM')
        WHERE d.filed_date >= date_sub(current_date(), 90)
          AND d.dispute_type = 'chargeback'
        GROUP BY d.merchant_id
    )
    SELECT
        mt.merchant_id,
        mt.merchant_name,
        mt.country,
        mt.segment,
        mt.risk_category,
        mt.txn_count_90d,
        mt.txn_volume_90d_eur,
        COALESCE(md.chargeback_count_90d, 0) AS chargeback_count_90d,
        ROUND(COALESCE(md.chargeback_count_90d, 0) * 100.0 / NULLIF(mt.txn_count_90d, 0), 3) AS chargeback_rate_pct,
        COALESCE(md.disputed_amount_eur, 0) AS disputed_amount_eur,
        COALESCE(md.net_loss_eur, 0) AS estimated_net_loss_eur,
        CASE
            WHEN COALESCE(md.chargeback_count_90d, 0) * 100.0 / NULLIF(mt.txn_count_90d, 0) > 1.0 THEN 'EXCEEDED'
            WHEN COALESCE(md.chargeback_count_90d, 0) * 100.0 / NULLIF(mt.txn_count_90d, 0) > 0.65 THEN 'WARNING'
            WHEN COALESCE(md.chargeback_count_90d, 0) * 100.0 / NULLIF(mt.txn_count_90d, 0) > 0.5 THEN 'ELEVATED'
            ELSE 'NORMAL'
        END AS program_status
    FROM merchant_txns mt
    LEFT JOIN merchant_disputes md
        ON mt.merchant_id = md.merchant_id
    WHERE COALESCE(md.chargeback_count_90d, 0) > 0
    ORDER BY chargeback_rate_pct DESC
    LIMIT 20
    Top Reason Codes with Win RatesNotebook Payments/Risk/Dispute Lifecycle Analysis · Spark SQL
    -- Top Reason Codes with Win Rates and Financial Impact
    -- Identify the most common dispute reasons and where merchants succeed in reversals.
    
    WITH reason_analysis AS (
        SELECT
            d.reason_code,
            d.reason_description,
            d.card_brand,
            COUNT(*) AS dispute_count,
            ROUND(SUM(d.dispute_amount * COALESCE(fx.inverse_rate, 1.0)), 2) AS total_disputed_eur,
            ROUND(AVG(d.dispute_amount * COALESCE(fx.inverse_rate, 1.0)), 2) AS avg_disputed_eur,
            SUM(CASE WHEN d.status = 'merchant_won' THEN 1 ELSE 0 END) AS won_count,
            SUM(CASE WHEN d.status = 'merchant_lost' THEN 1 ELSE 0 END) AS lost_count,
            SUM(CASE WHEN d.status = 'open' THEN 1 ELSE 0 END) AS pending_count,
            SUM(CASE WHEN d.liability_shift = 'issuer' THEN 1 ELSE 0 END) AS liability_shift_count
        FROM payment_processing.disputes d
        LEFT JOIN payment_processing.exchange_rates fx
            ON d.currency = fx.currency
            AND fx.base_currency = 'EUR'
            AND fx.rate_date = trunc(d.filed_date, 'MM')
        WHERE d.filed_date >= date_sub(current_date(), 180)
        GROUP BY d.reason_code, d.reason_description, d.card_brand
    )
    SELECT
        reason_code,
        reason_description,
        card_brand,
        dispute_count,
        total_disputed_eur,
        avg_disputed_eur,
        won_count,
        lost_count,
        pending_count,
        ROUND(won_count * 100.0 / NULLIF(won_count + lost_count, 0), 1) AS win_rate_pct,
        liability_shift_count,
        CASE
            WHEN LOWER(reason_description) LIKE '%fraud%' OR LOWER(reason_description) LIKE '%unauthorized%' THEN 'FRAUD'
            WHEN LOWER(reason_description) LIKE '%not received%' OR LOWER(reason_description) LIKE '%defective%' THEN 'SERVICE'
            WHEN LOWER(reason_description) LIKE '%duplicate%' OR LOWER(reason_description) LIKE '%incorrect%' THEN 'PROCESSING'
            ELSE 'OTHER'
        END AS reason_category
    FROM reason_analysis
    ORDER BY dispute_count DESC
    Dispute Overview by Type and StatusNotebook Payments/Risk/Dispute Lifecycle Analysis · Spark SQL
    -- Dispute Overview by Type and Status
    -- Summary of all disputes with resolution timing and merchant win rates.
    
    WITH dispute_metrics AS (
        SELECT
            d.dispute_type,
            d.status,
            COUNT(*) AS dispute_count,
            ROUND(AVG(
                CASE
                    WHEN d.resolved_date IS NOT NULL
                    THEN DATEDIFF(d.resolved_date, d.filed_date)
                    ELSE NULL
                END
            ), 1) AS avg_resolution_days,
            ROUND(MIN(
                CASE
                    WHEN d.resolved_date IS NOT NULL
                    THEN DATEDIFF(d.resolved_date, d.filed_date)
                    ELSE NULL
                END
            ), 0) AS min_resolution_days,
            ROUND(MAX(
                CASE
                    WHEN d.resolved_date IS NOT NULL
                    THEN DATEDIFF(d.resolved_date, d.filed_date)
                    ELSE NULL
                END
            ), 0) AS max_resolution_days,
            ROUND(SUM(d.dispute_amount * COALESCE(fx.inverse_rate, 1.0)), 2) AS total_disputed_eur,
            SUM(CASE WHEN d.status = 'merchant_won' THEN 1 ELSE 0 END) AS merchant_wins
        FROM payment_processing.disputes d
        LEFT JOIN payment_processing.exchange_rates fx
            ON d.currency = fx.currency
            AND fx.base_currency = 'EUR'
            AND fx.rate_date = trunc(d.filed_date, 'MM')
        GROUP BY d.dispute_type, d.status
    )
    SELECT
        dispute_type,
        status,
        dispute_count,
        avg_resolution_days,
        min_resolution_days,
        max_resolution_days,
        total_disputed_eur,
        merchant_wins,
        ROUND(merchant_wins * 100.0 / NULLIF(dispute_count, 0), 1) AS merchant_win_rate_pct
    FROM dispute_metrics
    ORDER BY dispute_type, dispute_count DESC
    Evidence and Response ImpactNotebook Payments/Risk/Dispute Lifecycle Analysis · Spark SQL
    -- Evidence and Response Impact on Dispute Outcomes
    -- Analyze how merchant response and evidence submission affect win rates.
    
    WITH evidence_analysis AS (
        SELECT
            CASE
                WHEN d.merchant_responded = true AND d.evidence_submitted IS NOT NULL
                    THEN d.evidence_submitted
                WHEN d.merchant_responded = true AND d.evidence_submitted IS NULL
                    THEN 'responded_no_evidence'
                ELSE 'no_response'
            END AS response_category,
            d.liability_shift,
            COUNT(*) AS dispute_count,
            SUM(CASE WHEN d.status = 'merchant_won' THEN 1 ELSE 0 END) AS won_count,
            SUM(CASE WHEN d.status = 'merchant_lost' THEN 1 ELSE 0 END) AS lost_count,
            ROUND(SUM(d.dispute_amount * COALESCE(fx.inverse_rate, 1.0)), 2) AS total_disputed_eur,
            ROUND(SUM(
                CASE WHEN d.status = 'merchant_lost'
                THEN d.dispute_amount * COALESCE(fx.inverse_rate, 1.0)
                ELSE 0 END
            ), 2) AS total_lost_eur
        FROM payment_processing.disputes d
        LEFT JOIN payment_processing.exchange_rates fx
            ON d.currency = fx.currency
            AND fx.base_currency = 'EUR'
            AND fx.rate_date = trunc(d.filed_date, 'MM')
        WHERE d.filed_date >= date_sub(current_date(), 180)
          AND d.status IN ('merchant_won', 'merchant_lost')
        GROUP BY
            CASE
                WHEN d.merchant_responded = true AND d.evidence_submitted IS NOT NULL
                    THEN d.evidence_submitted
                WHEN d.merchant_responded = true AND d.evidence_submitted IS NULL
                    THEN 'responded_no_evidence'
                ELSE 'no_response'
            END,
            d.liability_shift
    )
    SELECT
        response_category,
        liability_shift,
        dispute_count,
        won_count,
        lost_count,
        ROUND(won_count * 100.0 / NULLIF(won_count + lost_count, 0), 1) AS win_rate_pct,
        total_disputed_eur,
        total_lost_eur,
        ROUND(total_lost_eur * 100.0 / NULLIF(total_disputed_eur, 0), 1) AS loss_rate_pct
    FROM evidence_analysis
    ORDER BY win_rate_pct DESC
    payment_processing.disputesChargeback and dispute records. Tracks dispute lifecycle from filing through resolution including merchant response and liability assignment.
    dispute_idUnique dispute identifier (format: DSP-XXXXXXXXXX)
    transaction_idFK to transactions table (original disputed transaction)
    merchant_idFK to merchants table
    dispute_typeDispute category: chargeback, retrieval_request, pre_arbitration, arbitration
    reason_codeCard scheme reason code (e.g. 10.4 for CNP fraud)
    dispute_amountDisputed amount in local currency
    filed_dateDate dispute was filed by issuer
    resolved_dateDate dispute was resolved (null if still open)
    statusDispute outcome: open, merchant_won, merchant_lost, expired, withdrawn
    merchant_respondedWhether merchant submitted a representment response
    evidence_submittedType of evidence: compelling_evidence, proof_of_delivery, signed_contract, none
    liability_shiftParty bearing financial liability: issuer, merchant, psp
    card_brandCard network: visa, mastercard, amex
    payment_processing.transactionsCore payment transaction fact table. All card, SEPA, wallet, and BNPL transactions across all markets.Partitioned by event_month and country.
    transaction_idUnique transaction reference (format: PTX-XXXXXXXXXXXX)
    merchant_idFK to merchants table
    payment_methodPayment instrument: card_visa, card_mastercard, card_amex, sepa_transfer, digital_wallet, bnpl, ideal, giropay
    transaction_typeTransaction category: purchase, refund, payout, fee, chargeback_debit
    amountGross transaction amount in local currency
    channelOrigination channel: ecommerce, in_store, mobile_app, recurring, moto
    event_timestampExact timestamp of transaction processing
    statusProcessing status: captured, authorized, declined, refunded, settled, failed
    sca_methodStrong Customer Authentication method: 3ds2, exemption_low_value, exemption_tra, exemption_recurring, not_applicable
    payment_processing.merchantsCore merchant dimension. One row per onboarded merchant across all markets.
    merchant_idUnique merchant identifier (format: MCH-XXXXXXXX)
    mcc_code4-digit Merchant Category Code per ISO 18245
    segmentMerchant size tier: micro, small, mid_market, enterprise
    risk_categoryRisk classification: low, standard, elevated, high
    statusCurrent merchant status: active, suspended, terminated, under_review
    payment_processing.merchant_risk_scoresWritten by payments-monthly-risk on the 1st: one row per active merchant and month.Partitioned by score_date.
    merchant_idThe merchant scored
    score_dateThe 1st of the month scored
    chargeback_risk_scoreBetween 0 and 1
    fraud_risk_scoreBetween 0 and 1
    chargeback_count_90dDisputes filed in the 90 days before
    chargeback_ratio_90dThose disputes over the transactions of the 90 days
    declined_count_90dDeclined transactions of the 90 days
    Monitoring bands of the query
    StatusChargeback ratioNext step
    EXCEEDED - PROGRAM ENTRYover 1.0%Immediate action, program entry
    WARNINGover 0.65%Remediation plan required within 30 days
    ELEVATEDover 0.5%Monitor closely, review fraud controls
    NORMAL0.5% or lessNo action required

    How to run chargeback monitoring on Ilum, step by step

    Six steps from an empty cluster to a ratio checked daily, scores on the 1st and a risk team that reads both. Each uses a part of Ilum that comes with the default install.

    An empty cluster

    A ratio checked daily, scores on the 1st

    1. Helm chart

      Add the chart repository and install it on any CNCF-compliant Kubernetes. Spark, the SQL editor, the Hive Metastore and MinIO come with it.

      helm repo add ilum https://charts.ilum.cloud
      helm install ilum ilum/ilum
    2. Spark

      A Spark job reads the exports of your payment platform and the dispute feed from S3, GCS, Azure Blob or HDFS and writes merchants, transactions and disputes into payment_processing as Delta tables.

    3. SQL editor

      Save Chargeback Monitoring in the SQL editor in a folder such as Payments/Compliance. It runs on Spark SQL, the default engine.

    4. Schedules

      Upload monthly_risk_scoring.py as a Spark job and schedule it with the cron 0 6 1 * * and three retries. Ilum creates a Kubernetes CronJob for the schedule and starts a failed run again. How a schedule fires.

    5. Roles

      A RISK_COMPLIANCE_OFFICER role holds SQL_EXECUTE, SQLNOTEBOOK_READ and LINEAGE_READ and creates no jobs or schedules. Put the team in a group that carries it.

    6. Tags

      Tag disputes and merchant_risk_scores REGULATORY, and the scores’ columns with it, so the Lineage view marks them beside the job that wrote them. A PCI DSS data lake tags cardholder data the same way.

    Questions and answers

    How is the chargeback ratio calculated?

    Chargebacks filed against a merchant in a period over its purchases in the same period. The query here counts chargebacks only, not retrievals or arbitration, over captured and settled purchases of the last 90 days, per active merchant.

    What chargeback ratio puts a merchant at risk?

    The query marks ELEVATED over 0.5%, WARNING over 0.65% and program entry over 1%. The card schemes’ programs set their own thresholds and counts and change them, so set the band edges to the program your acquirer enrolls you in.

    What is reason code 10.4?

    Fraud in a card-absent environment, the most common fraud reason on online payments. The monthly risk job counts a merchant’s 10.4 disputes apart and raises its chargeback score when there are more than five in 90 days. Fraud detection with Spark checks the fraud score of the same job against the disputes that followed.

    How do I score merchant risk with Spark?

    Aggregate 90 days of transactions and disputes per merchant in a Spark job, turn thresholds on the ratios into points of a score, write one row per merchant and month, and schedule it for the 1st. How a Spark job runs on Ilum.

    How long does a chargeback dispute take?

    A chargeback takes 30 to 45 days, a retrieval request 10 to 20, pre-arbitration 30 and arbitration 45 to 90. Measure your own from filed_date to resolved_date.

    Why measure only merchants with enough purchases?

    Because one chargeback on a small merchant is a large ratio: on 15 purchases it is 6.7%. Chargeback Monitoring measures merchants from 500 paid purchases in 90 days, where one chargeback moves the ratio by 0.2 points at most, as the card schemes count merchants from a minimum number of disputes.

    Is Ilum open source?

    No. Ilum Community is free to run under a license from Ilum. It is built on open-source engines such as Apache Spark, Trino and DuckDB.

    Contact

    Tell us about your cluster.

    Name one workload you want to move.

    Tell us where it runs today.

    We answer with a plan, not a deck.

    [email protected]

    We reply within two working days.