Skip to content

Commit

Permalink
chore: yarn format and yarn lint
Browse files Browse the repository at this point in the history
  • Loading branch information
Scrip7 committed Apr 1, 2022
1 parent 14bbbfa commit b04cf5d
Show file tree
Hide file tree
Showing 25 changed files with 56 additions and 57 deletions.
2 changes: 1 addition & 1 deletion src/drivers/behpardakht/index.ts
@@ -1,4 +1,4 @@
import soap from 'soap';
import * as soap from 'soap';
import { Driver } from '../../driver';
import { PaymentException, RequestException, VerificationException } from '../../exceptions';
import * as API from './api';
Expand Down
3 changes: 1 addition & 2 deletions src/drivers/idpay/api.ts
Expand Up @@ -266,8 +266,7 @@ export const errors: ErrorList = {
// 406
'37': '丌丿乇爻 亘丕夭诏卮鬲 callback 賳亘丕蹖丿 禺丕賱蹖 亘丕卮丿.',
// 406
'38':
'丿乇禺賵丕爻鬲 卮賲丕 丕夭 丌丿乇爻 {domain} 丕乇爻丕賱 卮丿賴 丕爻鬲. 丿丕賲賳賴 丌丿乇爻 亘丕夭诏卮鬲 callback 亘丕 丌丿乇爻 孬亘鬲 卮丿賴 丿乇 賵亘 爻乇賵蹖爻 賴賲禺賵丕賳蹖 賳丿丕乇丿.',
'38': '丿乇禺賵丕爻鬲 卮賲丕 丕夭 丌丿乇爻 {domain} 丕乇爻丕賱 卮丿賴 丕爻鬲. 丿丕賲賳賴 丌丿乇爻 亘丕夭诏卮鬲 callback 亘丕 丌丿乇爻 孬亘鬲 卮丿賴 丿乇 賵亘 爻乇賵蹖爻 賴賲禺賵丕賳蹖 賳丿丕乇丿.',
// 406
'41': '賮蹖賱鬲乇 賵囟毓蹖鬲 鬲乇丕讴賳卮 賴丕 賲蹖 亘丕蹖爻鬲 丌乇丕蹖賴 丕蹖 (賱蹖爻鬲蹖) 丕夭 賵囟毓蹖鬲 賴丕蹖 賲噩丕夭 丿乇 賲爻鬲賳丿丕鬲 亘丕卮丿.',
// 406
Expand Down
8 changes: 4 additions & 4 deletions src/drivers/idpay/index.ts
Expand Up @@ -15,7 +15,7 @@ export class IdPay extends Driver<API.Config> {

const { amount, callbackUrl, mobile, email, description, name } = options;

let response = await axios.post<API.RequestPaymentReq, { data: API.RequestPaymentRes }>(
const response = await axios.post<API.RequestPaymentReq, { data: API.RequestPaymentRes }>(
this.getLinks().REQUEST,
{
amount: amount,
Expand All @@ -28,7 +28,7 @@ export class IdPay extends Driver<API.Config> {
},
{
headers: this.getHeaders(),
}
},
);

if ('error_message' in response.data) {
Expand All @@ -41,7 +41,7 @@ export class IdPay extends Driver<API.Config> {

verifyPayment = async (
_options: API.VerifyOptions,
params: API.CallbackParams_GET | API.CallbackParams_POST
params: API.CallbackParams_GET | API.CallbackParams_POST,
): Promise<API.Receipt> => {
const { id, order_id, status } = params;

Expand All @@ -57,7 +57,7 @@ export class IdPay extends Driver<API.Config> {
},
{
headers: this.getHeaders(),
}
},
);

if ('error_message' in response.data) {
Expand Down
4 changes: 2 additions & 2 deletions src/drivers/nextpay/index.ts
Expand Up @@ -13,7 +13,7 @@ export class NextPay extends Driver<API.Config> {
requestPayment = async (options: API.RequestOptions) => {
options = this.getParsedData(options, API.tRequestOptions);

let { amount, callbackUrl, mobile, customFields } = options;
const { amount, callbackUrl, mobile, customFields } = options;

const response = await axios.post<API.RequestPaymentReq, { data: API.RequestPaymentRes }>(this.getLinks().REQUEST, {
api_key: this.config.apiKey,
Expand Down Expand Up @@ -46,7 +46,7 @@ export class NextPay extends Driver<API.Config> {
amount: +amount * 10,
trans_id,
api_key: this.config.apiKey,
}
},
);

const { Shaparak_Ref_Id, code, card_holder } = response.data;
Expand Down
2 changes: 1 addition & 1 deletion src/drivers/parsian/index.ts
@@ -1,4 +1,4 @@
import soap from 'soap';
import * as soap from 'soap';
import { Driver } from '../../driver';
import { PaymentException, RequestException, VerificationException } from '../../exceptions';
import * as API from './api';
Expand Down
4 changes: 2 additions & 2 deletions src/drivers/payir/index.ts
Expand Up @@ -13,7 +13,7 @@ export class Payir extends Driver<API.Config> {
requestPayment = async (options: API.RequestOptions) => {
options = this.getParsedData(options, API.tRequestOptions);

let { amount, callbackUrl, description, mobile, nationalCode, validCardNumber } = options;
const { amount, callbackUrl, description, mobile, nationalCode, validCardNumber } = options;

const response = await axios.post<API.RequestPaymentReq, { data: API.RequestPaymentRes }>(this.getLinks().REQUEST, {
api: this.getApiKey(),
Expand Down Expand Up @@ -48,7 +48,7 @@ export class Payir extends Driver<API.Config> {
{
api: this.getApiKey(),
token,
}
},
);

const verifyStatus = response.data.status;
Expand Down
2 changes: 1 addition & 1 deletion src/drivers/payping/index.ts
Expand Up @@ -14,7 +14,7 @@ export class PayPing extends Driver<API.Config> {
requestPayment = async (options: API.RequestOptions) => {
options = this.getParsedData(options, API.tRequestOptions);

let { amount, callbackUrl, mobile, email, name, description } = options;
const { amount, callbackUrl, mobile, email, name, description } = options;
let response;

try {
Expand Down
4 changes: 2 additions & 2 deletions src/drivers/sadad/index.ts
@@ -1,5 +1,5 @@
import axios from 'axios';
import CryptoJS from 'crypto-js';
import * as CryptoJS from 'crypto-js';
import { Driver } from '../../driver';
import { PaymentException, RequestException, VerificationException } from '../../exceptions';
import * as API from './api';
Expand Down Expand Up @@ -53,7 +53,7 @@ export class Sadad extends Driver<API.Config> {
{
SignData: signData(Token, terminalKey),
Token,
}
},
);

const { ResCode: verificationResCode, SystemTraceNo } = response.data;
Expand Down
2 changes: 1 addition & 1 deletion src/drivers/saman/api.ts
Expand Up @@ -119,7 +119,7 @@ export const callbackErrors: ErrorList = {
'12': '卮賲丕乇賴 鬲乇賲蹖賳丕賱 丕乇爻丕賱 卮丿賴 蹖丕賮鬲 賳卮丿.',
};

export interface VerifyPaymentReq {}
// export interface VerifyPaymentReq {}

export type VerifyPaymentRes = number;

Expand Down
2 changes: 1 addition & 1 deletion src/drivers/saman/index.ts
@@ -1,5 +1,5 @@
import axios from 'axios';
import soap from 'soap';
import * as soap from 'soap';
import { Driver } from '../../driver';
import { PaymentException, RequestException, VerificationException } from '../../exceptions';
import * as API from './api';
Expand Down
4 changes: 2 additions & 2 deletions src/drivers/vandar/index.ts
Expand Up @@ -16,7 +16,7 @@ export class Vandar extends Driver<API.Config> {
const { amount, callbackUrl, ...otherOptions } = options;
const { api_key } = this.config;

let response = await axios.post<API.RequestPaymentReq, { data: API.RequestPaymentRes }>(this.getLinks().REQUEST, {
const response = await axios.post<API.RequestPaymentReq, { data: API.RequestPaymentRes }>(this.getLinks().REQUEST, {
api_key,
amount: amount,
callback_url: callbackUrl,
Expand Down Expand Up @@ -52,7 +52,7 @@ export class Vandar extends Driver<API.Config> {
api_key,
token,
},
{}
{},
);
const { errors } = response.data;

Expand Down
4 changes: 2 additions & 2 deletions src/drivers/zarinpal/index.ts
Expand Up @@ -16,7 +16,7 @@ export class Zarinpal extends Driver<API.Config> {
const { amount, callbackUrl, mobile, email, ...otherOptions } = options;
const { merchantId } = this.config;

let response = await axios.post<API.RequestPaymentReq, { data: API.RequestPaymentRes }>(this.getLinks().REQUEST, {
const response = await axios.post<API.RequestPaymentReq, { data: API.RequestPaymentRes }>(this.getLinks().REQUEST, {
merchant_id: merchantId,
amount: amount,
callback_url: callbackUrl,
Expand Down Expand Up @@ -56,7 +56,7 @@ export class Zarinpal extends Driver<API.Config> {
merchant_id: merchantId,
amount: amount,
},
{}
{},
);
const { data, errors } = response.data;

Expand Down
4 changes: 2 additions & 2 deletions src/drivers/zibal/index.ts
Expand Up @@ -13,7 +13,7 @@ export class Zibal extends Driver<API.Config> {
requestPayment = async (options: API.RequestOptions) => {
options = this.getParsedData(options, API.tRequestOptions);

let { amount, ...otherOptions } = options;
const { amount, ...otherOptions } = options;

const response = await axios.post<API.RequestPaymentReq, { data: API.RequestPaymentRes }>(this.getLinks().REQUEST, {
merchant: this.getMerchantId(),
Expand Down Expand Up @@ -41,7 +41,7 @@ export class Zibal extends Driver<API.Config> {
{
merchant: this.getMerchantId(),
trackId: +trackId,
}
},
);

const { result } = response.data;
Expand Down
4 changes: 2 additions & 2 deletions src/payment-info.ts
Expand Up @@ -3,13 +3,13 @@ export class PaymentInfo {
public readonly referenceId: string | number,
public readonly method: 'GET' | 'POST',
public readonly url: string,
public readonly params: Record<string, any> = {}
public readonly params: Record<string, any> = {},
) {}

public getScript() {
const { method, params, url } = this;
let script = `var form = document.createElement("form");form.setAttribute("method", "${method}");form.setAttribute("action", "${url}");form.setAttribute("target", "_self");`;
Object.keys(params).forEach(key => {
Object.keys(params).forEach((key) => {
const value = params[key];
script += `var monopay_hidden_field__${key} = document.createElement("input");monopay_hidden_field__${key}.setAttribute("name", ${key});monopay_hidden_field__${key}.setAttribute("value", ${value});form.appendChild(monopay_hidden_field__${key});`;
});
Expand Down
6 changes: 3 additions & 3 deletions test/drivers/behpardakht.spec.ts
Expand Up @@ -27,7 +27,7 @@ describe('Behpardakht Driver', () => {
amount: 20000,
callbackUrl: 'https://mysite.com/callback',
})
).url
).url,
).toBe('string');
});

Expand All @@ -47,7 +47,7 @@ describe('Behpardakht Driver', () => {
await driver.requestPayment({
amount: 20000,
callbackUrl: 'https://mysite.com/callback',
})
}),
).rejects.toThrow(RequestException);
});

Expand All @@ -73,7 +73,7 @@ describe('Behpardakht Driver', () => {
});

expect(await (await driver.verifyPayment({ amount: 2000 }, callbackParams)).transactionId).toBe(
expectedResult.transactionId
expectedResult.transactionId,
);
});
});
6 changes: 3 additions & 3 deletions test/drivers/idpay.spec.ts
Expand Up @@ -19,7 +19,7 @@ describe('IdPay Driver', () => {
const driver = getPaymentDriver<IdPay>('idpay', { apiKey: '2134' });

expect(
typeof (await driver.requestPayment({ callbackUrl: 'https://path.to/callback-url', amount: 20000 })).url
typeof (await driver.requestPayment({ callbackUrl: 'https://path.to/callback-url', amount: 20000 })).url,
).toBe('string');
});

Expand All @@ -34,7 +34,7 @@ describe('IdPay Driver', () => {
const driver = getPaymentDriver<IdPay>('idpay', { apiKey: '2134' });

await expect(async () => await driver.requestPayment({ amount: 2000, callbackUrl: 'asd' })).rejects.toThrow(
RequestException
RequestException,
);
});

Expand Down Expand Up @@ -65,7 +65,7 @@ describe('IdPay Driver', () => {

expect(
(await driver.verifyPayment({ amount: 2000 }, { status: '200', track_id: '1234', id: '123', order_id: '321' }))
.transactionId
.transactionId,
).toEqual(expectedResult.transactionId);
});
});
6 changes: 3 additions & 3 deletions test/drivers/nextpay.spec.ts
Expand Up @@ -19,7 +19,7 @@ describe('NextPay Driver', () => {
const driver = getPaymentDriver<NextPay>('nextpay', { apiKey: '1234' });

expect(
typeof (await driver.requestPayment({ callbackUrl: 'https://path.to/callback-url', amount: 20000 })).url
typeof (await driver.requestPayment({ callbackUrl: 'https://path.to/callback-url', amount: 20000 })).url,
).toBe('string');
});

Expand All @@ -34,7 +34,7 @@ describe('NextPay Driver', () => {
const driver = getPaymentDriver<NextPay>('nextpay', { apiKey: '1234' });

await expect(async () => await driver.requestPayment({ amount: 2000, callbackUrl: 'asd' })).rejects.toThrow(
RequestException
RequestException,
);
});

Expand All @@ -55,7 +55,7 @@ describe('NextPay Driver', () => {

expect(
(await driver.verifyPayment({ amount: 2000 }, { trans_id: '12345', order_id: '1234', amount: 20000 }))
.transactionId
.transactionId,
).toEqual(expectedResult.transactionId);
});
});
6 changes: 3 additions & 3 deletions test/drivers/parsian.spec.ts
Expand Up @@ -28,7 +28,7 @@ describe('Parsian Driver', () => {
amount: 20000,
callbackUrl: 'https://mysite.com/callback',
})
).url
).url,
).toBe('string');
});

Expand All @@ -48,7 +48,7 @@ describe('Parsian Driver', () => {
await driver.requestPayment({
amount: 20000,
callbackUrl: 'https://mysite.com/callback',
})
}),
).rejects.toThrow(RequestException);
});

Expand Down Expand Up @@ -79,7 +79,7 @@ describe('Parsian Driver', () => {
});

expect(await (await driver.verifyPayment({ amount: 2000 }, callbackParams)).transactionId).toBe(
expectedResult.transactionId
expectedResult.transactionId,
);
});
});
6 changes: 3 additions & 3 deletions test/drivers/payir.spec.ts
Expand Up @@ -19,7 +19,7 @@ describe('Payir Driver', () => {
const driver = getPaymentDriver<Payir>('payir', { apiKey: '2134' });

expect(
typeof (await driver.requestPayment({ callbackUrl: 'https://path.to/callback-url', amount: 20000 })).url
typeof (await driver.requestPayment({ callbackUrl: 'https://path.to/callback-url', amount: 20000 })).url,
).toBe('string');
});

Expand All @@ -35,7 +35,7 @@ describe('Payir Driver', () => {
const driver = getPaymentDriver<Payir>('payir', { apiKey: '2134' });

await expect(async () => await driver.requestPayment({ amount: 2000, callbackUrl: 'asd' })).rejects.toThrow(
RequestException
RequestException,
);
});

Expand All @@ -57,7 +57,7 @@ describe('Payir Driver', () => {
const driver = getPaymentDriver<Payir>('payir', { apiKey: '2134' });

expect((await driver.verifyPayment({ amount: 2000 }, { token: '12345', status: '1' })).transactionId).toEqual(
expectedResult.transactionId
expectedResult.transactionId,
);
});
});
8 changes: 4 additions & 4 deletions test/drivers/payping.spec.ts
Expand Up @@ -18,7 +18,7 @@ describe('PayPing Driver', () => {
const driver = getPaymentDriver<PayPing>('payping', { apiKey: '2134' });

expect(
typeof (await driver.requestPayment({ callbackUrl: 'https://path.to/callback-url', amount: 20000 })).url
typeof (await driver.requestPayment({ callbackUrl: 'https://path.to/callback-url', amount: 20000 })).url,
).toBe('string');
});

Expand All @@ -29,7 +29,7 @@ describe('PayPing Driver', () => {
const driver = getPaymentDriver<PayPing>('payping', { apiKey: '2134' });

await expect(async () => await driver.requestPayment({ amount: 2000, callbackUrl: 'asd' })).rejects.toThrow(
RequestException
RequestException,
);
});

Expand All @@ -55,9 +55,9 @@ describe('PayPing Driver', () => {
clientrefid: 'clientrefid',
cardnumber: '1234-****-****-1234',
refid: '1234',
}
},
)
).transactionId
).transactionId,
).toEqual(expectedResult.transactionId);
});
});
6 changes: 3 additions & 3 deletions test/drivers/sadad.spec.ts
Expand Up @@ -30,7 +30,7 @@ describe('Sadad Driver', () => {
callbackUrl: 'https://callback.url/',
mobile: '09120000000',
})
).url
).url,
).toBe('string');
});

Expand All @@ -55,7 +55,7 @@ describe('Sadad Driver', () => {
amount: 20000,
callbackUrl: 'https://callback.url/',
mobile: '09120000000',
})
}),
).rejects.toThrow(RequestException);
});

Expand Down Expand Up @@ -87,7 +87,7 @@ describe('Sadad Driver', () => {
});

expect((await driver.verifyPayment({ amount: 10000 }, callbackParams)).transactionId).toBe(
expectedResult.transactionId
expectedResult.transactionId,
);
});
});

0 comments on commit b04cf5d

Please sign in to comment.