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

Allow for token on Stripe.Customer.create/1 / Stripe.Customer.create/2 #478

Closed
Kartstig opened this issue Apr 8, 2019 · 1 comment · Fixed by #523
Closed

Allow for token on Stripe.Customer.create/1 / Stripe.Customer.create/2 #478

Kartstig opened this issue Apr 8, 2019 · 1 comment · Fixed by #523

Comments

@Kartstig
Copy link

Kartstig commented Apr 8, 2019

According to the Stripe Customer Documentation, a token can be passed into this endpoint which will create a new default payment source for the customer:
Screenshot from 2019-04-08 12-43-23

Currently, this method accepts a Stripe.Source.t(), but that would require an additional HTTP request. Instead, if we allow a binary type for the param token then we can let Stripe handle the downstream Source creation.

I'm currently getting around this by doing the following:

Stripe.Customer.create(%{source: %Stripe.Source{token: "tok_visa"}})

This allows the token to be passed when it encounters cast_id

However, this isn't really clear in the docs. If we don't want to change the type contracts to accept a binary() for source, then maybe we should indicate this solution in the documentation. Also, there are no tests that pass parameters to this function, the only test for create passes an empty map.

@Kartstig
Copy link
Author

Kartstig commented Apr 8, 2019

It seems to be working fine with the specified workaround, however, Dialyzer is yelling at me

snewcomer pushed a commit that referenced this issue Jul 26, 2019
We're already coercing the source to an id via the `cast_to_id` call,
this just makes the typespec match the implementation.

Closes #478
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 a pull request may close this issue.

1 participant