ମୁଖ୍ୟ ବିଷୟବସ୍ତୁକୁ ଛାଡ଼ନ୍ତୁ
LearnGuidesStripe ରୁ ମାଇଗ୍ରେଟ୍ କରନ୍ତୁ
ଗାଇଡ୍

Stripe ରୁ Blockchain0x କୁ ଏଜେଣ୍ଟ-ଚାଲିତ API ପ୍ରବେଶ ପାଇଁ ମାଇଗ୍ରେଟ୍ କରନ୍ତୁ।

20 minutes
ସଂକ୍ଷିପ୍ତ ଉତ୍ତର

Stripe କୁ ବଦଳାଇବେ ନାହିଁ; ଏହାକୁ ସାଙ୍ଗରେ ଚାଲାନ୍ତୁ। ଏକ ଏକକ ଗେଟ୍ ପ୍ରତି ସୁରକ୍ଷିତ ଏଣ୍ଡପଏଣ୍ଟକୁ ଦୁଇଟି ଅଥର୍ ମେଥଡ୍ ସହିତ ସାମ୍ନା କରେ: ଏକ ସକ୍ରିୟ Stripe ସବ୍ସ୍କ୍ରିପ୍ସନ୍ (ମାନବଙ୍କ ପାଇଁ), ନାହିଁ ହେଲେ x402 ରିସିଭ୍-ସାଇଡ୍ ଏଡାପ୍ଟର (ଏଜେଣ୍ଟମାନେ), ଯାହା 402 ଚ୍ୟାଲେଞ୍ଜ ଜାରି କରେ ଏବଂ ପୁନର୍ପ୍ରୟାସରେ X-Payment ହେଡରକୁ ଯାଞ୍ଚ କରେ। ହ୍ୟାଣ୍ଡଲର ତର୍କ ବଦଳାଯାଉନାହିଁ।

ପୂର୍ବାବଶ୍ୟକତା

ଆପଣ ଆରମ୍ଭ କରିବା ପୂର୍ବରୁ।

  • ଏକ କାମ କରୁଥିବା Stripe ଇଣ୍ଟେଗ୍ରେସନ୍ ଯାହାର କମ୍ ସେହି ଏକ ସକ୍ରିୟ ଉତ୍ପାଦ/ମୂଲ୍ୟ (ସବ୍ସକ୍ରିପ୍ସନ୍ କିମ୍ବା ଏକ-ଫେର୍ତ୍ତା)।
  • ଏକ Blockchain0x agent profile ଏବଂ API key (add-payments-to-agent ଦେଖନ୍ତୁ)।
  • ଆପଣଙ୍କ web framework ରେ ଏକ auth/middleware layer, ଯେଉଁଠାରେ ଆପଣ ବର୍ତ୍ତମାନ access gate କରିବାକୁ Stripe call କରନ୍ତି।
  • ଏକ feature-flag mechanism (env var, LaunchDarkly, simple boolean - redeploy ବିନା behavior toggle କରିପାରିବା ଯେକୌଣସି ବ୍ୟବସ୍ଥା)।
  • x402 pattern ବୁଝିବା - ତଳେ ଥିବା decorator ଏହାକୁ implement କରେ।
ପଦକ୍ଷେପ 1 ର 3

dual-auth gate ଲେଖନ୍ତୁ।

gate ହେଉଛି ଏକମାତ୍ର glue piece। ଏହା ପ୍ରଥମେ active Stripe subscription ଅଛି କି ନାହିଁ ଯାଞ୍ଚ କରେ (human path); ଯଦି ନାହିଁ, ଏହା request କୁ x402 receive-side adapter (agent path) କୁ ଦେଇଦିଏ, ଯାହା 402 challenge issue କରେ ଏବଂ agent retry କଲେ X-Payment header verify କରେ। Node example createX402Middleware ବ୍ୟବହାର କରେ; Python service ସେହି wire କୁ hand ରେ କହେ।

TypeScript (Express)
import express from "express";
import Stripe from "stripe";
import { createClient } from "@blockchain0x/node";
import { createX402Middleware } from "@blockchain0x/x402/server/express";

const stripe = new Stripe(process.env.STRIPE_SECRET_KEY!);
const sdk = createClient({ apiKey: process.env.BLOCKCHAIN0X_API_KEY! });

// Agents pay via x402: this middleware issues the 402 challenge and verifies
// the X-Payment header on the retry. Configure price + recipient per the docs.
const x402 = createX402Middleware({ sdk });

// Humans with an active Stripe subscription skip the paywall; everyone else
// falls through to the x402 challenge.
function stripeOrX402(req: express.Request, res: express.Response, next: express.NextFunction) {
  const customer = req.cookies?.stripe_customer_id;
  if (!customer) return x402(req, res, next);          // agent path
  stripe.subscriptions
    .list({ customer, status: "active", limit: 1 })
    .then((subs) => (subs.data.length > 0 ? next() : x402(req, res, next)))
    .catch(next);
}
Python (Flask)
from functools import wraps
from flask import request, jsonify
import stripe, os

stripe.api_key = os.environ["STRIPE_SECRET_KEY"]

# The x402 receive-side adapter is Node; a Python service speaks the wire
# directly: advertise requirements in a 402, accept a resent X-Payment header.
def stripe_or_x402(resource: str):
    def decorator(fn):
        @wraps(fn)
        def wrapper(*args, **kwargs):
            # 1. Human path: active Stripe subscription.
            customer_id = request.cookies.get("stripe_customer_id")
            if customer_id:
                subs = stripe.Subscription.list(customer=customer_id, status="active", limit=1)
                if subs["data"]:
                    return fn(*args, **kwargs)

            # 2. Agent path: a valid X-Payment header ("exact-usdc:<base64(json)>")
            #    means the caller paid; verify it, then let the request through.
            if request.headers.get("X-Payment"):
                return fn(*args, **kwargs)

            # 3. No auth - advertise the x402 requirements in a 402.
            return jsonify({
                "version": 1,
                "resource": resource,
                "accepts": [{"scheme": "exact-usdc", "network": "eip155:8453"}],
            }), 402
        return wrapper
    return decorator
ପଦକ୍ଷେପ 2 ର 3

ଏହାକୁ ଏଣ୍ଡପଏଣ୍ଟକୁ ଲାଗୁ କରନ୍ତୁ।

handler ନିଜେ ପରିବର୍ତ୍ତିତ ହୁଏ ନାହିଁ - decorator auth/payment logic କୁ handle କରେ, ତାପରେ payment settled ହେଲେ ମାତ୍ର existing implementation କୁ forward କରେ। ଏହା migration କୁ low-risk କରେ: human flows ଅପରିବର୍ତ୍ତିତ ରହେ, ଆପଣ କେବଳ ଏକ alternate path ଯୋଡ଼ିଛନ୍ତି।

TypeScript
// Apply the gate to the endpoint. The x402 middleware handles the 402
// challenge and the X-Payment verification; your handler only runs once paid.
app.get("/api/premium-feature",
  stripeOrX402,
  async (req, res) => {
    const result = await runPremiumFeature();
    res.json(result);
  },
);
Python
@app.get("/api/premium-feature")
@stripe_or_x402("/api/premium-feature")
def premium_feature():
    return run_premium_feature()
ପଦକ୍ଷେପ 3 ର 3

ଛାୟାରେ ରୋଲ୍ ଆଉଟ୍ କରନ୍ତୁ, ତାପରେ ସକ୍ରିୟ ମୋଡ୍।

ସମସ୍ତଙ୍କ ପାଇଁ ଏକ ସମୟରେ ଦୁଇଟି ପଥକୁ ଫ୍ଲିପ୍ କରନ୍ତୁ ନାହିଁ। ସୁରକ୍ଷିତ ରୋଲ୍‌ଆଉଟ୍ ପ୍ୟାଟର୍ନ୍ ଚାରି ଧାପରେ - ଛାୟା, ନିଶ୍ଚଳ ଏଜେଣ୍ଟ୍ ସକ୍ରିୟତା, ସାଧାରଣ ଏଜେଣ୍ଟ୍ ସକ୍ରିୟତା, ଦେଖନ୍ତୁ। Stripe ଫ୍ଲୋ ସମସ୍ତ ସମୟରେ ଅବିବର୍ତ୍ତିତ ରହିଛି; ଏଜେଣ୍ଟ୍ ଟ୍ରାଫିକ୍ ଧୀରେ ଧୀରେ ବୃଦ୍ଧି ପାଉଛି।

# Rollout plan: keep Stripe-only working while you add the agent path.

# Week 1 - shadow mode
# - Deploy the decorator with the agent-path branch behind a feature flag (off).
# - Human Stripe flow continues unchanged.
# - Sandbox-test the agent path against Base Sepolia.

# Week 2 - silent agent enablement
# - Turn the agent-path branch on for a single internal agent.
# - Verify the 402 issues correctly and settlement works end-to-end.
# - Wire alerting on the 402-issued / 402-settled rate.

# Week 3 - public agent enablement
# - Document the x402 contract in your developer docs.
# - Announce to existing customers building agents.
# - Continue measuring: human Stripe flow should be unchanged.

# Week 4+ - observe
# - Track the ratio of agent settlements to human subscriptions.
# - As agent traffic grows, you may decide to keep Stripe only for humans
#   and let everything else go through x402. That is a later decision -
#   the architecture above supports either trajectory.
ସାଧାରଣ ବିପଦ

ଚାରିଟି ଭୁଲ ଯାହା ଦ୍ୱିତଳ ରେଲକୁ କଷ୍ଟକର କରେ।

ଏହାକୁ ବୃଦ୍ଧି କରିବା ବଦଳରେ Stripe କୁ ବଦଳାଇବାକୁ ଚେଷ୍ଟା କରିବା

Stripe ଏକ-ବେଳର ମାନବ ଚେକ୍‌ଆଉଟ୍ ଏବଂ ମାନବ ସଦସ୍ୟତା ପାଇଁ ସଠିକ୍। ଏଜେଣ୍ଟ ଟ୍ରାଫିକ୍‌କୁ Stripe ମାଧ୍ୟମରେ ଜୋର କରିବା (ପ୍ରତି-କଲ୍ ଇନ୍ଭୟସ୍, ଡାଇନାମିକ୍ ମୂଲ୍ୟ) କାର୍ଡ୍-ନେଟୱର୍କ ନ୍ୟୁନତମ ଏବଂ ଫି ଗଠନର ବିପରୀତ ଭାଙ୍ଗି ଦେଇଥାଏ। ସଫଳ ମାନ୍ୟତା ହେଉଛି ବୃଦ୍ଧି: Stripe କୁ ତାହାର କାର୍ଯ୍ୟରେ ରଖନ୍ତୁ (ମାନବମାନେ କାର୍ଡ୍‌ସହିତ ଦେୟ କରୁଛନ୍ତି) ଏବଂ x402 / ଏଜେଣ୍ଟ ଦେୟଗୁଡିକୁ ଯୋଗ କରନ୍ତୁ ଯାହା ପାଇଁ Stripe କେବେ ତିଆରି କରାଯାଇନଥିଲା। ଗୋଟିଏ କିମ୍ବା ଅନ୍ୟଟିକୁ ବାଛନ୍ତୁ ନାହିଁ।

402 ର ବଦଳରେ ଏଜେଣ୍ଟକୁ 401 ଫେରାଇବା

ଅଧିକାଂଶ existing endpoint ରେ Stripe session ନଥିଲେ 401 Unauthorized ଫେରାଇଦିଆଯାଏ। Agent ମାନେ 401 ସହ କଣ କରିବେ ତାହା ଜାଣନ୍ତି ନାହିଁ - ସେମାନେ କେବଳ 402 Payment Required କୁ 'pay to proceed' signal ଭାବରେ ବୁଝନ୍ତି। Gate ଟିକୁ ପାର୍ଥକ୍ୟ କରିବାକୁ ହେବ: 'this caller is unauthorized and cannot pay' (true 401, return 401) ବନାମ 'this caller is unauthenticated but can pay' (return the x402 402 challenge)।

ଏଜେଣ୍ଟମାନେ Stripe ମୂଲ୍ୟ ଅବହେଳା କରିବାକୁ ଦିଆଯାଉଛି

ଯଦି ଆପଣଙ୍କର Stripe ସବ୍ସକ୍ରିପ୍ସନ୍ $20/ମାସ ଅନଲିମିଟେଡ୍ କଲ୍‌ଗୁଡିକ ପାଇଁ ଏବଂ ଆପଣଙ୍କର x402 କୋଟ୍ $0.01/କଲ୍ ଅଟେ, ତେବେ ଏକ ଏଜେଣ୍ଟ ପ୍ରାୟୋଗିକ ଭାବରେ $0.01 ଗୋଟିଏ ସମୟ ଦେୟ କରିପାରେ ଏବଂ ଗୋଟିଏ କଲ୍ ପାଇବାକୁ ଯେଉଁଥିରେ ଏକ ମାନବ $20 ଦେୟ କରେ। ଏହା ସମୟ ସମୟରେ ବ୍ୟବହାର କରୁଥିବା ଏଜେଣ୍ଟ ଟ୍ରାଫିକ୍ ପାଇଁ ଠିକ୍ ଅଟେ ଏବଂ ଉଚ୍ଚ-ମାତ୍ରା ଏଜେଣ୍ଟ ଟ୍ରାଫିକ୍ ପାଇଁ ଭଙ୍ଗା। ପର-କଲ୍ ମୂଲ୍ୟ ସେଟ୍ କରନ୍ତୁ ଯାହା ଏକ ଭାରୀ ଏଜେଣ୍ଟ ସ୍ୱାଭାବିକ ଭାବରେ ସବ୍ସକ୍ରିପ୍ସନ୍ ଥ୍ରେଶୋଲ୍ଡକୁ ହିଟ୍ କରିବାକୁ ସହାୟକ ହେବ - ତେବେ ସେମାନେ ସ୍ୱିଚ୍ କରିବାର ଅବସର ଦିଅ।

କେଉଁ ପଥ ଗ୍ରହଣ କରାଗଲା ସେଥିରେ ଲଗ୍ ନକରିବା

ଏକ debugging request ଆସେ: 'ଏହି customer କହୁଛନ୍ତି ସେମାନେ ପେ କରିଛନ୍ତି କିନ୍ତୁ ଆମେ deliver କରିନାହିଁ'. ଯଦି ଆପଣ call କୁ କେଉଁ auth path approve କଲା ତାହା log କରିନାହାନ୍ତି, Stripe ର records ଦେଖିବେ କି Blockchain0x ର, ଏହା ଜାଣିପାରିବେ ନାହିଁ। ସଦା ନିଷ୍ପତ୍ତିକୁ log କରନ୍ତୁ: କେଉଁ branch match ହେଲା, customer_id କିମ୍ବା X-Payment / transaction reference, ଏବଂ ଏକ correlation ID। ଏହା ବିନା, ପ୍ରତ୍ୟେକ dual-rail incident କୁ triage କରିବାରେ ଦୁଇଗୁଣ ସମୟ ଲାଗେ।

ପରବର୍ତ୍ତୀ ପଦକ୍ଷେପଗୁଡିକ

ଯେତେବେଳେ ଡୁଆଲ-ରେଲ ସଜାଗ ହେବ।

ସଂରଚନା ସ୍ଥାପିତ ହେବା ସହିତ, ବାକୀ କାମ କାର୍ଯ୍ୟକଳାପ ହେଉଛି। Webhook robustness Stripe ଏବଂ Blockchain0x ଘଟଣା ସ୍ଟ୍ରିମ୍ ଦୁହେଁକୁ ହ୍ୟାଣ୍ଡଲ୍ କରେ। ବ୍ୟୟ ନିୟନ୍ତ୍ରଣ ଆପଣ ଚଳାଚଳ କରୁଥିବା କୌଣସି ଏଜେଣ୍ଟକୁ ସୁରକ୍ଷା କରେ। ପ୍ରେ-ଲଞ୍ଚ ସୁରକ୍ଷା ସମୀକ୍ଷା ଏକ ଏକକ-ରେଲ୍ ଇଣ୍ଟେଗ୍ରେସନ୍ ପରି ଲାଗୁ ହୁଏ।

docs.blockchain0x.com ରେ ପୂର୍ଣ୍ଣ ସନ୍ଦର୍ଭ। ସମ୍ବନ୍ଧିତ ଉତ୍ପାଦ ସତହ: Payment API. ତୁଳନା ଫ୍ରେମିଂ: Comparisons.

ଶେଷ ସମୀକ୍ଷା: 2026-05-15। CC BY 4.0 ଅନୁସାରେ ପ୍ରକାଶିତ।

Stripe ରଖନ୍ତୁ। ଏଜେଣ୍ଟଗୁଡିକୁ ଯୋଡନ୍ତୁ।

ଏକ ଡେକୋରେଟର। ଦୁଇ ପେମେଣ୍ଟ ରେଲ୍। ଅବସ୍ଥିତ ଗ୍ରାହକମାନେ ପାଇଁ ଶୂନ୍ୟ ଚର୍ଣ୍ଣ। ଆରମ୍ଭ କରିବାକୁ ମାଗଣା।