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

Conversation

PabloG6
Copy link
Contributor

@PabloG6 PabloG6 commented Apr 21, 2020

Made a minor change to the api that allows you to pass a default payment method directly into the parameters of Stripe.Subscription.create.

@coveralls
Copy link

coveralls commented Apr 21, 2020

Coverage Status

Coverage remained the same at 88.079% when pulling afe4c3e on PabloG6:master into e54dd47 on code-corps:master.

@@ -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.

@@ -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.

Copy link
Collaborator

@snewcomer snewcomer left a comment

Choose a reason for hiding this comment

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

🥇

@snewcomer snewcomer merged commit 337807d into beam-community:master Jun 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants