ChainSafe / ChainSafe/open-creator-rails

Subscription plan selection UX — show multiple payment options at purchase

Open
#98 2 comments 0 reactions 1 assignee Claimed by @dhyaniarun1993 View on GitHub
Dominant language
Solidity
Stars
2
Forks
1
PR merge metrics
No merged PRs in 30d

Description

## What

The SDK needs to expose a method that returns all available subscription plans for a given asset in a structured, consumable format — so that integrators can render a plan-selection UI without manually parsing on-chain tier data.

## Why

Integrators (e.g. a game portal) need to present subscription options to players. Currently they would have to read raw tier data from the contract and manually compute durations and prices. The SDK should abstract this.

## Required SDK surface

```ts
// Returns all purchasable plans for an asset
getAvailablePlans(assetAddress: string): Promise

interface SubscriptionPlan {
id: string // tier identifier
durationSeconds: number // total duration covered
totalPrice: bigint // total USDC cost
pricePerMonth: bigint // normalised monthly rate for display
label?: string // optional human-readable hint (e.g. "1 month", "1 year")
}
```

- Reads from on-chain tier data (#31) and base price (#97)
- Returns plans sorted by duration ascending
- The `subscribe` call should accept a `SubscriptionPlan` (or plan id) directly

## Acceptance Criteria

- [ ] `getAvailablePlans(assetAddress)` returns correct tiers from chain
- [ ] Returned data is sufficient to render a plan picker without additional contract calls
- [ ] `subscribe` accepts a selected plan and validates payment accordingly
- [ ] Documented with usage example in SDK docs

## Dependencies

- #31 — tiered pricing by duration
- #97 — flexible base price

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.