UNPKG

@bootpay/backend-js

Version:

Bootpay Server Side Package for Node.js

78 lines (77 loc) 3.12 kB
"use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.OrderCancelModule = void 0; class OrderCancelModule { constructor(bootpay) { this.bootpay = bootpay; } /** * 취소 요청 목록 조회 * @param params 조회 파라미터 */ list(params) { return __awaiter(this, void 0, void 0, function* () { const queryParams = new URLSearchParams(); if (params) { if (params.order_id) queryParams.append('order_id', params.order_id); if (params.order_number) queryParams.append('order_number', params.order_number); } const query = queryParams.toString(); return this.bootpay.get(`order/cancel${query ? `?${query}` : ''}`); }); } /** * 취소 요청 * @param params 취소 요청 파라미터 */ request(params) { return __awaiter(this, void 0, void 0, function* () { return this.bootpay.post('order/cancel', params); }); } /** * 취소 요청 철회 * @param orderCancelRequestHistoryId 취소 요청 이력 ID */ withdraw(orderCancelRequestHistoryId) { return __awaiter(this, void 0, void 0, function* () { return this.bootpay.put(`order/cancel/${orderCancelRequestHistoryId}/withdraw`, {}); }); } /** * 취소 승인 * @param params 취소 승인 파라미터 */ approve(params) { return __awaiter(this, void 0, void 0, function* () { if (!params.order_cancel_request_history_id) { return Promise.reject({ success: false, error: 'order_cancel_request_history_id is required' }); } return this.bootpay.put(`order/cancel/${params.order_cancel_request_history_id}/approve`, params); }); } /** * 취소 거절 * @param params 취소 거절 파라미터 */ reject(params) { return __awaiter(this, void 0, void 0, function* () { if (!params.order_cancel_request_history_id) { return Promise.reject({ success: false, error: 'order_cancel_request_history_id is required' }); } return this.bootpay.put(`order/cancel/${params.order_cancel_request_history_id}/reject`, params); }); } } exports.OrderCancelModule = OrderCancelModule;