When taking payments though stripe in my Phoenix application, the posting of the credit card information goes directly to the stripe service for PCI reasons. It works this way regardless of the backend for good reason, but this means storing the billing information for an account or user is not a normal CRUD operation.
Assuming my billing schema looks like this (below), what would be the preferred way to handle the interaction to stripe? In the controller, in the changeset using virtual fields or wrap the stripe interaction into a larger function that gets called from the controller.
Handling it in the changeset looks appealing but this is a lot of interaction that is just tangentially related to storing the billing information.
schema "billings" do
field :customer_id, :string
field :payment_id, :string
field :card_brand, :string
field :card_exp_month, :integer
field :card_exp_year, :integer
field :card_last4, :string
field :card_updated, :utc_datetime
belongs_to :user, Testapp.Accounts.User
field :subscription_id, :string
field :subscription_period_end, :utc_datetime
field :subscription_period_start, :utc_datetime
field :subscription_status, :string
field :subscription_type, :string, virtual: true
timestamps()
end