nowpayments-api-typescript
Version:
Nowpayments typescript API wrapper
51 lines (44 loc) • 1.04 kB
text/typescript
import ApiConnection from './../utils/api-connection';
import { ICreateInvoice, IError } from './../interfaces';
export interface InvoiceResponse {
id: number;
order_id: string;
order_description: string;
price_amount: number;
price_currency: string;
pay_currency: string | null;
ipn_callback_url: string;
invoice_url: string;
success_url: string;
cancel_url: string;
created_at: string;
updated_at: string;
}
export interface CreateInvoice extends ICreateInvoice {
apiKey: string;
}
const createInvoice = async ({
apiKey,
price_amount,
price_currency,
pay_currency,
ipn_callback_url,
order_id,
order_description,
success_url,
cancel_url,
}: CreateInvoice): Promise<InvoiceResponse | IError> => {
const api = new ApiConnection({ apiKey });
const { data } = await api.post(`/invoice`, {
price_amount,
price_currency,
pay_currency,
ipn_callback_url,
order_id,
order_description,
success_url,
cancel_url,
});
return data;
};
export default createInvoice;