@binance/pay
Version:
Official Binance Pay Connector - A lightweight library that provides a convenient interface to Binance's Pay REST API.
318 lines (311 loc) • 11.7 kB
JavaScript
var __defProp = Object.defineProperty;
var __export = (target, all) => {
for (var name2 in all)
__defProp(target, name2, { get: all[name2], enumerable: true });
};
// src/pay.ts
import { buildUserAgent, ConfigurationRestAPI as ConfigurationRestAPI3, PAY_REST_API_PROD_URL } from "@binance/common";
// package.json
var name = "@binance/pay";
var version = "3.0.7";
// src/rest-api/index.ts
var rest_api_exports = {};
__export(rest_api_exports, {
PayApi: () => PayApi,
RestAPI: () => RestAPI
});
// src/rest-api/modules/pay-api.ts
import {
sendRequest
} from "@binance/common";
var PayApiAxiosParamCreator = function(configuration) {
return {
/**
* Get Pay Trade History
*
* If startTime and endTime are not sent, the recent 90 days' data will be returned.
* The max interval between startTime and endTime is 90 days.
* Support for querying orders within the last 18 months.
* For payerInfo and receiverInfo,there are different return values in different orderTypes.
* Sender's perspective when orderType is C2C
* payerInfo : binanceId
* receiverInfo : name, binanceId/accountId/email/countryCode/phoneNumber/mobileCode (based on user input)
* Receiver's perspective when orderType is C2C
* payerInfo : name, accountId
* receiverInfo : binanceId
* Sender's perspective when orderType is CRYPTO_BOX
* payerInfo : binanceId
* receiverInfo : name(the value is always "Crypto Box")
* Receiver's perspective when orderType is CRYPTO_BOX
* payerInfo : name, accountId
* receiverInfo : binanceId
* Sender's perspective when orderType is PAY
* payerInfo : binanceId
* receiverInfo : name
* Receiver's perspective when orderType is PAY
* payerInfo : name, accountId
* receiverInfo : binanceId, name
* Sender's perspective when orderType is PAY_REFUND
* payerInfo : binanceId, name
* receiverInfo : name, accountId
* Receiver's perspective when orderType is PAY_REFUND
* payerInfo : name
* receiverInfo : binanceId
* Sender's perspective when orderType is PAYOUT
* payerInfo : binanceId, name
* receiverInfo : name, accountId
* Receiver's perspective when orderType is PAYOUT
* payerInfo : name
* receiverInfo : binanceId
* Receiver's perspective when orderType is CRYPTO_BOX_RF
* payerInfo : name(the value is always "Crypto Box")
* receiverInfo : binanceId
* Sender's perspective when orderType is REMITTANCE
* payerInfo : binanceId
* receiverInfo : name, institutionName, cardNumber, digitalWalletId
*
* Weight: 3000
*
* @summary Get Pay Trade History
* @param {number} [startTime]
* @param {number} [endTime]
* @param {number} [limit] default 100, max 100
* @param {number} [recvWindow]
*
* @throws {RequiredError}
*/
getPayTradeHistory: async (startTime, endTime, limit, recvWindow) => {
const localVarQueryParameter = {};
if (startTime !== void 0 && startTime !== null) {
localVarQueryParameter["startTime"] = startTime;
}
if (endTime !== void 0 && endTime !== null) {
localVarQueryParameter["endTime"] = endTime;
}
if (limit !== void 0 && limit !== null) {
localVarQueryParameter["limit"] = limit;
}
if (recvWindow !== void 0 && recvWindow !== null) {
localVarQueryParameter["recvWindow"] = recvWindow;
}
let _timeUnit;
if ("timeUnit" in configuration) _timeUnit = configuration.timeUnit;
return {
endpoint: "/sapi/v1/pay/transactions",
method: "GET",
params: localVarQueryParameter,
timeUnit: _timeUnit
};
}
};
};
var PayApi = class {
constructor(configuration) {
this.configuration = configuration;
this.localVarAxiosParamCreator = PayApiAxiosParamCreator(configuration);
}
/**
* Get Pay Trade History
*
* If startTime and endTime are not sent, the recent 90 days' data will be returned.
* The max interval between startTime and endTime is 90 days.
* Support for querying orders within the last 18 months.
* For payerInfo and receiverInfo,there are different return values in different orderTypes.
* Sender's perspective when orderType is C2C
* payerInfo : binanceId
* receiverInfo : name, binanceId/accountId/email/countryCode/phoneNumber/mobileCode (based on user input)
* Receiver's perspective when orderType is C2C
* payerInfo : name, accountId
* receiverInfo : binanceId
* Sender's perspective when orderType is CRYPTO_BOX
* payerInfo : binanceId
* receiverInfo : name(the value is always "Crypto Box")
* Receiver's perspective when orderType is CRYPTO_BOX
* payerInfo : name, accountId
* receiverInfo : binanceId
* Sender's perspective when orderType is PAY
* payerInfo : binanceId
* receiverInfo : name
* Receiver's perspective when orderType is PAY
* payerInfo : name, accountId
* receiverInfo : binanceId, name
* Sender's perspective when orderType is PAY_REFUND
* payerInfo : binanceId, name
* receiverInfo : name, accountId
* Receiver's perspective when orderType is PAY_REFUND
* payerInfo : name
* receiverInfo : binanceId
* Sender's perspective when orderType is PAYOUT
* payerInfo : binanceId, name
* receiverInfo : name, accountId
* Receiver's perspective when orderType is PAYOUT
* payerInfo : name
* receiverInfo : binanceId
* Receiver's perspective when orderType is CRYPTO_BOX_RF
* payerInfo : name(the value is always "Crypto Box")
* receiverInfo : binanceId
* Sender's perspective when orderType is REMITTANCE
* payerInfo : binanceId
* receiverInfo : name, institutionName, cardNumber, digitalWalletId
*
* Weight: 3000
*
* @summary Get Pay Trade History
* @param {GetPayTradeHistoryRequest} requestParameters Request parameters.
* @returns {Promise<RestApiResponse<GetPayTradeHistoryResponse>>}
* @throws {RequiredError | ConnectorClientError | UnauthorizedError | ForbiddenError | TooManyRequestsError | RateLimitBanError | ServerError | NotFoundError | NetworkError | BadRequestError}
* @memberof PayApi
* @see {@link https://developers.binance.com/docs/pay/rest-api/Get-Pay-Trade-History Binance API Documentation}
*/
async getPayTradeHistory(requestParameters = {}) {
const localVarAxiosArgs = await this.localVarAxiosParamCreator.getPayTradeHistory(
requestParameters?.startTime,
requestParameters?.endTime,
requestParameters?.limit,
requestParameters?.recvWindow
);
return sendRequest(
this.configuration,
localVarAxiosArgs.endpoint,
localVarAxiosArgs.method,
localVarAxiosArgs.params,
localVarAxiosArgs?.timeUnit,
{ isSigned: true }
);
}
};
// src/rest-api/rest-api.ts
import { sendRequest as sendRequest2 } from "@binance/common";
var RestAPI = class {
constructor(configuration) {
this.configuration = configuration;
this.payApi = new PayApi(configuration);
}
/**
* Generic function to send a request.
* @param endpoint - The API endpoint to call.
* @param method - HTTP method to use (GET, POST, DELETE, etc.).
* @param params - Query parameters for the request.
*
* @returns A promise resolving to the response data object.
*/
sendRequest(endpoint, method, params = {}) {
return sendRequest2(this.configuration, endpoint, method, params, void 0);
}
/**
* Generic function to send a signed request.
* @param endpoint - The API endpoint to call.
* @param method - HTTP method to use (GET, POST, DELETE, etc.).
* @param params - Query parameters for the request.
*
* @returns A promise resolving to the response data object.
*/
sendSignedRequest(endpoint, method, params = {}) {
return sendRequest2(this.configuration, endpoint, method, params, void 0, {
isSigned: true
});
}
/**
* Get Pay Trade History
*
* If startTime and endTime are not sent, the recent 90 days' data will be returned.
* The max interval between startTime and endTime is 90 days.
* Support for querying orders within the last 18 months.
* For payerInfo and receiverInfo,there are different return values in different orderTypes.
* Sender's perspective when orderType is C2C
* payerInfo : binanceId
* receiverInfo : name, binanceId/accountId/email/countryCode/phoneNumber/mobileCode (based on user input)
* Receiver's perspective when orderType is C2C
* payerInfo : name, accountId
* receiverInfo : binanceId
* Sender's perspective when orderType is CRYPTO_BOX
* payerInfo : binanceId
* receiverInfo : name(the value is always "Crypto Box")
* Receiver's perspective when orderType is CRYPTO_BOX
* payerInfo : name, accountId
* receiverInfo : binanceId
* Sender's perspective when orderType is PAY
* payerInfo : binanceId
* receiverInfo : name
* Receiver's perspective when orderType is PAY
* payerInfo : name, accountId
* receiverInfo : binanceId, name
* Sender's perspective when orderType is PAY_REFUND
* payerInfo : binanceId, name
* receiverInfo : name, accountId
* Receiver's perspective when orderType is PAY_REFUND
* payerInfo : name
* receiverInfo : binanceId
* Sender's perspective when orderType is PAYOUT
* payerInfo : binanceId, name
* receiverInfo : name, accountId
* Receiver's perspective when orderType is PAYOUT
* payerInfo : name
* receiverInfo : binanceId
* Receiver's perspective when orderType is CRYPTO_BOX_RF
* payerInfo : name(the value is always "Crypto Box")
* receiverInfo : binanceId
* Sender's perspective when orderType is REMITTANCE
* payerInfo : binanceId
* receiverInfo : name, institutionName, cardNumber, digitalWalletId
*
* Weight: 3000
*
* @summary Get Pay Trade History
* @param {GetPayTradeHistoryRequest} requestParameters Request parameters.
* @returns {Promise<RestApiResponse<GetPayTradeHistoryResponse>>}
* @throws {RequiredError | ConnectorClientError | UnauthorizedError | ForbiddenError | TooManyRequestsError | RateLimitBanError | ServerError | NotFoundError | NetworkError | BadRequestError}
* @see {@link https://developers.binance.com/docs/pay/rest-api/Get-Pay-Trade-History Binance API Documentation}
*/
getPayTradeHistory(requestParameters = {}) {
return this.payApi.getPayTradeHistory(requestParameters);
}
};
// src/pay.ts
var Pay = class {
constructor(config) {
const userAgent = buildUserAgent(name, version);
if (config?.configurationRestAPI) {
const configRestAPI = new ConfigurationRestAPI3(
config.configurationRestAPI
);
configRestAPI.basePath = configRestAPI.basePath || PAY_REST_API_PROD_URL;
configRestAPI.baseOptions = configRestAPI.baseOptions || {};
configRestAPI.baseOptions.headers = {
...configRestAPI.baseOptions.headers || {},
"User-Agent": userAgent
};
this.restAPI = new RestAPI(configRestAPI);
}
}
};
// src/index.ts
import {
PAY_REST_API_PROD_URL as PAY_REST_API_PROD_URL2,
ConnectorClientError,
RequiredError,
UnauthorizedError,
ForbiddenError,
TooManyRequestsError,
RateLimitBanError,
ServerError,
NetworkError,
NotFoundError,
BadRequestError
} from "@binance/common";
export {
BadRequestError,
ConnectorClientError,
ForbiddenError,
NetworkError,
NotFoundError,
PAY_REST_API_PROD_URL2 as PAY_REST_API_PROD_URL,
Pay,
rest_api_exports as PayRestAPI,
RateLimitBanError,
RequiredError,
ServerError,
TooManyRequestsError,
UnauthorizedError
};
//# sourceMappingURL=index.mjs.map