@yosle/tropipayjs 0.1.22 → 0.1.23
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/.nvmrc +1 -1
- package/.vscode/launch.json +18 -18
- package/LICENSE +9 -9
- package/README.md +152 -152
- package/api/TropipayAPI.d.ts +1 -0
- package/docs/readme.md +3 -3
- package/globals.d.ts +75 -75
- package/index.d.ts +10 -6
- package/index.js +26 -3
- package/interfaces/countries/index.d.ts +1 -1
- package/interfaces/index.d.ts +9 -6
- package/jest.config.js +5 -5
- package/package.json +49 -49
- package/paymentcard/paymentcard.spec.d.ts +1 -1
- package/rollup.config.js +24 -24
- package/src/api/TropipayAPI.ts +370 -338
- package/src/config/TropipayConfig.ts +2 -2
- package/src/constants/TropipayConstants.ts +2 -2
- package/src/depositAccount/depositAccounts.ts +139 -139
- package/src/hooks/TropipayHooks.ts +154 -154
- package/src/index.ts +28 -28
- package/src/interfaces/depositaccounts/index.ts +70 -70
- package/src/interfaces/index.js +1 -1
- package/src/interfaces/index.ts +201 -197
- package/src/interfaces/mediation/index.ts +22 -22
- package/src/interfaces/paymentlink/index.d.ts +36 -36
- package/src/interfaces/paymentlink/index.js +2 -2
- package/src/interfaces/paymentlink/index.ts +91 -91
- package/src/mediationPaymentCard/MediationPaymentCard.ts +42 -42
- package/src/paymentcard/PaymentCard.ts +123 -123
- package/src/paymentcard/paymentcard.spec.ts +79 -79
- package/src/utils/TropipayUtils.ts +126 -126
- package/src/utils/errors.ts +92 -92
- package/tsconfig.json +96 -96
|
@@ -1,91 +1,91 @@
|
|
|
1
|
-
type PaymentMethodElement = "EXT" | "TPP";
|
|
2
|
-
export type PaymentMethods =
|
|
3
|
-
| Element
|
|
4
|
-
| [PaymentMethodElement, PaymentMethodElement];
|
|
5
|
-
|
|
6
|
-
enum Reasons {
|
|
7
|
-
HOUSING_ARRANGEMENT = 1,
|
|
8
|
-
FINANCIAL_AID = 2,
|
|
9
|
-
FAMILY_SUPPORT = 3,
|
|
10
|
-
TRAVEL_FUND = 4,
|
|
11
|
-
REAL_ESTATE_PURCHASE = 5,
|
|
12
|
-
FURNITURE_PURCHASE = 6,
|
|
13
|
-
EDUCATION = 7,
|
|
14
|
-
MEDICAL_EXPENSES = 8,
|
|
15
|
-
OTHER = 9,
|
|
16
|
-
DEBT_PAYMENT = 10,
|
|
17
|
-
TOURISM = 11,
|
|
18
|
-
SELF_SHIPPING = 12,
|
|
19
|
-
ACCOUNT_ACTIVATION = 13,
|
|
20
|
-
SPORTS_ACTIVITIES = 14,
|
|
21
|
-
DONATION = 15,
|
|
22
|
-
AFFILIATE_COMMISSION = 16,
|
|
23
|
-
SALARY = 17,
|
|
24
|
-
SAVINGS = 18,
|
|
25
|
-
RENT_AND_LEASING = 19,
|
|
26
|
-
SHARED_EXPENSES = 20,
|
|
27
|
-
SERVICE_PAYMENT = 21,
|
|
28
|
-
GIFT = 22,
|
|
29
|
-
CRYPTOCURRENCY_PURCHASE = 23,
|
|
30
|
-
OPERATING_EXPENSES = 24,
|
|
31
|
-
CURRENCY_EXCHANGE = 25,
|
|
32
|
-
ACCOMMODATION = 26,
|
|
33
|
-
EQUIPMENT_PURCHASE = 27,
|
|
34
|
-
CONSULTING = 28,
|
|
35
|
-
SOFTWARE_DEVELOPMENT = 29,
|
|
36
|
-
REFUND = 30,
|
|
37
|
-
PACKAGE_DELIVERY = 31,
|
|
38
|
-
PERSONAL_EXPENSES = 32,
|
|
39
|
-
INVESTMENT = 33,
|
|
40
|
-
BILL_PAYMENT = 34,
|
|
41
|
-
HOST_PAYMENT = 35,
|
|
42
|
-
TRANSPORTATION = 36,
|
|
43
|
-
LOAN = 37,
|
|
44
|
-
BONUS = 38,
|
|
45
|
-
HALLOWEEN_REMITTANCE = 39,
|
|
46
|
-
PLINK_REMITTANCE = 41,
|
|
47
|
-
R1_2023 = 78,
|
|
48
|
-
HAPPYWEEK = 79,
|
|
49
|
-
SENDING_YOU_A_KISS = 80,
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
export interface PaymentLinkPayload {
|
|
53
|
-
reference: string;
|
|
54
|
-
concept: string;
|
|
55
|
-
favorite: boolean;
|
|
56
|
-
amount: number;
|
|
57
|
-
currency: string;
|
|
58
|
-
description: string;
|
|
59
|
-
singleUse: boolean;
|
|
60
|
-
reasonId: Reasons;
|
|
61
|
-
expirationDays: number;
|
|
62
|
-
lang: string;
|
|
63
|
-
urlSuccess: string;
|
|
64
|
-
urlFailed: string;
|
|
65
|
-
urlNotification: string;
|
|
66
|
-
serviceDate: string;
|
|
67
|
-
/**
|
|
68
|
-
* fgfsgdfgdfgd
|
|
69
|
-
*/
|
|
70
|
-
client?: {
|
|
71
|
-
name: string;
|
|
72
|
-
lastName: string;
|
|
73
|
-
address: string;
|
|
74
|
-
phone: string;
|
|
75
|
-
email: string;
|
|
76
|
-
countryId: number;
|
|
77
|
-
termsAndConditions: boolean;
|
|
78
|
-
} | null;
|
|
79
|
-
directPayment?: boolean;
|
|
80
|
-
paymentMethods?: PaymentMethods;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
export interface PaymentLink extends PaymentLinkPayload {
|
|
84
|
-
expirationDate: string;
|
|
85
|
-
hasClient: boolean;
|
|
86
|
-
updatedAt: string;
|
|
87
|
-
createdAt: string;
|
|
88
|
-
qrImage: string;
|
|
89
|
-
shortUrl: string;
|
|
90
|
-
paymentUrl: string;
|
|
91
|
-
}
|
|
1
|
+
type PaymentMethodElement = "EXT" | "TPP";
|
|
2
|
+
export type PaymentMethods =
|
|
3
|
+
| Element
|
|
4
|
+
| [PaymentMethodElement, PaymentMethodElement];
|
|
5
|
+
|
|
6
|
+
enum Reasons {
|
|
7
|
+
HOUSING_ARRANGEMENT = 1,
|
|
8
|
+
FINANCIAL_AID = 2,
|
|
9
|
+
FAMILY_SUPPORT = 3,
|
|
10
|
+
TRAVEL_FUND = 4,
|
|
11
|
+
REAL_ESTATE_PURCHASE = 5,
|
|
12
|
+
FURNITURE_PURCHASE = 6,
|
|
13
|
+
EDUCATION = 7,
|
|
14
|
+
MEDICAL_EXPENSES = 8,
|
|
15
|
+
OTHER = 9,
|
|
16
|
+
DEBT_PAYMENT = 10,
|
|
17
|
+
TOURISM = 11,
|
|
18
|
+
SELF_SHIPPING = 12,
|
|
19
|
+
ACCOUNT_ACTIVATION = 13,
|
|
20
|
+
SPORTS_ACTIVITIES = 14,
|
|
21
|
+
DONATION = 15,
|
|
22
|
+
AFFILIATE_COMMISSION = 16,
|
|
23
|
+
SALARY = 17,
|
|
24
|
+
SAVINGS = 18,
|
|
25
|
+
RENT_AND_LEASING = 19,
|
|
26
|
+
SHARED_EXPENSES = 20,
|
|
27
|
+
SERVICE_PAYMENT = 21,
|
|
28
|
+
GIFT = 22,
|
|
29
|
+
CRYPTOCURRENCY_PURCHASE = 23,
|
|
30
|
+
OPERATING_EXPENSES = 24,
|
|
31
|
+
CURRENCY_EXCHANGE = 25,
|
|
32
|
+
ACCOMMODATION = 26,
|
|
33
|
+
EQUIPMENT_PURCHASE = 27,
|
|
34
|
+
CONSULTING = 28,
|
|
35
|
+
SOFTWARE_DEVELOPMENT = 29,
|
|
36
|
+
REFUND = 30,
|
|
37
|
+
PACKAGE_DELIVERY = 31,
|
|
38
|
+
PERSONAL_EXPENSES = 32,
|
|
39
|
+
INVESTMENT = 33,
|
|
40
|
+
BILL_PAYMENT = 34,
|
|
41
|
+
HOST_PAYMENT = 35,
|
|
42
|
+
TRANSPORTATION = 36,
|
|
43
|
+
LOAN = 37,
|
|
44
|
+
BONUS = 38,
|
|
45
|
+
HALLOWEEN_REMITTANCE = 39,
|
|
46
|
+
PLINK_REMITTANCE = 41,
|
|
47
|
+
R1_2023 = 78,
|
|
48
|
+
HAPPYWEEK = 79,
|
|
49
|
+
SENDING_YOU_A_KISS = 80,
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export interface PaymentLinkPayload {
|
|
53
|
+
reference: string;
|
|
54
|
+
concept: string;
|
|
55
|
+
favorite: boolean;
|
|
56
|
+
amount: number;
|
|
57
|
+
currency: string;
|
|
58
|
+
description: string;
|
|
59
|
+
singleUse: boolean;
|
|
60
|
+
reasonId: Reasons;
|
|
61
|
+
expirationDays: number;
|
|
62
|
+
lang: string;
|
|
63
|
+
urlSuccess: string;
|
|
64
|
+
urlFailed: string;
|
|
65
|
+
urlNotification: string;
|
|
66
|
+
serviceDate: string;
|
|
67
|
+
/**
|
|
68
|
+
* fgfsgdfgdfgd
|
|
69
|
+
*/
|
|
70
|
+
client?: {
|
|
71
|
+
name: string;
|
|
72
|
+
lastName: string;
|
|
73
|
+
address: string;
|
|
74
|
+
phone: string;
|
|
75
|
+
email: string;
|
|
76
|
+
countryId: number;
|
|
77
|
+
termsAndConditions: boolean;
|
|
78
|
+
} | null;
|
|
79
|
+
directPayment?: boolean;
|
|
80
|
+
paymentMethods?: PaymentMethods;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export interface PaymentLink extends PaymentLinkPayload {
|
|
84
|
+
expirationDate: string;
|
|
85
|
+
hasClient: boolean;
|
|
86
|
+
updatedAt: string;
|
|
87
|
+
createdAt: string;
|
|
88
|
+
qrImage: string;
|
|
89
|
+
shortUrl: string;
|
|
90
|
+
paymentUrl: string;
|
|
91
|
+
}
|
|
@@ -1,42 +1,42 @@
|
|
|
1
|
-
import { Tropipay } from "../api/TropipayAPI";
|
|
2
|
-
import { PaymentLink } from "../interfaces";
|
|
3
|
-
import { MediationPaymentCardConfig } from "../interfaces";
|
|
4
|
-
import { handleExceptions } from "../utils/errors";
|
|
5
|
-
|
|
6
|
-
export default class MediationPaymentCard {
|
|
7
|
-
private tropipay: Tropipay;
|
|
8
|
-
constructor(tropipayInstance: Tropipay) {
|
|
9
|
-
this.tropipay = tropipayInstance;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* (ONLY FOR BUSINESS ACCOUNTS) Create a mediation paymentcard (an escrow payment link) with the specified options.
|
|
14
|
-
* This allows a payment to be made to persons belonging or not to the TropiPay platform with the
|
|
15
|
-
* particularity that the payment will be held in custody or retained until it is released with
|
|
16
|
-
* the approval of the payer.
|
|
17
|
-
* @param payload PaymentLinkPayload Object.
|
|
18
|
-
* @returns Promise<PaymentLink> or throws an Exception.
|
|
19
|
-
* @see https://tpp.stoplight.io/docs/tropipay-api-doc/12a128ff971e4-creating-a-mediation-payment-card
|
|
20
|
-
*/
|
|
21
|
-
async create(payload: MediationPaymentCardConfig): Promise<PaymentLink> {
|
|
22
|
-
if (!Tropipay.accessToken) {
|
|
23
|
-
await this.tropipay.login();
|
|
24
|
-
}
|
|
25
|
-
try {
|
|
26
|
-
const paylink = await this.tropipay.request.post(
|
|
27
|
-
"/api/v2/paymentcards/mediation",
|
|
28
|
-
payload,
|
|
29
|
-
{
|
|
30
|
-
headers: {
|
|
31
|
-
"Content-Type": "application/json",
|
|
32
|
-
Authorization: `Bearer ${Tropipay.accessToken}`,
|
|
33
|
-
Accept: "application/json",
|
|
34
|
-
},
|
|
35
|
-
}
|
|
36
|
-
);
|
|
37
|
-
return paylink.data as PaymentLink;
|
|
38
|
-
} catch (error) {
|
|
39
|
-
throw handleExceptions(error as unknown as any);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
}
|
|
1
|
+
import { Tropipay } from "../api/TropipayAPI";
|
|
2
|
+
import { PaymentLink } from "../interfaces";
|
|
3
|
+
import { MediationPaymentCardConfig } from "../interfaces";
|
|
4
|
+
import { handleExceptions } from "../utils/errors";
|
|
5
|
+
|
|
6
|
+
export default class MediationPaymentCard {
|
|
7
|
+
private tropipay: Tropipay;
|
|
8
|
+
constructor(tropipayInstance: Tropipay) {
|
|
9
|
+
this.tropipay = tropipayInstance;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* (ONLY FOR BUSINESS ACCOUNTS) Create a mediation paymentcard (an escrow payment link) with the specified options.
|
|
14
|
+
* This allows a payment to be made to persons belonging or not to the TropiPay platform with the
|
|
15
|
+
* particularity that the payment will be held in custody or retained until it is released with
|
|
16
|
+
* the approval of the payer.
|
|
17
|
+
* @param payload PaymentLinkPayload Object.
|
|
18
|
+
* @returns Promise<PaymentLink> or throws an Exception.
|
|
19
|
+
* @see https://tpp.stoplight.io/docs/tropipay-api-doc/12a128ff971e4-creating-a-mediation-payment-card
|
|
20
|
+
*/
|
|
21
|
+
async create(payload: MediationPaymentCardConfig): Promise<PaymentLink> {
|
|
22
|
+
if (!Tropipay.accessToken) {
|
|
23
|
+
await this.tropipay.login();
|
|
24
|
+
}
|
|
25
|
+
try {
|
|
26
|
+
const paylink = await this.tropipay.request.post(
|
|
27
|
+
"/api/v2/paymentcards/mediation",
|
|
28
|
+
payload,
|
|
29
|
+
{
|
|
30
|
+
headers: {
|
|
31
|
+
"Content-Type": "application/json",
|
|
32
|
+
Authorization: `Bearer ${Tropipay.accessToken}`,
|
|
33
|
+
Accept: "application/json",
|
|
34
|
+
},
|
|
35
|
+
}
|
|
36
|
+
);
|
|
37
|
+
return paylink.data as PaymentLink;
|
|
38
|
+
} catch (error) {
|
|
39
|
+
throw handleExceptions(error as unknown as any);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -1,123 +1,123 @@
|
|
|
1
|
-
import { Tropipay } from "../api/TropipayAPI";
|
|
2
|
-
import { PaymentLink } from "../interfaces";
|
|
3
|
-
import { PaymentLinkPayload } from "../interfaces";
|
|
4
|
-
import { handleExceptions } from "../utils/errors";
|
|
5
|
-
export default class PaymentCard {
|
|
6
|
-
private tropipay: Tropipay;
|
|
7
|
-
constructor(tropipayInstance: Tropipay) {
|
|
8
|
-
this.tropipay = tropipayInstance;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Create a paymentLink with the specified options.
|
|
13
|
-
* @param payload PaymentLinkPayload Object.
|
|
14
|
-
* @returns Promise<PaymentLink> or throws an Exception.
|
|
15
|
-
* @see https://tpp.stoplight.io/docs/tropipay-api-doc/b3A6ODgyNTM3OQ-create-a-new-pay-link-charge
|
|
16
|
-
*/
|
|
17
|
-
async create(payload: PaymentLinkPayload): Promise<PaymentLink> {
|
|
18
|
-
if (!Tropipay.accessToken) {
|
|
19
|
-
await this.tropipay.login();
|
|
20
|
-
}
|
|
21
|
-
try {
|
|
22
|
-
const paylink = await this.tropipay.request.post(
|
|
23
|
-
"/api/v2/paymentcards",
|
|
24
|
-
payload,
|
|
25
|
-
{
|
|
26
|
-
headers: {
|
|
27
|
-
"Content-Type": "application/json",
|
|
28
|
-
Authorization: `Bearer ${Tropipay.accessToken}`,
|
|
29
|
-
Accept: "application/json",
|
|
30
|
-
},
|
|
31
|
-
}
|
|
32
|
-
);
|
|
33
|
-
return paylink.data as PaymentLink;
|
|
34
|
-
} catch (error) {
|
|
35
|
-
throw handleExceptions(error as unknown as any);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Shows a list of stored paymentcards created by user.
|
|
40
|
-
* This list includes active and closed paylinks
|
|
41
|
-
* @returns Array of paymentlinks
|
|
42
|
-
*/
|
|
43
|
-
public async list() {
|
|
44
|
-
if (!Tropipay.accessToken) {
|
|
45
|
-
await this.tropipay.login();
|
|
46
|
-
}
|
|
47
|
-
try {
|
|
48
|
-
const paymentcards = await this.tropipay.request.get(
|
|
49
|
-
`/api/v2/paymentcards`,
|
|
50
|
-
{
|
|
51
|
-
headers: {
|
|
52
|
-
"Content-Type": "application/json",
|
|
53
|
-
Authorization: `Bearer ${Tropipay.accessToken}`,
|
|
54
|
-
Accept: "application/json",
|
|
55
|
-
},
|
|
56
|
-
}
|
|
57
|
-
);
|
|
58
|
-
return paymentcards.data;
|
|
59
|
-
} catch (error) {
|
|
60
|
-
throw new Error(`Could not retrieve PaymenCards list`);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* Retrieves a payment card with the specified ID.
|
|
66
|
-
*
|
|
67
|
-
* @param {string} id - The ID of the payment card to retrieve.
|
|
68
|
-
* @return {Promise<any>} A Promise that resolves to the payment card data.
|
|
69
|
-
* @throws {Error} If an error occurs while retrieving the payment card.
|
|
70
|
-
*/
|
|
71
|
-
public async get(id: string) {
|
|
72
|
-
if (!Tropipay.accessToken) {
|
|
73
|
-
await this.tropipay.login();
|
|
74
|
-
}
|
|
75
|
-
try {
|
|
76
|
-
const paymentcard = await this.tropipay.request.get(
|
|
77
|
-
`/api/v2/paymentcards/${id}`,
|
|
78
|
-
{
|
|
79
|
-
headers: {
|
|
80
|
-
"Content-Type": "application/json",
|
|
81
|
-
Authorization: `Bearer ${Tropipay.accessToken}`,
|
|
82
|
-
Accept: "application/json",
|
|
83
|
-
},
|
|
84
|
-
}
|
|
85
|
-
);
|
|
86
|
-
return paymentcard.data;
|
|
87
|
-
} catch (error) {
|
|
88
|
-
throw handleExceptions(error as unknown as any);
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
/**
|
|
93
|
-
* Deletes a payment card with the specified ID. Its a LOGIC delete
|
|
94
|
-
* so this will delete the paymentcard from paymentcard list and
|
|
95
|
-
* disable shortUrl but not paymentUrl
|
|
96
|
-
* @param {string} id - The ID of the payment card to delete.
|
|
97
|
-
* @return {Promise<any>} A Promise that resolves to the deleted payment card data.
|
|
98
|
-
* @throws {Error} If an error occurs while deleting the payment card.
|
|
99
|
-
*/
|
|
100
|
-
public async delete(id: string) {
|
|
101
|
-
if (!Tropipay.accessToken) {
|
|
102
|
-
await this.tropipay.login();
|
|
103
|
-
}
|
|
104
|
-
try {
|
|
105
|
-
const paymentcard = await this.tropipay.request.delete(
|
|
106
|
-
`/api/v2/paymentcards/`,
|
|
107
|
-
{
|
|
108
|
-
headers: {
|
|
109
|
-
"Content-Type": "application/json",
|
|
110
|
-
Authorization: `Bearer ${Tropipay.accessToken}`,
|
|
111
|
-
Accept: "application/json",
|
|
112
|
-
},
|
|
113
|
-
data: {
|
|
114
|
-
cardId: id,
|
|
115
|
-
},
|
|
116
|
-
}
|
|
117
|
-
);
|
|
118
|
-
return paymentcard.data;
|
|
119
|
-
} catch (error) {
|
|
120
|
-
throw handleExceptions(error as unknown as any);
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
}
|
|
1
|
+
import { Tropipay } from "../api/TropipayAPI";
|
|
2
|
+
import { PaymentLink } from "../interfaces";
|
|
3
|
+
import { PaymentLinkPayload } from "../interfaces";
|
|
4
|
+
import { handleExceptions } from "../utils/errors";
|
|
5
|
+
export default class PaymentCard {
|
|
6
|
+
private tropipay: Tropipay;
|
|
7
|
+
constructor(tropipayInstance: Tropipay) {
|
|
8
|
+
this.tropipay = tropipayInstance;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Create a paymentLink with the specified options.
|
|
13
|
+
* @param payload PaymentLinkPayload Object.
|
|
14
|
+
* @returns Promise<PaymentLink> or throws an Exception.
|
|
15
|
+
* @see https://tpp.stoplight.io/docs/tropipay-api-doc/b3A6ODgyNTM3OQ-create-a-new-pay-link-charge
|
|
16
|
+
*/
|
|
17
|
+
async create(payload: PaymentLinkPayload): Promise<PaymentLink> {
|
|
18
|
+
if (!Tropipay.accessToken) {
|
|
19
|
+
await this.tropipay.login();
|
|
20
|
+
}
|
|
21
|
+
try {
|
|
22
|
+
const paylink = await this.tropipay.request.post(
|
|
23
|
+
"/api/v2/paymentcards",
|
|
24
|
+
payload,
|
|
25
|
+
{
|
|
26
|
+
headers: {
|
|
27
|
+
"Content-Type": "application/json",
|
|
28
|
+
Authorization: `Bearer ${Tropipay.accessToken}`,
|
|
29
|
+
Accept: "application/json",
|
|
30
|
+
},
|
|
31
|
+
}
|
|
32
|
+
);
|
|
33
|
+
return paylink.data as PaymentLink;
|
|
34
|
+
} catch (error) {
|
|
35
|
+
throw handleExceptions(error as unknown as any);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Shows a list of stored paymentcards created by user.
|
|
40
|
+
* This list includes active and closed paylinks
|
|
41
|
+
* @returns Array of paymentlinks
|
|
42
|
+
*/
|
|
43
|
+
public async list() {
|
|
44
|
+
if (!Tropipay.accessToken) {
|
|
45
|
+
await this.tropipay.login();
|
|
46
|
+
}
|
|
47
|
+
try {
|
|
48
|
+
const paymentcards = await this.tropipay.request.get(
|
|
49
|
+
`/api/v2/paymentcards`,
|
|
50
|
+
{
|
|
51
|
+
headers: {
|
|
52
|
+
"Content-Type": "application/json",
|
|
53
|
+
Authorization: `Bearer ${Tropipay.accessToken}`,
|
|
54
|
+
Accept: "application/json",
|
|
55
|
+
},
|
|
56
|
+
}
|
|
57
|
+
);
|
|
58
|
+
return paymentcards.data;
|
|
59
|
+
} catch (error) {
|
|
60
|
+
throw new Error(`Could not retrieve PaymenCards list`);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Retrieves a payment card with the specified ID.
|
|
66
|
+
*
|
|
67
|
+
* @param {string} id - The ID of the payment card to retrieve.
|
|
68
|
+
* @return {Promise<any>} A Promise that resolves to the payment card data.
|
|
69
|
+
* @throws {Error} If an error occurs while retrieving the payment card.
|
|
70
|
+
*/
|
|
71
|
+
public async get(id: string) {
|
|
72
|
+
if (!Tropipay.accessToken) {
|
|
73
|
+
await this.tropipay.login();
|
|
74
|
+
}
|
|
75
|
+
try {
|
|
76
|
+
const paymentcard = await this.tropipay.request.get(
|
|
77
|
+
`/api/v2/paymentcards/${id}`,
|
|
78
|
+
{
|
|
79
|
+
headers: {
|
|
80
|
+
"Content-Type": "application/json",
|
|
81
|
+
Authorization: `Bearer ${Tropipay.accessToken}`,
|
|
82
|
+
Accept: "application/json",
|
|
83
|
+
},
|
|
84
|
+
}
|
|
85
|
+
);
|
|
86
|
+
return paymentcard.data;
|
|
87
|
+
} catch (error) {
|
|
88
|
+
throw handleExceptions(error as unknown as any);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Deletes a payment card with the specified ID. Its a LOGIC delete
|
|
94
|
+
* so this will delete the paymentcard from paymentcard list and
|
|
95
|
+
* disable shortUrl but not paymentUrl
|
|
96
|
+
* @param {string} id - The ID of the payment card to delete.
|
|
97
|
+
* @return {Promise<any>} A Promise that resolves to the deleted payment card data.
|
|
98
|
+
* @throws {Error} If an error occurs while deleting the payment card.
|
|
99
|
+
*/
|
|
100
|
+
public async delete(id: string) {
|
|
101
|
+
if (!Tropipay.accessToken) {
|
|
102
|
+
await this.tropipay.login();
|
|
103
|
+
}
|
|
104
|
+
try {
|
|
105
|
+
const paymentcard = await this.tropipay.request.delete(
|
|
106
|
+
`/api/v2/paymentcards/`,
|
|
107
|
+
{
|
|
108
|
+
headers: {
|
|
109
|
+
"Content-Type": "application/json",
|
|
110
|
+
Authorization: `Bearer ${Tropipay.accessToken}`,
|
|
111
|
+
Accept: "application/json",
|
|
112
|
+
},
|
|
113
|
+
data: {
|
|
114
|
+
cardId: id,
|
|
115
|
+
},
|
|
116
|
+
}
|
|
117
|
+
);
|
|
118
|
+
return paymentcard.data;
|
|
119
|
+
} catch (error) {
|
|
120
|
+
throw handleExceptions(error as unknown as any);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|