takefy-cryptomus
Version:
TypeScript SDK for the Cryptomus payment system API
139 lines (138 loc) • 6.71 kB
TypeScript
import type { ListServicesResponse, VerifyWebhookSignatureResponse } from "../types";
import type { BlockStaticWalletRequest, BlockStaticWalletResponse, CreatePaymentRequest, CreatePaymentResponse, CreateQrCodeForInvoiceRequest, CreateQrCodeForInvoiceResponse, CreateQrCodeForWalletRequest, CreateQrCodeForWalletResponse, CreateWalletRequest, CreateWalletResponse, GetPaymentInfoRequest, GetPaymentInfoResponse, GetPaymentsHistoryRequest, GetPaymentsHistoryResponse, ListDiscountsResponse, RefundPaymentOnBlockedWalletRequest, RefundPaymentOnBlockedWalletResponse, RefundPaymentRequest, RefundPaymentResponse, ResendWebhookRequest, ResendWebhookResponse, SetDiscountForPaymentMethodRequest, SetDiscountForPaymentMethodResponse, TestPaymentWebhookRequest, TestPaymentWebhookResponse, TestPayoutWebhookRequest, TestPayoutWebhookResponse, TestWalletWebhookRequest, TestWalletWebhookResponse, VerifyPaymentWebhookSignatureRequest } from "../types/payments";
import { BaseService } from "./base";
/**
* Service class for handling payment-related operations in the Cryptomus API.
* Provides methods for creating payments, managing wallets, and handling discounts.
*/
export declare class PaymentsService extends BaseService {
/**
* Creates a new payment in the Cryptomus system.
*
* @param {CreatePaymentRequest} data - Payment creation parameters including amount, currency, and order details.
* @returns {Promise<CreatePaymentResponse>} A promise that resolves with the created payment details.
* @throws {Error} If the payment creation fails or returns an error response.
*
* @example
* ```typescript
* const payment = await payments.create({
* amount: "100",
* currency: "USD",
* order_id: "order123"
* });
* ```
*/
create(params: CreatePaymentRequest): Promise<CreatePaymentResponse>;
/**
* Creates a new wallet for receiving payments.
*
* @param {CreateWalletRequest} data - Parameters for creating the wallet.
* @returns {Promise<CreateWalletResponse>} A promise that resolves with the created wallet details.
* @throws {Error} If the request fails or returns an error response.
*
* @example
* ```typescript
* const wallet = await payments.createWallet({
* currency: "USDT",
* network: "TRX",
* order_id: "wallet123"
* });
* ```
*/
createWallet(params: CreateWalletRequest): Promise<CreateWalletResponse>;
/**
* Generates a QR code for a specific wallet address.
*
* @param {CreateQrCodeForWalletRequest} data - Parameters for generating the QR code.
* @returns {Promise<CreateQrCodeForWalletResponse>} A promise that resolves with the QR code details.
* @throws {Error} If the request fails or returns an error response.
*
* @example
* ```typescript
* const qr = await payments.createQrCodeForWallet({
* wallet_address_uuid: "wallet-uuid"
* });
* ```
*/
createQrCodeForWallet(params: CreateQrCodeForWalletRequest): Promise<CreateQrCodeForWalletResponse>;
createQrCodeForInvoice(params: CreateQrCodeForInvoiceRequest): Promise<CreateQrCodeForInvoiceResponse>;
blockStaticWallet(params: BlockStaticWalletRequest): Promise<BlockStaticWalletResponse>;
refundPaymentOnBlockedWallet(params: RefundPaymentOnBlockedWalletRequest): Promise<RefundPaymentOnBlockedWalletResponse>;
/**
* Retrieves information about a specific payment.
*
* @param {GetPaymentInfoRequest} data - Parameters to identify the payment (uuid or order_id).
* @returns {Promise<GetPaymentInfoResponse>} A promise that resolves with the payment information.
* @throws {Error} If the request fails or returns an error response.
*
* @example
* ```typescript
* const info = await payments.getInfo({
* uuid: "payment-uuid"
* });
* ```
*/
getInfo(params: GetPaymentInfoRequest): Promise<GetPaymentInfoResponse>;
refund(params: RefundPaymentRequest): Promise<RefundPaymentResponse>;
resendWebhook(params: ResendWebhookRequest): Promise<ResendWebhookResponse>;
testPaymentWebhook(params: TestPaymentWebhookRequest): Promise<TestPaymentWebhookResponse>;
testPayoutWebhook(params: TestPayoutWebhookRequest): Promise<TestPayoutWebhookResponse>;
testWalletWebhook(params: TestWalletWebhookRequest): Promise<TestWalletWebhookResponse>;
/**
* Retrieves a list of available payment services and their details.
*
* @returns {Promise<ListServicesResponse>} A promise that resolves with the list of payment services.
* @throws {Error} If the request fails or returns an error response.
*
* @example
* ```typescript
* const services = await payments.listServices();
* ```
*/
listServices(): Promise<ListServicesResponse[]>;
/**
* Retrieves payment history based on specified date range and filters.
*
* @param {GetPaymentsHistoryRequest} data - Parameters for filtering payment history.
* @returns {Promise<GetPaymentsHistoryResponse>} A promise that resolves with the payment history.
* @throws {Error} If the request fails or returns an error response.
*
* @example
* ```typescript
* const history = await payments.getHistory({
* date_from: "2025-01-01",
* date_to: "2025-02-01"
* });
* ```
*/
getHistory(params: GetPaymentsHistoryRequest): Promise<GetPaymentsHistoryResponse>;
verifyWebhookSignature(params: VerifyPaymentWebhookSignatureRequest): Promise<VerifyWebhookSignatureResponse>;
/**
* Retrieves a list of available discounts for payments.
*
* @returns {Promise<ListDiscountsResponse>} A promise that resolves with the list of discounts.
* @throws {Error} If the request fails or returns an error response.
*
* @example
* ```typescript
* const discounts = await payments.listDiscounts();
* ```
*/
listDiscounts(): Promise<ListDiscountsResponse>;
/**
* Sets or updates a discount for payments.
*
* @param {SetDiscountForPaymentMethodRequest} data - Parameters for setting the discount.
* @returns {Promise<SetDiscountForPaymentMethodResponse>} A promise that resolves with the updated discount details.
* @throws {Error} If the request fails or returns an error response.
*
* @example
* ```typescript
* const discount = await payments.setDiscount({
* currency: "USDT",
* percent: 5
* });
* ```
*/
setDiscount(params: SetDiscountForPaymentMethodRequest): Promise<SetDiscountForPaymentMethodResponse>;
}