storacha / w3up

⁂ w3up protocol implementation
https://github.com/storacha-network/specs
Other
58 stars 19 forks source link

Pricing capabilities #959

Open Gozala opened 11 months ago

Gozala commented 11 months ago

We want to have capabilities to switch between pricing plans. Here is the preliminary list

Check current plan

{
   "can": "plan/get",
   "with": "did:mailto:web.mail:alice"
}
// receipt
{
   out:
     ok: {
        updatedAt: 1696865150828, // timestamp when plan was set
        product: "did:web:starter.w3up.storage"
     }
   }
}

Update plan

{
  "can": "plan/set"
  "with": "did:mailto:web.mail:alice"
  "nb": {
     "product": "did:web:lite.w3up.storage"
  }
}
// receipt
{
   out:
     ok: {
        updatedAt: 1696865387813, // timestamp when plan was set
        product: "did:web:lite.w3up.storage"
     }
   }
}

List plans (user can choose from)

{
  "can": "plan/list",
  "with": "did:mailto:web.mail:alice"
}
{
  out: {
    ok: {
      "did:web:starter.w3up.storage": {
          ???
      },
      "did:web:lite.w3up.storage": {
         ???
      },
      "did:web:expert.w3up.storage": {
          ??
      }
    }
  }
}
Gozala commented 11 months ago

And here is the my sketch of dynamo table

export const customerTableProps = {
  fields: {
    /**
     * CID of the UCAN invocation that set it to the current value.
     */
    cause: 'string',
    /**
     * DID of the user account e.g. `did:mailto:agent`.
     */
    customer: 'string',
    /**
     * Opaque identifier representing an account in the payment system
     * e.g. Stripe customer ID (stripe:cus_9s6XKzkNRiz8i3)
     */
    account: 'string',
    /**
     * Unique identifier of the product a.k.a tier.
     */
    product: 'string',
    insertedAt: 'string', // `2022-12-24T...`
    updatedAt: 'string', // `2022-12-24T...`
  },
  primaryIndex: { partitionKey: 'customer' },
}
travis commented 11 months ago
    updatedAt: 1696865150828, // timestamp when plan was set

We have generally used ISO8601 date strings in capabilities, so I think it makes sense to stick with them.

Otherwise this all looks great!

per the update above, I've implemented plan/get in https://github.com/web3-storage/w3up/pull/1005