-
-
Notifications
You must be signed in to change notification settings - Fork 138
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
Implement Default
Trait for CreatePaymentIntent
Struct
#639
Comments
Have you considered just using let mut params = CreatePaymentIntent::new(amount, currency);
params.payment_method = ...
params.customer = ...
params.confirm = ...
params.off_session = ... |
Yes I did. I am not a big fan of having to mutate the instance. I know this works but I want to make it very clear that there is nothing changed to the payment intent in the creation. So it is more ergonomically but in my eyes not cleanly written. Thanks for the help though :) |
You could also try something like this to get the ergonomics you want: let params = {
let mut params = CreatePaymentIntent::new(amount, currency);
params.payment_method = ...
params.customer = ...
params.confirm = ...
params.off_session = ...
params
}; This way the mutability is limited only to the scope of your initialization. |
Thanks! I really like that idea of using scope and name aliasing. Never thought if that but really cool idea. Definitely going to use that in other code too. |
Is your feature request related to a problem? Please describe.
I am currently using this crate to implement a pre-authorization payment which requires some tweaking of the
createPaymentIntent
struct. I am following the instructions in the stripe docs on "Place a hold on a payment method". The issue is more about improving ergonomics rather than adding new functionality. As of my knowledge for my use case I need to initialize the struct with all fields which is quite tedious.Describe the solution you'd like
I would implement the
Default
trait forCreatePaymentIntent
to simplify the initialization process to allow only using subsets of the fields.So some implementation such as this:
Describe alternatives you've considered
No response
Additional context
No response
The text was updated successfully, but these errors were encountered: