UNPKG

@spreeloop/orange_money

Version:
69 lines 2.82 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.OrangeMoneyPaymentLive = void 0; const get_access_token_1 = require("../operations/get_access_token"); const get_pay_token_1 = require("../operations/get_pay_token"); const get_payment_status_1 = require("../operations/get_payment_status"); const initialize_om_payment_1 = require("../operations/initialize_om_payment"); const routes_1 = require("../routes/routes"); /** * Implements the orange money live payment. */ class OrangeMoneyPaymentLive { /** * Creates a new instance of the PaymentConfig class. * * @param {PaymentConfig} config - The configuration for the PaymentConfig instance. */ constructor(config) { this.config = config; this.route = new routes_1.Routes(config.orangeMoneyVersion); } /** * Gets a pay token using the provided access token. * * @param {string} accessToken - The access token used to create the pay token. * @return {Promise<GetPayTokenResponse>} A promise that resolves to the pay token response. */ async getPayToken(accessToken) { return (0, get_pay_token_1.getPayToken)(this.config, accessToken, this.route.mobilePayToken()); } /** * Gets an access token. * * @return {Promise<GetAccessTokenResponse>} the access token response */ async getAccessToken() { return (0, get_access_token_1.getAccessToken)(this.config, this.route.mobileAccessToken()); } /** * Initializes the orange money payment. * * @param {InitializeOrangeMoneyRequest} mobileInitParams - Parameters for mobile initialization * @return {Promise<InitializeOrangeMoneyResponse>} A promise that resolves with the mobile payment initialization response */ async initializeOrangeMoneyPayment(mobileInitParams) { return (0, initialize_om_payment_1.initializeOmPayment)({ paymentConfig: this.config, mobileInitParams: mobileInitParams, endPoint: this.route.mobileInitPayment(), }); } /** * Gets the status of a payment. * * @param {GetOrangeMoneyPaymentRequest} checkStatusParams - The parameters for checking the status. * @return {Promise<GetOrangeMoneyPaymentResponse>} The response containing the payment status. */ async getOrangeMoneyPaymentStatus(checkStatusParams) { return (0, get_payment_status_1.getPaymentStatus)({ paymentServiceConfig: this.config, mobileStatusVerificationParams: checkStatusParams, endPoint: this.route.mobilePaymentStatus({ payToken: checkStatusParams.payToken, }), }); } } exports.OrangeMoneyPaymentLive = OrangeMoneyPaymentLive; //# sourceMappingURL=live.js.map