bc-payments-sdk
Version:
BetterCommerce's Payments NodeJS SDK is a complete solution for storefront clients that integrate payments. `bc-payments-sdk` is a single point interface for storefront clients for interacting with payment gateways.
31 lines (30 loc) • 1.79 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.PaymentMethod = void 0;
const api_1 = require("./api");
const BCEnvironment_1 = require("../../base/config/BCEnvironment");
const constants_1 = require("../../constants/constants");
const RequestMethod_1 = require("../../constants/enums/RequestMethod");
/**
* Class {PaymentMethod} contains methods for interacting with the PaymentMethod endpoint on the CommerceHub API.
*
* The methods in this class can be used to retrieve payment methods, update payment methods, and more.
*/
class PaymentMethod {
/**
* Retrieves all payment methods.
*
* Retrieves all payment methods based on the provided data, headers, and cookies.
* The method makes an API call to fetch the payment methods and returns the result.
*
* @param data - The data required to identify the basket.
* @param { headers, cookies } - The headers and cookies to include in the request.
* @returns A promise that resolves to the payment methods result or an error object if the request fails.
*/
static async getAll(data, { headers, cookies }) {
const params = { country: (data === null || data === void 0 ? void 0 : data.countryCode) || BCEnvironment_1.BCEnvironment.getDefaultCountry(), currency: (data === null || data === void 0 ? void 0 : data.currencyCode) || BCEnvironment_1.BCEnvironment.getDefaultCurrency(), basketId: (data === null || data === void 0 ? void 0 : data.basketId) || constants_1.Defaults.Guid.Value, };
const paymentMethodsResult = await api_1.Api.call(`api/v2/commerce/checkout/payment-methods`, RequestMethod_1.RequestMethod.GET, params, headers, cookies);
return paymentMethodsResult;
}
}
exports.PaymentMethod = PaymentMethod;