@spreeloop/orange_money
Version:
A orange money api integration package
110 lines • 4.75 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.OrangeMoneyPaymentFake = void 0;
const constants_1 = require("../utils/constants");
const payTokenResponse = {
message: 'success',
data: {
payToken: 'MP220807558VEF7A9C4F09AED',
},
};
const mobileAccessTokenResponse = {
access_token: '1e23bee1-37dc-3015-a7d6-cb70e566bd64',
token_type: 'bearer',
expires_in: 3600,
scope: 'read write',
};
/**
* Implement the orange money fake payment.
*/
class OrangeMoneyPaymentFake {
/**
* Generates a pay token using the provided access token.
*
* @return {Promise<GetPayTokenResponse>} A promise that resolves to the pay token response.
*/
async getPayToken() {
return Promise.resolve({
raw: payTokenResponse,
data: 'MP220806C74C8F5787A9C4F79AED',
});
}
/**
* Generates an access token.
*
* @return {Promise<GetAccessTokenResponse>} the access token response
*/
async getAccessToken() {
return Promise.resolve({
raw: mobileAccessTokenResponse,
data: '1e23bee1-37dc-3015-a7d6-cb70e566bd64',
});
}
/**
* Retrieves The orange money payment status.
* @param {MobileParamsForCheckStatus} checkStatusParams the necessary parameters to get the mobile payment status.
* @return {GetOrangeMoneyPaymentResponse} the response who contains the payment state.
*/
async getOrangeMoneyPaymentStatus(checkStatusParams) {
return Promise.resolve({
raw: {
message: 'Transaction retrieved successfully',
data: {
id: 74581010,
createtime: '1682001669',
subscriberMsisdn: '655637944',
amount: 1100,
payToken: checkStatusParams.payToken,
txnid: 'MP230420.1541.C39196',
txnmode: 'zSapffVPWccheVZQRtvG',
inittxnmessage: 'Paiement e la clientele done.The devrez confirmer le paiement en saisissant son code PIN et vous recevrez alors un SMS. Merci dutiliser des services Orange Money.',
inittxnstatus: '200',
confirmtxnstatus: '200',
confirmtxnmessage: 'Paiement de SPREELOOP reussi par 655637944 PEKE. ID transaction:MP230420.1541.C39196, Montant:1100 FCFA. Solde: 55.81 FCFA.',
status: constants_1.OrangeMoneyPaymentStatus.SUCCESSFULL_MOBILE_PAYMENT,
notifUrl: 'https://europe-west1-place-prod.cloudfunctions.net/api-1/payment/orange_money/live/zSapffVPWccheVZQRtvG',
description: 'Commande',
channelUserMsisdn: '696431937',
},
},
data: {
status: constants_1.OrangeMoneyPaymentStatus.SUCCESSFULL_MOBILE_PAYMENT,
},
});
}
/**
* Initiates the orange money payment.
* @param {InitializeOrangeMoneyRequest} mobileInitParams the necessary parameters to initialize the mobile payment.
* @return {InitializeOrangeMoneyResponse} the response of initialization.
*
**/
async initializeOrangeMoneyPayment(mobileInitParams) {
return Promise.resolve({
raw: {
message: 'Transaction retrieved successfully',
data: {
id: 74581010,
createtime: '1682001669',
subscriberMsisdn: '655637944',
amount: 1100,
payToken: mobileInitParams.payToken,
txnid: 'MP230420.1541.C39196',
txnmode: 'zSapffVPWccheVZQRtvG',
inittxnmessage: 'Paiement e la clientele done.The devrez confirmer le paiement en saisissant son code PIN et vous recevrez alors un SMS. Merci dutiliser des services Orange Money.',
inittxnstatus: '200',
confirmtxnstatus: '200',
confirmtxnmessage: 'Paiement de SPREELOOP reussi par 655637944 PEKE. ID transaction:MP230420.1541.C39196, Montant:1100 FCFA. Solde: 55.81 FCFA.',
status: constants_1.OrangeMoneyPaymentStatus.PENDING_PAYMENT,
notifUrl: 'https://europe-west1-place-prod.cloudfunctions.net/api-1/payment/orange_money/live/zSapffVPWccheVZQRtvG',
description: 'Commande',
channelUserMsisdn: '696431937',
},
},
data: {
payToken: mobileInitParams.payToken,
},
});
}
}
exports.OrangeMoneyPaymentFake = OrangeMoneyPaymentFake;
//# sourceMappingURL=fake.js.map