Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- export enum PaymentDevice {
- 'mobile' = 'mobile',
- 'desktop' = 'desktop',
- }
- export interface PaymentError {
- redirectTo: string;
- message: string;
- paymentGatewayResponse: any;
- }
- export interface IPaymentService {
- device: PaymentDevice;
- redirectUrl: string;
- errorResponse?: PaymentError;
- createPaymentGateway(
- payment: CreatePaymentGatewayInput,
- ): string;
- verifyPayment(): boolean;
- }
- interface CreatePaymentGatewayInput {
- amount: number;
- description: string;
- phoneNumber: string;
- email: string;
- }
- export class ZarinpalPaymentGatewayService
- implements IPaymentService
- {
- #device?: PaymentDevice;
- #errorResponse?: PaymentError;
- #redirectUrl?: string;
- set device(device: PaymentDevice) {
- this.#device = device;
- }
- get device() {
- if (!this.#device) {
- throw new Error('E_EMPTY_DEVICE')
- }
- return this.#device;
- }
- set redirectUrl(redirectUrl: string) {
- this.#redirectUrl = redirectUrl;
- }
- get redirectUrl() {
- if (!this.#redirectUrl) {
- throw new Error('E_EMPTY_REDIRECT_URL')
- }
- return this.#redirectUrl;
- }
- verifyPayment() {
- return true;
- }
- // Why it does not show me an error for empty function parameter?
- createPaymentGateway() {
- const url =
- 'https://www.zarinpal.com/pg/StartPay/$Authority';
- // const {} = payment;
- return '';
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement