@aptly-as/types
Version:
Aptly types and enums
129 lines (128 loc) • 4.18 kB
TypeScript
import { AptlyAddress } from './address.js';
import { AptlyAllowanceChargeSchema, AptlyLegalMonetaryTotal } from './algorithm.js';
import { AptlyAppSchema } from './app.js';
import { AptlyCustomerData, AptlyCustomerDataSchema } from './customer.js';
import { AptlyDocumentSchema } from './document.js';
import { AptlyBaseSchema } from './extends.js';
import { AptlyOrder, AptlyOrderPaymentStatus, AptlyOrderSchema } from './order.js';
import { AptlyOrganizationContent, AptlyOrganizationSchema } from './organization.js';
import { AptlyPickConfirmedSchema } from './pick.js';
import { AptlyProjectContent, AptlyProjectSchema } from './project.js';
import { AptlyUnitContent, AptlyUnitSchema } from './unit.js';
import { AptlyUserSchema } from './user.js';
import { AptlyOfferSchema } from './offer';
import { Populated } from '../core';
export type AptlyPayment = AptlyPaymentSchema<string, string>;
export interface AptlyPaymentSchema<ID, DATE> extends Omit<AptlyBaseSchema<ID, DATE>, 'name' | 'archived'> {
organization: ID | AptlyOrganizationSchema<ID, DATE>;
project: ID | AptlyProjectSchema<ID, DATE> | null;
unit: ID | AptlyUnitSchema<ID, DATE> | null;
order: ID | AptlyOrderSchema<ID, DATE>;
offer: ID | AptlyOfferSchema<ID, DATE> | null;
app: ID | AptlyAppSchema<ID, DATE>;
document?: ID | AptlyDocumentSchema<ID, DATE>;
reportDocument?: ID | AptlyDocumentSchema<ID, DATE>;
status: AptlyPaymentStatus;
number: number;
amount: number;
vatAmount: number;
totalCost: number;
totalVat: number;
total?: AptlyLegalMonetaryTotal | null;
allowanceCharges?: AptlyAllowanceChargeSchema<ID, boolean>[];
items: AptlyPaymentItemSchema<ID>[];
picks: (ID | AptlyPickConfirmedSchema<ID, DATE>)[];
transaction: {
ref: string;
at: DATE;
};
company: AptlyPaymentCompany;
customer: AptlyCustomerDataSchema<ID, DATE>;
shipping: AptlyAddress;
shippingDate?: DATE;
shippingDescription?: string;
billing?: AptlyAddress;
card?: {
brand: string;
last4: string;
};
splits: AptlyPaymentSplitSchema<ID>[];
captures: AptlyPaymentCaptureSchema<ID, DATE>[];
captured: {
amount: number;
at: DATE;
};
createdBy: Populated<AptlyUserSchema<ID, DATE>> | null;
}
export declare enum AptlyPaymentStatus {
Authorized = "AUTHORIZED",
PendingDelivery = "PENDING_DELIVERY",
PendingCapture = "PENDING_CAPTURE",
Captured = "CAPTURED",
Annulled = "ANNULLED"
}
export type AptlyPaymentSplit = AptlyPaymentSplitSchema<string>;
export interface AptlyPaymentSplitSchema<ID> {
_id: ID;
destination: 'platform' | string;
amount: number;
}
export type AptlyPaymentCapture = AptlyPaymentCaptureSchema<string, string>;
export interface AptlyPaymentCaptureSchema<ID, DATE> {
_id: ID;
amount: number;
description: string;
ref: string;
user?: ID | AptlyUserSchema<ID, DATE>;
at: DATE;
}
export interface AptlyPaymentCompany {
vat: string;
name: string;
email: string;
address: AptlyAddress;
phone?: string;
}
export interface AptlyPaymentItemSchema<ID> {
_id: ID;
name: string;
sku: string;
quantity: number;
vat: number;
baseCost: number;
unitCost: number;
unitVat: number;
totalCost: number;
totalVat: number;
}
export interface AptlyPaymentInitPaymentBody {
organization: AptlyOrganizationContent;
project?: AptlyProjectContent;
unit?: AptlyUnitContent;
order: AptlyOrder;
customer: AptlyCustomerData;
shipping: AptlyAddress;
billing: AptlyAddress;
redirectUri: string;
}
export interface AptlyPaymentTransactionBody {
app: string;
id: string;
at: string;
customer: AptlyCustomerData;
card: AptlyPayment['card'];
shipping: AptlyAddress;
billing?: AptlyAddress;
splits: Omit<AptlyPaymentSplit, '_id'>[];
}
export interface AptlyPaymentCaptureBody {
terms: boolean;
description?: string;
}
export interface AptlyPaymentCaptureResponse {
id: string;
capturedAmount: number;
status: AptlyOrderPaymentStatus;
totalCost: number;
at: string;
}