Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

changed params for subscription to accept default payment method #592

Merged
merged 2 commits into from
Jun 2, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/stripe/subscriptions/subscription.ex
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ defmodule Stripe.Subscription do
optional(:trial_from_plan) => boolean,
optional(:trial_period_days) => non_neg_integer
}
def create(%{customer: _, items: _} = params, opts \\ []) do
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

THis ensures that the create action is passed with a customer and items.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think we need this? It seems these two are required.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ping!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh sorry, I think it's necessary to provide it for the sake of keeping in line with the tutorial. If we'd like to figure out if the user has passed in a customer and items key, we can probably just use the Map.has_key?(params, :customer) and if it returns false, we throw an exception.

def create(params, opts \\ []) do
new_request(opts)
|> put_endpoint(@plural_endpoint)
|> put_params(params)
Expand Down Expand Up @@ -164,6 +164,7 @@ defmodule Stripe.Subscription do
optional(:items) => [
%{
:plan => Stripe.id() | Stripe.Plan.t(),
optional(:id) => Stripe.id() | binary(),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's located here as an optional parameter

It's also considered a required parameter when upgrading and downgrading a user subscription
When updating a new subscription, it's considered to be an optional parameter. When I was attempting to upgrade and downgrade my current subscription, I realized this library doesn't allow for me to upgrade/downgrade an existing subscription.

optional(:billing_methods) => map,
optional(:metadata) => map,
optional(:quantity) => non_neg_integer,
Expand Down