ฉันยังใหม่กับ Stripe ฉันใช้ระบบการชำระเงินด้วยบัตรโดยใช้ Stripe ใน .NET
รหัสของฉันอยู่ภายใต้:
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 });
ดังที่คุณเห็นข้างต้น ฉันกำลังส่ง CustomerId ที่ฉันจัดเก็บไว้ใน DB
ปัญหาคือลูกค้าที่ชำระเงินแต่ละครั้งจะป้อนบัตรใบเดียวกัน 4242 4242 4242 4242
โดยมีวันหมดอายุเดียวกัน 12/20
และ CVV 123
แต่ Stripe กำลังสร้างบัตรหลายใบเมื่อเห็นบนแดชบอร์ดสำหรับลูกค้ารายเดียวกัน
นอกจากนี้ ฉันสามารถส่งรหัสวิธีการชำระเงิน (รหัสบัตรที่บันทึกด้วย Stripe สำหรับการชำระเงินครั้งที่ผ่านมา) เพื่อให้ลูกค้าไม่จำเป็นต้องป้อนรายละเอียดบัตรและสามารถเลือกบัตรที่ใช้ในการชำระเงินในอดีตได้โดยตรงหรือไม่