-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add connectio fo payment and add new field on checkout form
- Loading branch information
1 parent
e5d0f91
commit da1c4cb
Showing
19 changed files
with
2,895 additions
and
187 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,13 @@ | ||
# ROADMAP | ||
|
||
- [ ] Add sentry errors in payment checkout and api Cybersource errors | ||
- [ ] Save in table links ids authroize, capture or in table of transactions (Analizer) | ||
- [ ] Add logo of eleven in button payment | ||
- [ ] Fix avoid zoom whne fill fiels on mobile | ||
- [ ] Sticky info payment on the right | ||
- [ ] Middleware no check user logged in when is public route like /:link | ||
- [ ] Redirect when login with google to localhost in production | ||
- [ ] Multiple redirect_urls auth supabase https://supabase.com/docs/guides/auth/redirect-urls for production and dev | ||
- [ ] Add text of "With technology of Cybersource(logo)" | ||
- [ ] Payment checkout Medusa and Cybersource | ||
- [ ] Detect when user leaves the page |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,67 @@ | ||
import { COUNTRIES_REQUIRED_STATE } from "@/lib/cybersource"; | ||
import validCreditCard from "card-validator"; | ||
import { z } from "zod"; | ||
|
||
export const checkoutSchema = z.object({ | ||
email: z.string().email({ message: "Required" }), | ||
"cc-number": z | ||
.string() | ||
.min(16, { message: "Required" }) | ||
.refine( | ||
(value) => { | ||
const cardValidator = validCreditCard.number(value); | ||
return cardValidator.isPotentiallyValid; | ||
}, | ||
{ | ||
message: "Invalid credit card number", | ||
}, | ||
), | ||
"cc-expiration": z | ||
.string() | ||
.min(1, { message: "Required" }) | ||
.refine( | ||
(value) => { | ||
const cardValidator = validCreditCard.expirationDate(value); | ||
return cardValidator.isValid; | ||
}, | ||
{ | ||
message: "Invalid expiration date", | ||
}, | ||
), | ||
"cc-cvv": z | ||
.string() | ||
.min(3, { message: "Required" }) | ||
.max(4, { message: "Required" }), | ||
"cc-name": z.string().min(1, { message: "Required" }), | ||
link: z.string().optional(), | ||
}); | ||
export const checkoutSchema = z | ||
.object({ | ||
email: z.string().email({ message: "Required" }), | ||
"cc-number": z | ||
.string() | ||
.min(1, { message: "Required" }) | ||
.refine( | ||
(value) => { | ||
const cardValidator = validCreditCard.number(value); | ||
return cardValidator.isPotentiallyValid; | ||
}, | ||
{ | ||
message: "Invalid credit card number", | ||
}, | ||
), | ||
"cc-expiration": z | ||
.string() | ||
.min(1, { message: "Required" }) | ||
.refine( | ||
(value) => { | ||
const cardValidator = validCreditCard.expirationDate(value); | ||
return cardValidator.isValid; | ||
}, | ||
{ | ||
message: "Invalid expiration date", | ||
}, | ||
), | ||
"cc-cvv": z | ||
.string() | ||
.min(3, { message: "Required" }) | ||
.max(4, { message: "Required" }), | ||
"cc-name": z.string().min(1, { message: "Required" }), | ||
name: z.string().min(1, { message: "Required" }), | ||
lastName: z.string().min(1, { message: "Required" }), | ||
country: z | ||
.string() | ||
.min(2, { message: "Required" }) | ||
.max(2, { message: "Required" }), | ||
state: z.string(), | ||
zip: z.string(), | ||
address: z.string().min(1, { message: "Required" }), | ||
city: z.string().min(1, { message: "Required" }), | ||
link: z.string().optional(), | ||
}) | ||
.superRefine((data, ctx) => { | ||
if (COUNTRIES_REQUIRED_STATE.includes(data.country)) { | ||
if (data.state === "") { | ||
ctx.addIssue({ | ||
code: z.ZodIssueCode.custom, | ||
message: "Required", | ||
path: ["state"], | ||
}); | ||
} | ||
|
||
if (data.zip === "") { | ||
ctx.addIssue({ | ||
code: z.ZodIssueCode.custom, | ||
message: "Required", | ||
path: ["zip"], | ||
}); | ||
} | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.