add: paymnet in toman
This commit is contained in:
@@ -49,7 +49,10 @@ export class BillsService {
|
||||
const companyMap = new Map<string, Company>(companies.map((c) => [c.id, c]));
|
||||
|
||||
for (const value of values) {
|
||||
const subtotal = new Decimal(waterRate).mul(value.waterUsage);
|
||||
const waterCost = new Decimal(waterRate).mul(value.waterUsage);
|
||||
const sewageCost = waterCost.mul(waterCost);
|
||||
const subtotal = waterCost.add(sewageCost);
|
||||
|
||||
const tax = subtotal.mul(0.1);
|
||||
const totalPrice = subtotal.add(tax);
|
||||
const company = companyMap.get(value.companyId);
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
export const ZARINPAL_CONFIG = "ZARINPAL_CONFIG";
|
||||
//===============================================
|
||||
|
||||
/** Payment currency: IRR = Iranian Rial, IRT = Iran Toman (1 Toman = 10 Rials) */
|
||||
export const PAYMENT_CURRENCY = "IRT" as const;
|
||||
|
||||
export const PAYMENT = Object.freeze({
|
||||
QUEUE_NAME: "payment",
|
||||
START: "payment_start",
|
||||
|
||||
@@ -5,7 +5,7 @@ import { catchError, firstValueFrom } from "rxjs";
|
||||
|
||||
import { PaymentMessage } from "../../../common/enums/message.enum";
|
||||
import { IZarinpalConfig } from "../../../configs/zarinpal.config";
|
||||
import { ZARINPAL_CONFIG } from "../constants";
|
||||
import { PAYMENT_CURRENCY, ZARINPAL_CONFIG } from "../constants";
|
||||
import { GatewayEnum } from "../enums/gateway.enum";
|
||||
import {
|
||||
IPaymentGateway,
|
||||
@@ -36,7 +36,7 @@ export class ZarinpalGateway implements IPaymentGateway {
|
||||
amount: processParams.amount,
|
||||
callback_url: `${this.config.callBackUrl}/${GatewayEnum.ZARINPAL}`,
|
||||
description: processParams.description,
|
||||
currency: "IRT",
|
||||
currency: PAYMENT_CURRENCY, // IRT = Iranian Rial
|
||||
metadata: { email: processParams.email, mobile: processParams.mobile },
|
||||
};
|
||||
|
||||
|
||||
@@ -57,6 +57,7 @@ export class PaymentsService {
|
||||
|
||||
if (invoice.company.user.id !== user.id) throw new BadRequestException(InvoiceMessage.NOT_FOUND_BY_ID_OR_NOT_BELONG_TO_USER);
|
||||
|
||||
// Amount is in IRT (Iranian Toman)
|
||||
const gatewayData = await this.processPayment(paymentGateway.name, {
|
||||
amount: new Decimal(invoice.totalPrice).toNumber(),
|
||||
description: PaymentMessage.CHECKOUT_INVOICE_MESSAGE.replace("[invoiceNumber]", invoice.numericId.toString()),
|
||||
|
||||
Reference in New Issue
Block a user