Stripe-dotnet: One time charge getting "Must provide source or customer id" error response

Created on 21 May 2015  ·  5Comments  ·  Source: stripe/stripe-dotnet

I'm using the latest version of Stripe.net (nice API by the way!), my version of the stripe api on my stripe dashboard is 2013-08-13 (if that matters which I doubt that it does). I get the error noted in the subject line above with the code below (I get a valid tokenID back from a javascript call to stripe prior to invoking this c# method). Any clues to what I'm doing wrong?

StripeChargeCreateOptions oneTimeCharge = new StripeChargeCreateOptions();

oneTimeCharge.Amount = 13900;
oneTimeCharge.Currency = "usd";
oneTimeCharge.Description = "New purchase";
oneTimeCharge.Card = new StripeCreditCardOptions();
oneTimeCharge.Card.TokenId = viewModel.StripeToken;

StripeChargeService chargeService = new StripeChargeService();
StripeCharge stripeCharge;
try
{
stripeCharge = chargeService.Create(oneTimeCharge);
}
catch (StripeException se)
{
// Declined or some other problem. Return message to the user.
viewModel.ErrorMessage = se.Message;
return;
}

Most helpful comment

I'm not able to change the API key from the account settings in stripe, I've even created a brand new account and it stated "API version will be automatically chosen when you make the first API usage", so I did a Stripe.NET connection and it chose " 2015-04-07 (latest)". So I'm pretty stuck right now.

EDIT:
Problem solved, it was a problem with a null token string. My error, sorry.

All 5 comments

Did you ever create a StripeCustomer? If so, you will need to set the CustomerId on oneTimeCharge.

edit: source was added in a later version of the stripe api, which stripe.net does not use yet. So that shouldn't be applicable.

I'm having the same issue, I don't want to use StripeCustomers. The fact is that stripe uses the "source" parameter to pass the TokenID. How can I solve this? https://stripe.com/docs/tutorials/charges

There is a test for this case, which passes for me. I'm not sure what is different in your situation other than the API key (which might have an impact if Stripe is attempting to look for source). Try changing the API key to "2015-02-10" and see if that has an impact.

Otherwise, you could attach a debugger & put a breakpoint at GetWebRequest to verify that there is a proper "card[tokenid]" parameter in the url.

I'm not able to change the API key from the account settings in stripe, I've even created a brand new account and it stated "API version will be automatically chosen when you make the first API usage", so I did a Stripe.NET connection and it chose " 2015-04-07 (latest)". So I'm pretty stuck right now.

EDIT:
Problem solved, it was a problem with a null token string. My error, sorry.

@spiez he how were able to solve the problem with JS file sending a null token string. i am having the same issue. I don't believe my Js file is parsing the info

Was this page helpful?
0 / 5 - 0 ratings