Brownie-Points Redemption — WordPress Proxy Endpoint Spec

Phase 2 · 1 BP = $1.00 USD · Per-member fixed-rate currency · Inspection surface · 05 October 2026 (Monday, UTC)

1. The Brownie-Points system, anchored

Brownie Points (BP) are the operation's universal currency at the fixed rate 1 BP = $1.00 USD. The fixed-rate discipline is the load-bearing piece for the operation's universal-currency surface. Brownie Points are not a per-member accounting credit that happens to be exchangeable; Brownie Points are a fixed-rate currency, exchangeable for anything in the operation at 1 BP = $1.00. The wish is the load-bearing piece for the operation's universal-currency surface at the simplest possible discipline.

The earning surface is explicit: marketplace sub-pieces participation, dating sub-piece participation, holiday dreams sub-pieces participation, residency-swap sub-piece participation, ORB-Food vertical participation, Orb-Share Community elder-care work + young-member work-trade, sustained charitable-allocation contribution. The exchange surface is universal: food (ORB-Food vertical purchases), timeshare exchange fees, high-end-home peak-season stays, marketplace purchases, premium features, services, per-plot produce, charity event attendance, maker-space rental. The fixed-rate is the load-bearing piece for the value discipline; the per-jurisdiction financial-services review is the load-bearing piece for the structural protection.

2. The redemption endpoint, in plain words

The WordPress proxy exposes a fifth endpoint at /wp-json/orb-wallet/v1/bp-redeem that handles Brownie-Points redemption at the per-restaurant's online-ordering checkout. The endpoint reads the per-member's BP balance, debits the BP-amount, applies the BP-amount as a per-transaction discount, and returns the discount to the per-restaurant's online-ordering surface. The per-restaurant is paid the gross amount minus the BP-discount; the operator absorbs the BP-discount as the per-Operation currency sponsor.

The endpoint is a POST request. The request body contains the per-member's authentication token (or session cookie), the per-restaurant's slug, the per-transaction subtotal, and the requested BP-amount. The endpoint validates the per-member's authentication, validates the per-restaurant exists, validates the BP-amount does not exceed the per-member's BP balance, validates the BP-amount does not exceed the per-transaction subtotal (you can't pay more in BPs than the total), debits the BP-amount from the per-member's BP balance, credits the per-restaurant's BP-sponsor account with the BP-amount (so the per-restaurant sees a corresponding credit on the operator's platform), and returns the per-transaction discount to the per-restaurant's online-ordering surface.

3. The request shape

POST /wp-json/orb-wallet/v1/bp-redeem
Content-Type: application/json
Cookie: orb_session=<session_token>  // or Authorization: Bearer <jwt>

{
  "restaurant_slug": "trattoria-bellini",
  "subtotal": 78.00,
  "bp_amount": 10,
  "line_items": [
    {"id": "bruschetta", "qty": 2, "price": 12},
    {"id": "burrata", "qty": 3, "price": 18}
  ]
}

4. The response shape

200 OK
Content-Type: application/json

{
  "redemption_id": "bp_1696483200_a3f7e2",
  "bp_amount": 10,
  "discount_amount_usd": 10.00,
  "new_subtotal_usd": 68.00,
  "per_member_new_bp_balance": 47,
  "per_restaurant_bp_credit_balance": 10,
  "redemption_status": "applied"
}

Error responses:

400 Bad Request · bp_amount exceeds subtotal
401 Unauthorized · per-member not authenticated
402 Payment Required · per-member BP balance insufficient
404 Not Found · per-restaurant slug does not exist
409 Conflict · per-restaurant has no active Orb-Wallet subscription

5. The PHP endpoint (the actual code)

// /wp-content/plugins/orb-wallet-gateway/includes/class-bp-redeem.php
add_action('rest_api_init', function () {
  register_rest_route('orb-wallet/v1', '/bp-redeem', [
    'methods' => 'POST',
    'callback' => 'orb_wallet_bp_redeem',
    'permission_callback' => function ($req) {
      return is_user_logged_in();
    }
  ]);
});

function orb_wallet_bp_redeem($request) {
  $user_id = get_current_user_id();
  $slug = sanitize_text_field($request->get_param('restaurant_slug'));
  $subtotal = floatval($request->get_param('subtotal'));
  $bp_amount = intval($request->get_param('bp_amount'));

  // 1. Validate
  if ($bp_amount <= 0) return new WP_Error('invalid_bp_amount', 'BP amount must be > 0', ['status' => 400]);
  if ($bp_amount > $subtotal) return new WP_Error('bp_exceeds_subtotal', 'BP amount exceeds subtotal', ['status' => 400]);

  $restaurant = get_posts(['post_type' => 'orb_wallet_restaurant', 'name' => $slug, 'posts_per_page' => 1]);
  if (empty($restaurant)) return new WP_Error('restaurant_not_found', 'Restaurant not found', ['status' => 404]);
  $restaurant_id = $restaurant[0]->ID;

  $status = get_post_meta($restaurant_id, '_orb_subscription_status', true);
  if ($status !== 'active') return new WP_Error('subscription_inactive', 'Restaurant subscription not active', ['status' => 409]);

  // 2. Read per-member BP balance
  $balance = (int) get_user_meta($user_id, '_orb_bp_balance', true);
  if ($bp_amount > $balance) return new WP_Error('insufficient_bp', 'Insufficient BP balance', ['status' => 402]);

  // 3. Debit per-member, credit per-restaurant sponsor
  $new_balance = $balance - $bp_amount;
  update_user_meta($user_id, '_orb_bp_balance', $new_balance);

  $sponsor_credit = (int) get_post_meta($restaurant_id, '_orb_bp_sponsor_credit', true);
  update_post_meta($restaurant_id, '_orb_bp_sponsor_credit', $sponsor_credit + $bp_amount);

  // 4. Log the redemption
  $redemption_id = 'bp_' . time() . '_' . wp_generate_password(6, false, false);
  wp_insert_post([
    'post_type' => 'orb_wallet_bp_redemption',
    'post_status' => 'publish',
    'post_title' => $redemption_id,
    'post_content' => json_encode([
      'user_id' => $user_id,
      'restaurant_id' => $restaurant_id,
      'bp_amount' => $bp_amount,
      'subtotal' => $subtotal,
      'discount_amount_usd' => $bp_amount * 1.00,
      'new_subtotal_usd' => $subtotal - $bp_amount,
      'timestamp' => current_time('mysql')
    ])
  ]);

  // 5. Return the discount to the per-restaurant's surface
  return [
    'redemption_id' => $redemption_id,
    'bp_amount' => $bp_amount,
    'discount_amount_usd' => $bp_amount * 1.00,
    'new_subtotal_usd' => $subtotal - $bp_amount,
    'per_member_new_bp_balance' => $new_balance,
    'per_restaurant_bp_credit_balance' => $sponsor_credit + $bp_amount,
    'redemption_status' => 'applied'
  ];
}

6. The audit-trail surface, named honestly

Every Brownie-Points redemption is logged in the per-member's audit trail + the per-restaurant's audit trail + the operation-wide audit trail. The redemption is captured as a custom post type orb_wallet_bp_redemption on WordPress, with the per-member's user_id, the per-restaurant's restaurant_id, the BP-amount, the per-transaction subtotal, the discount amount, the new subtotal, the timestamp. The redemption is auditable from the operator's perspective (the per-restaurant's BP-sponsor credit balance is updated in real-time) and from the per-member's perspective (the per-member's BP balance is updated in real-time) and from the per-restaurant's perspective (the per-restaurant sees the redemption on the per-restaurant's Orb-Wallet dashboard).
BP-redemption is a custom post type on WordPress; the post type is the load-bearing piece of the audit trail. The orb_wallet_bp_redemption custom post type stores every redemption event with full JSON metadata. The post type is queryable from the WordPress admin; the post type is queryable from the operator's analytics dashboard; the post type is queryable from the per-restaurant's Orb-Wallet dashboard. The audit trail is one place; the audit trail is on the operator's platform; the audit trail is the load-bearing piece of the trust-earning.
Three failure modes the BP-redemption endpoint must defend against. (1) BP balance tampering — the per-member's BP balance is read from the per-member's user meta, but a malicious per-member could potentially modify the user meta directly. The defense: the BP balance is also stored as a custom post type orb_wallet_bp_ledger with full earning + redemption history; the user meta is the cache, the ledger is the source-of-truth. (2) BP-amount greater than subtotal — the endpoint validates the BP-amount does not exceed the subtotal. (3) BP-amount greater than per-member balance — the endpoint validates the BP-amount does not exceed the per-member's BP balance. The endpoint returns 400 / 402 errors for these cases; the per-restaurant's surface renders the error and the per-member adjusts the BP-amount.