UNPKG

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.

59 lines (58 loc) 2.28 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.OpayoPayment = void 0; // Package Imports const bc_opayo_sdk_1 = require("bc-opayo-sdk"); const BasePaymentProvider_1 = require("../../base/entity/BasePaymentProvider"); /** * Class {OpayoPayment} extends {BasePaymentProvider} and implements {IPaymentProvider}. * It provides the concrete implementation of the Opayo/Sagepay payment provider. * * @class OpayoPayment * @extends BasePaymentProvider * @implements IPaymentProvider * * @remark * This class is responsible for initializing the Opayo SDK and providing the concrete * implementation of the Opayo/Sagepay payment provider methods. */ class OpayoPayment extends BasePaymentProvider_1.BasePaymentProvider { initPaymentIntent(data) { throw new Error("Method not implemented."); } /** * Requests a payment or payout through the Opayo/Sagepay payment provider. * * This method initializes the SDK and attempts to request a payment or payout * with the provided data. If the SDK initialization is successful, it returns * the result of the transaction request. If the SDK initialization fails, it * returns null. In case of an error during the process, it returns an object * containing the error details. * * _____ * OPAYO * ‾‾‾‾‾ * API Reference - https://developer.elavon.com/products/hosted-payment-page/v1/take-a-payment * * @param data - The payment data required by Opayo/Sagepay. * @returns A promise that resolves to the result of the payment request * or an object with error details if an error occurs. */ async requestPayment(data) { try { if (super.initSDK()) { const transaction = new bc_opayo_sdk_1.Transaction(); const transactionResult = await transaction.request(data); return transactionResult; } return null; } catch (error) { return { hasError: true, error: error === null || error === void 0 ? void 0 : error.message }; } } getOrderDetails(data) { throw new Error("Method not implemented."); } } exports.OpayoPayment = OpayoPayment;