@up-im/medotvet_sdk 0.0.20 → 0.0.22

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/README.md CHANGED
@@ -90,12 +90,13 @@ const client = createClient({
90
90
  - `getHistory({ page? })` — история прохождений.
91
91
 
92
92
  ### payment
93
- - `addSBP({ sum, bank })` — заявка на выплату через СБП, вернёт
94
- `iPayment`.
95
- - `addCard({ sum, card_number })` — заявка на карту, вернёт `iPayment`.
93
+ - `add({ sum })` — заявка на выплату. Реквизиты выплат (карта/СБП/счёт)
94
+ пользователь указывает сам на странице верификации SolarStaff.
96
95
  - `getList({ page?, select })` — список выплат, сортировка `id desc`.
97
96
  - `balance()` — баланс и суммы начислений/выплат.
98
- - `getVerificationUrl()` — ссылка на KYC SolarStaff и признак `verified`.
97
+ - `getVerificationUrl()` — ссылка на KYC-страницу SolarStaff, где
98
+ пользователь проходит верификацию и добавляет платёжные реквизиты.
99
+ Возвращает `{ url, verified }`.
99
100
  - `checkVerificationStatus()` — статус KYC:
100
101
  `not_started|pending|active|blocked` + текст.
101
102
 
@@ -2,24 +2,16 @@ import { ApiAbstract } from "./abstract";
2
2
  import { iPagingItems } from "../interfaces/iPagingItems";
3
3
  import { iPayment } from "../interfaces/iPayment";
4
4
  import { iBalance } from "../interfaces/iBalance";
5
+ import { iPaymentCard } from "../interfaces/iPaymentCard";
5
6
  export declare class ApiPayment extends ApiAbstract {
6
7
  /**
7
- * добавление запроса на выплату по системе быстрых платежей
8
- * * @param {number} props.sum - сумма выплаты
9
- * * @param {number} props.bank - id банка из справочника content.getBanks
8
+ * Добавление запроса на выплату.
9
+ * Перед выплатой нужны: верификация (getVerificationUrl) И привязанная
10
+ * карта (requestCardCode + addCard). Реквизиты в этот запрос не передаются.
11
+ * @param {number} props.sum - сумма выплаты
10
12
  */
11
- addSBP(props: {
13
+ add(props: {
12
14
  sum: number;
13
- bank: number;
14
- }): Promise<iPayment>;
15
- /**
16
- * добавление запроса на выплату по номеру карты
17
- * * @param {number} props.sum - сумма выплаты
18
- * * @param {number} props.card_number - номер карты
19
- */
20
- addCard(props: {
21
- sum: number;
22
- card_number: number;
23
15
  }): Promise<iPayment>;
24
16
  /**
25
17
  * список начислений
@@ -36,8 +28,8 @@ export declare class ApiPayment extends ApiAbstract {
36
28
  */
37
29
  balance(): Promise<iBalance>;
38
30
  /**
39
- * Получить URL для верификации в SolarStaff
40
- * Необходимо для получения выплат
31
+ * Получить URL страницы верификации (KYC) в SolarStaff.
32
+ * Привязка карты — отдельный процесс (см. requestCardCode/addCard).
41
33
  */
42
34
  getVerificationUrl(): Promise<{
43
35
  url: string;
@@ -51,4 +43,34 @@ export declare class ApiPayment extends ApiAbstract {
51
43
  status: "not_started" | "pending" | "active" | "blocked";
52
44
  message: string;
53
45
  }>;
46
+ /**
47
+ * Шаг 1 привязки карты: запрос кода подтверждения.
48
+ * SolarStaff отправит SMS с кодом на телефон фрилансера.
49
+ * @returns тип сообщения и телефон, куда ушёл код
50
+ */
51
+ requestCardCode(): Promise<{
52
+ type: string;
53
+ phone: string | null;
54
+ }>;
55
+ /**
56
+ * Шаг 2 привязки карты: получить ссылку на терминал по коду из SMS.
57
+ * Открой полученный url — фрилансер вводит данные карты на стороне SolarStaff.
58
+ * @param {number} props.code - код из SMS
59
+ * @param {string} [props.redirectUrl] - URL возврата после привязки
60
+ */
61
+ addCard(props: {
62
+ code: number;
63
+ redirectUrl?: string;
64
+ }): Promise<{
65
+ url: string;
66
+ uuid: string;
67
+ }>;
68
+ /**
69
+ * Список привязанных карт + флаг наличия активной карты (cardBound).
70
+ * Поллить после открытия терминала, пока не появится активная карта.
71
+ */
72
+ getCards(): Promise<{
73
+ cards: iPaymentCard[];
74
+ cardBound: boolean;
75
+ }>;
54
76
  }
@@ -3,35 +3,20 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ApiPayment = void 0;
4
4
  const abstract_1 = require("./abstract");
5
5
  const apiRoute_1 = require("../http/apiRoute");
6
- const payoutType_1 = require("../interfaces/payoutType");
7
6
  const apiError_1 = require("../http/apiError");
8
7
  class ApiPayment extends abstract_1.ApiAbstract {
9
8
  /**
10
- * добавление запроса на выплату по системе быстрых платежей
11
- * * @param {number} props.sum - сумма выплаты
12
- * * @param {number} props.bank - id банка из справочника content.getBanks
9
+ * Добавление запроса на выплату.
10
+ * Перед выплатой нужны: верификация (getVerificationUrl) И привязанная
11
+ * карта (requestCardCode + addCard). Реквизиты в этот запрос не передаются.
12
+ * @param {number} props.sum - сумма выплаты
13
13
  */
14
- async addSBP(props) {
14
+ async add(props) {
15
15
  if (!await this.userStorage.isAuth())
16
16
  throw new apiError_1.ApiError(401, "Пользователь не авторизован");
17
17
  const data = await this.fetcher({
18
18
  route: apiRoute_1.apiRoutePaymentAdd,
19
- postBody: { ...props, type: payoutType_1.PayoutType.sbp },
20
- options: { addToken: true }
21
- });
22
- return data.payment;
23
- }
24
- /**
25
- * добавление запроса на выплату по номеру карты
26
- * * @param {number} props.sum - сумма выплаты
27
- * * @param {number} props.card_number - номер карты
28
- */
29
- async addCard(props) {
30
- if (!await this.userStorage.isAuth())
31
- throw new apiError_1.ApiError(401, "Пользователь не авторизован");
32
- const data = await this.fetcher({
33
- route: apiRoute_1.apiRoutePaymentAdd,
34
- postBody: { ...props, type: payoutType_1.PayoutType.card },
19
+ postBody: props,
35
20
  options: { addToken: true }
36
21
  });
37
22
  return data.payment;
@@ -64,8 +49,8 @@ class ApiPayment extends abstract_1.ApiAbstract {
64
49
  });
65
50
  }
66
51
  /**
67
- * Получить URL для верификации в SolarStaff
68
- * Необходимо для получения выплат
52
+ * Получить URL страницы верификации (KYC) в SolarStaff.
53
+ * Привязка карты — отдельный процесс (см. requestCardCode/addCard).
69
54
  */
70
55
  async getVerificationUrl() {
71
56
  if (!await this.userStorage.isAuth())
@@ -86,5 +71,46 @@ class ApiPayment extends abstract_1.ApiAbstract {
86
71
  options: { addToken: true }
87
72
  });
88
73
  }
74
+ /**
75
+ * Шаг 1 привязки карты: запрос кода подтверждения.
76
+ * SolarStaff отправит SMS с кодом на телефон фрилансера.
77
+ * @returns тип сообщения и телефон, куда ушёл код
78
+ */
79
+ async requestCardCode() {
80
+ if (!await this.userStorage.isAuth())
81
+ throw new apiError_1.ApiError(401, "Пользователь не авторизован");
82
+ return await this.fetcher({
83
+ route: apiRoute_1.apiRoutePaymentCardRequestCode,
84
+ postBody: {},
85
+ options: { addToken: true }
86
+ });
87
+ }
88
+ /**
89
+ * Шаг 2 привязки карты: получить ссылку на терминал по коду из SMS.
90
+ * Открой полученный url — фрилансер вводит данные карты на стороне SolarStaff.
91
+ * @param {number} props.code - код из SMS
92
+ * @param {string} [props.redirectUrl] - URL возврата после привязки
93
+ */
94
+ async addCard(props) {
95
+ if (!await this.userStorage.isAuth())
96
+ throw new apiError_1.ApiError(401, "Пользователь не авторизован");
97
+ return await this.fetcher({
98
+ route: apiRoute_1.apiRoutePaymentCardAdd,
99
+ postBody: props,
100
+ options: { addToken: true }
101
+ });
102
+ }
103
+ /**
104
+ * Список привязанных карт + флаг наличия активной карты (cardBound).
105
+ * Поллить после открытия терминала, пока не появится активная карта.
106
+ */
107
+ async getCards() {
108
+ if (!await this.userStorage.isAuth())
109
+ throw new apiError_1.ApiError(401, "Пользователь не авторизован");
110
+ return await this.fetcher({
111
+ route: apiRoute_1.apiRoutePaymentCards,
112
+ options: { addToken: true }
113
+ });
114
+ }
89
115
  }
90
116
  exports.ApiPayment = ApiPayment;
@@ -74,6 +74,9 @@ export declare const apiRoutePaymentList: ({ page, filters, sorters, select, }:
74
74
  export declare const apiRoutePaymentBalance = "/payment/balance";
75
75
  export declare const apiRoutePaymentVerificationUrl = "/payment/verification_url";
76
76
  export declare const apiRoutePaymentVerificationStatus = "/payment/verification_status";
77
+ export declare const apiRoutePaymentCardRequestCode = "/payment/card/request_code";
78
+ export declare const apiRoutePaymentCardAdd = "/payment/card/add";
79
+ export declare const apiRoutePaymentCards = "/payment/cards";
77
80
  export declare const apiRouteViewAdd = "/view/add";
78
81
  export declare const apiRouteStatAdd = "/stat/add";
79
82
  export declare const apiRouteStatGet = "/stat/get";
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.apiRoutePushRegister = exports.apiRoutePushCountNew = exports.apiRoutePushList = exports.apiRouteBannerGetRand = exports.apiRouteBookmarksCount = exports.apiRouteBookmarksRemove = exports.apiRouteBookmarksAdd = exports.apiRouteBookmarksGet = exports.apiRouteStatGet = exports.apiRouteStatAdd = exports.apiRouteViewAdd = exports.apiRoutePaymentVerificationStatus = exports.apiRoutePaymentVerificationUrl = exports.apiRoutePaymentBalance = exports.apiRoutePaymentList = exports.apiRoutePaymentAdd = exports.apiRouteSurveyHistory = exports.apiRouteSurveyCancel = exports.apiRouteSurveySaveAnswer = exports.apiRouteSurveyStart = exports.apiRouteSurveyItem = exports.apiRouteSurveyList = exports.apiRouteUserDiplomaStatus = exports.apiRouteUserDiplomaUpload = exports.apiRouteUserSetRef = exports.apiRouteUserDelete = exports.apiRouteUserLogout = exports.apiRouteUserUploadPhoto = exports.apiRouteUserEdit = exports.apiRouteUserLoginWithCode = exports.apiRouteUserRefresh = exports.apiRouteUserGetMe = exports.apiRouteGeoDetect = exports.apiRouteBasketMoveToDraft = exports.apiRouteBasketMutate = exports.apiRouteBasketGet = exports.apiRouteBasketTotal = exports.apiRouteNodeGeneratedLinks = exports.apiRouteNodeById = exports.apiRouteNode = exports.apiRouteNodeList = exports.apiRouteNodeTreeContentByFilters = exports.apiRouteNodeTree = exports.apiRouteItemById = exports.apiRouteItem = exports.apiRouteFilters = exports.apiRouteList = exports.apiRouteGetCloudVersion = exports.apiRouteCheckAppVersion = exports.apiRouteEnv = void 0;
4
- exports.apiRouteTestStatus = exports.apiRouteTestResults = exports.apiRouteTestSubmit = exports.apiRouteTestQuestions = exports.apiRoutePromocodeActivate = exports.apiRouteChatUnread = exports.apiRoutePushViewAll = exports.apiRoutePushView = exports.apiRoutePushIsSubscribed = exports.apiRoutePushUnsubscribe = void 0;
3
+ exports.apiRouteBannerGetRand = exports.apiRouteBookmarksCount = exports.apiRouteBookmarksRemove = exports.apiRouteBookmarksAdd = exports.apiRouteBookmarksGet = exports.apiRouteStatGet = exports.apiRouteStatAdd = exports.apiRouteViewAdd = exports.apiRoutePaymentCards = exports.apiRoutePaymentCardAdd = exports.apiRoutePaymentCardRequestCode = exports.apiRoutePaymentVerificationStatus = exports.apiRoutePaymentVerificationUrl = exports.apiRoutePaymentBalance = exports.apiRoutePaymentList = exports.apiRoutePaymentAdd = exports.apiRouteSurveyHistory = exports.apiRouteSurveyCancel = exports.apiRouteSurveySaveAnswer = exports.apiRouteSurveyStart = exports.apiRouteSurveyItem = exports.apiRouteSurveyList = exports.apiRouteUserDiplomaStatus = exports.apiRouteUserDiplomaUpload = exports.apiRouteUserSetRef = exports.apiRouteUserDelete = exports.apiRouteUserLogout = exports.apiRouteUserUploadPhoto = exports.apiRouteUserEdit = exports.apiRouteUserLoginWithCode = exports.apiRouteUserRefresh = exports.apiRouteUserGetMe = exports.apiRouteGeoDetect = exports.apiRouteBasketMoveToDraft = exports.apiRouteBasketMutate = exports.apiRouteBasketGet = exports.apiRouteBasketTotal = exports.apiRouteNodeGeneratedLinks = exports.apiRouteNodeById = exports.apiRouteNode = exports.apiRouteNodeList = exports.apiRouteNodeTreeContentByFilters = exports.apiRouteNodeTree = exports.apiRouteItemById = exports.apiRouteItem = exports.apiRouteFilters = exports.apiRouteList = exports.apiRouteGetCloudVersion = exports.apiRouteCheckAppVersion = exports.apiRouteEnv = void 0;
4
+ exports.apiRouteTestStatus = exports.apiRouteTestResults = exports.apiRouteTestSubmit = exports.apiRouteTestQuestions = exports.apiRoutePromocodeActivate = exports.apiRouteChatUnread = exports.apiRoutePushViewAll = exports.apiRoutePushView = exports.apiRoutePushIsSubscribed = exports.apiRoutePushUnsubscribe = exports.apiRoutePushRegister = exports.apiRoutePushCountNew = exports.apiRoutePushList = void 0;
5
5
  const queryString_1 = require("../utils/queryString");
6
6
  exports.apiRouteEnv = "/env";
7
7
  const apiRouteCheckAppVersion = (appStore, appVersion) => `/env/check_app_version/${appStore}/${appVersion}`;
@@ -159,6 +159,9 @@ exports.apiRoutePaymentList = apiRoutePaymentList;
159
159
  exports.apiRoutePaymentBalance = '/payment/balance';
160
160
  exports.apiRoutePaymentVerificationUrl = '/payment/verification_url';
161
161
  exports.apiRoutePaymentVerificationStatus = '/payment/verification_status';
162
+ exports.apiRoutePaymentCardRequestCode = '/payment/card/request_code';
163
+ exports.apiRoutePaymentCardAdd = '/payment/card/add';
164
+ exports.apiRoutePaymentCards = '/payment/cards';
162
165
  //stat
163
166
  exports.apiRouteViewAdd = '/view/add';
164
167
  exports.apiRouteStatAdd = '/stat/add';
@@ -1,6 +1,5 @@
1
1
  import { PaymentStatus, PaymentStatusKeys } from "./paymentStatus";
2
2
  import { PaymentType, PaymentTypeKeys } from "./paymentType";
3
- import { PayoutType, PayoutTypeKeys } from "./payoutType";
4
3
  export interface iPayment {
5
4
  id: number;
6
5
  reg_date: string;
@@ -14,7 +13,6 @@ export interface iPayment {
14
13
  shop: number | null;
15
14
  cashback_level: 0 | 1 | 2 | 3;
16
15
  max_cashback_level: null | 0 | 1 | 2 | 3;
17
- payout_type: typeof PayoutType[PayoutTypeKeys] | null;
18
16
  last_error: string;
19
17
  price: number;
20
18
  }
@@ -0,0 +1,7 @@
1
+ export interface iPaymentCard {
2
+ id: number;
3
+ number: string;
4
+ status: number;
5
+ active: boolean;
6
+ autoPay: boolean;
7
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@up-im/medotvet_sdk",
3
- "version": "0.0.20",
3
+ "version": "0.0.22",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -4,102 +4,133 @@ import {
4
4
  apiRoutePaymentBalance,
5
5
  apiRoutePaymentList,
6
6
  apiRoutePaymentVerificationUrl,
7
- apiRoutePaymentVerificationStatus
7
+ apiRoutePaymentVerificationStatus,
8
+ apiRoutePaymentCardRequestCode,
9
+ apiRoutePaymentCardAdd,
10
+ apiRoutePaymentCards
8
11
  } from "../http/apiRoute"
9
12
  import { iPagingItems } from "../interfaces/iPagingItems"
10
13
  import { iPayment } from "../interfaces/iPayment"
11
- import { PayoutType } from "../interfaces/payoutType"
12
14
  import { ApiError } from "../http/apiError"
13
15
  import { iBalance } from "../interfaces/iBalance"
16
+ import { iPaymentCard } from "../interfaces/iPaymentCard"
14
17
 
15
18
  export class ApiPayment extends ApiAbstract {
16
- /**
17
- * добавление запроса на выплату по системе быстрых платежей
18
- * * @param {number} props.sum - сумма выплаты
19
- * * @param {number} props.bank - id банка из справочника content.getBanks
20
- */
21
- async addSBP(props: { sum: number, bank: number }) {
22
- if (!await this.userStorage.isAuth()) throw new ApiError(401, "Пользователь не авторизован")
23
- const data = await this.fetcher<{ payment: iPayment }>({
24
- route: apiRoutePaymentAdd,
25
- postBody: { ...props, type: PayoutType.sbp },
26
- options: { addToken: true }
27
- })
28
- return data.payment
29
- }
30
- /**
31
- * добавление запроса на выплату по номеру карты
32
- * * @param {number} props.sum - сумма выплаты
33
- * * @param {number} props.card_number - номер карты
34
- */
35
- async addCard(props: { sum: number, card_number: number }) {
36
- if (!await this.userStorage.isAuth()) throw new ApiError(401, "Пользователь не авторизован")
37
- const data = await this.fetcher<{ payment: iPayment }>({
38
- route: apiRoutePaymentAdd,
39
- postBody: { ...props, type: PayoutType.card },
40
- options: { addToken: true }
41
- })
42
- return data.payment
43
- }
44
- /**
45
- * список начислений
46
- * * @param {number} page - отсчет страниц с первой, чтобы не было путаницы
47
- */
48
- async getList<Keys extends keyof iPayment>({
49
- page = 1,
50
- select,
51
- }: {
52
- page: number
53
- select: Keys[],
54
- }) {
55
- if (!await this.userStorage.isAuth()) throw new ApiError(401, "Пользователь не авторизован")
56
- return await this.fetcher<iPagingItems<Pick<iPayment, Keys>>>({
57
- route: apiRoutePaymentList({
58
- page,
59
- sorters: ["id desc"],
60
- select
61
- }),
62
- options: { addToken: true }
63
- })
64
- }
65
- /**
66
- * баланс пользователя
67
- */
68
- async balance() {
69
- if (!await this.userStorage.isAuth()) throw new ApiError(401, "Пользователь не авторизован")
70
- return await this.fetcher<iBalance>({
71
- route: apiRoutePaymentBalance,
72
- options: { addToken: true }
73
- })
74
- }
19
+ /**
20
+ * Добавление запроса на выплату.
21
+ * Перед выплатой нужны: верификация (getVerificationUrl) И привязанная
22
+ * карта (requestCardCode + addCard). Реквизиты в этот запрос не передаются.
23
+ * @param {number} props.sum - сумма выплаты
24
+ */
25
+ async add(props: { sum: number }) {
26
+ if (!await this.userStorage.isAuth()) throw new ApiError(401, "Пользователь не авторизован")
27
+ const data = await this.fetcher<{ payment: iPayment }>({
28
+ route: apiRoutePaymentAdd,
29
+ postBody: props,
30
+ options: { addToken: true }
31
+ })
32
+ return data.payment
33
+ }
34
+ /**
35
+ * список начислений
36
+ * * @param {number} page - отсчет страниц с первой, чтобы не было путаницы
37
+ */
38
+ async getList<Keys extends keyof iPayment>({
39
+ page = 1,
40
+ select,
41
+ }: {
42
+ page: number
43
+ select: Keys[],
44
+ }) {
45
+ if (!await this.userStorage.isAuth()) throw new ApiError(401, "Пользователь не авторизован")
46
+ return await this.fetcher<iPagingItems<Pick<iPayment, Keys>>>({
47
+ route: apiRoutePaymentList({
48
+ page,
49
+ sorters: ["id desc"],
50
+ select
51
+ }),
52
+ options: { addToken: true }
53
+ })
54
+ }
55
+ /**
56
+ * баланс пользователя
57
+ */
58
+ async balance() {
59
+ if (!await this.userStorage.isAuth()) throw new ApiError(401, "Пользователь не авторизован")
60
+ return await this.fetcher<iBalance>({
61
+ route: apiRoutePaymentBalance,
62
+ options: { addToken: true }
63
+ })
64
+ }
75
65
 
76
- /**
77
- * Получить URL для верификации в SolarStaff
78
- * Необходимо для получения выплат
79
- */
80
- async getVerificationUrl() {
81
- if (!await this.userStorage.isAuth()) throw new ApiError(401, "Пользователь не авторизован")
82
- return await this.fetcher<{
83
- url: string,
84
- verified: boolean
85
- }>({
86
- route: apiRoutePaymentVerificationUrl,
87
- options: { addToken: true }
88
- })
89
- }
66
+ /**
67
+ * Получить URL страницы верификации (KYC) в SolarStaff.
68
+ * Привязка карты — отдельный процесс (см. requestCardCode/addCard).
69
+ */
70
+ async getVerificationUrl() {
71
+ if (!await this.userStorage.isAuth()) throw new ApiError(401, "Пользователь не авторизован")
72
+ return await this.fetcher<{
73
+ url: string,
74
+ verified: boolean
75
+ }>({
76
+ route: apiRoutePaymentVerificationUrl,
77
+ options: { addToken: true }
78
+ })
79
+ }
90
80
 
91
- /**
92
- * Проверить статус верификации пользователя в SolarStaff
93
- */
94
- async checkVerificationStatus() {
95
- if (!await this.userStorage.isAuth()) throw new ApiError(401, "Пользователь не авторизован")
96
- return await this.fetcher<{
97
- verified: boolean,
98
- status: "not_started" | "pending" | "active" | "blocked",
99
- message: string
100
- }>({
101
- route: apiRoutePaymentVerificationStatus,
102
- options: { addToken: true }
103
- })
104
- }
105
- }
81
+ /**
82
+ * Проверить статус верификации пользователя в SolarStaff
83
+ */
84
+ async checkVerificationStatus() {
85
+ if (!await this.userStorage.isAuth()) throw new ApiError(401, "Пользователь не авторизован")
86
+ return await this.fetcher<{
87
+ verified: boolean,
88
+ status: "not_started" | "pending" | "active" | "blocked",
89
+ message: string
90
+ }>({
91
+ route: apiRoutePaymentVerificationStatus,
92
+ options: { addToken: true }
93
+ })
94
+ }
95
+
96
+ /**
97
+ * Шаг 1 привязки карты: запрос кода подтверждения.
98
+ * SolarStaff отправит SMS с кодом на телефон фрилансера.
99
+ * @returns тип сообщения и телефон, куда ушёл код
100
+ */
101
+ async requestCardCode() {
102
+ if (!await this.userStorage.isAuth()) throw new ApiError(401, "Пользователь не авторизован")
103
+ return await this.fetcher<{ type: string, phone: string | null }>({
104
+ route: apiRoutePaymentCardRequestCode,
105
+ postBody: {},
106
+ options: { addToken: true }
107
+ })
108
+ }
109
+
110
+ /**
111
+ * Шаг 2 привязки карты: получить ссылку на терминал по коду из SMS.
112
+ * Открой полученный url — фрилансер вводит данные карты на стороне SolarStaff.
113
+ * @param {number} props.code - код из SMS
114
+ * @param {string} [props.redirectUrl] - URL возврата после привязки
115
+ */
116
+ async addCard(props: { code: number, redirectUrl?: string }) {
117
+ if (!await this.userStorage.isAuth()) throw new ApiError(401, "Пользователь не авторизован")
118
+ return await this.fetcher<{ url: string, uuid: string }>({
119
+ route: apiRoutePaymentCardAdd,
120
+ postBody: props,
121
+ options: { addToken: true }
122
+ })
123
+ }
124
+
125
+ /**
126
+ * Список привязанных карт + флаг наличия активной карты (cardBound).
127
+ * Поллить после открытия терминала, пока не появится активная карта.
128
+ */
129
+ async getCards() {
130
+ if (!await this.userStorage.isAuth()) throw new ApiError(401, "Пользователь не авторизован")
131
+ return await this.fetcher<{ cards: iPaymentCard[], cardBound: boolean }>({
132
+ route: apiRoutePaymentCards,
133
+ options: { addToken: true }
134
+ })
135
+ }
136
+ }
@@ -189,6 +189,9 @@ export const apiRoutePaymentList = ({
189
189
  export const apiRoutePaymentBalance = '/payment/balance'
190
190
  export const apiRoutePaymentVerificationUrl = '/payment/verification_url'
191
191
  export const apiRoutePaymentVerificationStatus = '/payment/verification_status'
192
+ export const apiRoutePaymentCardRequestCode = '/payment/card/request_code'
193
+ export const apiRoutePaymentCardAdd = '/payment/card/add'
194
+ export const apiRoutePaymentCards = '/payment/cards'
192
195
  //stat
193
196
  export const apiRouteViewAdd = '/view/add'
194
197
  export const apiRouteStatAdd = '/stat/add'
@@ -1,6 +1,5 @@
1
1
  import { PaymentStatus, PaymentStatusKeys } from "./paymentStatus";
2
2
  import { PaymentType, PaymentTypeKeys } from "./paymentType";
3
- import { PayoutType, PayoutTypeKeys } from "./payoutType";
4
3
 
5
4
 
6
5
  export interface iPayment {
@@ -17,10 +16,9 @@ export interface iPayment {
17
16
  sku: number | null//id акции
18
17
  shop: number | null//id аптеки
19
18
  cashback_level: 0 | 1 | 2 | 3//уровень кэшбека по которому произошло начисление
20
- max_cashback_level: null | 0 | 1 | 2 | 3 //макс. возможный уровень кэшбека по акции, поле есть только у начислений в чеках
19
+ max_cashback_level: null | 0 | 1 | 2 | 3 //макс. возможный уровень кэшбека по акции, поле есть только у начислений в чеках
21
20
 
22
21
  //списание
23
- payout_type: typeof PayoutType[PayoutTypeKeys] | null //способ выплаты
24
22
  last_error: string//текст ошибки выплаты
25
23
 
26
24
  //размер
@@ -0,0 +1,7 @@
1
+ export interface iPaymentCard {
2
+ id: number//ID карты в SolarStaff
3
+ number: string//маскированный номер (первые 6 и последние 4 цифры)
4
+ status: number//1 - инициализирована, 3 - заблокирована, 4 - подтверждена, 7 - удалена
5
+ active: boolean//status === 4 (добавлена и подтверждена)
6
+ autoPay: boolean//включена ли автовыплата на карту
7
+ }