If you process payments using Stripe Payment Element with PaymentIntent, you can start using Corgi Model or Corgi Rule Engine by migrating to Corgi-Controlled PaymentIntent Confirmation. This enables deterministic Request 3DS, Allow, Block, and Review decisions enforced by Corgi Labs before payment confirmation, without changing your checkout UX.

Changes at a high level

You will make one flow change. Instead of having Stripe’s standard client confirmation flow finalize the payment, you collect payment details in your existing Payment Element, create a Stripe ConfirmationToken, send it to your backend, and let your server call Corgi Labs’ confirm-payment endpoint.

Your checkout UX remains largely unchanged, but the confirmation control is moved to your server. Your customers should not experience any noticeable changes.

Before After
Client flow Mount Payment Element, then call stripe.confirmPayment(...) Mount Payment Element, collect a Fingerprint event, call elements.submit(), create a ConfirmationToken, then call your backend finalize endpoint with confirmationTokenId and fpEventId
Server flow Create PaymentIntent directly with Stripe Call Corgi Labs to create the PaymentIntent, evaluate rules, and execute confirmation
Risk evaluation Controlled by Stripe Radar Controlled by Corgi Model and Corgi Rule Engine

Migrate to Corgi-Controlled Confirmation

Step 1 — Replace direct PaymentIntent creation with server finalization

Allow Corgi Labs to evaluate the payment during the server-finalize flow. This is the main backend change.

❌ Before (direct Stripe call)

# server.py
pi = stripe.PaymentIntent.create(
    amount=5000,
    currency="usd",
    automatic_payment_methods={"enabled": True},
    metadata={"order_id": "123"},
)

return {"client_secret": pi.client_secret}

✅ After (HTTP API example, recommended)

Create a CORGI_API_TOKEN in your Corgi Web App at app.corgilabs.ai. Keep that token on your server only.

# server.py
import os
import requests

CORGI_API_TOKEN = os.environ["CORGI_API_TOKEN"]

# /api/finalize-payment
def finalize_payment(confirmation_token_id, fp_event_id):
    response = requests.post(
        "<https://app.corgilabs.ai/api/v1/corgi-sdk/confirm-payment>",
        headers={
            "Authorization": f"Bearer {CORGI_API_TOKEN}",
            "Content-Type": "application/json",
        },
        json={
            "confirmationTokenId": confirmation_token_id,
            "paymentIntentParams": {
                "amount": 5000,
                "currency": "usd",
                "metadata": {
                    "order_id": "123",
                    "fp_event_id": fp_event_id,
                }
            }
        },
        timeout=15,
    )
    response.raise_for_status()
    return response.json()

Optional: SDK(Nodejs) example

import { CorgiSDK } from 'corgi-sdk';

const corgi = new CorgiSDK({
  token: process.env.CORGI_API_TOKEN,
});

// /api/finalize-payment
export async function finalizePayment(
  confirmationTokenId: string,
  fpEventId: string,
) {
  return await corgi.confirmPayment(confirmationTokenId, {
    amount: 5000,
    currency: 'usd',
    metadata: {
      order_id: 'order_123',
      fp_event_id: fpEventId,
    },
  });
}

Step 2 — Change the frontend to create a Stripe ConfirmationToken

Move the client from Stripe-controlled confirmation to token creation plus server finalization. The checkout UI remains the same, but the submit path changes.

Your frontend should also embed Fingerprint.js, collect a Fingerprint event ID for each checkout attempt, and send that fpEventId to your backend. Your backend should persist that value to PaymentIntent metadata as fp_event_id during the Corgi confirm call. This lets Corgi retrieve IP address, user agent, and related request/device context.