stripe-dotnet: Trying To Create Card With Metadata Causes Exception

I have the following code:

Stripe.StripeCardCreateOptions CardCreateOptions = new Stripe.StripeCardCreateOptions();
CardCreateOptions.Source = new Stripe.StripeSourceOptions();
CardCreateOptions.Source.TokenId = PaymentId;
CardCreateOptions.Source.Metadata = new Dictionary<string, string>();
CardCreateOptions.Source.Metadata["parentUserId"] = Id;
Stripe.StripeCardService CardService = new Stripe.StripeCardService();
Stripe.StripeCard Card = CardService.Create(StripeCustomerId, CardCreateOptions);

It always produces the following exception:

“Error while talking with one of our backends. Sorry about that! We have been notified of the problem. Please contact support@stripe.com if you have any questions.”

If I comment out the two lines creating the card metadata, everything works properly.

Any ideas here?

About this issue

  • Original URL
  • State: closed
  • Created 9 years ago
  • Comments: 21 (9 by maintainers)

Most upvoted comments

@jaymedavis your answer helped me. Thanks.

You cannot set a source token AND a source card - it’s one or the other. That’s why the code examples are separate.