Skip to content

Type Safety & Validation

The SDK uses Zod for runtime type validation and TypeScript for compile-time type safety.

Supported Payment Rails

  • ACH - Automated Clearing House
  • SAMEDAYACH - Same Day ACH
  • WIRE - Domestic Wire Transfer
  • SWIFT - International Wire Transfer
  • INTERNAL - Internal Transfer
  • FXPAY - Foreign Exchange Payment
  • CARD - Card Payment

Payment Statuses

  • DRAFT, AML_SCREENING, AML_REJECTED
  • EXECUTION_SCHEDULED, EXECUTION_PROCESSING, EXECUTION_SUCCESS, EXECUTION_FAILURE
  • RETURNED, CANCELLED, COMPLIANCE_FAILURE, DELETED, UNKNOWN

Validation Features

  • Input Validation: All create/update operations validate data structure
  • Response Validation: API responses are validated before returning
  • Custom Rules: WIRE transfers require recipient address with state/country
  • Type Safety: Full TypeScript support with inferred types

Usage with Zod Schemas

You can import and use the Zod schemas directly for custom validation:

typescript
import { 
  CreatePaymentInputSchema, 
  Payment, 
  PaymentFilters 
} from '@mbanq/core-sdk-js/types/zod';

// Validate payment input
const result = CreatePaymentInputSchema.safeParse(paymentData);

if (!result.success) {
  console.log('Validation errors:', result.error.errors);
} else {
  const validPayment = result.data;
}

Type Exports

The SDK exports TypeScript types that can be imported separately:

typescript
import type { 
  Payment, 
  Transfer, 
  Card, 
  Client 
} from '@mbanq/core-sdk-js/types';

Command Imports

Import specific commands as needed:

typescript
import { 
  CreatePayment, 
  GetTransfers, 
  GetCards,
  CreateClient 
} from '@mbanq/core-sdk-js/command';

Full TypeScript Example

typescript
import { createInstance, CreatePayment } from '@mbanq/core-sdk-js';
import type { CreatePaymentInput, ProcessOutput } from '@mbanq/core-sdk-js/types';

const client = createInstance({
  baseUrl: 'https://api.cloud.mbanq.com',
  tenantId: 'your-tenant-id'
});

// Fully typed payment data
const paymentData: CreatePaymentInput = {
  amount: 100.00,
  currency: 'USD',
  paymentRail: 'ACH',
  paymentType: 'CREDIT',
  originator: { accountId: '123456789' },
  recipient: {
    name: 'Jane Smith',
    accountNumber: '987654321',
    accountType: 'SAVINGS',
    recipientType: 'INDIVIDUAL',
    address: {
      line1: '789 Oak Ave',
      city: 'Another Town',
      stateCode: 'CA',
      countryCode: 'US',
      postalCode: '54321'
    },
    bankInformation: { routingNumber: '321070007' }
  }
};

// Response is fully typed as ProcessOutput
const result: ProcessOutput = await client.request(CreatePayment(paymentData));

Released under the MIT License.