-
Notifications
You must be signed in to change notification settings - Fork 85
Closed
Description
Problem
Right now, this is how the creation of a subscription record works:
- We get the quantity and the current user
- We do a
store.createRecordusing quantity and current user. - We call save, with an
adapterOptionsparameter hash, containing aprojectIdkey
subscription.save({ adapterOptions: { projectId: currentProjectId} })The adapterOptions hash is handled during serialization and the project id is added as a plain JSON API attribute to the payload.
Then, on the API side, the controller receives the request and passes the parameters into StripeService.StripeConnectSubscription.find_or_create/2, which, during a long process, loads the project and the plan for that project, then assigns the plan to the subscription during creation.
My guess is, this was done when we didn't yet have a stripe connect plan relationship with the project on ember side. It's needlessly complicated.
I propose that we do the following:
In Ember we simply
- fetch the
user,quantityandstripeConnectPlan - create and save a
stripeConnectSubscriptionrecord using those properties - get rid of the whole
adapterOptionslogic - get rid of the
projectIdvirtual attribute
In API we
- expect the
find_or_createrequest to receive a plan id - rework project loading to load by associated plan id (we still need the project to validate that it is ready to accept donations)
- everything else remains the same
- clean up subscription controller tests. they do not need the custom payloads anymore