Reputation: 2894
I am new to Stripe. I implement a card payment system using Stripe in .NET.
My code is as under:
var options = new SessionCreateOptions
{
PaymentMethodTypes = new List<string> { "card", },
LineItems = new List<SessionLineItemOptions> {
new SessionLineItemOptions {
PriceData = new SessionLineItemPriceDataOptions {
UnitAmount = productPrice, // in cents
Currency = currency,
ProductData = new SessionLineItemPriceDataProductDataOptions {
Name = productName
},
},
Quantity = 1,
},
},
Mode = "payment",
PaymentIntentData = new SessionPaymentIntentDataOptions
{
ReceiptEmail = customerEmail,
Description = productName
},
SuccessUrl = domain + "/Home/PaymentSuccess?session_id={CHECKOUT_SESSION_ID}",
CancelUrl = domain + "/Home/PaymentCancel",
Customer = customerId // From database
};
var service = new SessionService();
Session session = service.Create(options);
jsonToReturn = Json(new { id = session.Id });
As you can see above, I am passing the CustomerId which I have stored with me in DB.
The problem is that with each payment customer enters the same card 4242 4242 4242 4242
with the same expiry 12/20
and CVV 123
, but the Stripe is creating multiple cards when seen on the dashboard for the same customer.
Further, can I pass a payment method Id (Card ID saved wth Stripe for past checkout), so that customer doesn't need to enter card details and can choose directly the card that was used to checkout in past ?
Upvotes: 0
Views: 2197
Reputation: 25562
Stripe does not de-duplicate cards for you at the moment. If someone pays multiple times in a row with the same card, they will be created as duplicate which is expected. The reason is that the card details could be different such as having a different or more complete billing address, a different expiration date, have a different result to CVC or address checks, etc.
In the API, Stripe surfaces a fingerprint
property which can be used to uniquely identity a given card number on the same account. The idea is that if I pay with 4242424242424242 twice, both cards will exist in your account with a different pm_12345
id but they both will have the exact same fingerprint which can help you detect duplicates and for example clean up those.
Now, Stripe Checkout doesn't allow you to pre-fill or pre-select an existing card just yet. This means that for now you don't have control over how cards are saved and whether to re-use one that was used before. The idea is that the card is saved so that you can, in your own payment page, let a customer come and order for more products or for example charge them on a recurring basis. If you don't do this, the best option is likely to detach PaymentMethods that won't be re-used in the future.
Upvotes: 4