Documentation

    Documentation

    Documentation

    Ring Platform Logo

    Завантаження документації...

    Підготовка контенту платформи Ring

    Ring Platform Logo

    Завантаження документації...

    Підготовка контенту платформи Ring

    Ring Platform Logo

    Завантаження документації...

    Підготовка контенту платформи Ring

    1. /
    2. /Affiliate & Referral Enablement

    Updated Jun 12, 20263 min listen

    1. /
    2. /Affiliate & Referral Enablement

    Updated Jun 12, 20263 min listen

    1. /
    2. /Affiliate & Referral Enablement

    Updated Jun 12, 20263 min listen

    Concepts, value, and typical clone scenarios — less code.

    Welcome to Ring
    Quick Reference
    Getting Started
    Prerequisites
    Installation
    Database migrations
    First Success Validation
    Troubleshooting
    Next Steps
    Architecture
    Backend modes and databases
    Data Model
    Authentication Architecture
    Email AI-CRM architecture
    PaymentConductor architecture
    Refcodes architecture
    News Kingdom architecture
    Proxy and internationalization
    Real Time
    Discovery Mutation Sync
    Security
    Features
    Doc System
    Authentication
    Email AI-CRM
    Entities
    Opportunities
    Notifications
    Push Notifications with FCM (Ring-Powered)
    Tunnel Protocol
    Web3 Wallet
    Multi-Vendor Store
    Inventory & Stock
    Vendor Management
    Commissions & Settlements
    Referral Codes (Refcodes)
    Affiliate & Referral Enablement
    Payment Integration
    PaymentConductor
    VideoConductor
    WayForPay Payment Integration
    News Module - Digital Newspaper Experience
    Member Blogs
    Scientific Editor
    Locale System
    Security & Compliance
    NFT Marketplace
    Token Staking System
    Performance Optimization Patterns
    Mobile Experience
    Wallet
    Wallet Security Tips
    API
    Authentication
    Email AI-CRM API
    Entities
    Opportunities
    Messaging API
    Notifications API
    Wallet API
    Store API
    Admin API
    CLI
    Customization
    Quick Start — Your First Ring Clone
    Customization Guide
    Database Backend Selection
    Token Economics Setup
    Payment Gateway Integration
    AI Agent Customization
    Reference Ring deployments
    Branding
    Features
    Localization
    Themes
    Components
    Web3
    Token launch jurisdictions
    Deployment
    Self-hosted deployment
    Vercel
    Docker
    Environment Configuration
    Monitoring & Analytics
    Performance Optimization
    Backup & Recovery
    Development
    Local Setup
    Code Structure
    Documentation components
    Community tooling
    Ring MCP Server
    Generative Images (ImageConductor)
    Autonomous Newsroom (Grok)
    OSS vs enterprise
    Whitelabel Navigation
    Best Practices
    Workflow
    Code Style
    Performance
    Testing
    Deployment
    Debugging
    Contributing
    MCP
    ring-image-create
    ring-video-create
    Roadmap
    Examples
    Quick Start
    Authentication
    Email AI-CRM developer guide
    API Integration Examples
    Web3 Integration
    White Label
    Real World
    API Examples (cURL)
    Integrations
    Ethereum wallets (Wagmi v3)

    Quick entry (CTOs · auditors · agents)

    Welcome — mission & audiences
    Quick Reference
    Getting started
    Architecture & Auth.js
    Backend modes & databases (DB_BACKEND_MODE)
    Self-hosted
    Ring MCP Tools
    Ring MCP Server
    Token economics
    Token launch jurisdictions
    Deploy (Docker · k8s)
    Security & compliance reads
    ringdom.org — LegioX homebase
    Source — MIT license (GitHub)

    Concepts, value, and typical clone scenarios — less code.

    Welcome to Ring
    Quick Reference
    Getting Started
    Prerequisites
    Installation
    Database migrations
    First Success Validation
    Troubleshooting
    Next Steps
    Architecture
    Backend modes and databases
    Data Model
    Authentication Architecture
    Email AI-CRM architecture
    PaymentConductor architecture
    Refcodes architecture
    News Kingdom architecture
    Proxy and internationalization
    Real Time
    Discovery Mutation Sync
    Security
    Features
    Doc System
    Authentication
    Email AI-CRM
    Entities
    Opportunities
    Notifications
    Push Notifications with FCM (Ring-Powered)
    Tunnel Protocol
    Web3 Wallet
    Multi-Vendor Store
    Inventory & Stock
    Vendor Management
    Commissions & Settlements
    Referral Codes (Refcodes)
    Affiliate & Referral Enablement
    Payment Integration
    PaymentConductor
    VideoConductor
    WayForPay Payment Integration
    News Module - Digital Newspaper Experience
    Member Blogs
    Scientific Editor
    Locale System
    Security & Compliance
    NFT Marketplace
    Token Staking System
    Performance Optimization Patterns
    Mobile Experience
    Wallet
    Wallet Security Tips
    API
    Authentication
    Email AI-CRM API
    Entities
    Opportunities
    Messaging API
    Notifications API
    Wallet API
    Store API
    Admin API
    CLI
    Customization
    Quick Start — Your First Ring Clone
    Customization Guide
    Database Backend Selection
    Token Economics Setup
    Payment Gateway Integration
    AI Agent Customization
    Reference Ring deployments
    Branding
    Features
    Localization
    Themes
    Components
    Web3
    Token launch jurisdictions
    Deployment
    Self-hosted deployment
    Vercel
    Docker
    Environment Configuration
    Monitoring & Analytics
    Performance Optimization
    Backup & Recovery
    Development
    Local Setup
    Code Structure
    Documentation components
    Community tooling
    Ring MCP Server
    Generative Images (ImageConductor)
    Autonomous Newsroom (Grok)
    OSS vs enterprise
    Whitelabel Navigation
    Best Practices
    Workflow
    Code Style
    Performance
    Testing
    Deployment
    Debugging
    Contributing
    MCP
    ring-image-create
    ring-video-create
    Roadmap
    Examples
    Quick Start
    Authentication
    Email AI-CRM developer guide
    API Integration Examples
    Web3 Integration
    White Label
    Real World
    API Examples (cURL)
    Integrations
    Ethereum wallets (Wagmi v3)

    Quick entry (CTOs · auditors · agents)

    Welcome — mission & audiences
    Quick Reference
    Getting started
    Architecture & Auth.js
    Backend modes & databases (DB_BACKEND_MODE)
    Self-hosted
    Ring MCP Tools
    Ring MCP Server
    Token economics
    Token launch jurisdictions
    Deploy (Docker · k8s)
    Security & compliance reads
    ringdom.org — LegioX homebase
    Source — MIT license (GitHub)

    Concepts, value, and typical clone scenarios — less code.

    Welcome to Ring
    Quick Reference
    Getting Started
    Prerequisites
    Installation
    Database migrations
    First Success Validation
    Troubleshooting
    Next Steps
    Architecture
    Backend modes and databases
    Data Model
    Authentication Architecture
    Email AI-CRM architecture
    PaymentConductor architecture
    Refcodes architecture
    News Kingdom architecture
    Proxy and internationalization
    Real Time
    Discovery Mutation Sync
    Security
    Features
    Doc System
    Authentication
    Email AI-CRM
    Entities
    Opportunities
    Notifications
    Push Notifications with FCM (Ring-Powered)
    Tunnel Protocol
    Web3 Wallet
    Multi-Vendor Store
    Inventory & Stock
    Vendor Management
    Commissions & Settlements
    Referral Codes (Refcodes)
    Affiliate & Referral Enablement
    Payment Integration
    PaymentConductor
    VideoConductor
    WayForPay Payment Integration
    News Module - Digital Newspaper Experience
    Member Blogs
    Scientific Editor
    Locale System
    Security & Compliance
    NFT Marketplace
    Token Staking System
    Performance Optimization Patterns
    Mobile Experience
    Wallet
    Wallet Security Tips
    API
    Authentication
    Email AI-CRM API
    Entities
    Opportunities
    Messaging API
    Notifications API
    Wallet API
    Store API
    Admin API
    CLI
    Customization
    Quick Start — Your First Ring Clone
    Customization Guide
    Database Backend Selection
    Token Economics Setup
    Payment Gateway Integration
    AI Agent Customization
    Reference Ring deployments
    Branding
    Features
    Localization
    Themes
    Components
    Web3
    Token launch jurisdictions
    Deployment
    Self-hosted deployment
    Vercel
    Docker
    Environment Configuration
    Monitoring & Analytics
    Performance Optimization
    Backup & Recovery
    Development
    Local Setup
    Code Structure
    Documentation components
    Community tooling
    Ring MCP Server
    Generative Images (ImageConductor)
    Autonomous Newsroom (Grok)
    OSS vs enterprise
    Whitelabel Navigation
    Best Practices
    Workflow
    Code Style
    Performance
    Testing
    Deployment
    Debugging
    Contributing
    MCP
    ring-image-create
    ring-video-create
    Roadmap
    Examples
    Quick Start
    Authentication
    Email AI-CRM developer guide
    API Integration Examples
    Web3 Integration
    White Label
    Real World
    API Examples (cURL)
    Integrations
    Ethereum wallets (Wagmi v3)

    Quick entry (CTOs · auditors · agents)

    Welcome — mission & audiences
    Quick Reference
    Getting started
    Architecture & Auth.js
    Backend modes & databases (DB_BACKEND_MODE)
    Self-hosted
    Ring MCP Tools
    Ring MCP Server
    Token economics
    Token launch jurisdictions
    Deploy (Docker · k8s)
    Security & compliance reads
    ringdom.org — LegioX homebase
    Source — MIT license (GitHub)
    Docs
    Features
    Docs
    Features
    Docs
    Features

    Affiliate & Referral Enablement

    Ring Platform reconciles legacy vendor-commission scaffolding with the refcodes growth module. One attribution cookie drives two payout rails: vendors fund fiat-side referral commission through ERP settlements; the platform funds referrer token rewards via an on-chain minter. Both rails share orderReference for cross-audit.

    Executive summary

    Referrers earn tokens. Vendors fund their share of referral commission from settlement. Buyers see a referral badge at checkout when attributed. Operators approve fiat-path mints, run cron for the approved queue, and review commissions at /admin/store/commissions.

    Deep dives: Referral codes (refcodes) · Refcodes architecture · ERP commissions

    Dual-rail economics

    RailWho paysMechanismWhen it runs
    ERP (vendor-funded)Vendor net payoutcalculateCommission() → settlements.metadata.commissionBreakdown.referralCommissionPaid store order (WayForPay or credit)
    Refcodes (platform-funded)Platform treasury / mint authorityReferralRewardService → ReferralRewards.payReferral on PolygonAfter order paid (fiat: post-approval; credit: immediate)

    Both rails use resolveReferralCommissionPercent (features/store/lib/referral-commission.ts) — product override → merchant config → platform default (5%) → REFERRAL_REWARD_PERCENT env.

    Scope

    In scope: store orders and membership upgrades. Out of scope (this iteration): news promotion referrals, referee checkout discounts (referrer-only incentive).

    Dual-rail attribution and payout

    Attribution lifecycle

    1. 1

      Land with ?ref= — proxy.ts sets httpOnly ring_ref and client-readable ring_ref_visible (30 days, first-touch).

    2. 2

      Visit beacon — ReferralAttributionEffect (public layout) calls POST /api/refcodes/track; visitDaily buckets power dashboard stats (28-day retention).

    3. 3

      Signup persistence — Auth.js signIn for new users runs persistSignupReferralAttribution so users.data.referredBy survives cookie expiry (membership upgrades without a store order).

    4. 4

      Checkout — Review step shows ReferralCheckoutBadge; order APIs return referralApplied + referralCode; credit checkout shows a toast; WayForPay stashes a sessionStorage flash for the processing page.

    5. 5

      Payment success — Store webhook or credit path writes settlements (ERP rail) and referral_rewards (token rail). Membership webhook calls ReferralRewardService.onMembershipPaid when referredBy is set.

    Operator surfaces

    Referrer dashboard

    /refcodes — share links, reward history, visit stats (total / today / 7d / 28d).

    Admin refcodes

    /admin/refcodes — approve fiat rewards, batch mint, platform visit aggregates.

    Admin commissions

    /admin/store/commissions — settlement ledger, referral breakdown, process due payouts.

    Cross-rail audit

    Every attributed paid event should carry the same orderReference (PaymentConductor string) on:

    RecordField
    settlementsorderId / metadata
    erp_sales_assistsorderId
    referral_rewardsorderReference (unique index)
    On-chainkeccak256(orderReference) in ReferralRewards.paidOrders

    Smoke: scripts/smoke-erp-referral-pipeline.cts, scripts/smoke-growth-pipelines.cts, scripts/smoke-refcodes-http.cts (require DB_BACKEND_MODE + NODE_OPTIONS=--conditions=react-server — see scripts/run-all-smokes.sh).

    Operations checklist

    StepAction
    1. MigrationsApply 005_refcodes_schema.sql then 007_settlements_schema.sql (apply-refcodes-migrations-dev.sh, apply-erp-migrations-dev.sh).
    2. EnvFill REFERRAL CODES and CRON_SECRET in env.local.template; deploy ReferralRewards proxy; grant token mint to proxy.
    3. CronSchedule GET /api/cron/refcodes-mint with Authorization: Bearer $CRON_SECRET (up to 20 approved rewards per run).
    4. VerifyReferred order → settlements with referralCommission + erp_sales_assists + referral_rewards sharing orderReference.
    Smoke suites

    Run ./scripts/run-all-smokes.sh (sets DB_BACKEND_MODE and NODE_OPTIONS=--conditions=react-server). Targeted: smoke-erp-referral-pipeline.cts, smoke-growth-pipelines.cts, smoke-refcodes-http.cts.

    Related

    • Referral codes — user/admin UI, contract deploy, env vars
    • ERP commissions — settlement hierarchy and payout modes
    • PaymentConductor — webhooks and orderReference contract
    • Multi-vendor store — checkout and vendor flows

    Affiliate & Referral Enablement

    Ring Platform reconciles legacy vendor-commission scaffolding with the refcodes growth module. One attribution cookie drives two payout rails: vendors fund fiat-side referral commission through ERP settlements; the platform funds referrer token rewards via an on-chain minter. Both rails share orderReference for cross-audit.

    Executive summary

    Referrers earn tokens. Vendors fund their share of referral commission from settlement. Buyers see a referral badge at checkout when attributed. Operators approve fiat-path mints, run cron for the approved queue, and review commissions at /admin/store/commissions.

    Deep dives: Referral codes (refcodes) · Refcodes architecture · ERP commissions

    Dual-rail economics

    RailWho paysMechanismWhen it runs
    ERP (vendor-funded)Vendor net payoutcalculateCommission() → settlements.metadata.commissionBreakdown.referralCommissionPaid store order (WayForPay or credit)
    Refcodes (platform-funded)Platform treasury / mint authorityReferralRewardService → ReferralRewards.payReferral on PolygonAfter order paid (fiat: post-approval; credit: immediate)

    Both rails use resolveReferralCommissionPercent (features/store/lib/referral-commission.ts) — product override → merchant config → platform default (5%) → REFERRAL_REWARD_PERCENT env.

    Scope

    In scope: store orders and membership upgrades. Out of scope (this iteration): news promotion referrals, referee checkout discounts (referrer-only incentive).

    Dual-rail attribution and payout

    Attribution lifecycle

    1. 1

      Land with ?ref= — proxy.ts sets httpOnly ring_ref and client-readable ring_ref_visible (30 days, first-touch).

    2. 2

      Visit beacon — ReferralAttributionEffect (public layout) calls POST /api/refcodes/track; visitDaily buckets power dashboard stats (28-day retention).

    3. 3

      Signup persistence — Auth.js signIn for new users runs persistSignupReferralAttribution so users.data.referredBy survives cookie expiry (membership upgrades without a store order).

    4. 4

      Checkout — Review step shows ReferralCheckoutBadge; order APIs return referralApplied + referralCode; credit checkout shows a toast; WayForPay stashes a sessionStorage flash for the processing page.

    5. 5

      Payment success — Store webhook or credit path writes settlements (ERP rail) and referral_rewards (token rail). Membership webhook calls ReferralRewardService.onMembershipPaid when referredBy is set.

    Operator surfaces

    Referrer dashboard

    /refcodes — share links, reward history, visit stats (total / today / 7d / 28d).

    Admin refcodes

    /admin/refcodes — approve fiat rewards, batch mint, platform visit aggregates.

    Admin commissions

    /admin/store/commissions — settlement ledger, referral breakdown, process due payouts.

    Cross-rail audit

    Every attributed paid event should carry the same orderReference (PaymentConductor string) on:

    RecordField
    settlementsorderId / metadata
    erp_sales_assistsorderId
    referral_rewardsorderReference (unique index)
    On-chainkeccak256(orderReference) in ReferralRewards.paidOrders

    Smoke: scripts/smoke-erp-referral-pipeline.cts, scripts/smoke-growth-pipelines.cts, scripts/smoke-refcodes-http.cts (require DB_BACKEND_MODE + NODE_OPTIONS=--conditions=react-server — see scripts/run-all-smokes.sh).

    Operations checklist

    StepAction
    1. MigrationsApply 005_refcodes_schema.sql then 007_settlements_schema.sql (apply-refcodes-migrations-dev.sh, apply-erp-migrations-dev.sh).
    2. EnvFill REFERRAL CODES and CRON_SECRET in env.local.template; deploy ReferralRewards proxy; grant token mint to proxy.
    3. CronSchedule GET /api/cron/refcodes-mint with Authorization: Bearer $CRON_SECRET (up to 20 approved rewards per run).
    4. VerifyReferred order → settlements with referralCommission + erp_sales_assists + referral_rewards sharing orderReference.
    Smoke suites

    Run ./scripts/run-all-smokes.sh (sets DB_BACKEND_MODE and NODE_OPTIONS=--conditions=react-server). Targeted: smoke-erp-referral-pipeline.cts, smoke-growth-pipelines.cts, smoke-refcodes-http.cts.

    Related

    • Referral codes — user/admin UI, contract deploy, env vars
    • ERP commissions — settlement hierarchy and payout modes
    • PaymentConductor — webhooks and orderReference contract
    • Multi-vendor store — checkout and vendor flows

    Affiliate & Referral Enablement

    Ring Platform reconciles legacy vendor-commission scaffolding with the refcodes growth module. One attribution cookie drives two payout rails: vendors fund fiat-side referral commission through ERP settlements; the platform funds referrer token rewards via an on-chain minter. Both rails share orderReference for cross-audit.

    Executive summary

    Referrers earn tokens. Vendors fund their share of referral commission from settlement. Buyers see a referral badge at checkout when attributed. Operators approve fiat-path mints, run cron for the approved queue, and review commissions at /admin/store/commissions.

    Deep dives: Referral codes (refcodes) · Refcodes architecture · ERP commissions

    Dual-rail economics

    RailWho paysMechanismWhen it runs
    ERP (vendor-funded)Vendor net payoutcalculateCommission() → settlements.metadata.commissionBreakdown.referralCommissionPaid store order (WayForPay or credit)
    Refcodes (platform-funded)Platform treasury / mint authorityReferralRewardService → ReferralRewards.payReferral on PolygonAfter order paid (fiat: post-approval; credit: immediate)

    Both rails use resolveReferralCommissionPercent (features/store/lib/referral-commission.ts) — product override → merchant config → platform default (5%) → REFERRAL_REWARD_PERCENT env.

    Scope

    In scope: store orders and membership upgrades. Out of scope (this iteration): news promotion referrals, referee checkout discounts (referrer-only incentive).

    Dual-rail attribution and payout

    Attribution lifecycle

    1. 1

      Land with ?ref= — proxy.ts sets httpOnly ring_ref and client-readable ring_ref_visible (30 days, first-touch).

    2. 2

      Visit beacon — ReferralAttributionEffect (public layout) calls POST /api/refcodes/track; visitDaily buckets power dashboard stats (28-day retention).

    3. 3

      Signup persistence — Auth.js signIn for new users runs persistSignupReferralAttribution so users.data.referredBy survives cookie expiry (membership upgrades without a store order).

    4. 4

      Checkout — Review step shows ReferralCheckoutBadge; order APIs return referralApplied + referralCode; credit checkout shows a toast; WayForPay stashes a sessionStorage flash for the processing page.

    5. 5

      Payment success — Store webhook or credit path writes settlements (ERP rail) and referral_rewards (token rail). Membership webhook calls ReferralRewardService.onMembershipPaid when referredBy is set.

    Operator surfaces

    Referrer dashboard

    /refcodes — share links, reward history, visit stats (total / today / 7d / 28d).

    Admin refcodes

    /admin/refcodes — approve fiat rewards, batch mint, platform visit aggregates.

    Admin commissions

    /admin/store/commissions — settlement ledger, referral breakdown, process due payouts.

    Cross-rail audit

    Every attributed paid event should carry the same orderReference (PaymentConductor string) on:

    RecordField
    settlementsorderId / metadata
    erp_sales_assistsorderId
    referral_rewardsorderReference (unique index)
    On-chainkeccak256(orderReference) in ReferralRewards.paidOrders

    Smoke: scripts/smoke-erp-referral-pipeline.cts, scripts/smoke-growth-pipelines.cts, scripts/smoke-refcodes-http.cts (require DB_BACKEND_MODE + NODE_OPTIONS=--conditions=react-server — see scripts/run-all-smokes.sh).

    Operations checklist

    StepAction
    1. MigrationsApply 005_refcodes_schema.sql then 007_settlements_schema.sql (apply-refcodes-migrations-dev.sh, apply-erp-migrations-dev.sh).
    2. EnvFill REFERRAL CODES and CRON_SECRET in env.local.template; deploy ReferralRewards proxy; grant token mint to proxy.
    3. CronSchedule GET /api/cron/refcodes-mint with Authorization: Bearer $CRON_SECRET (up to 20 approved rewards per run).
    4. VerifyReferred order → settlements with referralCommission + erp_sales_assists + referral_rewards sharing orderReference.
    Smoke suites

    Run ./scripts/run-all-smokes.sh (sets DB_BACKEND_MODE and NODE_OPTIONS=--conditions=react-server). Targeted: smoke-erp-referral-pipeline.cts, smoke-growth-pipelines.cts, smoke-refcodes-http.cts.

    Related

    • Referral codes — user/admin UI, contract deploy, env vars
    • ERP commissions — settlement hierarchy and payout modes
    • PaymentConductor — webhooks and orderReference contract
    • Multi-vendor store — checkout and vendor flows

    Architecture

    Cookie → ledger → contract integration map and idempotency keys.

    Architecture

    Cookie → ledger → contract integration map and idempotency keys.

    Architecture

    Cookie → ledger → contract integration map and idempotency keys.