pancake-client-sdk
Version:
Official TypeScript SDK for Pancake POS API
100 lines • 3.14 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.PaymentResource = void 0;
const base_1 = require("./base");
class PaymentResource extends base_1.BaseResource {
/**
* Get list of payment gateways
*/
async listGateways() {
return this.client.get(this.getShopPath('/payment/gateways'));
}
/**
* Get gateway by code
*/
async getGateway(code) {
return this.client.get(this.getShopPath(`/payment/gateways/${code}`));
}
/**
* Update gateway settings
*/
async updateGatewaySettings(code, settings) {
return this.client.put(this.getShopPath(`/payment/gateways/${code}/settings`), settings);
}
/**
* Get list of payment methods
*/
async listMethods(params) {
return this.client.get(this.getShopPath('/payment/methods'), params);
}
/**
* Create payment transaction
*/
async createPayment(data) {
return this.client.post(this.getShopPath('/payment/transactions'), data);
}
/**
* Get transaction by ID
*/
async getTransaction(transactionId) {
return this.client.get(this.getShopPath(`/payment/transactions/${transactionId}`));
}
/**
* List transactions
*/
async listTransactions(params) {
return this.client.get(this.getShopPath('/payment/transactions'), params);
}
/**
* Refund transaction
*/
async refund(data) {
return this.client.post(this.getShopPath(`/payment/transactions/${data.transaction_id}/refund`), data);
}
/**
* Cancel transaction
*/
async cancel(transactionId, reason) {
return this.client.post(this.getShopPath(`/payment/transactions/${transactionId}/cancel`), { reason });
}
/**
* Get payment analytics
*/
async getAnalytics(params) {
return this.client.get(this.getShopPath('/payment/analytics'), params);
}
/**
* Handle webhook event
*/
async handleWebhook(gatewayCode, data, signature) {
return this.client.post(this.getShopPath(`/payment/gateways/${gatewayCode}/webhook`), data, {
headers: signature ? { 'X-Webhook-Signature': signature } : undefined
});
}
/**
* Get installment plans
*/
async getInstallmentPlans(params) {
return this.client.get(this.getShopPath('/payment/installment-plans'), params);
}
/**
* Get bank transfer info
*/
async getBankTransferInfo(transactionId) {
return this.client.get(this.getShopPath(`/payment/transactions/${transactionId}/bank-transfer-info`));
}
/**
* Verify bank transfer
*/
async verifyBankTransfer(transactionId, data) {
return this.client.post(this.getShopPath(`/payment/transactions/${transactionId}/verify-transfer`), data);
}
/**
* Get payment QR code
*/
async getPaymentQR(transactionId, params) {
return this.client.get(this.getShopPath(`/payment/transactions/${transactionId}/qr-code`), params);
}
}
exports.PaymentResource = PaymentResource;
//# sourceMappingURL=payment.js.map