-
Notifications
You must be signed in to change notification settings - Fork 353
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
Support new Checkout flow #466
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks pretty close! Just a few comments and we can merge. Thank you!
lib/stripe/checkout/session.ex
Outdated
optional(:state) => String.t() | ||
} | ||
|
||
@type shipping_info :: %{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in stripe/types.ex
, we have a shipping
type
lib/stripe/checkout/session.ex
Outdated
|
||
@type capture_method :: :automatic | :manual | ||
|
||
@type address :: %{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in stripe/types.ex
, we have a shipping
type
lib/stripe/checkout/session.ex
Outdated
optional(:application_fee_amount) => integer(), | ||
optional(:capture_method) => capture_method, | ||
optional(:description) => String.t(), | ||
optional(:metadata) => map(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
r/String.t()/Stripe.Types.metadata()
use Stripe.Entity | ||
import Stripe.Request | ||
|
||
@type line_item :: %{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have a Stripe.LineItem
object. Has everything except images
. Don't see it here though 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that might be a new feature for the new Stripe Checkout: https://stripe.com/docs/api/checkout/sessions/create#create_checkout_session-line_items
My personal thinking is that the Stripe.LineItem
type has a lot of fields on it that won't be accepted by this endpoint, so it would be better to have a second local line_item
type that is specific to this use case. If you prefer though, I'm happy to add an images
field to Stripe.LineItem
and use that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
na we can leave it as is 👍
result = Converter.convert_result(fixture) | ||
|
||
assert result == expected_result | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
lib/stripe/checkout/session.ex
Outdated
optional(:subscription_data) => subscription_data | ||
} | ||
|
||
@type t :: %{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need %__MODULE__{
here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great catch!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Woooo hoooo! Lmk how it works on your end!
Works great! The new checkout flow also uses a new |
Stripe is launching a new flow for Checkout: https://stripe.com/docs/payments/checkout
This PR adds the backend Session functionality that is required for this new flow. Because this is my first major PR to this library, I have tried to maintain the style of existing modules, but I would love feedback on anything I could be doing better.