UNPKG

expresscheckout-nodejs

Version:

Juspay's official expresscheckout-nodejs sdk

114 lines 4.68 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const JuspayResource_js_1 = __importDefault(require("../JuspayResource.js")); class Order extends JuspayResource_js_1.default { constructor(juspayEnvironment) { super(juspayEnvironment); } /** * - Create an order that is a representation of your shopping cart. * - The order contains important information like amount, customer details, shipping address, billing address, etc. * - Only after an order is created, payment can be started. * - Order create is a server to server call. * * @param body order_id, amount is must * @param juspayConfig override config using this params usage:- {apiKey: '', merchantId: '', ...} * @returns Promise Response Object * * @link https://docs.juspay.in/api-reference/docs/express-checkout/create-order-api */ create(body, juspayConfig) { return this.makeServiceCall({ method: 'POST', path: '/orders', body, juspayOverrideConfig: juspayConfig, }); } /** * * - Retrieve the order object associated with the order_id. * - Refer the link to include relevant version in the header - https://developer.juspay.in/reference#section-version * * - this route supports jwe authentiction * - if decided auth is jwe (if jweAuth config is set) please review the data given * - as the api is different * - for /order/:orderId aka basic auth refer to this:- https://developer.juspay.in/reference/get-order-status * - for jwe auth it's type is, please go through the document share with you * * @param orderId - Unique Identifier for the order * @param query - request body * @param juspayConfig override config using this params usage:- {apiKey: '', merchantId: '', ...} * @param authMethod - to choose auth type currently supports 'JWE' and 'BASIC' * @returns Promise Response Object * * @link https://docs.juspay.in/api-reference/docs/express-checkout/order-status-api * */ status(orderId, query, juspayConfig, authMethod) { query = Object.assign(Object.assign({}, query), { order_id: orderId }); if (authMethod == 'SIGNATURE') { throw new TypeError('this route does not support signature auth'); } return this.makeServiceCall({ method: 'GET', path: '/orders/' + orderId, juspayOverrideConfig: juspayConfig, auth: authMethod == undefined ? ['JWE', 'BASIC'] : [authMethod], query, opts: { authPriority: 'ordered', jwePath: '/v4/order-status', }, }); } /** * * - Update an order that has already been created. * - The only amount, address and UDF fields can be updated. * - Address fields can be optionally sent as explained in the /orders API. * - The API response is similar to that of the order create API * * @param orderId - Unique Identifier for the order * @param body: - amount is required * @param juspayConfig override config using this params usage:- {apiKey: '', merchantId: '', ...} * @returns Promise Response Object * * @link https://docs.juspay.in/api-reference/docs/express-checkout/update-order-api * */ update(orderId, body, juspayConfig) { return this.makeServiceCall({ method: 'POST', path: '/orders' + orderId, body, juspayOverrideConfig: juspayConfig, }); } /** * * - Create a refund for an Order. * - Refunds can be initiated only for transactions that are CHARGED. * * @param orderId - Unique Identifier for the order * @param juspayConfig override config using this params usage:- {apiKey: '', merchantId: '', ...} * @returns Promise Response Object * - The response of refund initiation is similar to that of order status API Response with the addition of refund block. * * @link https://docs.juspay.in/api-reference/docs/express-checkout/refund-order-api */ refund(orderId, body, juspayConfig) { return this.makeServiceCall({ method: 'POST', path: `/orders/${orderId}/refunds`, body, juspayOverrideConfig: juspayConfig, auth: ['JWE'], }); } } exports.default = Order; //# sourceMappingURL=Order.js.map