UNPKG

@yuju/tosspayments-sdk

Version:

Toss Payments SDK for Node.js

54 lines (53 loc) 1.82 kB
import { makeTossPaymentsResult } from '../utils/makeTossPaymentsResult.js'; import { filterUndefined } from '../utils/filterUndefined.js'; /** * 현금영수증 API */ export class CashReceiptApi { constructor(client) { Object.defineProperty(this, "client", { enumerable: true, configurable: true, writable: true, value: client }); } /** * 현금영수증 발급 * @param issueCashReceiptRequest 현금영수증 발급 요청 * @param idempotencyKey 멱등키 * @return 현금영수증 정보 */ async issue(issueCashReceiptRequest, idempotencyKey) { return makeTossPaymentsResult(async () => { return this.client.post(filterUndefined({ 'Content-Type': 'application/json', 'Idempotency-Key': idempotencyKey, }), '/v1/cash-receipts', issueCashReceiptRequest); }); } /** * 현금영수증 취소 * @param receiptKey 현금영수증 키 * @param idempotencyKey 멱등키 * @return 현금영수증 정보 */ async cancel(receiptKey, idempotencyKey) { return makeTossPaymentsResult(async () => { return this.client.post(filterUndefined({ 'Content-Type': 'application/json', 'Idempotency-Key': idempotencyKey, }), `/v1/cash-receipts/${receiptKey}/cancel`, undefined); }); } /** * 현금영수증 조회 * @param cashReceiptInquiryRequest 현금영수증 조회 요청 * @return 현금영수증 정보 */ async inquiry(cashReceiptInquiryRequest) { return makeTossPaymentsResult(async () => { return this.client.get('/v1/cash-receipts', cashReceiptInquiryRequest); }); } }