2

Is there a way I can add multiple cards for a customer using stripe.net, I know that we need to retrieve the customer and add a new card using the source object as shown here(https://stripe.com/docs/api#create_card). But with the stripe.net I cant seem to figure how to do this, any pointers will be great help.

2 Answers2

2

Figured it out. If it helps anyone here is the way I did it:

var myCustomer = new StripeCardCreateOptions();       
myCustomer.SourceCard = new SourceCard
{
   Number = txtnumero.Text,
   ExpirationYear = txtyear.Text,
   ExpirationMonth = txtmonth.Text,
   Cvc = txtCVV.Text
 };

 StripeCardService NewStripeCardService = new StripeCardService();
 StripeCard stripeCustomer = NewStripeCardService.Create(**CustomerID**,myCustomer);
2

Update to address changes in the Stripe API..

var myCustomerCardNested = new Stripe.CardCreateNestedOptions();
myCustomerCardNested.Number = cardNumber;
myCustomerCardNested.ExpYear = year;
myCustomerCardNested.ExpMonth = month;
myCustomerCardNested.Cvc = CVC;

var myCustomerCard = new Stripe.CardCreateOptions() { SourceCard = myCustomerCardNested };
stripeCustomerCard = NewStripeCardService.Create(stripeCustomer.Id, myCustomerCard);
Scooter
  • 364
  • 3
  • 8