This commit is contained in:
2026-02-24 12:27:32 +03:30
parent a1fe186c5f
commit d679ed56af
2 changed files with 5 additions and 6 deletions
@@ -36,10 +36,9 @@ export class PaymentController {
return this.paymentService.payInvoice(invoiceId, dto); return this.paymentService.payInvoice(invoiceId, dto);
} }
@Post('public/payments/online/:token/verify') @Get('public/payments/online/:token/verify')
@UseGuards(AuthGuard)
@ApiOperation({ summary: 'Verify online payment' }) @ApiOperation({ summary: 'Verify online payment' })
verifyOnlinePayment(@Param('paymentId') token: string) { verifyOnlinePayment(@Param('token') token: string) {
return this.paymentService.verifyOnlinePayment(token); return this.paymentService.verifyOnlinePayment(token);
} }
@@ -21,7 +21,7 @@ export class ZarinpalGateway implements IPaymentGateway {
private readonly zarinpalVerifyUrl: string; private readonly zarinpalVerifyUrl: string;
private readonly zarinpalPaymentBaseUrl: string; private readonly zarinpalPaymentBaseUrl: string;
private readonly zarinpalMerchantId: string; private readonly zarinpalMerchantId: string;
private readonly websiteUrl: string = 'https://negareh.ir' private readonly apiUrl: string = 'https://negareh-api.dev.danakcorp.com/'
private readonly axiosConfig = { private readonly axiosConfig = {
timeout: 10_000, timeout: 10_000,
headers: { headers: {
@@ -31,10 +31,10 @@ export class ZarinpalGateway implements IPaymentGateway {
constructor(private readonly configService: ConfigService) { constructor(private readonly configService: ConfigService) {
const zarinpalBaseUrl = this.configService.get<string>('ZARINPAL_BASE_URL') || 'https://sandbox.zarinpal.com'; const zarinpalBaseUrl = this.configService.get<string>('ZARINPAL_BASE_URL') || 'https://sandbox.zarinpal.com';
this.zarinpalPaymentBaseUrl = zarinpalBaseUrl;
this.zarinpalRequestUrl = `${zarinpalBaseUrl}/pg/v4/payment/request.json`; this.zarinpalRequestUrl = `${zarinpalBaseUrl}/pg/v4/payment/request.json`;
this.zarinpalVerifyUrl = `${zarinpalBaseUrl}/pg/v4/payment/verify.json`; this.zarinpalVerifyUrl = `${zarinpalBaseUrl}/pg/v4/payment/verify.json`;
this.zarinpalMerchantId = this.configService.getOrThrow<string>('ZARINPAL_BASE_MERCHANT') this.zarinpalMerchantId = this.configService.getOrThrow<string>('ZARINPAL_BASE_MERCHANT')
this.apiUrl = this.configService.getOrThrow<string>('API_URL') || 'https://negareh-api.dev.danakcorp.com/'
} }
private getAxiosErrorData(error: unknown): { status?: number; data?: unknown } | null { private getAxiosErrorData(error: unknown): { status?: number; data?: unknown } | null {
@@ -44,7 +44,7 @@ export class ZarinpalGateway implements IPaymentGateway {
async requestPayment({ amount, invoiceId }: IRequestPaymentParams): Promise<IRequestPaymentData> { async requestPayment({ amount, invoiceId }: IRequestPaymentParams): Promise<IRequestPaymentData> {
// Transform camelCase to snake_case for Zarinpal API v4 // Transform camelCase to snake_case for Zarinpal API v4
const callbackUrl = `${this.websiteUrl}/verify/${invoiceId}`; const callbackUrl = `${this.apiUrl}/verify/${invoiceId}`;
const zarinpalRequest: IZarinpalRequestPayment = { const zarinpalRequest: IZarinpalRequestPayment = {
amount, amount,
merchant_id: this.zarinpalMerchantId, merchant_id: this.zarinpalMerchantId,