UNPKG

yookassa-sdk-node

Version:
57 lines 1.33 kB
// src/index.ts import createClient from "openapi-fetch"; var YooKassaSDK = class { constructor({ shopId, secretKey, requestInitExt }) { this.client = createClient({ baseUrl: "https://api.yookassa.ru/v3/", requestInitExt }); this.client.use({ onRequest({ request }) { const credentials = btoa(`${shopId}:${secretKey}`); request.headers.set("Authorization", "Basic " + credentials); } }); } client; createPayment({ body, idempotenceKey }) { return this.client.POST("/payments", { params: { header: { ["Idempotence-Key"]: idempotenceKey } }, body }); } getPaymentList({ query }) { return this.client.GET("/payments", { params: { query } }); } getPayment({ payment_id }) { return this.client.GET("/payments/{payment_id}", { params: { path: { payment_id } } }); } createInvoice({ body, idempotenceKey }) { return this.client.POST("/invoices", { params: { header: { ["Idempotence-Key"]: idempotenceKey } }, body }); } getInvoice({ invoice_id }) { return this.client.GET("/invoices/{invoice_id}", { params: { path: { invoice_id } } }); } }; export { YooKassaSDK }; //# sourceMappingURL=index.mjs.map