Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 45 additions & 11 deletions apps/api/src/api/controllers/alfredpay.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -652,9 +652,14 @@ export class AlfredpayController {
accountType,
accountName,
accountBankCode,
accountAlias,
routingNumber,
networkIdentifier
bankStreet,
bankCity,
bankState,
bankCountry,
bankPostalCode,
documentType,
documentNumber
} = req.body as AlfredpayAddFiatAccountRequest;
const userId = req.userId!;

Expand All @@ -667,16 +672,45 @@ export class AlfredpayController {
return res.status(404).json({ error: "Alfredpay customer not found" });
}

const alfredpayFiatAccountType = type as AlfredpayFiatAccountType;

let fiatAccountFields;
if (alfredpayFiatAccountType === AlfredpayFiatAccountType.SPEI) {
fiatAccountFields = {
accountNumber,
accountType: "CLABE",
isExternal: true,
metadata: { accountHolderName: accountName }
};
} else if (alfredpayFiatAccountType === AlfredpayFiatAccountType.ACH) {
fiatAccountFields = {
accountName: accountBankCode,
accountNumber,
accountType: accountType ?? "",
isExternal: true,
metadata: { accountHolderName: accountName, documentNumber, documentType }
};
} else {
// BANK_USA
fiatAccountFields = {
accountName: accountBankCode,
accountNumber,
accountType: accountType ?? "",
bankCity,
bankCountry,
bankPostalCode,
bankState,
bankStreet,
routingNumber
};
}

const alfredpayService = AlfredpayApiService.getInstance();
const result = await alfredpayService.createFiatAccount(alfredPayCustomer.alfredPayId, type as AlfredpayFiatAccountType, {
accountAlias: accountAlias ?? "",
accountBankCode,
accountName,
accountNumber,
accountType: accountType ?? "",
networkIdentifier: networkIdentifier ?? "",
routingNumber
});
const result = await alfredpayService.createFiatAccount(
alfredPayCustomer.alfredPayId,
alfredpayFiatAccountType,
fiatAccountFields
);

res.json(result);
} catch (error) {
Expand Down
10 changes: 5 additions & 5 deletions apps/frontend/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/png" sizes="32x32" href="/frontend/favicon-32x32.png" />
<link rel="icon" type="image/png" sizes="16x16" href="/frontend/favicon-16x16.png" />
<link rel="icon" type="image/x-icon" href="/frontend/favicon.ico" />
<link rel="apple-touch-icon" sizes="180x180" href="/frontend/apple-touch-icon.png" />
<link rel="manifest" href="/frontend/site.webmanifest" />
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png" />
<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png" />
<link rel="icon" type="image/x-icon" href="/favicon.ico" />
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png" />
<link rel="manifest" href="/site.webmanifest" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title translate="no">Vortex</title>
<link rel="preconnect" href="https://fonts.googleapis.com" />
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
"icons": [
{
"sizes": "192x192",
"src": "/frontend/android-chrome-192x192.png",
"src": "/android-chrome-192x192.png",
"type": "image/png"
},
{
"sizes": "512x512",
"src": "/frontend/android-chrome-512x512.png",
"src": "/android-chrome-512x512.png",
"type": "image/png"
}
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { useAlfredpayFiatAccounts } from "../../../hooks/alfredpay/useFiatAccoun
import { DropdownSelector } from "../../ui/DropdownSelector";

function accountLabel(account: AlfredpayFiatAccount) {
return account.accountAlias || account.accountBankCode;
return account.accountName || account.metadata?.accountHolderName;
}

function AccountOption({
Expand Down Expand Up @@ -79,7 +79,7 @@ export function FiatAccountSelector() {
? (resolveAccountTypeKey(selectedAccount.type, country) ?? null)
: null;
const Icon = accountType ? ACCOUNT_TYPE_ICONS[accountType] : null;
const last4 = selectedAccount.accountNumber.slice(-4);
const last4 = selectedAccount?.accountNumber.slice(-4);

const triggerContent = selectedAccount ? (
<>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export const USOnrampDetails: FC = () => {
<>
<hr className="my-6" />
<div className="space-y-3 text-center">
<h2 className="text-lg font-bold">{t("components.SummaryPage.USOnrampDetails.title")}</h2>
<h2 className="font-bold text-lg">{t("components.SummaryPage.USOnrampDetails.title")}</h2>
<p>
{t("components.SummaryPage.USOnrampDetails.instruction", "Use these bank details to complete your ACH transfer.")}
</p>
Expand All @@ -103,15 +103,15 @@ export const USOnrampDetails: FC = () => {
const display = displayValue(value, fallbackValue);
return (
<div
className="space-y-1 border-b border-gray-100 py-3 last:border-b-0 last:pb-0 first:pt-0 flex items-center justify-between"
className="flex items-center justify-between space-y-1 border-gray-100 border-b py-3 first:pt-0 last:border-b-0 last:pb-0"
key={id}
>
<div>
<p className="text-xs text-gray-500">{label}</p>
<p className="min-w-0 mt-0.5 flex-1 font-mono text-sm text-gray-600 [overflow-wrap:anywhere]">{display}</p>
<p className="text-gray-500 text-xs">{label}</p>
<p className="mt-0.5 min-w-0 flex-1 font-mono text-gray-600 text-sm [overflow-wrap:anywhere]">{display}</p>
</div>
{copyable && display !== fallbackValue && (
<CopyButton className="p-2 rounded-full" hideText noBorder text={display} />
<CopyButton className="rounded-full p-2" hideText noBorder text={display} />
)}
</div>
);
Expand Down
38 changes: 26 additions & 12 deletions apps/frontend/src/constants/fiatAccountForms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,32 +47,26 @@ export const FORMS: Record<FiatAccountTypeKey, FieldDef[]> = {
field: "accountType",
label: "components.fiatAccountForms.accountType",
options: [
{ label: "components.fiatAccountForms.options.corriente", value: "CORRIENTE" },
{ label: "components.fiatAccountForms.options.ahorro", value: "AHORRO" },
{ label: "components.fiatAccountForms.options.nequi", value: "NEQUI" }
],
required: true,
type: "select"
},
{ field: "accountName", label: "components.fiatAccountForms.accountName", required: true, type: "text" },
{ field: "accountAlias", label: "components.fiatAccountForms.accountAlias", required: false, type: "text" }
{ field: "documentType", label: "components.fiatAccountForms.documentType", required: true, type: "text" },
{ field: "documentNumber", label: "components.fiatAccountForms.documentNumber", required: true, type: "text" }
],
SPEI: [
{
field: "accountBankCode",
label: "components.fiatAccountForms.bankName",
placeholder: "components.fiatAccountForms.placeholders.bankNameMx",
required: true,
type: "text"
},
{
field: "accountNumber",
label: "components.fiatAccountForms.clabe",
placeholder: "components.fiatAccountForms.placeholders.clabe",
required: true,
type: "text"
},
{ field: "accountName", label: "components.fiatAccountForms.accountName", required: true, type: "text" },
{ field: "accountAlias", label: "components.fiatAccountForms.accountAlias", required: false, type: "text" }
{ field: "accountName", label: "components.fiatAccountForms.accountName", required: true, type: "text" }
],
WIRE: [
{ field: "accountBankCode", label: "components.fiatAccountForms.bankName", required: true, type: "text" },
Expand All @@ -84,7 +78,27 @@ export const FORMS: Record<FiatAccountTypeKey, FieldDef[]> = {
type: "text"
},
{ field: "accountNumber", label: "components.fiatAccountForms.accountNumber", required: true, type: "text" },
{ field: "accountName", label: "components.fiatAccountForms.accountName", required: true, type: "text" },
{ field: "accountAlias", label: "components.fiatAccountForms.accountAlias", required: false, type: "text" }
{
field: "accountType",
label: "components.fiatAccountForms.accountType",
options: [
{ label: "components.fiatAccountForms.options.checking", value: "CHECKING" },
{ label: "components.fiatAccountForms.options.saving", value: "SAVING" }
],
required: true,
type: "select"
},
{ field: "bankStreet", label: "components.fiatAccountForms.bankStreet", required: true, type: "text" },
{ field: "bankCity", label: "components.fiatAccountForms.bankCity", required: true, type: "text" },
{ field: "bankState", label: "components.fiatAccountForms.bankState", required: true, type: "text" },
{
field: "bankCountry",
hint: "components.fiatAccountForms.hints.bankCountry",
label: "components.fiatAccountForms.bankCountry",
placeholder: "components.fiatAccountForms.placeholders.bankCountry",
required: true,
type: "text"
},
{ field: "bankPostalCode", label: "components.fiatAccountForms.bankPostalCode", required: true, type: "text" }
]
};
4 changes: 2 additions & 2 deletions apps/frontend/src/constants/fiatAccountMethods.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ export const ALFREDPAY_COUNTRY_METHODS: CountryFiatAccountConfig[] = [
country: "US",
countryName: "United States",
currency: "USD",
offramp: ["ACH", "WIRE"],
onramp: ["ACH", "WIRE"]
offramp: ["WIRE"],
onramp: ["WIRE"]
},
{
country: "MX",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ function FrontCardContent({
onDelete: (id: string) => void;
}) {
const { t } = useTranslation();
const { accountAlias, accountName, accountBankCode, accountNumber, type, fiatAccountId } = account;
const { accountName, metadata, accountNumber, type, fiatAccountId } = account;
const accountType = resolveAccountTypeKey(type, country);
const label = accountAlias || accountBankCode;
const label = accountName || metadata?.accountHolderName;
const last4 = accountNumber.slice(-4);
const sub = `${accountBankCode} ••••${last4}`;
const sub = `${label} ••••${last4}`;

return (
<div
Expand Down Expand Up @@ -54,11 +54,11 @@ function FrontCardContent({
}

function BackCardContent({ account, country, index }: { account: AlfredpayFiatAccount; country: string; index: number }) {
const { accountNumber, accountBankCode, type } = account;
const { accountNumber, accountName, type } = account;
const accountType = resolveAccountTypeKey(type, country);
const bg = index === 1 ? "bg-gray-50" : "bg-gray-100";
const last4 = accountNumber.slice(-4);
const sub = `${accountBankCode} ••••${last4}`;
const sub = `${accountName} ••••${last4}`;

return (
<div className={`flex h-full w-full items-start rounded-lg border border-gray-200 ${bg} shadow-sm`}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,11 @@ function buildZodSchema(
if (f.field === "accountNumber" && accountType === "ACH") {
schema = z.string().regex(/^\d{4,17}$/, t("components.fiatAccountRegistration.validation.accountNumber"));
}
if (f.field === "accountNumber" && accountType === "ACH_COL") {
schema = z.string().regex(/^\d{10,11}$/, t("components.fiatAccountRegistration.validation.accountNumber"));
}
if (f.field === "accountNumber" && accountType === "WIRE") {
schema = z.string().regex(/^\d{4,17}$/, t("components.fiatAccountRegistration.validation.accountNumber"));
schema = z.string().regex(/^\d{8,34}$/, t("components.fiatAccountRegistration.validation.accountNumber"));
}
if (f.field === "accountAlias") {
schema = z.string().max(40, t("components.fiatAccountRegistration.validation.nickname")).optional();
Expand Down Expand Up @@ -79,34 +82,34 @@ export function RegisterFiatAccountScreen({ country, accountType, onSuccess }: R

const onSubmit = async (data: Record<string, unknown>) => {
const {
accountAlias,
accountBankCode,
accountName,
accountNumber,
accountType: accountTypeField,
networkIdentifier,
routingNumber,
bankStreet,
bankCity,
bankState,
bankCountry,
bankPostalCode
bankPostalCode,
documentType,
documentNumber
} = data as Record<string, string>;

try {
await addFiatAccount.mutateAsync({
accountAlias,
accountBankCode: accountBankCode ?? "",
accountName: accountName ?? "",
accountBankCode,
accountName,
accountNumber: accountNumber ?? "",
accountType: accountTypeField ?? "",
accountType: accountTypeField,
bankCity,
bankCountry,
bankPostalCode,
bankState,
bankStreet,
country,
networkIdentifier,
documentNumber,
documentType,
routingNumber,
type: alfredType
});
Expand Down Expand Up @@ -182,7 +185,7 @@ export function RegisterFiatAccountScreen({ country, accountType, onSuccess }: R
/>
)}

{f.hint && <span className="mt-1 block text-gray-500 text-xs">{f.hint}</span>}
{f.hint && <span className="mt-1 block text-gray-500 text-xs">{t(f.hint)}</span>}
{errors[f.field] && <span className="mt-1 block text-error text-sm">{errors[f.field]?.message as string}</span>}
</div>
))}
Expand Down
16 changes: 13 additions & 3 deletions apps/frontend/src/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -340,21 +340,31 @@
"yourQuote": "Your quote"
},
"fiatAccountForms": {
"accountAlias": "Nickname (optional)",
"accountName": "Account Holder Name",
"accountNumber": "Account Number",
"accountType": "Account Type",
"bankCity": "Bank City",
"bankCountry": "Bank Country",
"bankName": "Bank Name",
"bankPostalCode": "Bank Postal Code",
"bankState": "Bank State",
"bankStreet": "Bank Street",
"clabe": "CLABE (18 digits)",
"documentNumber": "Document Number",
"documentType": "Document Type",
"hints": {
"bankCountry": "Use the 3-letter country code, e.g. USA"
},
"options": {
"ahorro": "Savings (Ahorro)",
"checking": "Checking",
"corriente": "Checking (Corriente)",
"nequi": "Nequi",
"savings": "Savings"
"saving": "Savings"
},
"placeholders": {
"accountNumberCo": "10 or 11-digit account number",
"bankNameMx": "e.g. BBVA, Santander, Banamex",
"bankCountry": "e.g. USA",
"clabe": "e.g. 032180000118359719",
"routingNumber": "e.g. 021000021"
},
Expand Down
16 changes: 13 additions & 3 deletions apps/frontend/src/translations/pt.json
Original file line number Diff line number Diff line change
Expand Up @@ -341,21 +341,31 @@
"yourQuote": "Sua cotação"
},
"fiatAccountForms": {
"accountAlias": "Apelido (opcional)",
"accountName": "Nome do Titular da Conta",
"accountNumber": "Número da Conta",
"accountType": "Tipo de Conta",
"bankCity": "Cidade do Banco",
"bankCountry": "País do Banco",
"bankName": "Nome do Banco",
"bankPostalCode": "CEP do Banco",
"bankState": "Estado do Banco",
"bankStreet": "Rua do Banco",
"clabe": "CLABE (18 dígitos)",
"documentNumber": "Número do Documento",
"documentType": "Tipo de Documento",
"hints": {
"bankCountry": "Use o código de 3 letras do país, ex. USA"
},
"options": {
"ahorro": "Poupança (Ahorro)",
"checking": "Corrente",
"corriente": "Corrente (Corriente)",
"nequi": "Nequi",
"savings": "Poupança"
"saving": "Poupança"
},
"placeholders": {
"accountNumberCo": "Número de conta de 10 ou 11 dígitos",
"bankNameMx": "ex. BBVA, Santander, Banamex",
"bankCountry": "ex. USA",
"clabe": "ex. 032180000118359719",
"routingNumber": "ex. 021000021"
},
Expand Down
Loading