Using Stripe elements and Stripe.net. I get the token and create a customer and source and charge it using the following code - works fine
StripeConfiguration.SetApiKey(stripeKey);
var charges = new StripeChargeService();
var charge = charges.Create(new StripeChargeCreateOptions
{
Amount = thisCharge.Amount,
Currency = "usd",
Description = thisCharge.ProductDesc,
StatementDescriptor = thisCharge.ProductDesc,
//SourceTokenOrExistingSourceId = source.Id,
ReceiptEmail = thisCharge.EmailAddress,
CustomerId = thisCharge.StripeCustomerID,
Metadata = new Dictionary<String, String>()
{
{ "Name", thisCharge.CardHolderName }, { "Email",thisCharge.EmailAddress }
}
});
I then try a second charge using a different card (5555 5555 5555 4444) with that same customer but apparently I am missing something.
using this code
static StripeSource NewSource(string stripeKey, Charge charge)
{
StripeConfiguration.SetApiKey(stripeKey);
var sourceOptions = new StripeSourceCreateOptions
{
Type = StripeSourceType.Card,
Currency = "usd",
Amount = charge.Amount,
Token = charge.Token,
Owner = new StripeSourceOwner
{
Email = charge.EmailAddress,
Name = charge.CardHolderName
}
};
var sourceService = new StripeSourceService();
StripeSource source = sourceService.Create(sourceOptions);
return source;
}
But I get this error:
Invalid token id: src_....
If I skip adding the new source then the charge goes through but against the original source.
So obviously missing something... any help is appreciated.