UNPKG

nowpayments-api-typescript

Version:
130 lines (119 loc) 2.57 kB
import NOWPaymentsService from './services'; import { ICreatePayment, IGetEstimatePrice, IGetPaymentStatus, IGetMinimumPaymentAmount, IGetListPayments, ICreateInvoice, } from './interfaces'; export class NOWPaymentsApi { readonly apiKey: string; constructor({ apiKey }: { apiKey: string }) { this.apiKey = apiKey; } async getApiStatus() { return await NOWPaymentsService.apiStatus(); } async getCurrencies() { return await NOWPaymentsService.getCurrencies({ apiKey: this.apiKey }); } async getEstimatePrice({ amount, currency_from, currency_to, }: IGetEstimatePrice) { return await NOWPaymentsService.getEstimatePrice({ apiKey: this.apiKey, amount, currency_from, currency_to, }); } async createPayment({ price_amount, price_currency, pay_amount, pay_currency, ipn_callback_url, order_id, order_description, purchase_id, payout_address, payout_currency, payout_extra_id, fixed_rate, }: ICreatePayment) { return await NOWPaymentsService.createPayment({ apiKey: this.apiKey, price_amount, price_currency, pay_amount, pay_currency, ipn_callback_url, order_id, order_description, purchase_id, payout_address, payout_currency, payout_extra_id, fixed_rate, }); } async getPaymentStatus({ payment_id }: IGetPaymentStatus) { return await NOWPaymentsService.getPaymentStatus({ apiKey: this.apiKey, payment_id, }); } async getMinimumPaymentAmount({ currency_from, currency_to, }: IGetMinimumPaymentAmount) { return await NOWPaymentsService.getMinimumPaymentAmount({ apiKey: this.apiKey, currency_from, currency_to, }); } async getListPayments({ limit, page, sortBy, orderBy, dateFrom, dateTo, }: IGetListPayments = {}) { return await NOWPaymentsService.getListPayments({ apiKey: this.apiKey, limit, page, sortBy, orderBy, dateFrom, dateTo, }); } async createInvoice({ price_amount, price_currency, pay_currency, ipn_callback_url, order_id, order_description, success_url, cancel_url, }: ICreateInvoice) { return await NOWPaymentsService.createInvoice({ apiKey: this.apiKey, price_amount, price_currency, pay_currency, ipn_callback_url, order_id, order_description, success_url, cancel_url, }); } }