@yosle/tropipayjs 0.1.12 → 0.1.14
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/api/TropipayAPI.d.ts +2 -0
- package/index.d.ts +21 -1
- package/index.js +75 -0
- package/package.json +1 -1
- package/src/api/TropipayAPI.ts +3 -0
- package/src/index.ts +1 -0
package/api/TropipayAPI.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ import { Axios } from "axios";
|
|
|
8
8
|
import { TropipayConfig, AccountBalance, Country, PaymentLink, mediationPaymentCardConfig, LoginResponse, AccountDeposits } from "../interfaces";
|
|
9
9
|
type ServerMode = "Development" | "Production";
|
|
10
10
|
import { TropipayHooks } from "../hooks/TropipayHooks";
|
|
11
|
+
import { PaymentCard } from "../paymentcard/PaymentCard";
|
|
11
12
|
export declare class Tropipay {
|
|
12
13
|
readonly clientId: string;
|
|
13
14
|
readonly clientSecret: string;
|
|
@@ -16,6 +17,7 @@ export declare class Tropipay {
|
|
|
16
17
|
static refreshToken: string | undefined;
|
|
17
18
|
serverMode: ServerMode;
|
|
18
19
|
hooks: TropipayHooks;
|
|
20
|
+
paymentcards: PaymentCard;
|
|
19
21
|
constructor(config: TropipayConfig);
|
|
20
22
|
login(): Promise<LoginResponse>;
|
|
21
23
|
/**
|
package/index.d.ts
CHANGED
|
@@ -198,6 +198,25 @@ declare class TropipayHooks {
|
|
|
198
198
|
events(): Promise<any>;
|
|
199
199
|
}
|
|
200
200
|
|
|
201
|
+
declare class PaymentCard {
|
|
202
|
+
private tropipay;
|
|
203
|
+
constructor(tropipayInstance: Tropipay);
|
|
204
|
+
/**
|
|
205
|
+
* Create a paymentLink with the specified options.
|
|
206
|
+
* @param payload PaymentLinkPayload Object.
|
|
207
|
+
* @returns Promise<PaymentLink> or throws an Exception.
|
|
208
|
+
* @see https://tpp.stoplight.io/docs/tropipay-api-doc/b3A6ODgyNTM3OQ-create-a-new-pay-link-charge
|
|
209
|
+
*/
|
|
210
|
+
create(payload: PaymentLinkPayload): Promise<PaymentLink>;
|
|
211
|
+
/**
|
|
212
|
+
* Shows a list of stored paymentcards created by user.
|
|
213
|
+
* This list includes active and closed paylinks
|
|
214
|
+
* @returns Array of paymentlinks
|
|
215
|
+
*/
|
|
216
|
+
list(): Promise<any>;
|
|
217
|
+
get(id: string): Promise<any>;
|
|
218
|
+
}
|
|
219
|
+
|
|
201
220
|
/**
|
|
202
221
|
* Tropipayjs is a Typescript/Javascript library for the Tropipay API.
|
|
203
222
|
*
|
|
@@ -215,6 +234,7 @@ declare class Tropipay {
|
|
|
215
234
|
static refreshToken: string | undefined;
|
|
216
235
|
serverMode: ServerMode;
|
|
217
236
|
hooks: TropipayHooks;
|
|
237
|
+
paymentcards: PaymentCard;
|
|
218
238
|
constructor(config: TropipayConfig);
|
|
219
239
|
login(): Promise<LoginResponse>;
|
|
220
240
|
/**
|
|
@@ -302,4 +322,4 @@ declare class ServerSideUtils {
|
|
|
302
322
|
|
|
303
323
|
declare const SERVER_MODE: ServerMode$1;
|
|
304
324
|
|
|
305
|
-
export { AccountBalance, AccountDeposits, ClientSideUtils, Country, Deposit, HookEventType, HookTargetType, LoginError, LoginResponse, PaymentLink, PaymentLinkPayload, SERVER_MODE, ServerMode$1 as ServerMode, ServerSideUtils, Tropipay, TropipayConfig, TropipayCredentials, TropipayHooks, UserHook, UserHookSubscribed, mediationPaymentCardConfig };
|
|
325
|
+
export { AccountBalance, AccountDeposits, ClientSideUtils, Country, Deposit, HookEventType, HookTargetType, LoginError, LoginResponse, PaymentCard, PaymentLink, PaymentLinkPayload, SERVER_MODE, ServerMode$1 as ServerMode, ServerSideUtils, Tropipay, TropipayConfig, TropipayCredentials, TropipayHooks, UserHook, UserHookSubscribed, mediationPaymentCardConfig };
|
package/index.js
CHANGED
|
@@ -158,6 +158,78 @@ class TropipayHooks {
|
|
|
158
158
|
}
|
|
159
159
|
}
|
|
160
160
|
|
|
161
|
+
class PaymentCard {
|
|
162
|
+
tropipay;
|
|
163
|
+
constructor(tropipayInstance) {
|
|
164
|
+
this.tropipay = tropipayInstance;
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Create a paymentLink with the specified options.
|
|
168
|
+
* @param payload PaymentLinkPayload Object.
|
|
169
|
+
* @returns Promise<PaymentLink> or throws an Exception.
|
|
170
|
+
* @see https://tpp.stoplight.io/docs/tropipay-api-doc/b3A6ODgyNTM3OQ-create-a-new-pay-link-charge
|
|
171
|
+
*/
|
|
172
|
+
async create(payload) {
|
|
173
|
+
if (!Tropipay.accessToken) {
|
|
174
|
+
await this.tropipay.login();
|
|
175
|
+
}
|
|
176
|
+
try {
|
|
177
|
+
const paylink = await this.tropipay.request.post("/api/v2/paymentcards", payload, {
|
|
178
|
+
headers: {
|
|
179
|
+
"Content-Type": "application/json",
|
|
180
|
+
Authorization: `Bearer ${Tropipay.accessToken}`,
|
|
181
|
+
Accept: "application/json",
|
|
182
|
+
},
|
|
183
|
+
});
|
|
184
|
+
return paylink.data;
|
|
185
|
+
}
|
|
186
|
+
catch (error) {
|
|
187
|
+
throw new Error(`TropipayJS - Error creating the Payment Card.`);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Shows a list of stored paymentcards created by user.
|
|
192
|
+
* This list includes active and closed paylinks
|
|
193
|
+
* @returns Array of paymentlinks
|
|
194
|
+
*/
|
|
195
|
+
async list() {
|
|
196
|
+
if (!Tropipay.accessToken) {
|
|
197
|
+
await this.tropipay.login();
|
|
198
|
+
}
|
|
199
|
+
try {
|
|
200
|
+
const paymentcards = await this.tropipay.request.get(`/api/v2/paymentcards`, {
|
|
201
|
+
headers: {
|
|
202
|
+
"Content-Type": "application/json",
|
|
203
|
+
Authorization: `Bearer ${Tropipay.accessToken}`,
|
|
204
|
+
Accept: "application/json",
|
|
205
|
+
},
|
|
206
|
+
});
|
|
207
|
+
return paymentcards.data;
|
|
208
|
+
}
|
|
209
|
+
catch (error) {
|
|
210
|
+
throw new Error(`Could not retrieve PaymenCards list`);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
async get(id) {
|
|
214
|
+
if (!Tropipay.accessToken) {
|
|
215
|
+
await this.tropipay.login();
|
|
216
|
+
}
|
|
217
|
+
try {
|
|
218
|
+
const paymentcard = await this.tropipay.request.get(`/api/v2/paymentcards/${id}`, {
|
|
219
|
+
headers: {
|
|
220
|
+
"Content-Type": "application/json",
|
|
221
|
+
Authorization: `Bearer ${Tropipay.accessToken}`,
|
|
222
|
+
Accept: "application/json",
|
|
223
|
+
},
|
|
224
|
+
});
|
|
225
|
+
return paymentcard.data;
|
|
226
|
+
}
|
|
227
|
+
catch (error) {
|
|
228
|
+
throw new Error(`Could not retrieve PaymenCards`);
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
|
|
161
233
|
/**
|
|
162
234
|
* Tropipayjs is a Typescript/Javascript library for the Tropipay API.
|
|
163
235
|
*
|
|
@@ -172,6 +244,7 @@ class Tropipay {
|
|
|
172
244
|
static refreshToken;
|
|
173
245
|
serverMode;
|
|
174
246
|
hooks;
|
|
247
|
+
paymentcards;
|
|
175
248
|
constructor(config) {
|
|
176
249
|
this.clientId = config.clientId;
|
|
177
250
|
this.clientSecret = config.clientSecret;
|
|
@@ -187,6 +260,7 @@ class Tropipay {
|
|
|
187
260
|
},
|
|
188
261
|
});
|
|
189
262
|
this.hooks = new TropipayHooks(this);
|
|
263
|
+
this.paymentcards = new PaymentCard(this);
|
|
190
264
|
}
|
|
191
265
|
async login() {
|
|
192
266
|
try {
|
|
@@ -454,6 +528,7 @@ if (typeof window !== "undefined") {
|
|
|
454
528
|
}
|
|
455
529
|
|
|
456
530
|
exports.ClientSideUtils = ClientSideUtils;
|
|
531
|
+
exports.PaymentCard = PaymentCard;
|
|
457
532
|
exports.SERVER_MODE = SERVER_MODE;
|
|
458
533
|
exports.ServerSideUtils = ServerSideUtils;
|
|
459
534
|
exports.Tropipay = Tropipay;
|
package/package.json
CHANGED
package/src/api/TropipayAPI.ts
CHANGED
|
@@ -18,6 +18,7 @@ import {
|
|
|
18
18
|
} from "../interfaces";
|
|
19
19
|
type ServerMode = "Development" | "Production";
|
|
20
20
|
import { TropipayHooks } from "../hooks/TropipayHooks";
|
|
21
|
+
import { PaymentCard } from "../paymentcard/PaymentCard";
|
|
21
22
|
export class Tropipay {
|
|
22
23
|
readonly clientId: string;
|
|
23
24
|
readonly clientSecret: string;
|
|
@@ -26,6 +27,7 @@ export class Tropipay {
|
|
|
26
27
|
public static refreshToken: string | undefined;
|
|
27
28
|
public serverMode: ServerMode;
|
|
28
29
|
public hooks: TropipayHooks;
|
|
30
|
+
public paymentcards: PaymentCard;
|
|
29
31
|
|
|
30
32
|
constructor(config: TropipayConfig) {
|
|
31
33
|
this.clientId = config.clientId;
|
|
@@ -43,6 +45,7 @@ export class Tropipay {
|
|
|
43
45
|
},
|
|
44
46
|
});
|
|
45
47
|
this.hooks = new TropipayHooks(this);
|
|
48
|
+
this.paymentcards = new PaymentCard(this);
|
|
46
49
|
}
|
|
47
50
|
|
|
48
51
|
public async login() {
|
package/src/index.ts
CHANGED
|
@@ -20,6 +20,7 @@ export { Tropipay } from "./api/TropipayAPI";
|
|
|
20
20
|
export { ClientSideUtils } from "./api/TropipayAPI";
|
|
21
21
|
export { ServerSideUtils } from "./utils/TropipayUtils";
|
|
22
22
|
export { TropipayHooks } from "./hooks/TropipayHooks";
|
|
23
|
+
export { PaymentCard } from "./paymentcard/PaymentCard";
|
|
23
24
|
export * from "./interfaces/index";
|
|
24
25
|
export { SERVER_MODE } from "./config/TropipayConfig";
|
|
25
26
|
export * from "./constants/TropipayConstants";
|