Skip to content

Event Ticketing: dynamic pricing and cancelled-event batch refunds#287

Merged
codebestia merged 1 commit into
ShadeProtocol:mainfrom
josephchimebuka:feat/event-dynamic-pricing-batch-refunds-261-264
Apr 29, 2026
Merged

Event Ticketing: dynamic pricing and cancelled-event batch refunds#287
codebestia merged 1 commit into
ShadeProtocol:mainfrom
josephchimebuka:feat/event-dynamic-pricing-batch-refunds-261-264

Conversation

@josephchimebuka
Copy link
Copy Markdown
Contributor

Summary

This PR implements two ticketing enhancements in the Shade event module:

  • Dynamic time-based ticket pricing (early-bird discount vs late markup)
  • Automated batch refunds for cancelled events

Issues Closed

Closes #264
Closes #261

What Changed

1) Dynamic Pricing Models (#264)

  • Added configurable dynamic pricing controls per event:
    • early_bird_end timestamp
    • early_bird_discount_bps
    • late_markup_bps
  • Added new public methods:
    • configure_dynamic_pricing(merchant, event_id, early_bird_end, early_bird_discount_bps, late_markup_bps)
    • get_current_ticket_price(event_id)
  • Updated purchase flow to evaluate current time and apply pricing adjustment before Shade payment split:
    • During early-bird window: discounted price
    • After early-bird window: marked-up price
    • If not configured: base price remains unchanged
  • Applied the same dynamic unit-price logic to bulk purchase calculations.

2) Batch Refund Logic for Cancelled Events (#261)

  • Added cancellation + batch refund flow:
    • cancel_event_and_batch_refund(merchant, event_id)
  • Flow behavior:
    • Validates merchant authorization for the event
    • Marks event as cancelled
    • Iterates all ticket IDs in EventTickets(event_id)
    • Refunds each holder based on stored primary purchase price (ticket.purchase_price)
    • Marks refund processing complete to prevent duplicate execution
  • Added guardrails:
    • Ticket purchases/resales are blocked for cancelled events
    • Second refund attempt for same event is rejected

Data Model Updates

  • Event now tracks:
    • early_bird_end, early_bird_discount_bps, late_markup_bps
    • cancelled, refunds_processed
  • Ticket now stores:
    • purchase_price (captured at purchase time and used for cancellation refunds)

Interface / Contract Surface

  • Extended Shade trait and implementation with:
    • configure_dynamic_pricing
    • get_current_ticket_price
    • cancel_event_and_batch_refund

Tests

Added/updated event ticket tests to cover:

  • Dynamic pricing transition (early-bird discounted buy, late marked-up buy)
  • Batch refunds returning funds to all ticket holders after cancellation
  • Duplicate batch refund prevention

Executed:

  • cargo test -q test_event_tickets in contracts/shade
  • Result: passing (17 passed)

Acceptance Criteria Mapping

#264 Create Dynamic Pricing Models

  • Time-based price checks implemented
  • Cost adjusted before Shade payment processing
  • Prices adjust over time between early and late windows

#261 Integrate Shade Batch Refund Logic for Cancelled Events

  • Ticket holders iterated via event ticket index
  • Refunds executed through Shade event cancellation/refund workflow
  • Bulk refunds execute correctly with duplicate-refund prevention

@drips-wave
Copy link
Copy Markdown

drips-wave Bot commented Apr 29, 2026

@josephchimebuka Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@codebestia codebestia merged commit a8d5570 into ShadeProtocol:main Apr 29, 2026
2 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Create Dynamic Pricing Models Integrate Shade Batch Refund Logic for Cancelled Events

2 participants