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

Proposal: Expose headers to class functions for Connect usage #91

Closed
dmvt opened this issue Sep 29, 2016 · 0 comments
Closed

Proposal: Expose headers to class functions for Connect usage #91

dmvt opened this issue Sep 29, 2016 · 0 comments

Comments

@dmvt
Copy link
Contributor

dmvt commented Sep 29, 2016

When acting on behalf of a Connected account, Stripe recommends using the Stripe-Account header as seen here: https://stripe.com/docs/connect/payments-fees#charging-directly

I propose updating the class functions to expose headers in the following way:

This:

  def create(params, key) do
    Stripe.make_request_with_key(:post, @endpoint, key, params)
    |> Stripe.Util.handle_stripe_response
  end

would become this:

  def create(params, key_or_headers) when is_bitstring(key_or_headers) do
    Stripe.make_request_with_key(:post, @endpoint, key_or_headers, params)
    |> Stripe.Util.handle_stripe_response
  end

  def create(params, key_or_headers) when is_map(key_or_headers) do
    Stripe.make_request_with_key(
      :post, @endpoint, Stripe.config_or_env_key, params, key_or_headers
    )
    |> Stripe.Util.handle_stripe_response
  end

This still allows a key override but also supports passing any headers required without using the low level API on the Stripe class. With your approval, I'll submit a PR in the next week or so.

@dmvt dmvt closed this as completed Oct 20, 2016
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

No branches or pull requests

1 participant