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.
54 lines (53 loc) • 2.11 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.PayPalPayment = void 0;
// Package Imports
const bc_paypal_sdk_1 = require("bc-paypal-sdk");
const BasePaymentProvider_1 = require("../../base/entity/BasePaymentProvider");
/**
* Class {PayPalPayment} extends {BasePaymentProvider} and implements {IPaymentProvider}.
* It provides the concrete implementation of the PayPal payment provider.
*
* @class PayPalPayment
* @extends BasePaymentProvider
* @implements IPaymentProvider
*
* @remark
* This class is responsible for initializing the PayPal SDK and providing the concrete implementation of the PayPal payment provider methods.
*/
class PayPalPayment extends BasePaymentProvider_1.BasePaymentProvider {
initPaymentIntent(data) {
throw new Error("Method not implemented.");
}
async requestPayment(data) {
throw new Error("Method not implemented.");
}
/**
* Retrieves the details of an order from PayPal.
*
* This method attempts to retrieve the order details with the provided data.
* If successful, it returns the result of the order details 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.
*
* API Reference - https://developer.paypal.com/docs/api/orders/v2/#orders_get
*
* @param data - The order ID required by PayPal.
* @returns A promise that resolves to the result of the order details request
* or an object with error details if an error occurs.
*/
async getOrderDetails(data) {
try {
if (super.initSDK()) {
const order = new bc_paypal_sdk_1.Order();
const orderDetailsResult = await order.get(data);
return orderDetailsResult;
}
return null;
}
catch (error) {
return { hasError: true, error: error === null || error === void 0 ? void 0 : error.message };
}
}
}
exports.PayPalPayment = PayPalPayment;