@@ -12,12 +12,18 @@ interface IVerifyArguments {
1212 token : number ;
1313}
1414
15+ /**
16+ * this class proved all of your required functions to make a successful payment using pay.ir gateway
17+ */
1518export default class PayIrTypescript {
1619 private readonly API_KEY : string ;
1720 private readonly sendEndPoint = 'https://pay.ir/pg/send' ;
1821 private readonly verifyEndPoint = 'https://pay.ir/pg/verify' ;
1922 private readonly gateway = 'https://pay.ir/pg/' ;
20-
23+ /**
24+ * Creates an instance of pay ir typescript.
25+ * @param api api code received from pay.ir
26+ */
2127 constructor ( api : string ) {
2228 if ( api === '' || typeof api !== 'string' ) {
2329 throw new Error (
@@ -26,7 +32,9 @@ export default class PayIrTypescript {
2632 }
2733 this . API_KEY = api ;
2834 }
29-
35+ /**
36+ * Handle errors of pay ir typescript
37+ */
3038 private handleErrors = ( reject : Function , error : any ) => {
3139 if ( error . response ) {
3240 // The request was made and the server responded with a status code
@@ -46,7 +54,9 @@ export default class PayIrTypescript {
4654 ) ;
4755 }
4856 } ;
49-
57+ /**
58+ * get payment url
59+ */
5060 public send = ( args : ISendArguments , getRedirect : boolean = false ) => {
5161 return new Promise ( ( resolve , reject ) => {
5262 if ( typeof args . amount !== 'number' || args . amount < 1000 ) {
@@ -75,7 +85,9 @@ export default class PayIrTypescript {
7585 } ) ;
7686 } ) ;
7787 } ;
78-
88+ /**
89+ * Verify successful payment token
90+ */
7991 public verify = ( args : IVerifyArguments ) => {
8092 return new Promise ( ( resolve , reject ) => {
8193 if ( typeof args . token !== 'number' ) {
0 commit comments