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]));
|
const companyMap = new Map<string, Company>(companies.map((c) => [c.id, c]));
|
||||||
|
|
||||||
for (const value of values) {
|
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 tax = subtotal.mul(0.1);
|
||||||
const totalPrice = subtotal.add(tax);
|
const totalPrice = subtotal.add(tax);
|
||||||
const company = companyMap.get(value.companyId);
|
const company = companyMap.get(value.companyId);
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
export const ZARINPAL_CONFIG = "ZARINPAL_CONFIG";
|
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({
|
export const PAYMENT = Object.freeze({
|
||||||
QUEUE_NAME: "payment",
|
QUEUE_NAME: "payment",
|
||||||
START: "payment_start",
|
START: "payment_start",
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import { catchError, firstValueFrom } from "rxjs";
|
|||||||
|
|
||||||
import { PaymentMessage } from "../../../common/enums/message.enum";
|
import { PaymentMessage } from "../../../common/enums/message.enum";
|
||||||
import { IZarinpalConfig } from "../../../configs/zarinpal.config";
|
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 { GatewayEnum } from "../enums/gateway.enum";
|
||||||
import {
|
import {
|
||||||
IPaymentGateway,
|
IPaymentGateway,
|
||||||
@@ -36,7 +36,7 @@ export class ZarinpalGateway implements IPaymentGateway {
|
|||||||
amount: processParams.amount,
|
amount: processParams.amount,
|
||||||
callback_url: `${this.config.callBackUrl}/${GatewayEnum.ZARINPAL}`,
|
callback_url: `${this.config.callBackUrl}/${GatewayEnum.ZARINPAL}`,
|
||||||
description: processParams.description,
|
description: processParams.description,
|
||||||
currency: "IRT",
|
currency: PAYMENT_CURRENCY, // IRT = Iranian Rial
|
||||||
metadata: { email: processParams.email, mobile: processParams.mobile },
|
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);
|
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, {
|
const gatewayData = await this.processPayment(paymentGateway.name, {
|
||||||
amount: new Decimal(invoice.totalPrice).toNumber(),
|
amount: new Decimal(invoice.totalPrice).toNumber(),
|
||||||
description: PaymentMessage.CHECKOUT_INVOICE_MESSAGE.replace("[invoiceNumber]", invoice.numericId.toString()),
|
description: PaymentMessage.CHECKOUT_INVOICE_MESSAGE.replace("[invoiceNumber]", invoice.numericId.toString()),
|
||||||
|
|||||||
Reference in New Issue
Block a user