@selfcommunity/api-services 0.6.7-payments.175 → 0.7.0-alpha.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/lib/cjs/client/index.d.ts +3 -3
- package/lib/cjs/client/index.js +3 -3
- package/lib/cjs/constants/Endpoints.js +1 -68
- package/lib/cjs/index.d.ts +2 -4
- package/lib/cjs/index.js +1 -7
- package/lib/cjs/services/user/index.d.ts +1 -21
- package/lib/cjs/services/user/index.js +0 -30
- package/lib/cjs/types/index.d.ts +1 -2
- package/lib/esm/client/index.d.ts +3 -3
- package/lib/esm/client/index.js +3 -3
- package/lib/esm/constants/Endpoints.js +1 -68
- package/lib/esm/index.d.ts +2 -4
- package/lib/esm/index.js +1 -3
- package/lib/esm/services/user/index.d.ts +1 -21
- package/lib/esm/services/user/index.js +0 -30
- package/lib/esm/types/index.d.ts +1 -2
- package/lib/umd/api-services.js +1 -1
- package/package.json +4 -4
- package/lib/cjs/services/community/index.d.ts +0 -65
- package/lib/cjs/services/community/index.js +0 -70
- package/lib/cjs/services/payment/index.d.ts +0 -193
- package/lib/cjs/services/payment/index.js +0 -197
- package/lib/cjs/types/payment.d.ts +0 -100
- package/lib/cjs/types/payment.js +0 -2
- package/lib/esm/services/community/index.d.ts +0 -65
- package/lib/esm/services/community/index.js +0 -65
- package/lib/esm/services/payment/index.d.ts +0 -193
- package/lib/esm/services/payment/index.js +0 -192
- package/lib/esm/types/payment.d.ts +0 -100
- package/lib/esm/types/payment.js +0 -1
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import { AxiosRequestConfig } from 'axios';
|
|
2
|
-
import { BaseGetParams, SCPaginatedResponse } from '../../types';
|
|
3
|
-
import { SCCommunityType } from '@selfcommunity/types';
|
|
4
|
-
export interface CommunityApiClientInterface {
|
|
5
|
-
/**
|
|
6
|
-
* Get list of communities. Used to get the payment products related to the community (aka paywalls)
|
|
7
|
-
* @param params
|
|
8
|
-
* @param config
|
|
9
|
-
*/
|
|
10
|
-
getCommunities(params?: BaseGetParams, config?: AxiosRequestConfig): Promise<SCPaginatedResponse<SCCommunityType>>;
|
|
11
|
-
/**
|
|
12
|
-
* Get Community
|
|
13
|
-
* @param id
|
|
14
|
-
* @param config
|
|
15
|
-
*/
|
|
16
|
-
getCommunity(id: number | string, config?: AxiosRequestConfig): Promise<SCCommunityType>;
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Contains all the endpoints needed to manage payments.
|
|
20
|
-
*/
|
|
21
|
-
export declare class CommunityApiClient {
|
|
22
|
-
/**
|
|
23
|
-
* Get list of communities. Used to get the payment products related to the community (aka paywalls)
|
|
24
|
-
* @param params
|
|
25
|
-
* @param config
|
|
26
|
-
*/
|
|
27
|
-
static getCommunities(params?: BaseGetParams, config?: AxiosRequestConfig): Promise<SCPaginatedResponse<SCCommunityType>>;
|
|
28
|
-
/**
|
|
29
|
-
* Get Community
|
|
30
|
-
* @param id
|
|
31
|
-
* @param config
|
|
32
|
-
*/
|
|
33
|
-
static getCommunity(id: number | string, config?: AxiosRequestConfig): Promise<SCCommunityType>;
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
*
|
|
37
|
-
:::tip Community service can be used in the following way:
|
|
38
|
-
|
|
39
|
-
```jsx
|
|
40
|
-
1. Import the service from our library:
|
|
41
|
-
|
|
42
|
-
import {CommunityService} from "@selfcommunity/api-services";
|
|
43
|
-
```
|
|
44
|
-
```jsx
|
|
45
|
-
2. Create a function and put the service inside it!
|
|
46
|
-
The async function `getCommunities` will return the events matching the search query.
|
|
47
|
-
|
|
48
|
-
async getCommunities() {
|
|
49
|
-
return await CommunityService.getCommunities({...});
|
|
50
|
-
}
|
|
51
|
-
```
|
|
52
|
-
If you need to customize the request, you can add optional config params (`AxiosRequestConfig` type).
|
|
53
|
-
|
|
54
|
-
1. Declare it(or declare them, it is possible to add multiple params)
|
|
55
|
-
|
|
56
|
-
const headers = headers: {Authorization: `Bearer ${yourToken}`}
|
|
57
|
-
|
|
58
|
-
2. Add it inside the brackets and pass it to the function, as shown in the previous example!
|
|
59
|
-
```
|
|
60
|
-
:::
|
|
61
|
-
*/
|
|
62
|
-
export default class CommunityService {
|
|
63
|
-
static getCommunities(params?: BaseGetParams, config?: AxiosRequestConfig): Promise<SCPaginatedResponse<SCCommunityType>>;
|
|
64
|
-
static getPaymentProduct(id: number | string, config?: AxiosRequestConfig): Promise<SCCommunityType>;
|
|
65
|
-
}
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import { __awaiter } from "tslib";
|
|
2
|
-
import Endpoints from '../../constants/Endpoints';
|
|
3
|
-
import { apiRequest } from '../../utils/apiRequest';
|
|
4
|
-
import { urlParams } from '../../utils/url';
|
|
5
|
-
/**
|
|
6
|
-
* Contains all the endpoints needed to manage payments.
|
|
7
|
-
*/
|
|
8
|
-
export class CommunityApiClient {
|
|
9
|
-
/**
|
|
10
|
-
* Get list of communities. Used to get the payment products related to the community (aka paywalls)
|
|
11
|
-
* @param params
|
|
12
|
-
* @param config
|
|
13
|
-
*/
|
|
14
|
-
static getCommunities(params, config) {
|
|
15
|
-
const p = urlParams(params);
|
|
16
|
-
return apiRequest(Object.assign(Object.assign({}, config), { url: `${Endpoints.GetCommunities.url({})}?${p.toString()}`, method: Endpoints.GetCommunities.method }));
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Get Community
|
|
20
|
-
* @param id
|
|
21
|
-
* @param config
|
|
22
|
-
*/
|
|
23
|
-
static getCommunity(id, config) {
|
|
24
|
-
return apiRequest(Object.assign(Object.assign({}, config), { url: Endpoints.GetCommunity.url({ id }), method: Endpoints.GetCommunity.method }));
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
*
|
|
29
|
-
:::tip Community service can be used in the following way:
|
|
30
|
-
|
|
31
|
-
```jsx
|
|
32
|
-
1. Import the service from our library:
|
|
33
|
-
|
|
34
|
-
import {CommunityService} from "@selfcommunity/api-services";
|
|
35
|
-
```
|
|
36
|
-
```jsx
|
|
37
|
-
2. Create a function and put the service inside it!
|
|
38
|
-
The async function `getCommunities` will return the events matching the search query.
|
|
39
|
-
|
|
40
|
-
async getCommunities() {
|
|
41
|
-
return await CommunityService.getCommunities({...});
|
|
42
|
-
}
|
|
43
|
-
```
|
|
44
|
-
If you need to customize the request, you can add optional config params (`AxiosRequestConfig` type).
|
|
45
|
-
|
|
46
|
-
1. Declare it(or declare them, it is possible to add multiple params)
|
|
47
|
-
|
|
48
|
-
const headers = headers: {Authorization: `Bearer ${yourToken}`}
|
|
49
|
-
|
|
50
|
-
2. Add it inside the brackets and pass it to the function, as shown in the previous example!
|
|
51
|
-
```
|
|
52
|
-
:::
|
|
53
|
-
*/
|
|
54
|
-
export default class CommunityService {
|
|
55
|
-
static getCommunities(params, config) {
|
|
56
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
57
|
-
return CommunityApiClient.getCommunities(params, config);
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
static getPaymentProduct(id, config) {
|
|
61
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
62
|
-
return CommunityApiClient.getCommunity(id, config);
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
}
|
|
@@ -1,193 +0,0 @@
|
|
|
1
|
-
import { AxiosRequestConfig } from 'axios';
|
|
2
|
-
import { BaseGetParams, SCPaginatedResponse } from '../../types';
|
|
3
|
-
import { CheckoutCreateSessionParams, CheckoutSessionParams, PaymentProductsParams, CustomerPortalCreateSessionParams, PaymentContentStatusParams, PaymentOrderParams, CreatePaymentProductParams } from '../../types/payment';
|
|
4
|
-
import { SCCheckoutSession, SCPaymentOrder, SCCheckoutSessionDetail, SCCheckoutSessionComplete, SCPaymentProduct, SCPaymentPrice, SCPaymentsCustomerPortalSession, SCPurchasableContent, SCPaywall } from '@selfcommunity/types';
|
|
5
|
-
export interface PaymentApiClientInterface {
|
|
6
|
-
/**
|
|
7
|
-
* Get payment products related to an object (aka paywalls) of type <content_type> and id <content_id> and the current payment_order
|
|
8
|
-
* @param params
|
|
9
|
-
* @param config
|
|
10
|
-
*/
|
|
11
|
-
getPaymentContentStatus(params?: PaymentContentStatusParams, config?: AxiosRequestConfig): Promise<SCPurchasableContent>;
|
|
12
|
-
/**
|
|
13
|
-
* Get payment products related to an object (aka paywalls) of type <content_type> and id <content_id>
|
|
14
|
-
* @param params
|
|
15
|
-
* @param config
|
|
16
|
-
*/
|
|
17
|
-
getPaywalls(params?: PaymentProductsParams, config?: AxiosRequestConfig): Promise<SCPaginatedResponse<SCPaywall>>;
|
|
18
|
-
/**
|
|
19
|
-
* Get payment products
|
|
20
|
-
* @param params
|
|
21
|
-
* @param config
|
|
22
|
-
*/
|
|
23
|
-
getPaymentProducts(params?: PaymentProductsParams, config?: AxiosRequestConfig): Promise<SCPaginatedResponse<SCPaymentProduct>>;
|
|
24
|
-
/**
|
|
25
|
-
* Get product
|
|
26
|
-
* @param id
|
|
27
|
-
* @param config
|
|
28
|
-
*/
|
|
29
|
-
getPaymentProduct(id: number | string, config?: AxiosRequestConfig): Promise<SCPaymentProduct>;
|
|
30
|
-
/**
|
|
31
|
-
* Get prices related to a product
|
|
32
|
-
* @param id
|
|
33
|
-
* @param params
|
|
34
|
-
* @param config
|
|
35
|
-
*/
|
|
36
|
-
getPaymentProductPrices(id: number | string, params?: BaseGetParams, config?: AxiosRequestConfig): Promise<SCPaginatedResponse<SCPaymentPrice>>;
|
|
37
|
-
/**
|
|
38
|
-
* Create session checkout with price_id for an object of type <content_type> and id <content_id>
|
|
39
|
-
* @param data
|
|
40
|
-
* @param config
|
|
41
|
-
*/
|
|
42
|
-
checkoutCreateSession(data: CheckoutCreateSessionParams | FormData, config?: AxiosRequestConfig): Promise<any>;
|
|
43
|
-
/**
|
|
44
|
-
* This endpoint retrieve checkout session
|
|
45
|
-
* @param params
|
|
46
|
-
* @param config
|
|
47
|
-
*/
|
|
48
|
-
getCheckoutSession(params?: CheckoutSessionParams, config?: AxiosRequestConfig): Promise<SCCheckoutSessionDetail>;
|
|
49
|
-
/**
|
|
50
|
-
* Complete session checkout
|
|
51
|
-
* @param data
|
|
52
|
-
* @param config
|
|
53
|
-
*/
|
|
54
|
-
checkoutCompleteSession(data: CheckoutSessionParams | FormData, config?: AxiosRequestConfig): Promise<SCCheckoutSessionComplete>;
|
|
55
|
-
/**
|
|
56
|
-
* This endpoint retrieve order history of authenticated user
|
|
57
|
-
* @param params
|
|
58
|
-
* @param config
|
|
59
|
-
*/
|
|
60
|
-
getPaymentsOrder(params?: PaymentOrderParams, config?: AxiosRequestConfig): Promise<SCPaginatedResponse<SCPaymentOrder>>;
|
|
61
|
-
/**
|
|
62
|
-
* This endpoint retrieve customer portal
|
|
63
|
-
* @param data
|
|
64
|
-
* @param config
|
|
65
|
-
*/
|
|
66
|
-
getPaymentsCustomerPortal(data: CustomerPortalCreateSessionParams | FormData, config?: AxiosRequestConfig): Promise<SCPaymentsCustomerPortalSession>;
|
|
67
|
-
/**
|
|
68
|
-
* Create payment product
|
|
69
|
-
* @param data
|
|
70
|
-
* @param config
|
|
71
|
-
*/
|
|
72
|
-
createPaymentProduct(data: CreatePaymentProductParams | FormData, config?: AxiosRequestConfig): Promise<SCPaymentProduct>;
|
|
73
|
-
}
|
|
74
|
-
/**
|
|
75
|
-
* Contains all the endpoints needed to manage payments.
|
|
76
|
-
*/
|
|
77
|
-
export declare class PaymentApiClient {
|
|
78
|
-
/**
|
|
79
|
-
* This endpoint retrieves all the products related to an object of type <content_type> and id <content_id> and the current payment_order
|
|
80
|
-
* @param params
|
|
81
|
-
* @param config
|
|
82
|
-
*/
|
|
83
|
-
static getPaymentContentStatus(params?: PaymentContentStatusParams, config?: AxiosRequestConfig): Promise<SCPurchasableContent>;
|
|
84
|
-
/**
|
|
85
|
-
* This endpoint retrieves all the products related to an object of type <content_type> and id <content_id>
|
|
86
|
-
* @param params
|
|
87
|
-
* @param config
|
|
88
|
-
*/
|
|
89
|
-
static getPaywalls(params?: PaymentProductsParams, config?: AxiosRequestConfig): Promise<SCPaginatedResponse<SCPaywall>>;
|
|
90
|
-
/**
|
|
91
|
-
* This endpoint retrieves all the payment products
|
|
92
|
-
* @param params
|
|
93
|
-
* @param config
|
|
94
|
-
*/
|
|
95
|
-
static getPaymentProducts(params?: PaymentProductsParams, config?: AxiosRequestConfig): Promise<SCPaginatedResponse<SCPaymentProduct>>;
|
|
96
|
-
/**
|
|
97
|
-
* This endpoint retrieves a specific payment product.
|
|
98
|
-
* @param id
|
|
99
|
-
* @param config
|
|
100
|
-
*/
|
|
101
|
-
static getPaymentProduct(id: number | string, config?: AxiosRequestConfig): Promise<SCPaymentProduct>;
|
|
102
|
-
/**
|
|
103
|
-
* This endpoint retrieves all the prices related to a product
|
|
104
|
-
* @param id
|
|
105
|
-
* @param params
|
|
106
|
-
* @param config
|
|
107
|
-
*/
|
|
108
|
-
static getPaymentProductPrices(id: number | string, params?: BaseGetParams, config?: AxiosRequestConfig): Promise<SCPaginatedResponse<SCPaymentPrice>>;
|
|
109
|
-
/**
|
|
110
|
-
* This endpoint creates a checkout session.
|
|
111
|
-
* @param data
|
|
112
|
-
* @param config
|
|
113
|
-
*/
|
|
114
|
-
static checkoutCreateSession(data: CheckoutCreateSessionParams | FormData, config?: AxiosRequestConfig): Promise<SCCheckoutSession>;
|
|
115
|
-
/**
|
|
116
|
-
* Create payment product
|
|
117
|
-
* @param data
|
|
118
|
-
* @param config
|
|
119
|
-
*/
|
|
120
|
-
static createPaymentProduct(data: CreatePaymentProductParams | FormData, config?: AxiosRequestConfig): Promise<SCPaymentProduct>;
|
|
121
|
-
/**
|
|
122
|
-
* This endpoint retrieve checkout session
|
|
123
|
-
* @param params
|
|
124
|
-
* @param config
|
|
125
|
-
*/
|
|
126
|
-
static getCheckoutSession(params?: CheckoutSessionParams, config?: AxiosRequestConfig): Promise<SCCheckoutSessionDetail>;
|
|
127
|
-
/**
|
|
128
|
-
* This endpoint complete checkout session
|
|
129
|
-
* @param data
|
|
130
|
-
* @param config
|
|
131
|
-
*/
|
|
132
|
-
static checkoutCompleteSession(data: CheckoutSessionParams | FormData, config?: AxiosRequestConfig): Promise<SCCheckoutSessionComplete>;
|
|
133
|
-
/**
|
|
134
|
-
* This endpoint retrive order history of authenticated user
|
|
135
|
-
* @param params
|
|
136
|
-
* @param config
|
|
137
|
-
*/
|
|
138
|
-
static getPaymentsOrder(params?: PaymentOrderParams, config?: AxiosRequestConfig): Promise<SCPaginatedResponse<SCPaymentOrder>>;
|
|
139
|
-
/**
|
|
140
|
-
* This endpoint retrive customer portal
|
|
141
|
-
* @param data
|
|
142
|
-
* @param config
|
|
143
|
-
*/
|
|
144
|
-
static getPaymentsCustomerPortal(data: CustomerPortalCreateSessionParams | FormData, config?: AxiosRequestConfig): Promise<SCPaymentsCustomerPortalSession>;
|
|
145
|
-
}
|
|
146
|
-
/**
|
|
147
|
-
*
|
|
148
|
-
:::tip Payment service can be used in the following way:
|
|
149
|
-
|
|
150
|
-
```jsx
|
|
151
|
-
1. Import the service from our library:
|
|
152
|
-
|
|
153
|
-
import {PaymentService} from "@selfcommunity/api-services";
|
|
154
|
-
```
|
|
155
|
-
```jsx
|
|
156
|
-
2. Create a function and put the service inside it!
|
|
157
|
-
The async function `getPaymentProducts` will return the events matching the search query.
|
|
158
|
-
|
|
159
|
-
async getPaymentProducts() {
|
|
160
|
-
return await PaymentService.getPaymentProducts({...});
|
|
161
|
-
}
|
|
162
|
-
```
|
|
163
|
-
```jsx
|
|
164
|
-
In case of required `params`, just add them inside the brackets.
|
|
165
|
-
|
|
166
|
-
async getPaymentPrices(eventId) {
|
|
167
|
-
return await PaymentService.getProductPrices(id);
|
|
168
|
-
}
|
|
169
|
-
```
|
|
170
|
-
```jsx
|
|
171
|
-
If you need to customize the request, you can add optional config params (`AxiosRequestConfig` type).
|
|
172
|
-
|
|
173
|
-
1. Declare it(or declare them, it is possible to add multiple params)
|
|
174
|
-
|
|
175
|
-
const headers = headers: {Authorization: `Bearer ${yourToken}`}
|
|
176
|
-
|
|
177
|
-
2. Add it inside the brackets and pass it to the function, as shown in the previous example!
|
|
178
|
-
```
|
|
179
|
-
:::
|
|
180
|
-
*/
|
|
181
|
-
export default class PaymentService {
|
|
182
|
-
static getPaymentContentStatus(params?: PaymentContentStatusParams, config?: AxiosRequestConfig): Promise<SCPurchasableContent>;
|
|
183
|
-
static getPaywalls(params?: PaymentProductsParams, config?: AxiosRequestConfig): Promise<SCPaginatedResponse<SCPaywall>>;
|
|
184
|
-
static getPaymentProducts(params?: PaymentProductsParams, config?: AxiosRequestConfig): Promise<SCPaginatedResponse<SCPaymentProduct>>;
|
|
185
|
-
static getPaymentProduct(id: number | string, config?: AxiosRequestConfig): Promise<SCPaymentProduct>;
|
|
186
|
-
static getPaymentProductPrices(id: number | string, params?: PaymentProductsParams, config?: AxiosRequestConfig): Promise<SCPaginatedResponse<SCPaymentPrice>>;
|
|
187
|
-
static checkoutCreateSession(data: CheckoutCreateSessionParams | FormData, config?: AxiosRequestConfig): Promise<SCCheckoutSession>;
|
|
188
|
-
static getCheckoutSession(params?: CheckoutSessionParams, config?: AxiosRequestConfig): Promise<SCCheckoutSessionDetail>;
|
|
189
|
-
static checkoutCompleteSession(data: CheckoutSessionParams | FormData, config?: AxiosRequestConfig): Promise<SCCheckoutSessionComplete>;
|
|
190
|
-
static getPaymentsOrder(params?: PaymentOrderParams, config?: AxiosRequestConfig): Promise<SCPaginatedResponse<SCPaymentOrder>>;
|
|
191
|
-
static getPaymentsCustomerPortal(data: CustomerPortalCreateSessionParams | FormData, config?: AxiosRequestConfig): Promise<SCPaymentsCustomerPortalSession>;
|
|
192
|
-
static createPaymentProduct(data: CreatePaymentProductParams | FormData, config?: AxiosRequestConfig): Promise<SCPaymentProduct>;
|
|
193
|
-
}
|
|
@@ -1,192 +0,0 @@
|
|
|
1
|
-
import { __awaiter } from "tslib";
|
|
2
|
-
import Endpoints from '../../constants/Endpoints';
|
|
3
|
-
import { apiRequest } from '../../utils/apiRequest';
|
|
4
|
-
import { urlParams } from '../../utils/url';
|
|
5
|
-
/**
|
|
6
|
-
* Contains all the endpoints needed to manage payments.
|
|
7
|
-
*/
|
|
8
|
-
export class PaymentApiClient {
|
|
9
|
-
/**
|
|
10
|
-
* This endpoint retrieves all the products related to an object of type <content_type> and id <content_id> and the current payment_order
|
|
11
|
-
* @param params
|
|
12
|
-
* @param config
|
|
13
|
-
*/
|
|
14
|
-
static getPaymentContentStatus(params, config) {
|
|
15
|
-
const p = urlParams(params);
|
|
16
|
-
return apiRequest(Object.assign(Object.assign({}, config), { url: `${Endpoints.GetPaymentContentStatus.url({})}?${p.toString()}`, method: Endpoints.GetPaymentContentStatus.method }));
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* This endpoint retrieves all the products related to an object of type <content_type> and id <content_id>
|
|
20
|
-
* @param params
|
|
21
|
-
* @param config
|
|
22
|
-
*/
|
|
23
|
-
static getPaywalls(params, config) {
|
|
24
|
-
const p = urlParams(params);
|
|
25
|
-
return apiRequest(Object.assign(Object.assign({}, config), { url: `${Endpoints.GetPaywalls.url({})}?${p.toString()}`, method: Endpoints.GetPaywalls.method }));
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* This endpoint retrieves all the payment products
|
|
29
|
-
* @param params
|
|
30
|
-
* @param config
|
|
31
|
-
*/
|
|
32
|
-
static getPaymentProducts(params, config) {
|
|
33
|
-
const p = urlParams(params);
|
|
34
|
-
return apiRequest(Object.assign(Object.assign({}, config), { url: `${Endpoints.GetPaymentProducts.url({})}?${p.toString()}`, method: Endpoints.GetPaymentProducts.method }));
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* This endpoint retrieves a specific payment product.
|
|
38
|
-
* @param id
|
|
39
|
-
* @param config
|
|
40
|
-
*/
|
|
41
|
-
static getPaymentProduct(id, config) {
|
|
42
|
-
return apiRequest(Object.assign(Object.assign({}, config), { url: Endpoints.GetPaymentProduct.url({ id }), method: Endpoints.GetPaymentProduct.method }));
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* This endpoint retrieves all the prices related to a product
|
|
46
|
-
* @param id
|
|
47
|
-
* @param params
|
|
48
|
-
* @param config
|
|
49
|
-
*/
|
|
50
|
-
static getPaymentProductPrices(id, params, config) {
|
|
51
|
-
const p = urlParams(params);
|
|
52
|
-
return apiRequest(Object.assign(Object.assign({}, config), { url: `${Endpoints.GetPaymentProductPrices.url({ id })}?${p.toString()}`, method: Endpoints.GetPaymentProductPrices.method }));
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* This endpoint creates a checkout session.
|
|
56
|
-
* @param data
|
|
57
|
-
* @param config
|
|
58
|
-
*/
|
|
59
|
-
static checkoutCreateSession(data, config) {
|
|
60
|
-
return apiRequest(Object.assign(Object.assign({}, config), { url: Endpoints.CheckoutCreateSession.url({}), method: Endpoints.CheckoutCreateSession.method, data }));
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* Create payment product
|
|
64
|
-
* @param data
|
|
65
|
-
* @param config
|
|
66
|
-
*/
|
|
67
|
-
static createPaymentProduct(data, config) {
|
|
68
|
-
return apiRequest(Object.assign(Object.assign({}, config), { url: Endpoints.CreatePaymentProduct.url({}), method: Endpoints.CreatePaymentProduct.method, data }));
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* This endpoint retrieve checkout session
|
|
72
|
-
* @param params
|
|
73
|
-
* @param config
|
|
74
|
-
*/
|
|
75
|
-
static getCheckoutSession(params, config) {
|
|
76
|
-
const p = urlParams(params);
|
|
77
|
-
return apiRequest(Object.assign(Object.assign({}, config), { url: `${Endpoints.GetCheckoutSession.url({})}?${p.toString()}`, method: Endpoints.GetCheckoutSession.method }));
|
|
78
|
-
}
|
|
79
|
-
/**
|
|
80
|
-
* This endpoint complete checkout session
|
|
81
|
-
* @param data
|
|
82
|
-
* @param config
|
|
83
|
-
*/
|
|
84
|
-
static checkoutCompleteSession(data, config) {
|
|
85
|
-
return apiRequest(Object.assign(Object.assign({}, config), { url: Endpoints.CheckoutSessionComplete.url({}), method: Endpoints.CheckoutSessionComplete.method, data }));
|
|
86
|
-
}
|
|
87
|
-
/**
|
|
88
|
-
* This endpoint retrive order history of authenticated user
|
|
89
|
-
* @param params
|
|
90
|
-
* @param config
|
|
91
|
-
*/
|
|
92
|
-
static getPaymentsOrder(params, config) {
|
|
93
|
-
const p = urlParams(params);
|
|
94
|
-
return apiRequest(Object.assign(Object.assign({}, config), { url: `${Endpoints.GetPaymentOrders.url({})}?${p.toString()}`, method: Endpoints.GetPaymentOrders.method }));
|
|
95
|
-
}
|
|
96
|
-
/**
|
|
97
|
-
* This endpoint retrive customer portal
|
|
98
|
-
* @param data
|
|
99
|
-
* @param config
|
|
100
|
-
*/
|
|
101
|
-
static getPaymentsCustomerPortal(data, config) {
|
|
102
|
-
return apiRequest(Object.assign(Object.assign({}, config), { url: Endpoints.CreateCustomerPortalSession.url({}), method: Endpoints.CreateCustomerPortalSession.method, data }));
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
/**
|
|
106
|
-
*
|
|
107
|
-
:::tip Payment service can be used in the following way:
|
|
108
|
-
|
|
109
|
-
```jsx
|
|
110
|
-
1. Import the service from our library:
|
|
111
|
-
|
|
112
|
-
import {PaymentService} from "@selfcommunity/api-services";
|
|
113
|
-
```
|
|
114
|
-
```jsx
|
|
115
|
-
2. Create a function and put the service inside it!
|
|
116
|
-
The async function `getPaymentProducts` will return the events matching the search query.
|
|
117
|
-
|
|
118
|
-
async getPaymentProducts() {
|
|
119
|
-
return await PaymentService.getPaymentProducts({...});
|
|
120
|
-
}
|
|
121
|
-
```
|
|
122
|
-
```jsx
|
|
123
|
-
In case of required `params`, just add them inside the brackets.
|
|
124
|
-
|
|
125
|
-
async getPaymentPrices(eventId) {
|
|
126
|
-
return await PaymentService.getProductPrices(id);
|
|
127
|
-
}
|
|
128
|
-
```
|
|
129
|
-
```jsx
|
|
130
|
-
If you need to customize the request, you can add optional config params (`AxiosRequestConfig` type).
|
|
131
|
-
|
|
132
|
-
1. Declare it(or declare them, it is possible to add multiple params)
|
|
133
|
-
|
|
134
|
-
const headers = headers: {Authorization: `Bearer ${yourToken}`}
|
|
135
|
-
|
|
136
|
-
2. Add it inside the brackets and pass it to the function, as shown in the previous example!
|
|
137
|
-
```
|
|
138
|
-
:::
|
|
139
|
-
*/
|
|
140
|
-
export default class PaymentService {
|
|
141
|
-
static getPaymentContentStatus(params, config) {
|
|
142
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
143
|
-
return PaymentApiClient.getPaymentContentStatus(params, config);
|
|
144
|
-
});
|
|
145
|
-
}
|
|
146
|
-
static getPaywalls(params, config) {
|
|
147
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
148
|
-
return PaymentApiClient.getPaywalls(params, config);
|
|
149
|
-
});
|
|
150
|
-
}
|
|
151
|
-
static getPaymentProducts(params, config) {
|
|
152
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
153
|
-
return PaymentApiClient.getPaymentProducts(params, config);
|
|
154
|
-
});
|
|
155
|
-
}
|
|
156
|
-
static getPaymentProduct(id, config) {
|
|
157
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
158
|
-
return PaymentApiClient.getPaymentProduct(id, config);
|
|
159
|
-
});
|
|
160
|
-
}
|
|
161
|
-
static getPaymentProductPrices(id, params, config) {
|
|
162
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
163
|
-
return PaymentApiClient.getPaymentProductPrices(id, params, config);
|
|
164
|
-
});
|
|
165
|
-
}
|
|
166
|
-
static checkoutCreateSession(data, config) {
|
|
167
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
168
|
-
return PaymentApiClient.checkoutCreateSession(data, config);
|
|
169
|
-
});
|
|
170
|
-
}
|
|
171
|
-
static getCheckoutSession(params, config) {
|
|
172
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
173
|
-
return PaymentApiClient.getCheckoutSession(params, config);
|
|
174
|
-
});
|
|
175
|
-
}
|
|
176
|
-
static checkoutCompleteSession(data, config) {
|
|
177
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
178
|
-
return PaymentApiClient.checkoutCompleteSession(data, config);
|
|
179
|
-
});
|
|
180
|
-
}
|
|
181
|
-
static getPaymentsOrder(params, config) {
|
|
182
|
-
return PaymentApiClient.getPaymentsOrder(params, config);
|
|
183
|
-
}
|
|
184
|
-
static getPaymentsCustomerPortal(data, config) {
|
|
185
|
-
return PaymentApiClient.getPaymentsCustomerPortal(data, config);
|
|
186
|
-
}
|
|
187
|
-
static createPaymentProduct(data, config) {
|
|
188
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
189
|
-
return PaymentApiClient.createPaymentProduct(data, config);
|
|
190
|
-
});
|
|
191
|
-
}
|
|
192
|
-
}
|
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
import { BaseGetParams, BaseSearchParams } from './baseParams';
|
|
2
|
-
import { SCCheckoutSessionUIMode, SCContentType, SCPaymentPriceCurrencyType } from '@selfcommunity/types';
|
|
3
|
-
/**
|
|
4
|
-
* PaymentParams interface.
|
|
5
|
-
*/
|
|
6
|
-
export interface PaymentProductsParams extends BaseGetParams {
|
|
7
|
-
/**
|
|
8
|
-
* Content id
|
|
9
|
-
*/
|
|
10
|
-
id?: number | string;
|
|
11
|
-
/**
|
|
12
|
-
* Content id
|
|
13
|
-
*/
|
|
14
|
-
content_id?: number | string;
|
|
15
|
-
/**
|
|
16
|
-
* Content type
|
|
17
|
-
*/
|
|
18
|
-
content_type?: SCContentType;
|
|
19
|
-
}
|
|
20
|
-
export interface CheckoutCreateSessionParams {
|
|
21
|
-
/**
|
|
22
|
-
* Content id
|
|
23
|
-
*/
|
|
24
|
-
content_id: number;
|
|
25
|
-
/**
|
|
26
|
-
* Content type
|
|
27
|
-
*/
|
|
28
|
-
content_type: SCContentType;
|
|
29
|
-
/**
|
|
30
|
-
* Price id
|
|
31
|
-
*/
|
|
32
|
-
payment_price_id: number;
|
|
33
|
-
/**
|
|
34
|
-
* Return url
|
|
35
|
-
*/
|
|
36
|
-
return_url?: string;
|
|
37
|
-
/**
|
|
38
|
-
* Success url
|
|
39
|
-
*/
|
|
40
|
-
success_url?: string;
|
|
41
|
-
/**
|
|
42
|
-
* Session UI mode
|
|
43
|
-
*/
|
|
44
|
-
ui_mode?: SCCheckoutSessionUIMode;
|
|
45
|
-
}
|
|
46
|
-
export interface CheckoutSessionParams {
|
|
47
|
-
/**
|
|
48
|
-
* Session Id
|
|
49
|
-
*/
|
|
50
|
-
session_id: string;
|
|
51
|
-
}
|
|
52
|
-
export interface CustomerPortalCreateSessionParams {
|
|
53
|
-
/**
|
|
54
|
-
* Return url
|
|
55
|
-
*/
|
|
56
|
-
return_url?: string;
|
|
57
|
-
}
|
|
58
|
-
/**
|
|
59
|
-
* PaymentContentStatusParams interface.
|
|
60
|
-
*/
|
|
61
|
-
export interface PaymentContentStatusParams extends BaseGetParams {
|
|
62
|
-
/**
|
|
63
|
-
* Content id
|
|
64
|
-
*/
|
|
65
|
-
content_id?: number | string;
|
|
66
|
-
/**
|
|
67
|
-
* Content type
|
|
68
|
-
*/
|
|
69
|
-
content_type?: SCContentType;
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* PaymentOrderParams interface.
|
|
73
|
-
*/
|
|
74
|
-
export interface PaymentOrderParams extends BaseSearchParams {
|
|
75
|
-
/**
|
|
76
|
-
* Ordering
|
|
77
|
-
*/
|
|
78
|
-
ordering?: string;
|
|
79
|
-
}
|
|
80
|
-
/**
|
|
81
|
-
* CreatePaymentProduct interface.
|
|
82
|
-
*/
|
|
83
|
-
export interface CreatePaymentProductParams {
|
|
84
|
-
/**
|
|
85
|
-
* Product name
|
|
86
|
-
*/
|
|
87
|
-
name: string;
|
|
88
|
-
/**
|
|
89
|
-
* Prduct price
|
|
90
|
-
*/
|
|
91
|
-
unit_amount: number;
|
|
92
|
-
/**
|
|
93
|
-
* Description name
|
|
94
|
-
*/
|
|
95
|
-
description?: string;
|
|
96
|
-
/**
|
|
97
|
-
* Price currency
|
|
98
|
-
*/
|
|
99
|
-
currency?: SCPaymentPriceCurrencyType;
|
|
100
|
-
}
|
package/lib/esm/types/payment.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|