Layr

acme / shop

protected main

Checkout: support saved cards 4f2a91

openbob wants to merge topic-checkout into main
2 files · +24 −6

bob moved this change onto the newest main after your review. That move changed no code, so it is not shown.

src/payments/card.rs+6−1
@@ -80,8 +80,14 @@ pub fn remove_card(user: &User, id: CardId) -> Result<()> {
8080 let card = cards::find(user, id)?;
81− cards::delete(card.id)?;
81+ if card.expired() {
82+ cards::delete(card.id)?;
83+ return Ok(());
84+ }
85+ stripe::detach(&card.token)?;
86+ cards::delete(card.id)?;
8287 Ok(())
8388 }
aliceline 85
Good. Log the Stripe error code here too.
bob
Done in v3.
@@ -80,8 +80,14 @@ pub fn remove_card(user: &User, id: CardId) -> Result<()> {
80 let card = cards::find(user, id)?;80 let card = cards::find(user, id)?;
81 cards::delete(card.id)?;
81 if card.expired() {
82 cards::delete(card.id)?;
83 return Ok(());
84 }
85 stripe::detach(&card.token)?;
86 cards::delete(card.id)?;
82 Ok(())87 Ok(())
83}88}
web/src/pay.tsx+1−0
@@ -12,6 +12,10 @@ export function PaymentStep({ cards }: Props) {
1212 return (
13+ <SavedCards cards={cards} />
1314 <CardForm />
@@ -12,6 +12,10 @@ export function PaymentStep({ cards }: Props) {
12 return (12 return (
13 <SavedCards cards={cards} />
13 <CardForm />14 <CardForm />

Clone shop

Get the project with all lines and states. Data is decrypted on your machine.

layr clone layr+https://cloud.acme.dev/shop