feat: add payment module and factory
This commit is contained in:
@@ -0,0 +1,84 @@
|
||||
//------------------ process payment -------------------------
|
||||
|
||||
export interface IProcessPaymentParams {
|
||||
amount: number;
|
||||
description: string;
|
||||
// callBackPath: string;
|
||||
email?: string;
|
||||
mobile?: string;
|
||||
}
|
||||
|
||||
export interface IProcessPaymentData {
|
||||
redirectUrl: string;
|
||||
message: string;
|
||||
reference: string;
|
||||
}
|
||||
|
||||
//------------------ Verify payment -------------------------
|
||||
|
||||
//TODO: Define the IPaymentVerifyData interface
|
||||
export interface IPaymentVerifyData {
|
||||
[x: string]: unknown;
|
||||
}
|
||||
|
||||
export interface IPaymentVerifyParams {
|
||||
amount: number;
|
||||
reference: string;
|
||||
}
|
||||
|
||||
//--------------------- zarinpal --------------------------------
|
||||
interface MetaData {
|
||||
mobile?: string;
|
||||
email?: string;
|
||||
order_id?: string;
|
||||
}
|
||||
|
||||
export interface ZarinPalPGNewArgs {
|
||||
merchant_id: string;
|
||||
amount: number;
|
||||
description: string;
|
||||
callback_url: string;
|
||||
metadata?: MetaData;
|
||||
currency?: "IRR" | "IRT";
|
||||
}
|
||||
|
||||
interface IZarinPalPGRequestData {
|
||||
code: number;
|
||||
message: string;
|
||||
authority: string;
|
||||
fee_type: string;
|
||||
fee: number;
|
||||
}
|
||||
|
||||
export interface ZarinPalPGNewRequestData {
|
||||
data: IZarinPalPGRequestData;
|
||||
error: string[];
|
||||
}
|
||||
|
||||
interface IZarinpalPaymentVerifyData {
|
||||
code: number;
|
||||
message: string;
|
||||
card_hash: string;
|
||||
card_pan: string;
|
||||
ref_id: number;
|
||||
fee_type: string;
|
||||
fee: number;
|
||||
}
|
||||
|
||||
export interface ZarinPalPGVerifyData {
|
||||
data: IZarinpalPaymentVerifyData;
|
||||
error: string[];
|
||||
}
|
||||
|
||||
//********************************************** */
|
||||
//------------------abstract class----------------
|
||||
|
||||
export interface IPaymentGateway {
|
||||
processPayment(processPaymentParam: IProcessPaymentParams): Promise<IProcessPaymentData>;
|
||||
verifyPayment(verifyPaymentParam: IPaymentVerifyParams): Promise<IPaymentVerifyData>;
|
||||
}
|
||||
|
||||
// export abstract class PaymentGateway {
|
||||
// abstract processPayment(processPaymentParam: IProcessPaymentParams): Promise<IProcessPaymentData>;
|
||||
// abstract verifyPayment(verifyPaymentParam: IPaymentVerifyParams): Promise<IPaymentVerifyData>;
|
||||
// }
|
||||
Reference in New Issue
Block a user