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

Wrong "StripeInvalidRequestError, Must provide source or customer" error? #307

Closed
bebbi opened this issue Feb 17, 2017 · 8 comments
Closed

Comments

@bebbi
Copy link

bebbi commented Feb 17, 2017

If I add

stripe_account: 'acct_XXXX',
application_fee: 100

to my call to stripe.charges.create(), it consistently fails with the error in the title. If I leave these out, it consistently succeeds.

Reading the API docs I realize that coming from python I'm probably posting the "stripe_account" info in the wrong way, but the error still looks invalid.

Two examples of the full payload (some anon with dots by me):

Success:

{
  "source": "tok_19oF...IZNC",
  "capture": false,
  "amount": 33000,
  "currency": "EUR",
  "description": "Some description",
  "receipt_email": "[email protected]",
  "metadata": {
    [... some metadata...]
  }

Failure:

{
  "source": "tok_19oF...StPM",
  "capture": false,
  "amount": 33000,
  "currency": "EUR",
  "application_fee": 100,
  "stripe_account": "acct_18Ea...",
  "description": "Some description",
  "receipt_email": "[email protected]",
  "metadata": {
    [... some metadata...]
  }
}
@remi-stripe
Copy link
Contributor

The stripe_account parameter must be passed in a separate hash. The code should be:

stripe.charges.create(
  {
    "source": "tok_19oF...StPM",
    "capture": false,
    "amount": 33000,
    "currency": "EUR",
    "application_fee": 100,
    "description": "Some description",
    "receipt_email": "[email protected]",
    "metadata": {
      [... some metadata...]
    }
  },
  {stripe_account: "acct_XXXXXX"}
);

@bebbi
Copy link
Author

bebbi commented Feb 19, 2017

Thanks for the clarification @remi-stripe! And apologies for confusion, this issue should actually be about the misleading error, not the actual call - it should probably say something along 'unexpected account_id field' rather than 'must provide source or customer'.

@remi-stripe
Copy link
Contributor

@bebbi I can't find that specific request but my guess is that something is not sent properly in your code so we default to the common error indicating that to charge a customer you need to pass a token or a customer id.

@jlomas-stripe
Copy link
Contributor

@bebbi There's an issue in the way requests get created if you don't separate out stripe_account into the options object: what ends up happening there is that all your values disappear in the request that Stripe receives, so Stripe's API responds to what it got in that case - which is a request without a source or customer.

@staringispolite
Copy link

I'm getting this error when I just try to package it up for the very first time with grunt run/grunt package, per the README instructions. What am I missing? There shouldn't be any stripe requests triggered in setup, should there?

@jlomas-stripe
Copy link
Contributor

@staringispolite This library is only for server-side use. On the client side, you'll want to use Checkout or Elements.

@Hasnain-110
Copy link

Hasnain-110 commented Jul 28, 2022

StripeInvalidRequestError: Funds can't be sent to accounts located in IN because it's restricted outside of your platform's region
can we avoid this error in stripe test mode?
@staringispolite jlomas-stripe
@TaylorBriggs

@remi-stripe
Copy link
Contributor

@Hasnain-110 this is a github issue from 5 years and you provided zero information and it's irrelevant to the question at hand.

Please work with our support team for help instead https://support.stripe.com/contact

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

5 participants