@yosle/tropipayjs 0.1.27 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.d.ts CHANGED
@@ -40,6 +40,7 @@ interface UserHookSubscribed extends UserHook {
40
40
  updatedAt: string;
41
41
  }
42
42
  interface PaymentLinkPayload {
43
+ accountId: number;
43
44
  reference: string;
44
45
  concept: string;
45
46
  favorite: boolean;
@@ -413,7 +414,9 @@ declare class ServerSideUtils {
413
414
  private tropipay;
414
415
  constructor(tropipayInstance: Tropipay);
415
416
  /**
416
- * Verify Topipay's signature on webhooks.
417
+ * DEPRECATED Verify Topipay's signature on API V2 webhooks.
418
+ * @deprecated This method is deprecated and will be removed in future versions.
419
+ * Use the `verifySignatureV3` method from the `ServerSideUtils` class instead.
417
420
  * @param credentials Credential object or Tropipay instance
418
421
  * @param {String} originalCurrencyAmount
419
422
  * @param bankOrderCode
@@ -452,6 +455,17 @@ declare class ServerSideUtils {
452
455
  * @return {Promise<string>} the valid base64 image
453
456
  */
454
457
  static isValidImage(base64Image: string): boolean;
458
+ /**
459
+ * Verify Topipay's signature on API V3 webhooks.
460
+ * @param {string} originalCurrencyAmount
461
+ * @param {string} bankOrderCode
462
+ * @param {string} signature signaturev3 field to be verified
463
+ * @returns {boolean}
464
+ */
465
+ static verifySignatureV3(credentials: {
466
+ clientId: string;
467
+ clientSecret: string;
468
+ } | Tropipay, originalCurrencyAmount: string, bankOrderCode: string, signature: string): boolean;
455
469
  }
456
470
 
457
471
  declare const SERVER_MODE: ServerMode$1;
package/index.js CHANGED
@@ -220,7 +220,7 @@ class PaymentCard {
220
220
  await this.tropipay.login();
221
221
  }
222
222
  try {
223
- const paylink = await this.tropipay.request.post("/api/v2/paymentcards", payload, {
223
+ const paylink = await this.tropipay.request.post("/api/v3/paymentcards", payload, {
224
224
  headers: {
225
225
  "Content-Type": "application/json",
226
226
  Authorization: `Bearer ${Tropipay.accessToken}`,
@@ -243,7 +243,7 @@ class PaymentCard {
243
243
  await this.tropipay.login();
244
244
  }
245
245
  try {
246
- const paymentcards = await this.tropipay.request.get(`/api/v2/paymentcards`, {
246
+ const paymentcards = await this.tropipay.request.get(`/api/v3/paymentcards`, {
247
247
  headers: {
248
248
  "Content-Type": "application/json",
249
249
  Authorization: `Bearer ${Tropipay.accessToken}`,
@@ -268,7 +268,7 @@ class PaymentCard {
268
268
  await this.tropipay.login();
269
269
  }
270
270
  try {
271
- const paymentcard = await this.tropipay.request.get(`/api/v2/paymentcards/${id}`, {
271
+ const paymentcard = await this.tropipay.request.get(`/api/v3/paymentcards/${id}`, {
272
272
  headers: {
273
273
  "Content-Type": "application/json",
274
274
  Authorization: `Bearer ${Tropipay.accessToken}`,
@@ -294,7 +294,7 @@ class PaymentCard {
294
294
  await this.tropipay.login();
295
295
  }
296
296
  try {
297
- const paymentcard = await this.tropipay.request.delete(`/api/v2/paymentcards/`, {
297
+ const paymentcard = await this.tropipay.request.delete(`/api/v3/paymentcards/`, {
298
298
  headers: {
299
299
  "Content-Type": "application/json",
300
300
  Authorization: `Bearer ${Tropipay.accessToken}`,
@@ -360,7 +360,7 @@ class DepositAccounts {
360
360
  await this.tropipay.login();
361
361
  }
362
362
  try {
363
- const deposit = await this.tropipay.request.get(`/api/v2/deposit_accounts`, {
363
+ const deposit = await this.tropipay.request.get(`/api/v3/deposit_accounts`, {
364
364
  headers: {
365
365
  "Content-Type": "application/json",
366
366
  Authorization: `Bearer ${Tropipay.accessToken}`,
@@ -383,7 +383,7 @@ class DepositAccounts {
383
383
  await this.tropipay.login();
384
384
  }
385
385
  try {
386
- const deposit = await this.tropipay.request.post("/api/v2/deposit_accounts", depositAccountObj, {
386
+ const deposit = await this.tropipay.request.post("/api/v3/deposit_accounts", depositAccountObj, {
387
387
  headers: {
388
388
  "Content-Type": "application/json",
389
389
  Authorization: `Bearer ${Tropipay.accessToken}`,
@@ -407,7 +407,7 @@ class DepositAccounts {
407
407
  await this.tropipay.login();
408
408
  }
409
409
  try {
410
- const deposit = await this.tropipay.request.get(`/api/v2/deposit_accounts/${id}`, {
410
+ const deposit = await this.tropipay.request.get(`/api/v3/deposit_accounts/${id}`, {
411
411
  headers: {
412
412
  "Content-Type": "application/json",
413
413
  Authorization: `Bearer ${Tropipay.accessToken}`,
@@ -430,7 +430,7 @@ class DepositAccounts {
430
430
  await this.tropipay.login();
431
431
  }
432
432
  try {
433
- const deposit = await this.tropipay.request.put(`/api/v2/deposit_accounts/`, {
433
+ const deposit = await this.tropipay.request.put(`/api/v3/deposit_accounts/`, {
434
434
  headers: {
435
435
  "Content-Type": "application/json",
436
436
  Authorization: `Bearer ${Tropipay.accessToken}`,
@@ -453,7 +453,7 @@ class DepositAccounts {
453
453
  await this.tropipay.login();
454
454
  }
455
455
  try {
456
- const deposit = await this.tropipay.request.delete(`/api/v2/deposit_accounts/${id}`, {
456
+ const deposit = await this.tropipay.request.delete(`/api/v3/deposit_accounts/${id}`, {
457
457
  headers: {
458
458
  "Content-Type": "application/json",
459
459
  Authorization: `Bearer ${Tropipay.accessToken}`,
@@ -519,7 +519,7 @@ class Tropipay {
519
519
  this.serverMode = config.serverMode || "Development";
520
520
  const tpp_env = this.serverMode === "Production"
521
521
  ? "https://www.tropipay.com"
522
- : "https://tropipay-dev.herokuapp.com";
522
+ : "https://sandbox.tropipay.me";
523
523
  this.request = axios__default["default"].create({
524
524
  baseURL: config.customTropipayUrl || tpp_env,
525
525
  headers: {
@@ -534,24 +534,22 @@ class Tropipay {
534
534
  headers: {
535
535
  "Content-Type": "application/json",
536
536
  Accept: "application/json",
537
- Authorization: `Bearer ${Tropipay.accessToken}`,
538
537
  },
539
538
  });
540
539
  // Add request interceptor for Token expired
541
540
  this.request.interceptors.request.use(async (config) => {
542
- const currentTimestamp = Math.floor(Date.now() / 1000); // Current time in seconds
541
+ const currentTimestamp = Math.floor(Date.now() / 1000);
543
542
  if (Tropipay.expiresIn && Tropipay.expiresIn < currentTimestamp) {
544
- // Token has expired, attempt to refresh it
543
+ console.debug("Token expired, attempting to log in");
545
544
  try {
546
545
  await this.login();
547
546
  }
548
547
  catch (error) {
549
- // Handle token refresh error
550
- Tropipay.accessToken = null;
551
- Tropipay.refreshToken = null;
552
548
  throw handleExceptions(error);
553
549
  }
554
550
  }
551
+ // Update the Authorization header in the config
552
+ config.headers.Authorization = `Bearer ${Tropipay.accessToken}`;
555
553
  return config;
556
554
  }, (error) => {
557
555
  return Promise.reject(error);
@@ -563,26 +561,8 @@ class Tropipay {
563
561
  }
564
562
  async login() {
565
563
  try {
566
- // if (Tropipay.refreshToken) {
567
- // const { data } = await this.loginRequest.post<LoginResponse>(
568
- // "/api/v2/access/token",
569
- // {
570
- // client_id: this.clientId,
571
- // client_secret: this.clientSecret,
572
- // grant_type: "refresh_token",
573
- // refresh_token: Tropipay.refreshToken,
574
- // },
575
- // {
576
- // headers: {
577
- // "Content-Type": "application/json",
578
- // Accept: "application/json",
579
- // },
580
- // }
581
- // );
582
- // return data;
583
- // }
584
564
  // normal credetials login
585
- const { data } = await this.loginRequest.post("/api/v2/access/token", {
565
+ const { data } = await this.loginRequest.post("/api/v3/access/token", {
586
566
  client_id: this.clientId,
587
567
  client_secret: this.clientSecret,
588
568
  grant_type: "client_credentials",
@@ -594,8 +574,6 @@ class Tropipay {
594
574
  },
595
575
  });
596
576
  Tropipay.accessToken = data.access_token;
597
- Tropipay.refreshToken = data.refresh_token;
598
- Tropipay.expiresIn = data.expires_in;
599
577
  Tropipay.expiresIn = data.expires_in;
600
578
  return data;
601
579
  }
@@ -790,7 +768,9 @@ class ServerSideUtils {
790
768
  this.tropipay = tropipayInstance;
791
769
  }
792
770
  /**
793
- * Verify Topipay's signature on webhooks.
771
+ * DEPRECATED Verify Topipay's signature on API V2 webhooks.
772
+ * @deprecated This method is deprecated and will be removed in future versions.
773
+ * Use the `verifySignatureV3` method from the `ServerSideUtils` class instead.
794
774
  * @param credentials Credential object or Tropipay instance
795
775
  * @param {String} originalCurrencyAmount
796
776
  * @param bankOrderCode
@@ -880,6 +860,28 @@ class ServerSideUtils {
880
860
  throw new Error(`Error checking base64 image`);
881
861
  }
882
862
  }
863
+ /**
864
+ * Verify Topipay's signature on API V3 webhooks.
865
+ * @param {string} originalCurrencyAmount
866
+ * @param {string} bankOrderCode
867
+ * @param {string} signature signaturev3 field to be verified
868
+ * @returns {boolean}
869
+ */
870
+ static verifySignatureV3(credentials, originalCurrencyAmount, bankOrderCode, signature) {
871
+ const sha1Secret = crypto__namespace
872
+ .createHash("sha1")
873
+ .update(credentials.clientSecret)
874
+ .digest("hex");
875
+ const dataToHash = bankOrderCode +
876
+ credentials.clientId +
877
+ sha1Secret +
878
+ originalCurrencyAmount;
879
+ const localSignature = crypto__namespace
880
+ .createHash("sha256")
881
+ .update(dataToHash)
882
+ .digest("hex");
883
+ return localSignature === signature;
884
+ }
883
885
  }
884
886
 
885
887
  const SERVER_MODE = "Development"; // Move the constant here
@@ -36,6 +36,7 @@ export interface UserHookSubscribed extends UserHook {
36
36
  updatedAt: string;
37
37
  }
38
38
  export interface PaymentLinkPayload {
39
+ accountId: number;
39
40
  reference: string;
40
41
  concept: string;
41
42
  favorite: boolean;
@@ -46,6 +46,7 @@ declare enum Reasons {
46
46
  SENDING_YOU_A_KISS = 80
47
47
  }
48
48
  export interface PaymentLinkPayload {
49
+ accountId: number;
49
50
  reference: string;
50
51
  concept: string;
51
52
  favorite: boolean;
@@ -60,9 +61,6 @@ export interface PaymentLinkPayload {
60
61
  urlFailed: string;
61
62
  urlNotification: string;
62
63
  serviceDate: string;
63
- /**
64
- * fgfsgdfgdfgd
65
- */
66
64
  client?: {
67
65
  name: string;
68
66
  lastName: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yosle/tropipayjs",
3
- "version": "0.1.27",
3
+ "version": "0.2.0",
4
4
  "description": "Javascript / Typescript SDK for the Tropipay API",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -46,4 +46,4 @@
46
46
  "type": "individual",
47
47
  "url": "https://tppay.me/l94qaa3h"
48
48
  }
49
- }
49
+ }
@@ -27,7 +27,7 @@ export class Tropipay {
27
27
  readonly clientSecret: string;
28
28
  readonly scopes: String[];
29
29
  public request: Axios;
30
- public loginRequest: Axios;
30
+ public loginRequest: Axios;
31
31
  public static accessToken: string | null;
32
32
  public static refreshToken: string | null;
33
33
  public static expiresIn: number | null;
@@ -73,11 +73,12 @@ export class Tropipay {
73
73
  this.clientSecret = config.clientSecret;
74
74
  this.serverMode = config.serverMode || "Development";
75
75
 
76
- const tpp_env = this.serverMode === "Production"
77
- ? "https://www.tropipay.com"
78
- : "https://tropipay-dev.herokuapp.com";
76
+ const tpp_env =
77
+ this.serverMode === "Production"
78
+ ? "https://www.tropipay.com"
79
+ : "https://sandbox.tropipay.me";
79
80
  this.request = axios.create({
80
- baseURL: config.customTropipayUrl || tpp_env,
81
+ baseURL: config.customTropipayUrl || tpp_env,
81
82
  headers: {
82
83
  "Content-Type": "application/json",
83
84
  Accept: "application/json",
@@ -85,36 +86,33 @@ export class Tropipay {
85
86
  },
86
87
  });
87
88
 
88
- // Create a separate instance for login requests
89
- this.loginRequest = axios.create({
90
- baseURL: config.customTropipayUrl || tpp_env,
91
- headers: {
92
- "Content-Type": "application/json",
93
- Accept: "application/json",
94
- Authorization: `Bearer ${Tropipay.accessToken}`,
95
- },
96
- });
89
+ // Create a separate instance for login requests
90
+ this.loginRequest = axios.create({
91
+ baseURL: config.customTropipayUrl || tpp_env,
92
+ headers: {
93
+ "Content-Type": "application/json",
94
+ Accept: "application/json",
95
+ },
96
+ });
97
97
 
98
- // Add request interceptor for Token expired
99
- this.request.interceptors.request.use(
100
- async (config: any) => {
101
- const currentTimestamp = Math.floor(Date.now() / 1000); // Current time in seconds
98
+ // Add request interceptor for Token expired
99
+ this.request.interceptors.request.use(
100
+ async (config) => {
101
+ const currentTimestamp = Math.floor(Date.now() / 1000);
102
102
 
103
103
  if (Tropipay.expiresIn && Tropipay.expiresIn < currentTimestamp) {
104
- // Token has expired, attempt to refresh it
104
+ console.debug("Token expired, attempting to log in");
105
105
  try {
106
- await this.login();
106
+ await this.login();
107
107
  } catch (error) {
108
- // Handle token refresh error
109
- Tropipay.accessToken = null;
110
- Tropipay.refreshToken = null;
111
- throw handleExceptions(error as any);
108
+ throw handleExceptions(error as Error);
112
109
  }
113
110
  }
114
-
111
+ // Update the Authorization header in the config
112
+ config.headers.Authorization = `Bearer ${Tropipay.accessToken}`;
115
113
  return config;
116
114
  },
117
- (error: AxiosError) => {
115
+ (error) => {
118
116
  return Promise.reject(error);
119
117
  }
120
118
  );
@@ -124,36 +122,13 @@ export class Tropipay {
124
122
  this.mediationPaymentCard = new MediationPaymentCard(this);
125
123
 
126
124
  this.depositAccounts = new DepositAccounts(this);
127
-
128
-
129
-
130
-
131
125
  }
132
126
 
133
127
  public async login() {
134
128
  try {
135
- // if (Tropipay.refreshToken) {
136
- // const { data } = await this.loginRequest.post<LoginResponse>(
137
- // "/api/v2/access/token",
138
- // {
139
- // client_id: this.clientId,
140
- // client_secret: this.clientSecret,
141
- // grant_type: "refresh_token",
142
- // refresh_token: Tropipay.refreshToken,
143
- // },
144
- // {
145
- // headers: {
146
- // "Content-Type": "application/json",
147
- // Accept: "application/json",
148
- // },
149
- // }
150
- // );
151
- // return data;
152
- // }
153
-
154
129
  // normal credetials login
155
130
  const { data } = await this.loginRequest.post<LoginResponse>(
156
- "/api/v2/access/token",
131
+ "/api/v3/access/token",
157
132
  {
158
133
  client_id: this.clientId,
159
134
  client_secret: this.clientSecret,
@@ -169,8 +144,6 @@ export class Tropipay {
169
144
  );
170
145
 
171
146
  Tropipay.accessToken = data.access_token;
172
- Tropipay.refreshToken = data.refresh_token;
173
- Tropipay.expiresIn = data.expires_in;
174
147
  Tropipay.expiresIn = data.expires_in;
175
148
  return data;
176
149
  } catch (error) {
@@ -18,7 +18,7 @@ export default class DepositAccounts {
18
18
  }
19
19
  try {
20
20
  const deposit = await this.tropipay.request.get(
21
- `/api/v2/deposit_accounts`,
21
+ `/api/v3/deposit_accounts`,
22
22
  {
23
23
  headers: {
24
24
  "Content-Type": "application/json",
@@ -43,7 +43,7 @@ export default class DepositAccounts {
43
43
  }
44
44
  try {
45
45
  const deposit = await this.tropipay.request.post(
46
- "/api/v2/deposit_accounts",
46
+ "/api/v3/deposit_accounts",
47
47
  depositAccountObj,
48
48
  {
49
49
  headers: {
@@ -70,7 +70,7 @@ export default class DepositAccounts {
70
70
  }
71
71
  try {
72
72
  const deposit = await this.tropipay.request.get(
73
- `/api/v2/deposit_accounts/${id}`,
73
+ `/api/v3/deposit_accounts/${id}`,
74
74
  {
75
75
  headers: {
76
76
  "Content-Type": "application/json",
@@ -96,7 +96,7 @@ export default class DepositAccounts {
96
96
  }
97
97
  try {
98
98
  const deposit = await this.tropipay.request.put(
99
- `/api/v2/deposit_accounts/`,
99
+ `/api/v3/deposit_accounts/`,
100
100
  {
101
101
  headers: {
102
102
  "Content-Type": "application/json",
@@ -122,7 +122,7 @@ export default class DepositAccounts {
122
122
  }
123
123
  try {
124
124
  const deposit = await this.tropipay.request.delete(
125
- `/api/v2/deposit_accounts/${id}`,
125
+ `/api/v3/deposit_accounts/${id}`,
126
126
  {
127
127
  headers: {
128
128
  "Content-Type": "application/json",
@@ -64,6 +64,7 @@ export interface UserHookSubscribed extends UserHook {
64
64
  }
65
65
 
66
66
  export interface PaymentLinkPayload {
67
+ accountId: number;
67
68
  reference: string;
68
69
  concept: string;
69
70
  favorite: boolean;
@@ -1,36 +1,37 @@
1
1
  export interface PaymentLinkPayload {
2
- reference: string;
3
- concept: string;
4
- favorite: boolean;
5
- amount: number;
6
- currency: string;
7
- description: string;
8
- singleUse: boolean;
9
- reasonId: number;
10
- expirationDays: number;
11
- lang: string;
12
- urlSuccess: string;
13
- urlFailed: string;
14
- urlNotification: string;
15
- serviceDate: string;
16
- client: {
17
- name: string;
18
- lastName: string;
19
- address: string;
20
- phone: string;
21
- email: string;
22
- countryId: number;
23
- termsAndConditions: boolean;
24
- };
25
- directPayment: boolean;
26
- paymentMethods?: string[];
2
+ accountId: number;
3
+ reference: string;
4
+ concept: string;
5
+ favorite: boolean;
6
+ amount: number;
7
+ currency: string;
8
+ description: string;
9
+ singleUse: boolean;
10
+ reasonId: number;
11
+ expirationDays: number;
12
+ lang: string;
13
+ urlSuccess: string;
14
+ urlFailed: string;
15
+ urlNotification: string;
16
+ serviceDate: string;
17
+ client: {
18
+ name: string;
19
+ lastName: string;
20
+ address: string;
21
+ phone: string;
22
+ email: string;
23
+ countryId: number;
24
+ termsAndConditions: boolean;
25
+ };
26
+ directPayment: boolean;
27
+ paymentMethods?: string[];
27
28
  }
28
29
  export interface PaymentLink extends PaymentLinkPayload {
29
- expirationDate: string;
30
- hasClient: boolean;
31
- updatedAt: string;
32
- createdAt: string;
33
- qrImage: string;
34
- shortUrl: string;
35
- paymentUrl: string;
30
+ expirationDate: string;
31
+ hasClient: boolean;
32
+ updatedAt: string;
33
+ createdAt: string;
34
+ qrImage: string;
35
+ shortUrl: string;
36
+ paymentUrl: string;
36
37
  }
@@ -50,6 +50,7 @@ enum Reasons {
50
50
  }
51
51
 
52
52
  export interface PaymentLinkPayload {
53
+ accountId: number;
53
54
  reference: string;
54
55
  concept: string;
55
56
  favorite: boolean;
@@ -64,9 +65,6 @@ export interface PaymentLinkPayload {
64
65
  urlFailed: string;
65
66
  urlNotification: string;
66
67
  serviceDate: string;
67
- /**
68
- * fgfsgdfgdfgd
69
- */
70
68
  client?: {
71
69
  name: string;
72
70
  lastName: string;
@@ -20,7 +20,7 @@ export default class PaymentCard {
20
20
  }
21
21
  try {
22
22
  const paylink = await this.tropipay.request.post(
23
- "/api/v2/paymentcards",
23
+ "/api/v3/paymentcards",
24
24
  payload,
25
25
  {
26
26
  headers: {
@@ -46,7 +46,7 @@ export default class PaymentCard {
46
46
  }
47
47
  try {
48
48
  const paymentcards = await this.tropipay.request.get(
49
- `/api/v2/paymentcards`,
49
+ `/api/v3/paymentcards`,
50
50
  {
51
51
  headers: {
52
52
  "Content-Type": "application/json",
@@ -74,7 +74,7 @@ export default class PaymentCard {
74
74
  }
75
75
  try {
76
76
  const paymentcard = await this.tropipay.request.get(
77
- `/api/v2/paymentcards/${id}`,
77
+ `/api/v3/paymentcards/${id}`,
78
78
  {
79
79
  headers: {
80
80
  "Content-Type": "application/json",
@@ -103,7 +103,7 @@ export default class PaymentCard {
103
103
  }
104
104
  try {
105
105
  const paymentcard = await this.tropipay.request.delete(
106
- `/api/v2/paymentcards/`,
106
+ `/api/v3/paymentcards/`,
107
107
  {
108
108
  headers: {
109
109
  "Content-Type": "application/json",
@@ -11,7 +11,9 @@ export class ServerSideUtils {
11
11
  }
12
12
 
13
13
  /**
14
- * Verify Topipay's signature on webhooks.
14
+ * DEPRECATED Verify Topipay's signature on API V2 webhooks.
15
+ * @deprecated This method is deprecated and will be removed in future versions.
16
+ * Use the `verifySignatureV3` method from the `ServerSideUtils` class instead.
15
17
  * @param credentials Credential object or Tropipay instance
16
18
  * @param {String} originalCurrencyAmount
17
19
  * @param bankOrderCode
@@ -123,4 +125,41 @@ export class ServerSideUtils {
123
125
  throw new Error(`Error checking base64 image`);
124
126
  }
125
127
  }
128
+
129
+ /**
130
+ * Verify Topipay's signature on API V3 webhooks.
131
+ * @param {string} originalCurrencyAmount
132
+ * @param {string} bankOrderCode
133
+ * @param {string} signature signaturev3 field to be verified
134
+ * @returns {boolean}
135
+ */
136
+ public static verifySignatureV3(
137
+ credentials:
138
+ | {
139
+ clientId: string;
140
+ clientSecret: string;
141
+ }
142
+ | Tropipay,
143
+ originalCurrencyAmount: string,
144
+ bankOrderCode: string,
145
+ signature: string
146
+ ): boolean {
147
+ const sha1Secret = crypto
148
+ .createHash("sha1")
149
+ .update(credentials.clientSecret)
150
+ .digest("hex");
151
+
152
+ const dataToHash =
153
+ bankOrderCode +
154
+ credentials.clientId +
155
+ sha1Secret +
156
+ originalCurrencyAmount;
157
+
158
+ const localSignature = crypto
159
+ .createHash("sha256")
160
+ .update(dataToHash)
161
+ .digest("hex");
162
+
163
+ return localSignature === signature;
164
+ }
126
165
  }
@@ -3,7 +3,9 @@ export declare class ServerSideUtils {
3
3
  private tropipay;
4
4
  constructor(tropipayInstance: Tropipay);
5
5
  /**
6
- * Verify Topipay's signature on webhooks.
6
+ * DEPRECATED Verify Topipay's signature on API V2 webhooks.
7
+ * @deprecated This method is deprecated and will be removed in future versions.
8
+ * Use the `verifySignatureV3` method from the `ServerSideUtils` class instead.
7
9
  * @param credentials Credential object or Tropipay instance
8
10
  * @param {String} originalCurrencyAmount
9
11
  * @param bankOrderCode
@@ -42,4 +44,15 @@ export declare class ServerSideUtils {
42
44
  * @return {Promise<string>} the valid base64 image
43
45
  */
44
46
  static isValidImage(base64Image: string): boolean;
47
+ /**
48
+ * Verify Topipay's signature on API V3 webhooks.
49
+ * @param {string} originalCurrencyAmount
50
+ * @param {string} bankOrderCode
51
+ * @param {string} signature signaturev3 field to be verified
52
+ * @returns {boolean}
53
+ */
54
+ static verifySignatureV3(credentials: {
55
+ clientId: string;
56
+ clientSecret: string;
57
+ } | Tropipay, originalCurrencyAmount: string, bankOrderCode: string, signature: string): boolean;
45
58
  }
@@ -1 +0,0 @@
1
- declare function sum(a: number, b: number): number;