@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
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@selfcommunity/api-services",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0-alpha.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"private": false,
|
|
6
6
|
"main": "./lib/cjs/index.js",
|
|
@@ -58,8 +58,8 @@
|
|
|
58
58
|
"access": "public"
|
|
59
59
|
},
|
|
60
60
|
"dependencies": {
|
|
61
|
-
"@selfcommunity/types": "0.
|
|
62
|
-
"@selfcommunity/utils": "0.2.64-
|
|
61
|
+
"@selfcommunity/types": "^0.8.0-alpha.0",
|
|
62
|
+
"@selfcommunity/utils": "^0.2.64-alpha.1",
|
|
63
63
|
"axios": "^1.4.0",
|
|
64
64
|
"jose": "^4.14.4"
|
|
65
65
|
},
|
|
@@ -115,5 +115,5 @@
|
|
|
115
115
|
"bugs": {
|
|
116
116
|
"url": "https://github.com/selfcommunity/community-js/issues"
|
|
117
117
|
},
|
|
118
|
-
"gitHead": "
|
|
118
|
+
"gitHead": "03d4b894685ad0ab6a4db32b1ac5f8dfecf4befb"
|
|
119
119
|
}
|
|
@@ -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,70 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CommunityApiClient = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const Endpoints_1 = tslib_1.__importDefault(require("../../constants/Endpoints"));
|
|
6
|
-
const apiRequest_1 = require("../../utils/apiRequest");
|
|
7
|
-
const url_1 = require("../../utils/url");
|
|
8
|
-
/**
|
|
9
|
-
* Contains all the endpoints needed to manage payments.
|
|
10
|
-
*/
|
|
11
|
-
class CommunityApiClient {
|
|
12
|
-
/**
|
|
13
|
-
* Get list of communities. Used to get the payment products related to the community (aka paywalls)
|
|
14
|
-
* @param params
|
|
15
|
-
* @param config
|
|
16
|
-
*/
|
|
17
|
-
static getCommunities(params, config) {
|
|
18
|
-
const p = (0, url_1.urlParams)(params);
|
|
19
|
-
return (0, apiRequest_1.apiRequest)(Object.assign(Object.assign({}, config), { url: `${Endpoints_1.default.GetCommunities.url({})}?${p.toString()}`, method: Endpoints_1.default.GetCommunities.method }));
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* Get Community
|
|
23
|
-
* @param id
|
|
24
|
-
* @param config
|
|
25
|
-
*/
|
|
26
|
-
static getCommunity(id, config) {
|
|
27
|
-
return (0, apiRequest_1.apiRequest)(Object.assign(Object.assign({}, config), { url: Endpoints_1.default.GetCommunity.url({ id }), method: Endpoints_1.default.GetCommunity.method }));
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
exports.CommunityApiClient = CommunityApiClient;
|
|
31
|
-
/**
|
|
32
|
-
*
|
|
33
|
-
:::tip Community service can be used in the following way:
|
|
34
|
-
|
|
35
|
-
```jsx
|
|
36
|
-
1. Import the service from our library:
|
|
37
|
-
|
|
38
|
-
import {CommunityService} from "@selfcommunity/api-services";
|
|
39
|
-
```
|
|
40
|
-
```jsx
|
|
41
|
-
2. Create a function and put the service inside it!
|
|
42
|
-
The async function `getCommunities` will return the events matching the search query.
|
|
43
|
-
|
|
44
|
-
async getCommunities() {
|
|
45
|
-
return await CommunityService.getCommunities({...});
|
|
46
|
-
}
|
|
47
|
-
```
|
|
48
|
-
If you need to customize the request, you can add optional config params (`AxiosRequestConfig` type).
|
|
49
|
-
|
|
50
|
-
1. Declare it(or declare them, it is possible to add multiple params)
|
|
51
|
-
|
|
52
|
-
const headers = headers: {Authorization: `Bearer ${yourToken}`}
|
|
53
|
-
|
|
54
|
-
2. Add it inside the brackets and pass it to the function, as shown in the previous example!
|
|
55
|
-
```
|
|
56
|
-
:::
|
|
57
|
-
*/
|
|
58
|
-
class CommunityService {
|
|
59
|
-
static getCommunities(params, config) {
|
|
60
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
61
|
-
return CommunityApiClient.getCommunities(params, config);
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
static getPaymentProduct(id, config) {
|
|
65
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
66
|
-
return CommunityApiClient.getCommunity(id, config);
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
exports.default = CommunityService;
|
|
@@ -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,197 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PaymentApiClient = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const Endpoints_1 = tslib_1.__importDefault(require("../../constants/Endpoints"));
|
|
6
|
-
const apiRequest_1 = require("../../utils/apiRequest");
|
|
7
|
-
const url_1 = require("../../utils/url");
|
|
8
|
-
/**
|
|
9
|
-
* Contains all the endpoints needed to manage payments.
|
|
10
|
-
*/
|
|
11
|
-
class PaymentApiClient {
|
|
12
|
-
/**
|
|
13
|
-
* This endpoint retrieves all the products related to an object of type <content_type> and id <content_id> and the current payment_order
|
|
14
|
-
* @param params
|
|
15
|
-
* @param config
|
|
16
|
-
*/
|
|
17
|
-
static getPaymentContentStatus(params, config) {
|
|
18
|
-
const p = (0, url_1.urlParams)(params);
|
|
19
|
-
return (0, apiRequest_1.apiRequest)(Object.assign(Object.assign({}, config), { url: `${Endpoints_1.default.GetPaymentContentStatus.url({})}?${p.toString()}`, method: Endpoints_1.default.GetPaymentContentStatus.method }));
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* This endpoint retrieves all the products related to an object of type <content_type> and id <content_id>
|
|
23
|
-
* @param params
|
|
24
|
-
* @param config
|
|
25
|
-
*/
|
|
26
|
-
static getPaywalls(params, config) {
|
|
27
|
-
const p = (0, url_1.urlParams)(params);
|
|
28
|
-
return (0, apiRequest_1.apiRequest)(Object.assign(Object.assign({}, config), { url: `${Endpoints_1.default.GetPaywalls.url({})}?${p.toString()}`, method: Endpoints_1.default.GetPaywalls.method }));
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* This endpoint retrieves all the payment products
|
|
32
|
-
* @param params
|
|
33
|
-
* @param config
|
|
34
|
-
*/
|
|
35
|
-
static getPaymentProducts(params, config) {
|
|
36
|
-
const p = (0, url_1.urlParams)(params);
|
|
37
|
-
return (0, apiRequest_1.apiRequest)(Object.assign(Object.assign({}, config), { url: `${Endpoints_1.default.GetPaymentProducts.url({})}?${p.toString()}`, method: Endpoints_1.default.GetPaymentProducts.method }));
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* This endpoint retrieves a specific payment product.
|
|
41
|
-
* @param id
|
|
42
|
-
* @param config
|
|
43
|
-
*/
|
|
44
|
-
static getPaymentProduct(id, config) {
|
|
45
|
-
return (0, apiRequest_1.apiRequest)(Object.assign(Object.assign({}, config), { url: Endpoints_1.default.GetPaymentProduct.url({ id }), method: Endpoints_1.default.GetPaymentProduct.method }));
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* This endpoint retrieves all the prices related to a product
|
|
49
|
-
* @param id
|
|
50
|
-
* @param params
|
|
51
|
-
* @param config
|
|
52
|
-
*/
|
|
53
|
-
static getPaymentProductPrices(id, params, config) {
|
|
54
|
-
const p = (0, url_1.urlParams)(params);
|
|
55
|
-
return (0, apiRequest_1.apiRequest)(Object.assign(Object.assign({}, config), { url: `${Endpoints_1.default.GetPaymentProductPrices.url({ id })}?${p.toString()}`, method: Endpoints_1.default.GetPaymentProductPrices.method }));
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* This endpoint creates a checkout session.
|
|
59
|
-
* @param data
|
|
60
|
-
* @param config
|
|
61
|
-
*/
|
|
62
|
-
static checkoutCreateSession(data, config) {
|
|
63
|
-
return (0, apiRequest_1.apiRequest)(Object.assign(Object.assign({}, config), { url: Endpoints_1.default.CheckoutCreateSession.url({}), method: Endpoints_1.default.CheckoutCreateSession.method, data }));
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* Create payment product
|
|
67
|
-
* @param data
|
|
68
|
-
* @param config
|
|
69
|
-
*/
|
|
70
|
-
static createPaymentProduct(data, config) {
|
|
71
|
-
return (0, apiRequest_1.apiRequest)(Object.assign(Object.assign({}, config), { url: Endpoints_1.default.CreatePaymentProduct.url({}), method: Endpoints_1.default.CreatePaymentProduct.method, data }));
|
|
72
|
-
}
|
|
73
|
-
/**
|
|
74
|
-
* This endpoint retrieve checkout session
|
|
75
|
-
* @param params
|
|
76
|
-
* @param config
|
|
77
|
-
*/
|
|
78
|
-
static getCheckoutSession(params, config) {
|
|
79
|
-
const p = (0, url_1.urlParams)(params);
|
|
80
|
-
return (0, apiRequest_1.apiRequest)(Object.assign(Object.assign({}, config), { url: `${Endpoints_1.default.GetCheckoutSession.url({})}?${p.toString()}`, method: Endpoints_1.default.GetCheckoutSession.method }));
|
|
81
|
-
}
|
|
82
|
-
/**
|
|
83
|
-
* This endpoint complete checkout session
|
|
84
|
-
* @param data
|
|
85
|
-
* @param config
|
|
86
|
-
*/
|
|
87
|
-
static checkoutCompleteSession(data, config) {
|
|
88
|
-
return (0, apiRequest_1.apiRequest)(Object.assign(Object.assign({}, config), { url: Endpoints_1.default.CheckoutSessionComplete.url({}), method: Endpoints_1.default.CheckoutSessionComplete.method, data }));
|
|
89
|
-
}
|
|
90
|
-
/**
|
|
91
|
-
* This endpoint retrive order history of authenticated user
|
|
92
|
-
* @param params
|
|
93
|
-
* @param config
|
|
94
|
-
*/
|
|
95
|
-
static getPaymentsOrder(params, config) {
|
|
96
|
-
const p = (0, url_1.urlParams)(params);
|
|
97
|
-
return (0, apiRequest_1.apiRequest)(Object.assign(Object.assign({}, config), { url: `${Endpoints_1.default.GetPaymentOrders.url({})}?${p.toString()}`, method: Endpoints_1.default.GetPaymentOrders.method }));
|
|
98
|
-
}
|
|
99
|
-
/**
|
|
100
|
-
* This endpoint retrive customer portal
|
|
101
|
-
* @param data
|
|
102
|
-
* @param config
|
|
103
|
-
*/
|
|
104
|
-
static getPaymentsCustomerPortal(data, config) {
|
|
105
|
-
return (0, apiRequest_1.apiRequest)(Object.assign(Object.assign({}, config), { url: Endpoints_1.default.CreateCustomerPortalSession.url({}), method: Endpoints_1.default.CreateCustomerPortalSession.method, data }));
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
exports.PaymentApiClient = PaymentApiClient;
|
|
109
|
-
/**
|
|
110
|
-
*
|
|
111
|
-
:::tip Payment service can be used in the following way:
|
|
112
|
-
|
|
113
|
-
```jsx
|
|
114
|
-
1. Import the service from our library:
|
|
115
|
-
|
|
116
|
-
import {PaymentService} from "@selfcommunity/api-services";
|
|
117
|
-
```
|
|
118
|
-
```jsx
|
|
119
|
-
2. Create a function and put the service inside it!
|
|
120
|
-
The async function `getPaymentProducts` will return the events matching the search query.
|
|
121
|
-
|
|
122
|
-
async getPaymentProducts() {
|
|
123
|
-
return await PaymentService.getPaymentProducts({...});
|
|
124
|
-
}
|
|
125
|
-
```
|
|
126
|
-
```jsx
|
|
127
|
-
In case of required `params`, just add them inside the brackets.
|
|
128
|
-
|
|
129
|
-
async getPaymentPrices(eventId) {
|
|
130
|
-
return await PaymentService.getProductPrices(id);
|
|
131
|
-
}
|
|
132
|
-
```
|
|
133
|
-
```jsx
|
|
134
|
-
If you need to customize the request, you can add optional config params (`AxiosRequestConfig` type).
|
|
135
|
-
|
|
136
|
-
1. Declare it(or declare them, it is possible to add multiple params)
|
|
137
|
-
|
|
138
|
-
const headers = headers: {Authorization: `Bearer ${yourToken}`}
|
|
139
|
-
|
|
140
|
-
2. Add it inside the brackets and pass it to the function, as shown in the previous example!
|
|
141
|
-
```
|
|
142
|
-
:::
|
|
143
|
-
*/
|
|
144
|
-
class PaymentService {
|
|
145
|
-
static getPaymentContentStatus(params, config) {
|
|
146
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
147
|
-
return PaymentApiClient.getPaymentContentStatus(params, config);
|
|
148
|
-
});
|
|
149
|
-
}
|
|
150
|
-
static getPaywalls(params, config) {
|
|
151
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
152
|
-
return PaymentApiClient.getPaywalls(params, config);
|
|
153
|
-
});
|
|
154
|
-
}
|
|
155
|
-
static getPaymentProducts(params, config) {
|
|
156
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
157
|
-
return PaymentApiClient.getPaymentProducts(params, config);
|
|
158
|
-
});
|
|
159
|
-
}
|
|
160
|
-
static getPaymentProduct(id, config) {
|
|
161
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
162
|
-
return PaymentApiClient.getPaymentProduct(id, config);
|
|
163
|
-
});
|
|
164
|
-
}
|
|
165
|
-
static getPaymentProductPrices(id, params, config) {
|
|
166
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
167
|
-
return PaymentApiClient.getPaymentProductPrices(id, params, config);
|
|
168
|
-
});
|
|
169
|
-
}
|
|
170
|
-
static checkoutCreateSession(data, config) {
|
|
171
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
172
|
-
return PaymentApiClient.checkoutCreateSession(data, config);
|
|
173
|
-
});
|
|
174
|
-
}
|
|
175
|
-
static getCheckoutSession(params, config) {
|
|
176
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
177
|
-
return PaymentApiClient.getCheckoutSession(params, config);
|
|
178
|
-
});
|
|
179
|
-
}
|
|
180
|
-
static checkoutCompleteSession(data, config) {
|
|
181
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
182
|
-
return PaymentApiClient.checkoutCompleteSession(data, config);
|
|
183
|
-
});
|
|
184
|
-
}
|
|
185
|
-
static getPaymentsOrder(params, config) {
|
|
186
|
-
return PaymentApiClient.getPaymentsOrder(params, config);
|
|
187
|
-
}
|
|
188
|
-
static getPaymentsCustomerPortal(data, config) {
|
|
189
|
-
return PaymentApiClient.getPaymentsCustomerPortal(data, config);
|
|
190
|
-
}
|
|
191
|
-
static createPaymentProduct(data, config) {
|
|
192
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
193
|
-
return PaymentApiClient.createPaymentProduct(data, config);
|
|
194
|
-
});
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
exports.default = PaymentService;
|
|
@@ -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/cjs/types/payment.js
DELETED