linkpay-api
Version:
LinkPay JS/TS API SDK
94 lines (93 loc) • 4.59 kB
JavaScript
;
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
var base_api_1 = require("./common/base-api");
var base_1 = require("./models/base");
/**
* LinkPay API
*/
var LinkPayAPI = /** @class */ (function (_super) {
__extends(LinkPayAPI, _super);
function LinkPayAPI(configuration) {
return _super.call(this, configuration) || this;
}
/**
* This API is used to create a LinkPay order and get a Payment Link. This API supports idempotentency, if the
* merchant does not receive the response for this API, it can re-call this API with the same
* merchantOrderID, merchantOrderTime and transAmount object.
*
* @param body LinkPay Request Message
* @returns
*/
LinkPayAPI.prototype.payment = function (body) {
var path = "/g2/v0/payment/mer/".concat(this.configuration.sid, "/evo.e-commerce.linkpay");
var headers = this.buildHeaders(base_1.HttpMethod.POST, path, body);
var pathParamMap = { sid: this.configuration.sid };
return this.restClient.post(path, headers, pathParamMap, body).then(function (response) {
return response;
});
};
/**
* This API is used to retrieve the transaction record from the LinkPay based on the merchantOrderID. This
* interface only supports to query the payment status of the LinkPay order.
*
* @param merchantOrderID Merchant Order ID
* @returns
*/
LinkPayAPI.prototype.retrievePayment = function (merchantOrderID) {
var path = "/g2/v0/payment/mer/".concat(this.configuration.sid, "/evo.e-commerce.linkpay/").concat(merchantOrderID);
var headers = this.buildHeaders(base_1.HttpMethod.GET, path);
var pathParamMap = { sid: this.configuration.sid, merchantOrderID: merchantOrderID };
return this.restClient.get(path, headers, pathParamMap).then(function (response) {
return response;
});
};
/**
* This API is used to refund the transaction fund from the LinkPay based on the merchantOrderID. This
* interface only supports to refund the paid LinkPay order. And this interface supports partial refund as well.
*
* @param merchantOrderID Merchant Order ID
* @param body Request Message
* @returns
*/
LinkPayAPI.prototype.refund = function (merchantOrderID, body) {
var path = "/g2/v0/payment/mer/".concat(this.configuration.sid, "/evo.e-commerce.linkpayRefund/").concat(merchantOrderID);
var headers = this.buildHeaders(base_1.HttpMethod.POST, path, body);
var pathParamMap = { sid: this.configuration.sid, merchantOrderID: merchantOrderID };
return this.restClient.post(path, headers, pathParamMap, body).then(function (response) {
return response;
});
};
/**
* This API is used to retrieve the refund transaction record from the LinkPay based on the merchantTransID
* of LinkPay refund transaction. This interface only supports to query the refund status of
* the LinkPay refund transaction.
*
* @param merchantTransID Merchant Transaction ID
* @returns
*/
LinkPayAPI.prototype.retrieveRefund = function (merchantTransID) {
var path = "/g2/v0/payment/mer/".concat(this.configuration.sid, "/evo.e-commerce.linkpayRefund/").concat(merchantTransID);
var headers = this.buildHeaders(base_1.HttpMethod.GET, path);
var pathParamMap = { sid: this.configuration.sid, merchantTransID: merchantTransID };
return this.restClient.get(path, headers, pathParamMap).then(function (response) {
return response;
});
};
return LinkPayAPI;
}(base_api_1.BaseAPI));
exports.default = LinkPayAPI;