@yosle/tropipayjs 0.1.28 → 0.2.1
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/accounts/accounts.d.ts +52 -0
- package/api/TropipayAPI.d.ts +2 -0
- package/index.d.ts +102 -1
- package/index.js +68 -15
- package/interfaces/index.d.ts +35 -0
- package/interfaces/paymentlink/index.d.ts +1 -3
- package/package.json +2 -2
- package/src/accounts/accounts.ts +86 -0
- package/src/api/TropipayAPI.ts +23 -29
- package/src/depositAccount/depositAccounts.ts +5 -5
- package/src/interfaces/index.ts +264 -201
- package/src/interfaces/paymentlink/index.d.ts +33 -32
- package/src/interfaces/paymentlink/index.ts +1 -3
- package/src/paymentcard/PaymentCard.ts +4 -4
- package/src/utils/TropipayUtils.ts +40 -1
- package/utils/TropipayUtils.d.ts +14 -1
- package/paymentcard/paymentcard.spec.d.ts +0 -1
|
@@ -1,36 +1,37 @@
|
|
|
1
1
|
export interface PaymentLinkPayload {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
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
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
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/
|
|
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/
|
|
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/
|
|
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/
|
|
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
|
}
|
package/utils/TropipayUtils.d.ts
CHANGED
|
@@ -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;
|