Migrate payment gateway services from hardcoded config to NestJS ConfigService injection. Improve payment handler error handling and update gateway factory specs. Co-Authored-By: Paperclip <noreply@paperclip.ing>
22 lines
547 B
TypeScript
22 lines
547 B
TypeScript
import { Result, ValueObject } from '@modules/shared';
|
|
|
|
interface MoneyProps {
|
|
amountVND: bigint;
|
|
}
|
|
|
|
export class Money extends ValueObject<MoneyProps> {
|
|
get value(): bigint {
|
|
return this.props.amountVND;
|
|
}
|
|
|
|
static create(amountVND: bigint): Result<Money, string> {
|
|
if (amountVND <= 0n) {
|
|
return Result.err('Số tiền phải lớn hơn 0');
|
|
}
|
|
if (amountVND > 999_999_999_999n) {
|
|
return Result.err('Số tiền vượt quá giới hạn cho phép');
|
|
}
|
|
return Result.ok(new Money({ amountVND }));
|
|
}
|
|
}
|