BillingWallet billing.wallet@1

Generated at from openvibe-contracts v0.419.0 and openvibe-sdk v0.161.0.

Version
1.0.0
Owner
billing
Visibility
public
Status
active
Compatibility
backward
Schema
https://openvibe.network/contracts/billing/wallet.v1.json

Universal wallet: billing.wallet. Personal bearer reads and purchases; server-side reviewed prices.

Fields

FieldTypeRequiredDescriptionConstraints
subjectobjectyes
  • no other fields
subject.typeconstyes
  • = "user"
subject.idstringyes
  • pattern ^usr_[0-9A-HJKMNP-TV-Z]{26}$
currencyconstyes
  • = "USD"
money_writes_frozenbooleanyes
used_ai_this_monthbooleanyes
balancesobjectyes
  • no other fields
balances.coinsobjectyes
  • no other fields
balances.coins.labelstringyes
balances.coins.amountstringyes
  • pattern ^[0-9]+$
balances.coins.currencyenumyes
  • one of "opencoins", "vibes-bits", "USD"
balances.coins.scaleenumyes
  • one of 0, 9
balances.coins.purposestringyes
balances.coins.actionstringyes
balances.coins.heldstring
  • pattern ^[0-9]+$
balances.vibesobjectyes
  • no other fields
balances.vibes.labelstringyes
balances.vibes.amountstringyes
  • pattern ^[0-9]+$
balances.vibes.currencyenumyes
  • one of "opencoins", "vibes-bits", "USD"
balances.vibes.scaleenumyes
  • one of 0, 9
balances.vibes.purposestringyes
balances.vibes.actionstringyes
balances.vibes.heldstring
  • pattern ^[0-9]+$
balances.balanceobjectyes
  • no other fields
balances.balance.labelstringyes
balances.balance.amountstringyes
  • pattern ^[0-9]+$
balances.balance.currencyenumyes
  • one of "opencoins", "vibes-bits", "USD"
balances.balance.scaleenumyes
  • one of 0, 9
balances.balance.purposestringyes
balances.balance.actionstringyes
balances.balance.heldstring
  • pattern ^[0-9]+$
bits_per_usdnumberyes
recent_activityarray of objectyes
  • maxItems 5
  • items: no other fields
recent_activity[].idstringyes
recent_activity[].atstringyes
  • format date-time
recent_activity[].kindenumyes
  • one of "coins", "vibes", "balance"
recent_activity[].amountstringyes
  • pattern ^-?[0-9]+$
recent_activity[].labelstringyes
recent_activity[].detailstringyes
recent_activity[].sitestringyes
checkoutobjectyes
  • no other fields
checkout.providersarray of objectyesThe checkout providers on offer, each with the hosts its hosted checkout may use. The wallet follows a checkout_url only to one of these hosts or to Billing itself.
  • items: no other fields
checkout.providers[].namestringyes
  • minLength 1
  • maxLength 40
checkout.providers[].hostsarray of stringyes
  • items: minLength 1
  • items: maxLength 253
checkout.vibesobjectyes
  • no other fields
checkout.vibes.minimumintegeryes
  • minimum 1
checkout.vibes.maximumintegeryes
  • minimum 1
checkout.vibes.price_tiersarray of objectyes
  • items: no other fields
checkout.vibes.price_tiers[].minintegeryes
  • minimum 0
checkout.vibes.price_tiers[].usd_per_bitnumberyes
checkout.topupobjectyes
  • no other fields
checkout.topup.enabledbooleanyes
checkout.topup.amounts_centsarray of integeryes
  • items: minimum 1
checkout.topup.fee_bpsinteger | nullyes
  • minimum 0
  • maximum 10000

Examples

From the contract's own test fixtures: valid ones validate, rejected ones must fail.

Valid: example
{
  "subject": {
    "type": "user",
    "id": "usr_00000000000000000000000001"
  },
  "currency": "USD",
  "money_writes_frozen": false,
  "used_ai_this_month": true,
  "balances": {
    "coins": {
      "label": "OpenCoins",
      "amount": "0",
      "currency": "opencoins",
      "scale": 0,
      "purpose": "Earned by taking part",
      "action": "How to earn OpenCoins"
    },
    "vibes": {
      "label": "Vibes",
      "amount": "0",
      "currency": "vibes-bits",
      "scale": 0,
      "purpose": "Support creators and buy items",
      "action": "Buy Vibes"
    },
    "balance": {
      "label": "Balance",
      "amount": "0",
      "currency": "USD",
      "scale": 9,
      "purpose": "AI and paid features",
      "action": "Top up"
    }
  },
  "bits_per_usd": 100,
  "recent_activity": [],
  "checkout": {
    "providers": [
      {
        "name": "stripe",
        "hosts": [
          "checkout.stripe.com"
        ]
      }
    ],
    "vibes": {
      "minimum": 100,
      "maximum": 100000,
      "price_tiers": [
        {
          "min": 100,
          "usd_per_bit": 0.012
        }
      ]
    },
    "topup": {
      "enabled": true,
      "amounts_cents": [
        1000
      ],
      "fee_bps": 0
    }
  }
}
Rejected: invalid-value
{
  "subject": {
    "type": "user",
    "id": "usr_00000000000000000000000001"
  },
  "currency": "USD",
  "money_writes_frozen": false,
  "used_ai_this_month": true,
  "balances": {},
  "bits_per_usd": 100,
  "recent_activity": [],
  "checkout": {
    "providers": [
      "stripe"
    ],
    "vibes": {
      "minimum": 100,
      "maximum": 100000,
      "price_tiers": [
        {
          "min": 100,
          "usd_per_bit": 0.012
        }
      ]
    },
    "topup": {
      "enabled": true,
      "amounts_cents": [
        1000
      ],
      "fee_bps": 0
    }
  }
}
Rejected: missing
{}

Validate

const contracts = require('openvibe-contracts');
contracts.validate('billing.wallet@1', value);   // { valid, errors: [{ path, message }] }