@spreeloop/orange_money 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.js +47 -0
- package/.prettierrc +6 -0
- package/README.md +192 -0
- package/babel.config.js +3 -0
- package/dist/logging/index.d.ts +2 -0
- package/dist/logging/index.d.ts.map +1 -0
- package/dist/logging/index.js +18 -0
- package/dist/logging/index.js.map +1 -0
- package/dist/logging/src/log_level.d.ts +24 -0
- package/dist/logging/src/log_level.d.ts.map +1 -0
- package/dist/logging/src/log_level.js +34 -0
- package/dist/logging/src/log_level.js.map +1 -0
- package/dist/logging/src/logging.d.ts +50 -0
- package/dist/logging/src/logging.d.ts.map +1 -0
- package/dist/logging/src/logging.js +87 -0
- package/dist/logging/src/logging.js.map +1 -0
- package/dist/logging/src/printer.d.ts +10 -0
- package/dist/logging/src/printer.d.ts.map +1 -0
- package/dist/logging/src/printer.js +3 -0
- package/dist/logging/src/printer.js.map +1 -0
- package/dist/main.js +3 -0
- package/dist/main.js.LICENSE.txt +1 -0
- package/dist/main.js.map +1 -0
- package/dist/orange_money/index.d.ts +2 -0
- package/dist/orange_money/index.d.ts.map +1 -0
- package/dist/orange_money/index.js +18 -0
- package/dist/orange_money/index.js.map +1 -0
- package/dist/orange_money/src/common/utils/https.d.ts +77 -0
- package/dist/orange_money/src/common/utils/https.d.ts.map +1 -0
- package/dist/orange_money/src/common/utils/https.js +240 -0
- package/dist/orange_money/src/common/utils/https.js.map +1 -0
- package/dist/orange_money/src/common/utils/https.spec.d.ts +2 -0
- package/dist/orange_money/src/common/utils/https.spec.d.ts.map +1 -0
- package/dist/orange_money/src/common/utils/https.spec.js +77 -0
- package/dist/orange_money/src/common/utils/https.spec.js.map +1 -0
- package/dist/orange_money/src/common/utils/logging_interface.d.ts +23 -0
- package/dist/orange_money/src/common/utils/logging_interface.d.ts.map +1 -0
- package/dist/orange_money/src/common/utils/logging_interface.js +3 -0
- package/dist/orange_money/src/common/utils/logging_interface.js.map +1 -0
- package/dist/orange_money/src/common/utils/operation_response.d.ts +16 -0
- package/dist/orange_money/src/common/utils/operation_response.d.ts.map +1 -0
- package/dist/orange_money/src/common/utils/operation_response.js +3 -0
- package/dist/orange_money/src/common/utils/operation_response.js.map +1 -0
- package/dist/orange_money/src/common/utils/utils.d.ts +6 -0
- package/dist/orange_money/src/common/utils/utils.d.ts.map +1 -0
- package/dist/orange_money/src/common/utils/utils.js +10 -0
- package/dist/orange_money/src/common/utils/utils.js.map +1 -0
- package/dist/orange_money/src/constants.d.ts +95 -0
- package/dist/orange_money/src/constants.d.ts.map +1 -0
- package/dist/orange_money/src/constants.js +111 -0
- package/dist/orange_money/src/constants.js.map +1 -0
- package/dist/orange_money/src/disbursements/implementations/disbursement_service.d.ts +63 -0
- package/dist/orange_money/src/disbursements/implementations/disbursement_service.d.ts.map +1 -0
- package/dist/orange_money/src/disbursements/implementations/disbursement_service.js +84 -0
- package/dist/orange_money/src/disbursements/implementations/disbursement_service.js.map +1 -0
- package/dist/orange_money/src/disbursements/implementations/src/live.d.ts +40 -0
- package/dist/orange_money/src/disbursements/implementations/src/live.d.ts.map +1 -0
- package/dist/orange_money/src/disbursements/implementations/src/live.js +61 -0
- package/dist/orange_money/src/disbursements/implementations/src/live.js.map +1 -0
- package/dist/orange_money/src/disbursements/implementations/src/sandbox.d.ts +40 -0
- package/dist/orange_money/src/disbursements/implementations/src/sandbox.d.ts.map +1 -0
- package/dist/orange_money/src/disbursements/implementations/src/sandbox.js +110 -0
- package/dist/orange_money/src/disbursements/implementations/src/sandbox.js.map +1 -0
- package/dist/orange_money/src/disbursements/operations/create_access_token.d.ts +28 -0
- package/dist/orange_money/src/disbursements/operations/create_access_token.d.ts.map +1 -0
- package/dist/orange_money/src/disbursements/operations/create_access_token.js +45 -0
- package/dist/orange_money/src/disbursements/operations/create_access_token.js.map +1 -0
- package/dist/orange_money/src/disbursements/operations/create_access_token.spec.d.ts +2 -0
- package/dist/orange_money/src/disbursements/operations/create_access_token.spec.d.ts.map +1 -0
- package/dist/orange_money/src/disbursements/operations/create_access_token.spec.js +106 -0
- package/dist/orange_money/src/disbursements/operations/create_access_token.spec.js.map +1 -0
- package/dist/orange_money/src/disbursements/operations/get_transfer_status.d.ts +114 -0
- package/dist/orange_money/src/disbursements/operations/get_transfer_status.d.ts.map +1 -0
- package/dist/orange_money/src/disbursements/operations/get_transfer_status.js +128 -0
- package/dist/orange_money/src/disbursements/operations/get_transfer_status.js.map +1 -0
- package/dist/orange_money/src/disbursements/operations/get_transfer_status.spec.d.ts +2 -0
- package/dist/orange_money/src/disbursements/operations/get_transfer_status.spec.d.ts.map +1 -0
- package/dist/orange_money/src/disbursements/operations/get_transfer_status.spec.js +148 -0
- package/dist/orange_money/src/disbursements/operations/get_transfer_status.spec.js.map +1 -0
- package/dist/orange_money/src/disbursements/operations/transfer.d.ts +45 -0
- package/dist/orange_money/src/disbursements/operations/transfer.d.ts.map +1 -0
- package/dist/orange_money/src/disbursements/operations/transfer.js +74 -0
- package/dist/orange_money/src/disbursements/operations/transfer.js.map +1 -0
- package/dist/orange_money/src/disbursements/operations/transfer.spec.d.ts +2 -0
- package/dist/orange_money/src/disbursements/operations/transfer.spec.d.ts.map +1 -0
- package/dist/orange_money/src/disbursements/operations/transfer.spec.js +178 -0
- package/dist/orange_money/src/disbursements/operations/transfer.spec.js.map +1 -0
- package/dist/orange_money/src/disbursements/routes/routes.d.ts +38 -0
- package/dist/orange_money/src/disbursements/routes/routes.d.ts.map +1 -0
- package/dist/orange_money/src/disbursements/routes/routes.js +53 -0
- package/dist/orange_money/src/disbursements/routes/routes.js.map +1 -0
- package/dist/orange_money/src/disbursements/utils/constants.d.ts +5 -0
- package/dist/orange_money/src/disbursements/utils/constants.d.ts.map +1 -0
- package/dist/orange_money/src/disbursements/utils/constants.js +9 -0
- package/dist/orange_money/src/disbursements/utils/constants.js.map +1 -0
- package/dist/orange_money/src/disbursements/utils/https.d.ts +74 -0
- package/dist/orange_money/src/disbursements/utils/https.d.ts.map +1 -0
- package/dist/orange_money/src/disbursements/utils/https.js +206 -0
- package/dist/orange_money/src/disbursements/utils/https.js.map +1 -0
- package/dist/orange_money/src/disbursements/utils/https.spec.d.ts +2 -0
- package/dist/orange_money/src/disbursements/utils/https.spec.d.ts.map +1 -0
- package/dist/orange_money/src/disbursements/utils/https.spec.js +77 -0
- package/dist/orange_money/src/disbursements/utils/https.spec.js.map +1 -0
- package/dist/orange_money/src/disbursements/utils/regex.d.ts +9 -0
- package/dist/orange_money/src/disbursements/utils/regex.d.ts.map +1 -0
- package/dist/orange_money/src/disbursements/utils/regex.js +12 -0
- package/dist/orange_money/src/disbursements/utils/regex.js.map +1 -0
- package/dist/orange_money/src/disbursements/utils/regex.spec.d.ts +2 -0
- package/dist/orange_money/src/disbursements/utils/regex.spec.d.ts.map +1 -0
- package/dist/orange_money/src/disbursements/utils/regex.spec.js +32 -0
- package/dist/orange_money/src/disbursements/utils/regex.spec.js.map +1 -0
- package/dist/orange_money/src/disbursements/utils/status.d.ts +53 -0
- package/dist/orange_money/src/disbursements/utils/status.d.ts.map +1 -0
- package/dist/orange_money/src/disbursements/utils/status.js +58 -0
- package/dist/orange_money/src/disbursements/utils/status.js.map +1 -0
- package/dist/orange_money/src/disbursements/utils/utils.d.ts +9 -0
- package/dist/orange_money/src/disbursements/utils/utils.d.ts.map +1 -0
- package/dist/orange_money/src/disbursements/utils/utils.js +26 -0
- package/dist/orange_money/src/disbursements/utils/utils.js.map +1 -0
- package/dist/orange_money/src/disbursements/utils/utils.spec.d.ts +2 -0
- package/dist/orange_money/src/disbursements/utils/utils.spec.d.ts.map +1 -0
- package/dist/orange_money/src/disbursements/utils/utils.spec.js +43 -0
- package/dist/orange_money/src/disbursements/utils/utils.spec.js.map +1 -0
- package/dist/orange_money/src/index.d.ts +8 -0
- package/dist/orange_money/src/index.d.ts.map +1 -0
- package/dist/orange_money/src/index.js +21 -0
- package/dist/orange_money/src/index.js.map +1 -0
- package/dist/orange_money/src/orange_money/orange_money.d.ts +58 -0
- package/dist/orange_money/src/orange_money/orange_money.d.ts.map +1 -0
- package/dist/orange_money/src/orange_money/orange_money.js +33 -0
- package/dist/orange_money/src/orange_money/orange_money.js.map +1 -0
- package/dist/orange_money/src/orange_money/orange_money_fake/fake_result.d.ts +7 -0
- package/dist/orange_money/src/orange_money/orange_money_fake/fake_result.d.ts.map +1 -0
- package/dist/orange_money/src/orange_money/orange_money_fake/fake_result.js +16 -0
- package/dist/orange_money/src/orange_money/orange_money_fake/fake_result.js.map +1 -0
- package/dist/orange_money/src/orange_money/orange_money_fake/orange_money_fake_payment.d.ts +29 -0
- package/dist/orange_money/src/orange_money/orange_money_fake/orange_money_fake_payment.d.ts.map +1 -0
- package/dist/orange_money/src/orange_money/orange_money_fake/orange_money_fake_payment.js +67 -0
- package/dist/orange_money/src/orange_money/orange_money_fake/orange_money_fake_payment.js.map +1 -0
- package/dist/orange_money/src/orange_money/orange_money_fake/orange_money_fake_payment.spec.d.ts +2 -0
- package/dist/orange_money/src/orange_money/orange_money_fake/orange_money_fake_payment.spec.d.ts.map +1 -0
- package/dist/orange_money/src/orange_money/orange_money_fake/orange_money_fake_payment.spec.js +51 -0
- package/dist/orange_money/src/orange_money/orange_money_fake/orange_money_fake_payment.spec.js.map +1 -0
- package/dist/orange_money/src/orange_money/orange_money_live/mobile_platfom/mobile_platform.d.ts +105 -0
- package/dist/orange_money/src/orange_money/orange_money_live/mobile_platfom/mobile_platform.d.ts.map +1 -0
- package/dist/orange_money/src/orange_money/orange_money_live/mobile_platfom/mobile_platform.js +459 -0
- package/dist/orange_money/src/orange_money/orange_money_live/mobile_platfom/mobile_platform.js.map +1 -0
- package/dist/orange_money/src/orange_money/orange_money_live/mobile_platfom/mobile_platform.spec.d.ts +2 -0
- package/dist/orange_money/src/orange_money/orange_money_live/mobile_platfom/mobile_platform.spec.d.ts.map +1 -0
- package/dist/orange_money/src/orange_money/orange_money_live/mobile_platfom/mobile_platform.spec.js +497 -0
- package/dist/orange_money/src/orange_money/orange_money_live/mobile_platfom/mobile_platform.spec.js.map +1 -0
- package/dist/orange_money/src/orange_money/orange_money_live/orange_money_live_payment.d.ts +26 -0
- package/dist/orange_money/src/orange_money/orange_money_live/orange_money_live_payment.d.ts.map +1 -0
- package/dist/orange_money/src/orange_money/orange_money_live/orange_money_live_payment.js +26 -0
- package/dist/orange_money/src/orange_money/orange_money_live/orange_money_live_payment.js.map +1 -0
- package/dist/orange_money/src/payments/implementations/fake.d.ts +33 -0
- package/dist/orange_money/src/payments/implementations/fake.d.ts.map +1 -0
- package/dist/orange_money/src/payments/implementations/fake.js +110 -0
- package/dist/orange_money/src/payments/implementations/fake.js.map +1 -0
- package/dist/orange_money/src/payments/implementations/live.d.ts +45 -0
- package/dist/orange_money/src/payments/implementations/live.d.ts.map +1 -0
- package/dist/orange_money/src/payments/implementations/live.js +69 -0
- package/dist/orange_money/src/payments/implementations/live.js.map +1 -0
- package/dist/orange_money/src/payments/implementations/payment_service.d.ts +44 -0
- package/dist/orange_money/src/payments/implementations/payment_service.d.ts.map +1 -0
- package/dist/orange_money/src/payments/implementations/payment_service.js +44 -0
- package/dist/orange_money/src/payments/implementations/payment_service.js.map +1 -0
- package/dist/orange_money/src/payments/implementations/src/fake.d.ts +31 -0
- package/dist/orange_money/src/payments/implementations/src/fake.d.ts.map +1 -0
- package/dist/orange_money/src/payments/implementations/src/fake.js +62 -0
- package/dist/orange_money/src/payments/implementations/src/fake.js.map +1 -0
- package/dist/orange_money/src/payments/implementations/src/live.d.ts +29 -0
- package/dist/orange_money/src/payments/implementations/src/live.d.ts.map +1 -0
- package/dist/orange_money/src/payments/implementations/src/live.js +44 -0
- package/dist/orange_money/src/payments/implementations/src/live.js.map +1 -0
- package/dist/orange_money/src/payments/operations/create_access_token.d.ts +19 -0
- package/dist/orange_money/src/payments/operations/create_access_token.d.ts.map +1 -0
- package/dist/orange_money/src/payments/operations/create_access_token.js +51 -0
- package/dist/orange_money/src/payments/operations/create_access_token.js.map +1 -0
- package/dist/orange_money/src/payments/operations/create_access_token.spec.d.ts +2 -0
- package/dist/orange_money/src/payments/operations/create_access_token.spec.d.ts.map +1 -0
- package/dist/orange_money/src/payments/operations/create_access_token.spec.js +70 -0
- package/dist/orange_money/src/payments/operations/create_access_token.spec.js.map +1 -0
- package/dist/orange_money/src/payments/operations/create_pay_token.d.ts +12 -0
- package/dist/orange_money/src/payments/operations/create_pay_token.d.ts.map +1 -0
- package/dist/orange_money/src/payments/operations/create_pay_token.js +62 -0
- package/dist/orange_money/src/payments/operations/create_pay_token.js.map +1 -0
- package/dist/orange_money/src/payments/operations/create_pay_token.spec.d.ts +2 -0
- package/dist/orange_money/src/payments/operations/create_pay_token.spec.d.ts.map +1 -0
- package/dist/orange_money/src/payments/operations/create_pay_token.spec.js +91 -0
- package/dist/orange_money/src/payments/operations/create_pay_token.spec.js.map +1 -0
- package/dist/orange_money/src/payments/operations/get_access_token.d.ts +11 -0
- package/dist/orange_money/src/payments/operations/get_access_token.d.ts.map +1 -0
- package/dist/orange_money/src/payments/operations/get_access_token.js +47 -0
- package/dist/orange_money/src/payments/operations/get_access_token.js.map +1 -0
- package/dist/orange_money/src/payments/operations/get_access_token.spec.d.ts +2 -0
- package/dist/orange_money/src/payments/operations/get_access_token.spec.d.ts.map +1 -0
- package/dist/orange_money/src/payments/operations/get_access_token.spec.js +75 -0
- package/dist/orange_money/src/payments/operations/get_access_token.spec.js.map +1 -0
- package/dist/orange_money/src/payments/operations/get_pay_token.d.ts +12 -0
- package/dist/orange_money/src/payments/operations/get_pay_token.d.ts.map +1 -0
- package/dist/orange_money/src/payments/operations/get_pay_token.js +43 -0
- package/dist/orange_money/src/payments/operations/get_pay_token.js.map +1 -0
- package/dist/orange_money/src/payments/operations/get_pay_token.spec.d.ts +2 -0
- package/dist/orange_money/src/payments/operations/get_pay_token.spec.d.ts.map +1 -0
- package/dist/orange_money/src/payments/operations/get_pay_token.spec.js +75 -0
- package/dist/orange_money/src/payments/operations/get_pay_token.spec.js.map +1 -0
- package/dist/orange_money/src/payments/operations/get_payment_status.d.ts +23 -0
- package/dist/orange_money/src/payments/operations/get_payment_status.d.ts.map +1 -0
- package/dist/orange_money/src/payments/operations/get_payment_status.js +51 -0
- package/dist/orange_money/src/payments/operations/get_payment_status.js.map +1 -0
- package/dist/orange_money/src/payments/operations/get_payment_status.spec.d.ts +2 -0
- package/dist/orange_money/src/payments/operations/get_payment_status.spec.d.ts.map +1 -0
- package/dist/orange_money/src/payments/operations/get_payment_status.spec.js +102 -0
- package/dist/orange_money/src/payments/operations/get_payment_status.spec.js.map +1 -0
- package/dist/orange_money/src/payments/operations/initialize_om_payment.d.ts +22 -0
- package/dist/orange_money/src/payments/operations/initialize_om_payment.d.ts.map +1 -0
- package/dist/orange_money/src/payments/operations/initialize_om_payment.js +124 -0
- package/dist/orange_money/src/payments/operations/initialize_om_payment.js.map +1 -0
- package/dist/orange_money/src/payments/operations/initialize_om_payment.spec.d.ts +2 -0
- package/dist/orange_money/src/payments/operations/initialize_om_payment.spec.d.ts.map +1 -0
- package/dist/orange_money/src/payments/operations/initialize_om_payment.spec.js +246 -0
- package/dist/orange_money/src/payments/operations/initialize_om_payment.spec.js.map +1 -0
- package/dist/orange_money/src/payments/operations/payment.d.ts +21 -0
- package/dist/orange_money/src/payments/operations/payment.d.ts.map +1 -0
- package/dist/orange_money/src/payments/operations/payment.js +204 -0
- package/dist/orange_money/src/payments/operations/payment.js.map +1 -0
- package/dist/orange_money/src/payments/operations/payment.spec.d.ts +2 -0
- package/dist/orange_money/src/payments/operations/payment.spec.d.ts.map +1 -0
- package/dist/orange_money/src/payments/operations/payment.spec.js +282 -0
- package/dist/orange_money/src/payments/operations/payment.spec.js.map +1 -0
- package/dist/orange_money/src/payments/payments.d.ts +57 -0
- package/dist/orange_money/src/payments/payments.d.ts.map +1 -0
- package/dist/orange_money/src/payments/payments.js +36 -0
- package/dist/orange_money/src/payments/payments.js.map +1 -0
- package/dist/orange_money/src/payments/routes/routes.d.ts +48 -0
- package/dist/orange_money/src/payments/routes/routes.d.ts.map +1 -0
- package/dist/orange_money/src/payments/routes/routes.js +61 -0
- package/dist/orange_money/src/payments/routes/routes.js.map +1 -0
- package/dist/orange_money/src/payments/utils/constants.d.ts +100 -0
- package/dist/orange_money/src/payments/utils/constants.d.ts.map +1 -0
- package/dist/orange_money/src/payments/utils/constants.js +117 -0
- package/dist/orange_money/src/payments/utils/constants.js.map +1 -0
- package/dist/orange_money/src/payments/utils/https.d.ts +43 -0
- package/dist/orange_money/src/payments/utils/https.d.ts.map +1 -0
- package/dist/orange_money/src/payments/utils/https.js +137 -0
- package/dist/orange_money/src/payments/utils/https.js.map +1 -0
- package/dist/orange_money/src/payments/utils/joi_schema.d.ts +71 -0
- package/dist/orange_money/src/payments/utils/joi_schema.d.ts.map +1 -0
- package/dist/orange_money/src/payments/utils/joi_schema.js +44 -0
- package/dist/orange_money/src/payments/utils/joi_schema.js.map +1 -0
- package/dist/orange_money/src/payments/utils/logging_interface.d.ts +23 -0
- package/dist/orange_money/src/payments/utils/logging_interface.d.ts.map +1 -0
- package/dist/orange_money/src/payments/utils/logging_interface.js +3 -0
- package/dist/orange_money/src/payments/utils/logging_interface.js.map +1 -0
- package/dist/orange_money/src/payments/utils/request_model.d.ts +75 -0
- package/dist/orange_money/src/payments/utils/request_model.d.ts.map +1 -0
- package/dist/orange_money/src/payments/utils/request_model.js +3 -0
- package/dist/orange_money/src/payments/utils/request_model.js.map +1 -0
- package/dist/orange_money/src/payments/utils/utils.d.ts +15 -0
- package/dist/orange_money/src/payments/utils/utils.d.ts.map +1 -0
- package/dist/orange_money/src/payments/utils/utils.js +27 -0
- package/dist/orange_money/src/payments/utils/utils.js.map +1 -0
- package/dist/orange_money/src/payments/utils/utils.spec.d.ts +2 -0
- package/dist/orange_money/src/payments/utils/utils.spec.d.ts.map +1 -0
- package/dist/orange_money/src/payments/utils/utils.spec.js +17 -0
- package/dist/orange_money/src/payments/utils/utils.spec.js.map +1 -0
- package/dist/orange_money/src/utils/logging_interface.d.ts +23 -0
- package/dist/orange_money/src/utils/logging_interface.d.ts.map +1 -0
- package/dist/orange_money/src/utils/logging_interface.js +3 -0
- package/dist/orange_money/src/utils/logging_interface.js.map +1 -0
- package/dist/orange_money/src/utils/requests_responses.d.ts +118 -0
- package/dist/orange_money/src/utils/requests_responses.d.ts.map +1 -0
- package/dist/orange_money/src/utils/requests_responses.js +31 -0
- package/dist/orange_money/src/utils/requests_responses.js.map +1 -0
- package/dist/orange_money/src/utils/resquest_params.d.ts +222 -0
- package/dist/orange_money/src/utils/resquest_params.d.ts.map +1 -0
- package/dist/orange_money/src/utils/resquest_params.js +57 -0
- package/dist/orange_money/src/utils/resquest_params.js.map +1 -0
- package/dist/orange_money/src/utils/utils.d.ts +65 -0
- package/dist/orange_money/src/utils/utils.d.ts.map +1 -0
- package/dist/orange_money/src/utils/utils.js +199 -0
- package/dist/orange_money/src/utils/utils.js.map +1 -0
- package/dist/orange_money/src/utils/utils.spec.d.ts +2 -0
- package/dist/orange_money/src/utils/utils.spec.d.ts.map +1 -0
- package/dist/orange_money/src/utils/utils.spec.js +17 -0
- package/dist/orange_money/src/utils/utils.spec.js.map +1 -0
- package/index.spec.ts +9 -0
- package/index.ts +1 -0
- package/jest.before-test.ts +3 -0
- package/jest.config.ts +54 -0
- package/package.json +52 -0
- package/src/disbursements/implementations/disbursement_service.ts +133 -0
- package/src/disbursements/implementations/src/live.ts +79 -0
- package/src/disbursements/implementations/src/sandbox.ts +124 -0
- package/src/disbursements/operations/create_access_token.spec.ts +87 -0
- package/src/disbursements/operations/create_access_token.ts +83 -0
- package/src/disbursements/operations/get_transfer_status.spec.ts +132 -0
- package/src/disbursements/operations/get_transfer_status.ts +265 -0
- package/src/disbursements/operations/transfer.spec.ts +158 -0
- package/src/disbursements/operations/transfer.ts +125 -0
- package/src/disbursements/routes/routes.ts +54 -0
- package/src/disbursements/utils/constants.ts +4 -0
- package/src/disbursements/utils/regex.spec.ts +39 -0
- package/src/disbursements/utils/regex.ts +10 -0
- package/src/disbursements/utils/status.ts +62 -0
- package/src/disbursements/utils/utils.spec.ts +42 -0
- package/src/disbursements/utils/utils.ts +24 -0
- package/src/index.ts +9 -0
- package/src/payments/implementations/fake.ts +133 -0
- package/src/payments/implementations/live.ts +87 -0
- package/src/payments/operations/get_access_token.spec.ts +60 -0
- package/src/payments/operations/get_access_token.ts +77 -0
- package/src/payments/operations/get_pay_token.spec.ts +65 -0
- package/src/payments/operations/get_pay_token.ts +66 -0
- package/src/payments/operations/get_payment_status.spec.ts +82 -0
- package/src/payments/operations/get_payment_status.ts +78 -0
- package/src/payments/operations/initialize_om_payment.spec.ts +234 -0
- package/src/payments/operations/initialize_om_payment.ts +191 -0
- package/src/payments/payments.ts +86 -0
- package/src/payments/routes/routes.ts +61 -0
- package/src/payments/utils/constants.ts +120 -0
- package/src/payments/utils/joi_schema.ts +117 -0
- package/src/payments/utils/request_model.ts +103 -0
- package/src/payments/utils/utils.ts +31 -0
- package/src/utils/https.spec.ts +101 -0
- package/src/utils/https.ts +266 -0
- package/src/utils/logging_interface.ts +25 -0
- package/src/utils/operation_response.ts +17 -0
- package/src/utils/utils.ts +5 -0
- package/tsconfig.build.json +4 -0
- package/tsconfig.dev.json +4 -0
- package/tsconfig.json +27 -0
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import * as requests from '../../utils/https';
|
|
2
|
+
import { OrangeMoneyPaymentStatus } from '../utils/constants';
|
|
3
|
+
|
|
4
|
+
import { TargetEnvironment } from '../../utils/utils';
|
|
5
|
+
import { GetOrangeMoneyPaymentRequest } from '../utils/request_model';
|
|
6
|
+
import { getPaymentStatus } from './get_payment_status';
|
|
7
|
+
|
|
8
|
+
const logger = console;
|
|
9
|
+
describe('Test the status verification', () => {
|
|
10
|
+
const mobilePaymentParamForCheckStatus: GetOrangeMoneyPaymentRequest = {
|
|
11
|
+
accessToken: '1e23bee1-37dc-3015-a7d6-cb70e566bd64',
|
|
12
|
+
payToken: 'MP220807558VEF7A9C4F09AED',
|
|
13
|
+
};
|
|
14
|
+
it('Return the payment status', async () => {
|
|
15
|
+
jest.spyOn(requests, 'getRequest').mockResolvedValue({
|
|
16
|
+
response: {
|
|
17
|
+
status: 200,
|
|
18
|
+
data: {
|
|
19
|
+
message: 'Transaction retrieved successfully',
|
|
20
|
+
data: {
|
|
21
|
+
id: 74581010,
|
|
22
|
+
createtime: '1682001669',
|
|
23
|
+
subscriberMsisdn: '655637944',
|
|
24
|
+
amount: 1100,
|
|
25
|
+
payToken: 'MP23042031A1724A914DF0382D01',
|
|
26
|
+
txnid: 'MP230420.1541.C39196',
|
|
27
|
+
txnmode: 'zSapffVPWccheVZQRtvG',
|
|
28
|
+
inittxnmessage:
|
|
29
|
+
'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.',
|
|
30
|
+
inittxnstatus: '200',
|
|
31
|
+
confirmtxnstatus: '200',
|
|
32
|
+
confirmtxnmessage:
|
|
33
|
+
'Paiement de SPREELOOP reussi par 655637944 PEKE. ID transaction:MP230420.1541.C39196, Montant:1100 FCFA. Solde: 55.81 FCFA.',
|
|
34
|
+
status: 'SUCCESSFULL',
|
|
35
|
+
notifUrl:
|
|
36
|
+
'https://europe-west1-place-prod.cloudfunctions.net/api-1/payment/orange_money/live/zSapffVPWccheVZQRtvG',
|
|
37
|
+
description: 'Commande',
|
|
38
|
+
channelUserMsisdn: '696431937',
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
});
|
|
43
|
+
const result = await getPaymentStatus({
|
|
44
|
+
mobileStatusVerificationParams: mobilePaymentParamForCheckStatus,
|
|
45
|
+
paymentServiceConfig: {
|
|
46
|
+
targetEnvironment: TargetEnvironment.fake,
|
|
47
|
+
xAuthToken: 'ABCDEGHIJKLMNOPQRSTUVW',
|
|
48
|
+
apiUserName: 'secret',
|
|
49
|
+
apiPassword: 'secret',
|
|
50
|
+
logger: logger,
|
|
51
|
+
},
|
|
52
|
+
endPoint: 'https://api.paytoken.co',
|
|
53
|
+
});
|
|
54
|
+
expect(result.data?.status).toBe(
|
|
55
|
+
OrangeMoneyPaymentStatus.SUCCESSFULL_MOBILE_PAYMENT
|
|
56
|
+
);
|
|
57
|
+
});
|
|
58
|
+
it('Return the error response', async () => {
|
|
59
|
+
jest.spyOn(requests, 'getRequest').mockResolvedValue({
|
|
60
|
+
error: {
|
|
61
|
+
responseError: {
|
|
62
|
+
data: [Object],
|
|
63
|
+
status: 401,
|
|
64
|
+
statusText: 'Unauthorized',
|
|
65
|
+
headers: null,
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
});
|
|
69
|
+
const result = await getPaymentStatus({
|
|
70
|
+
mobileStatusVerificationParams: mobilePaymentParamForCheckStatus,
|
|
71
|
+
paymentServiceConfig: {
|
|
72
|
+
targetEnvironment: TargetEnvironment.fake,
|
|
73
|
+
xAuthToken: 'ABCDEGHIJKLMNOPQRSTUVW',
|
|
74
|
+
apiUserName: 'secret',
|
|
75
|
+
apiPassword: 'secret',
|
|
76
|
+
logger: logger,
|
|
77
|
+
},
|
|
78
|
+
endPoint: 'https://api.paytoken.co',
|
|
79
|
+
});
|
|
80
|
+
expect(result.error).toBeDefined();
|
|
81
|
+
});
|
|
82
|
+
});
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { getRequest, isSuccessfulCodeResponse } from '../../utils/https';
|
|
2
|
+
import { ApiErrorType, ApiKey, ConstantRequestField } from '../utils/constants';
|
|
3
|
+
import {
|
|
4
|
+
GenericRequestResponseData,
|
|
5
|
+
OrangeMoneyPaymentParams,
|
|
6
|
+
} from '../utils/joi_schema';
|
|
7
|
+
import {
|
|
8
|
+
GetOrangeMoneyPaymentRequest,
|
|
9
|
+
GetOrangeMoneyPaymentResponse,
|
|
10
|
+
} from '../utils/request_model';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Gets the mobile payment status.
|
|
14
|
+
*
|
|
15
|
+
* @param {Object} options - The options object.
|
|
16
|
+
* @param {GetOrangeMoneyPaymentRequest} options.mobileStatusVerificationParams - The parameters for mobile status verification.
|
|
17
|
+
* @param {string} endPoint - The init payment end point.
|
|
18
|
+
* @param {OrangeMoneyPaymentParams} paymentServiceConfig - The mobile payment config parameters.
|
|
19
|
+
* - {TargetEnvironment} PaymentServiceConfig.targetEnvironment - The target environment.
|
|
20
|
+
* - {string} PaymentServiceConfig.apiUserName - The api user name.
|
|
21
|
+
* - {string} PaymentServiceConfig.xAuthToken - The x-auth-token.
|
|
22
|
+
* - {string} PaymentServiceConfig.apiPassword - The api password.
|
|
23
|
+
* - {string} [PaymentServiceConfig.orangeMoneyVersion] - The orange money version.
|
|
24
|
+
* - {LoggerInterface} PaymentServiceConfig.logger - The logger interface.
|
|
25
|
+
* @return {Promise<GetOrangeMoneyPaymentResponse>} The promise that resolves to the mobile payment check status response.
|
|
26
|
+
*/
|
|
27
|
+
export async function getPaymentStatus({
|
|
28
|
+
mobileStatusVerificationParams,
|
|
29
|
+
paymentServiceConfig,
|
|
30
|
+
endPoint,
|
|
31
|
+
}: {
|
|
32
|
+
mobileStatusVerificationParams: GetOrangeMoneyPaymentRequest;
|
|
33
|
+
paymentServiceConfig: OrangeMoneyPaymentParams;
|
|
34
|
+
endPoint: string;
|
|
35
|
+
}): Promise<GetOrangeMoneyPaymentResponse> {
|
|
36
|
+
const logger = paymentServiceConfig.logger;
|
|
37
|
+
|
|
38
|
+
const headers = {
|
|
39
|
+
[ApiKey.keyAuthorization]: `Bearer ${mobileStatusVerificationParams.accessToken}`,
|
|
40
|
+
[ApiKey.keyContentType]: ConstantRequestField.typeJson,
|
|
41
|
+
[ApiKey.keyXAuthToken]: paymentServiceConfig.xAuthToken,
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
logger.info(
|
|
45
|
+
`[ORANGE MONEY] Checks the ORANGE MONEY Payment status with route: ${endPoint}`
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
const response = await getRequest<GenericRequestResponseData>({
|
|
49
|
+
headers: headers,
|
|
50
|
+
route: endPoint,
|
|
51
|
+
logger: logger,
|
|
52
|
+
});
|
|
53
|
+
const responseData = response?.response;
|
|
54
|
+
|
|
55
|
+
if (responseData && isSuccessfulCodeResponse(responseData.status)) {
|
|
56
|
+
logger.log(
|
|
57
|
+
`[ORANGE MONEY] Status verification successful with result ${JSON.stringify(
|
|
58
|
+
responseData.data
|
|
59
|
+
)}`
|
|
60
|
+
);
|
|
61
|
+
return {
|
|
62
|
+
data: {
|
|
63
|
+
status: responseData.data.data.status,
|
|
64
|
+
},
|
|
65
|
+
raw: responseData.data,
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
logger.warn(
|
|
70
|
+
`[ORANGE MONEY] Status verification failed with error data: ${JSON.stringify(
|
|
71
|
+
response.error
|
|
72
|
+
)}`
|
|
73
|
+
);
|
|
74
|
+
return {
|
|
75
|
+
raw: response.error,
|
|
76
|
+
error: ApiErrorType.failedToCheckPaymentStatus,
|
|
77
|
+
};
|
|
78
|
+
}
|
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
import * as requests from '../../utils/https';
|
|
2
|
+
import { ApiErrorType } from '../utils/constants';
|
|
3
|
+
|
|
4
|
+
import { TargetEnvironment } from '../../utils/utils';
|
|
5
|
+
import { InitializeOrangeMoneyRequest } from '../utils/request_model';
|
|
6
|
+
import { initializeOmPayment } from './initialize_om_payment';
|
|
7
|
+
|
|
8
|
+
const logger = console;
|
|
9
|
+
|
|
10
|
+
describe('Test the initialization of payment', () => {
|
|
11
|
+
const mobileInitiateParams: InitializeOrangeMoneyRequest = {
|
|
12
|
+
amount: 100,
|
|
13
|
+
notifUrl: 'https://localhost',
|
|
14
|
+
transactionId: '1',
|
|
15
|
+
pinCode: '123',
|
|
16
|
+
channelUserNumber: '698526541',
|
|
17
|
+
subscriberNumber: '698526541',
|
|
18
|
+
accessToken: '1e23bee1-37dc-3015-a7d6-cb70e566bd64',
|
|
19
|
+
payToken: 'MP220807558VEF7A9C4F09AED',
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
it('Initialization failed cause of invalid channel number', async () => {
|
|
23
|
+
jest.spyOn(requests, 'postRequest').mockImplementationOnce(() =>
|
|
24
|
+
Promise.resolve({
|
|
25
|
+
response: {
|
|
26
|
+
status: 417,
|
|
27
|
+
data: {
|
|
28
|
+
message: '60019 :: Le solde du compte du payeur est insuffisant',
|
|
29
|
+
data: {
|
|
30
|
+
id: 75742131,
|
|
31
|
+
createtime: '1682612128',
|
|
32
|
+
subscriberMsisdn: '696689073',
|
|
33
|
+
amount: 90,
|
|
34
|
+
payToken: 'MP2304270429730CE5AC78D276A6',
|
|
35
|
+
txnid: null,
|
|
36
|
+
txnmode: '84d1uhuhiuhiliubi',
|
|
37
|
+
inittxnmessage: 'Le solde du compte du payeur est insuffisant',
|
|
38
|
+
inittxnstatus: '60019',
|
|
39
|
+
confirmtxnstatus: null,
|
|
40
|
+
confirmtxnmessage: null,
|
|
41
|
+
status: 'FAILED',
|
|
42
|
+
notifUrl: '',
|
|
43
|
+
description: '',
|
|
44
|
+
channelUserMsisdn: '696431937',
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
})
|
|
49
|
+
);
|
|
50
|
+
const result = await initializeOmPayment({
|
|
51
|
+
mobileInitParams: {
|
|
52
|
+
transactionId: mobileInitiateParams.transactionId,
|
|
53
|
+
amount: mobileInitiateParams.amount,
|
|
54
|
+
subscriberNumber: mobileInitiateParams.subscriberNumber,
|
|
55
|
+
notifUrl: mobileInitiateParams.notifUrl,
|
|
56
|
+
description: mobileInitiateParams.description,
|
|
57
|
+
pinCode: mobileInitiateParams.pinCode,
|
|
58
|
+
channelUserNumber: '688526541',
|
|
59
|
+
payToken: mobileInitiateParams.payToken,
|
|
60
|
+
accessToken: mobileInitiateParams.accessToken,
|
|
61
|
+
},
|
|
62
|
+
paymentConfig: {
|
|
63
|
+
orangeMoneyVersion: '1.2.0',
|
|
64
|
+
apiPassword: 'secret',
|
|
65
|
+
apiUserName: 'secret',
|
|
66
|
+
xAuthToken: 'ABCDEGHIJKLMNOPQRSTUVW',
|
|
67
|
+
targetEnvironment: TargetEnvironment.fake,
|
|
68
|
+
logger: logger,
|
|
69
|
+
},
|
|
70
|
+
endPoint: 'https://api.paytoken.co',
|
|
71
|
+
});
|
|
72
|
+
expect(result.error).toEqual(ApiErrorType.failedToInitiateThePayment);
|
|
73
|
+
});
|
|
74
|
+
it('Initialization failed cause of insufficient balance', async () => {
|
|
75
|
+
jest.spyOn(requests, 'postRequest').mockImplementationOnce(() =>
|
|
76
|
+
Promise.resolve({
|
|
77
|
+
response: {
|
|
78
|
+
status: 417,
|
|
79
|
+
data: {
|
|
80
|
+
message: '60019 :: Le solde du compte du payeur est insuffisant',
|
|
81
|
+
data: {
|
|
82
|
+
id: 75742131,
|
|
83
|
+
createtime: '1682612128',
|
|
84
|
+
subscriberMsisdn: '696689073',
|
|
85
|
+
amount: 90,
|
|
86
|
+
payToken: 'MP2304270429730CE5AC78D276A6',
|
|
87
|
+
txnid: null,
|
|
88
|
+
txnmode: '84d1uhuhiuhiliubi',
|
|
89
|
+
inittxnmessage: 'Le solde du compte du payeur est insuffisant',
|
|
90
|
+
inittxnstatus: '60019',
|
|
91
|
+
confirmtxnstatus: null,
|
|
92
|
+
confirmtxnmessage: null,
|
|
93
|
+
status: 'FAILED',
|
|
94
|
+
notifUrl: '',
|
|
95
|
+
description: '',
|
|
96
|
+
channelUserMsisdn: '696431937',
|
|
97
|
+
},
|
|
98
|
+
},
|
|
99
|
+
},
|
|
100
|
+
})
|
|
101
|
+
);
|
|
102
|
+
const result = await initializeOmPayment({
|
|
103
|
+
mobileInitParams: {
|
|
104
|
+
transactionId: mobileInitiateParams.transactionId,
|
|
105
|
+
amount: mobileInitiateParams.amount,
|
|
106
|
+
subscriberNumber: mobileInitiateParams.subscriberNumber,
|
|
107
|
+
notifUrl: mobileInitiateParams.notifUrl,
|
|
108
|
+
description: mobileInitiateParams.description,
|
|
109
|
+
pinCode: mobileInitiateParams.pinCode,
|
|
110
|
+
channelUserNumber: mobileInitiateParams.channelUserNumber,
|
|
111
|
+
payToken: mobileInitiateParams.payToken,
|
|
112
|
+
accessToken: mobileInitiateParams.accessToken,
|
|
113
|
+
},
|
|
114
|
+
paymentConfig: {
|
|
115
|
+
orangeMoneyVersion: '1.2.0',
|
|
116
|
+
apiPassword: 'secret',
|
|
117
|
+
apiUserName: 'secret',
|
|
118
|
+
xAuthToken: 'ABCDEGHIJKLMNOPQRSTUVW',
|
|
119
|
+
targetEnvironment: TargetEnvironment.fake,
|
|
120
|
+
logger: logger,
|
|
121
|
+
},
|
|
122
|
+
endPoint: 'https://api.paytoken.co',
|
|
123
|
+
});
|
|
124
|
+
expect(result.error).toEqual(ApiErrorType.insufficientFunds);
|
|
125
|
+
});
|
|
126
|
+
it('Initialization failed cause of account blocked ', async () => {
|
|
127
|
+
jest.spyOn(requests, 'postRequest').mockImplementationOnce(() =>
|
|
128
|
+
Promise.resolve({
|
|
129
|
+
response: {
|
|
130
|
+
status: 417,
|
|
131
|
+
data: {
|
|
132
|
+
message: '60019 :: Utilisateur bloque',
|
|
133
|
+
data: {
|
|
134
|
+
id: 75742131,
|
|
135
|
+
createtime: '1682612128',
|
|
136
|
+
subscriberMsisdn: '237696689073',
|
|
137
|
+
amount: 90,
|
|
138
|
+
payToken: 'MP2304270429730CE5AC78D276A6',
|
|
139
|
+
txnid: null,
|
|
140
|
+
txnmode: '84d1uhuhiuhiliubi',
|
|
141
|
+
inittxnmessage: 'Utilisateur bloque',
|
|
142
|
+
inittxnstatus: '60019',
|
|
143
|
+
confirmtxnstatus: null,
|
|
144
|
+
confirmtxnmessage: null,
|
|
145
|
+
status: 'FAILED',
|
|
146
|
+
notifUrl: '',
|
|
147
|
+
description: '',
|
|
148
|
+
channelUserMsisdn: '696431937',
|
|
149
|
+
},
|
|
150
|
+
},
|
|
151
|
+
},
|
|
152
|
+
})
|
|
153
|
+
);
|
|
154
|
+
const result = await initializeOmPayment({
|
|
155
|
+
mobileInitParams: {
|
|
156
|
+
transactionId: mobileInitiateParams.transactionId,
|
|
157
|
+
amount: mobileInitiateParams.amount,
|
|
158
|
+
subscriberNumber: mobileInitiateParams.subscriberNumber,
|
|
159
|
+
notifUrl: mobileInitiateParams.notifUrl,
|
|
160
|
+
description: mobileInitiateParams.description,
|
|
161
|
+
pinCode: mobileInitiateParams.pinCode,
|
|
162
|
+
channelUserNumber: mobileInitiateParams.channelUserNumber,
|
|
163
|
+
payToken: mobileInitiateParams.payToken,
|
|
164
|
+
accessToken: mobileInitiateParams.accessToken,
|
|
165
|
+
},
|
|
166
|
+
paymentConfig: {
|
|
167
|
+
orangeMoneyVersion: '1.2.0',
|
|
168
|
+
apiPassword: 'secret',
|
|
169
|
+
apiUserName: 'secret',
|
|
170
|
+
xAuthToken: 'ABCDEGHIJKLMNOPQRSTUVW',
|
|
171
|
+
targetEnvironment: TargetEnvironment.fake,
|
|
172
|
+
logger: logger,
|
|
173
|
+
},
|
|
174
|
+
endPoint: 'https://api.paytoken.co',
|
|
175
|
+
});
|
|
176
|
+
expect(result.error).toEqual(ApiErrorType.accountLocked);
|
|
177
|
+
});
|
|
178
|
+
|
|
179
|
+
it('Initialization Successful', async () => {
|
|
180
|
+
jest.spyOn(requests, 'postRequest').mockImplementationOnce(() =>
|
|
181
|
+
Promise.resolve({
|
|
182
|
+
response: {
|
|
183
|
+
status: 200,
|
|
184
|
+
data: {
|
|
185
|
+
message: 'Payment request successfully initiated',
|
|
186
|
+
data: {
|
|
187
|
+
id: 75742131,
|
|
188
|
+
createtime: '1682612128',
|
|
189
|
+
subscriberMsisdn: '237696689073',
|
|
190
|
+
amount: 90,
|
|
191
|
+
payToken: 'MP2304270429730CE5AC78D276A6',
|
|
192
|
+
txnid: null,
|
|
193
|
+
txnmode: '84d1uhuhiuhiliubi',
|
|
194
|
+
inittxnmessage:
|
|
195
|
+
'Vous avez saisi un montant superieur au montant maximum autorise',
|
|
196
|
+
inittxnstatus: '60019',
|
|
197
|
+
confirmtxnstatus: null,
|
|
198
|
+
confirmtxnmessage: null,
|
|
199
|
+
status: 'PENDING',
|
|
200
|
+
notifUrl: '',
|
|
201
|
+
description: '',
|
|
202
|
+
channelUserMsisdn: '696431937',
|
|
203
|
+
},
|
|
204
|
+
},
|
|
205
|
+
},
|
|
206
|
+
})
|
|
207
|
+
);
|
|
208
|
+
const result = await initializeOmPayment({
|
|
209
|
+
mobileInitParams: {
|
|
210
|
+
transactionId: mobileInitiateParams.transactionId,
|
|
211
|
+
amount: mobileInitiateParams.amount,
|
|
212
|
+
subscriberNumber: mobileInitiateParams.subscriberNumber,
|
|
213
|
+
notifUrl: mobileInitiateParams.notifUrl,
|
|
214
|
+
description: mobileInitiateParams.description,
|
|
215
|
+
pinCode: mobileInitiateParams.pinCode,
|
|
216
|
+
channelUserNumber: mobileInitiateParams.channelUserNumber,
|
|
217
|
+
payToken: mobileInitiateParams.payToken,
|
|
218
|
+
accessToken: mobileInitiateParams.accessToken,
|
|
219
|
+
},
|
|
220
|
+
paymentConfig: {
|
|
221
|
+
orangeMoneyVersion: '1.2.0',
|
|
222
|
+
apiPassword: 'secret',
|
|
223
|
+
apiUserName: 'secret',
|
|
224
|
+
xAuthToken: 'ABCDEGHIJKLMNOPQRSTUVW',
|
|
225
|
+
targetEnvironment: TargetEnvironment.fake,
|
|
226
|
+
logger: logger,
|
|
227
|
+
},
|
|
228
|
+
endPoint: 'https://api.paytoken.co',
|
|
229
|
+
});
|
|
230
|
+
expect(result.data).toStrictEqual({
|
|
231
|
+
payToken: 'MP220807558VEF7A9C4F09AED',
|
|
232
|
+
});
|
|
233
|
+
});
|
|
234
|
+
});
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
import {
|
|
2
|
+
RequestResponse,
|
|
3
|
+
RequestStatusCode,
|
|
4
|
+
isSuccessfulCodeResponse,
|
|
5
|
+
postRequest,
|
|
6
|
+
} from '../../utils/https';
|
|
7
|
+
import { Routes } from '../routes/routes';
|
|
8
|
+
import {
|
|
9
|
+
ApiErrorType,
|
|
10
|
+
ApiKey,
|
|
11
|
+
ConstantRequestField,
|
|
12
|
+
OrangeMoneyErrorMessage,
|
|
13
|
+
} from '../utils/constants';
|
|
14
|
+
import {
|
|
15
|
+
GenericRequestResponseData,
|
|
16
|
+
InitPaymentBodySchema,
|
|
17
|
+
OrangeMoneyPaymentParams,
|
|
18
|
+
initPaymentBodySchema,
|
|
19
|
+
} from '../utils/joi_schema';
|
|
20
|
+
import {
|
|
21
|
+
InitializeOrangeMoneyRequest,
|
|
22
|
+
InitializeOrangeMoneyResponse,
|
|
23
|
+
} from '../utils/request_model';
|
|
24
|
+
import { validateData } from '../utils/utils';
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Initiates the payment.
|
|
28
|
+
*
|
|
29
|
+
* @param {InitializeOmPaymentRequest} mobileInitParams - The mobile initialization parameters.
|
|
30
|
+
* @param {string} endPoint - The init payment end point.
|
|
31
|
+
* @param {OrangeMoneyPaymentParams} paymentConfig - The mobile payment config parameters.
|
|
32
|
+
* - {TargetEnvironment} paymentConfig.targetEnvironment - The target environment.
|
|
33
|
+
* - {string} paymentConfig.apiUserName - The api user name.
|
|
34
|
+
* - {string} paymentConfig.xAuthToken - The x-auth-token.
|
|
35
|
+
* - {string} paymentConfig.apiPassword - The api password.
|
|
36
|
+
* - {string} [paymentConfig.orangeMoneyVersion] - The orange money version.
|
|
37
|
+
* - {LoggerInterface} paymentConfig.logger - The logger interface.
|
|
38
|
+
* @return {Promise<InitializeOrangeMoneyResponse>} The promise that resolves to the mobile payment initialization response.
|
|
39
|
+
*/
|
|
40
|
+
export async function initializeOmPayment({
|
|
41
|
+
mobileInitParams,
|
|
42
|
+
paymentConfig,
|
|
43
|
+
endPoint,
|
|
44
|
+
}: {
|
|
45
|
+
mobileInitParams: InitializeOrangeMoneyRequest;
|
|
46
|
+
paymentConfig: OrangeMoneyPaymentParams;
|
|
47
|
+
endPoint: string;
|
|
48
|
+
}): Promise<InitializeOrangeMoneyResponse> {
|
|
49
|
+
const logger = paymentConfig.logger;
|
|
50
|
+
|
|
51
|
+
const paymentParams = {
|
|
52
|
+
mobileInitParams: mobileInitParams,
|
|
53
|
+
paymentConfig: paymentConfig,
|
|
54
|
+
endPoint: endPoint,
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
const response = await initializeOmPaymentInternal(paymentParams);
|
|
58
|
+
|
|
59
|
+
if (response.schemaErrorMessage) {
|
|
60
|
+
logger.warn(
|
|
61
|
+
`[ORANGE MONEY] Initialization failed with error data: ${JSON.stringify(
|
|
62
|
+
response.schemaErrorMessage
|
|
63
|
+
)}`
|
|
64
|
+
);
|
|
65
|
+
return {
|
|
66
|
+
raw: response.schemaErrorMessage,
|
|
67
|
+
error: ApiErrorType.failedToInitiateThePayment,
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
const requestResponse = response.requestResult?.response;
|
|
72
|
+
|
|
73
|
+
if (requestResponse && isSuccessfulCodeResponse(requestResponse.status)) {
|
|
74
|
+
logger.info(
|
|
75
|
+
`[ORANGE MONEY] Initialization successful with result ${JSON.stringify(
|
|
76
|
+
requestResponse.data
|
|
77
|
+
)}`
|
|
78
|
+
);
|
|
79
|
+
return {
|
|
80
|
+
data: {
|
|
81
|
+
payToken: mobileInitParams.payToken,
|
|
82
|
+
},
|
|
83
|
+
raw: requestResponse.data,
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
if (
|
|
87
|
+
requestResponse &&
|
|
88
|
+
requestResponse.status === RequestStatusCode.expectationFailed
|
|
89
|
+
) {
|
|
90
|
+
const errorData = requestResponse.data.data;
|
|
91
|
+
|
|
92
|
+
logger.warn(
|
|
93
|
+
`[ORANGE MONEY] Initialization failed failed. Raison: ${errorData.inittxnmessage}`
|
|
94
|
+
);
|
|
95
|
+
return {
|
|
96
|
+
raw: requestResponse.data,
|
|
97
|
+
error: getApiErrorMessage(errorData.inittxnmessage),
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
logger.warn(
|
|
102
|
+
`[ORANGE MONEY] Initialization failed with error data: ${JSON.stringify(
|
|
103
|
+
response.requestResult?.error
|
|
104
|
+
)}`
|
|
105
|
+
);
|
|
106
|
+
|
|
107
|
+
return {
|
|
108
|
+
error: ApiErrorType.failedToInitiateThePayment,
|
|
109
|
+
raw: response.requestResult?.error,
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Makes a payment request using the provided parameters.
|
|
115
|
+
*
|
|
116
|
+
* @param {Object} params - An object containing the following parameters:
|
|
117
|
+
* - {MobileInitPaymentParams} mobileInitParams: The mobile initialization parameters.
|
|
118
|
+
* - {PaymentConfig} paymentConfig - The mobile payment config parameters.
|
|
119
|
+
* - {string} endPoint: The init payment end point.
|
|
120
|
+
* @return {Promise} A promise that resolves to the payment request response.
|
|
121
|
+
*/
|
|
122
|
+
const initializeOmPaymentInternal = async (params: {
|
|
123
|
+
mobileInitParams: InitializeOrangeMoneyRequest;
|
|
124
|
+
paymentConfig: OrangeMoneyPaymentParams;
|
|
125
|
+
endPoint: string;
|
|
126
|
+
}): Promise<{
|
|
127
|
+
requestResult?: RequestResponse<GenericRequestResponseData>;
|
|
128
|
+
schemaErrorMessage?: string;
|
|
129
|
+
}> => {
|
|
130
|
+
const routes = new Routes(params.paymentConfig.orangeMoneyVersion);
|
|
131
|
+
const headers = {
|
|
132
|
+
[ApiKey.keyAuthorization]: `Bearer ${params.mobileInitParams.accessToken}`,
|
|
133
|
+
[ApiKey.keyContentType]: ConstantRequestField.typeJson,
|
|
134
|
+
[ApiKey.keyXAuthToken]: params.paymentConfig.xAuthToken,
|
|
135
|
+
};
|
|
136
|
+
const body = {
|
|
137
|
+
[ApiKey.keySubscriberMsisdn]: params.mobileInitParams.subscriberNumber,
|
|
138
|
+
[ApiKey.keyChannelUserMsisdn]: params.mobileInitParams.channelUserNumber,
|
|
139
|
+
[ApiKey.keyAmount]: params.mobileInitParams.amount.toString(),
|
|
140
|
+
[ApiKey.keyDescription]: params.mobileInitParams.description,
|
|
141
|
+
[ApiKey.keyMobileOrderId]: params.mobileInitParams.transactionId,
|
|
142
|
+
[ApiKey.keyPin]: params.mobileInitParams.pinCode,
|
|
143
|
+
[ApiKey.keyMobilePayToken]: params.mobileInitParams.payToken,
|
|
144
|
+
[ApiKey.keyMobileNotifUrl]: params.mobileInitParams.notifUrl,
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
const dataValidation = validateData<InitPaymentBodySchema>(
|
|
148
|
+
body,
|
|
149
|
+
initPaymentBodySchema
|
|
150
|
+
);
|
|
151
|
+
|
|
152
|
+
if (!dataValidation.isValidData) {
|
|
153
|
+
return { schemaErrorMessage: dataValidation.message };
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
params.paymentConfig.logger.info(
|
|
157
|
+
`Initiate the ORANGE MONEY Payment with data: ${JSON.stringify(
|
|
158
|
+
body
|
|
159
|
+
)}\nroute: ${routes.mobileInitPayment()}`
|
|
160
|
+
);
|
|
161
|
+
|
|
162
|
+
const response = await postRequest<GenericRequestResponseData>({
|
|
163
|
+
logger: params.paymentConfig.logger,
|
|
164
|
+
headers: headers,
|
|
165
|
+
data: body,
|
|
166
|
+
route: routes.mobileInitPayment(),
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
return { requestResult: response };
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* Maps an API error message to the corresponding API error type.
|
|
174
|
+
*
|
|
175
|
+
* @param {string} message - the error message to map
|
|
176
|
+
* @return {ApiErrorType} the corresponding API error type
|
|
177
|
+
*/
|
|
178
|
+
const getApiErrorMessage = (message: string): ApiErrorType => {
|
|
179
|
+
switch (message) {
|
|
180
|
+
case OrangeMoneyErrorMessage.beneficiaryNotFound:
|
|
181
|
+
return ApiErrorType.invalidOrangeMoneyNumber;
|
|
182
|
+
case OrangeMoneyErrorMessage.insufficientFunds:
|
|
183
|
+
return ApiErrorType.insufficientFunds;
|
|
184
|
+
case OrangeMoneyErrorMessage.accountLocked:
|
|
185
|
+
return ApiErrorType.accountLocked;
|
|
186
|
+
case OrangeMoneyErrorMessage.invalidPaymentAmount:
|
|
187
|
+
return ApiErrorType.invalidPaymentAmount;
|
|
188
|
+
default:
|
|
189
|
+
return ApiErrorType.failedToInitiateThePayment;
|
|
190
|
+
}
|
|
191
|
+
};
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { TargetEnvironment } from '../utils/utils';
|
|
2
|
+
import { OrangeMoneyPaymentFake } from './implementations/fake';
|
|
3
|
+
import { OrangeMoneyPaymentLive } from './implementations/live';
|
|
4
|
+
import { OrangeMoneyPaymentParams } from './utils/joi_schema';
|
|
5
|
+
import {
|
|
6
|
+
GetAccessTokenResponse,
|
|
7
|
+
GetOrangeMoneyPaymentRequest,
|
|
8
|
+
GetOrangeMoneyPaymentResponse,
|
|
9
|
+
GetPayTokenResponse,
|
|
10
|
+
InitializeOrangeMoneyRequest,
|
|
11
|
+
InitializeOrangeMoneyResponse,
|
|
12
|
+
} from './utils/request_model';
|
|
13
|
+
|
|
14
|
+
export interface OrangeMoneyPaymentInterface {
|
|
15
|
+
/**
|
|
16
|
+
* Gets the pay token token.
|
|
17
|
+
* @param {String} accessToken The access token for authorize the request.
|
|
18
|
+
* @returns {Promise<GetPayTokenResponse>} The promise that resolves to the pay token response.
|
|
19
|
+
*/
|
|
20
|
+
getPayToken(accessToken: string): Promise<GetPayTokenResponse>;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Gets the access token token.
|
|
24
|
+
*/
|
|
25
|
+
getAccessToken(): Promise<GetAccessTokenResponse>;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Initializes the orange money payment.
|
|
29
|
+
*
|
|
30
|
+
* @param {String} mobileInitParams.description the payment description.
|
|
31
|
+
* @param {String} mobileInitParams.subscriberNumber The phone number of the user making the payment.
|
|
32
|
+
* @param {String} mobileInitParams.channelUserNumber The phone number of the user receiving the payment.
|
|
33
|
+
* @param {String} mobileInitParams.transactionId Unique identifier of the customer transaction.
|
|
34
|
+
* @param {String} mobileInitParams.amount The amount of the transaction.
|
|
35
|
+
* @param {String} mobileInitParams.pinCode The Pin code of the ChannelUser.
|
|
36
|
+
* @param {String} mobileInitParams.notifUrl An http endpoint able to receive a post request.
|
|
37
|
+
* @param {String} mobileInitParams.payToken A payToken value useful to make payment
|
|
38
|
+
* and track the status of payment.
|
|
39
|
+
* @param {String} mobileInitParams.accessToken The access token for authorize the request.
|
|
40
|
+
* @returns {Promise<InitializeOrangeMoneyResponse>} The promise that resolves to the mobile payment initialization response.
|
|
41
|
+
**/
|
|
42
|
+
initializeOrangeMoneyPayment(
|
|
43
|
+
params: InitializeOrangeMoneyRequest
|
|
44
|
+
): Promise<InitializeOrangeMoneyResponse>;
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Gets The orange money payment status.
|
|
48
|
+
* @param {String} checkStatusParams.payToken unique identifier used to obtain payment status.
|
|
49
|
+
* @param {String} checkStatusParams.accessToken The access token for authorize the request.
|
|
50
|
+
* @returns {Promise<GetOrangeMoneyPaymentResponse>} The promise that resolves to the mobile payment status response.
|
|
51
|
+
*/
|
|
52
|
+
getOrangeMoneyPaymentStatus(
|
|
53
|
+
params: GetOrangeMoneyPaymentRequest
|
|
54
|
+
): Promise<GetOrangeMoneyPaymentResponse>;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Creates a orange money payment.
|
|
59
|
+
*/
|
|
60
|
+
export class OrangeMoneyPayment {
|
|
61
|
+
/**
|
|
62
|
+
* Create a new payment using the provided configuration.
|
|
63
|
+
*
|
|
64
|
+
* @param {OrangeMoneyPaymentParams} config - The payment configuration.
|
|
65
|
+
* - {TargetEnvironment} config.targetEnvironment the target environment.
|
|
66
|
+
* - {string} config.apiUserName channelUser api username.
|
|
67
|
+
* - {string} config.apiPassword channelUser api password.
|
|
68
|
+
* - {string} config.xAuthToken the x-auth-token.
|
|
69
|
+
* - {string} [mobileInitParams.omVersion] the mobile orange money version apply for payment request.The default orange money version
|
|
70
|
+
* is 1.0.2: for more information: https://apiw.orange.cm/omcoreapis/1.0.2/mp/pay.
|
|
71
|
+
* - {String} config.targetEnvironment the target environment.
|
|
72
|
+
* @return {OrangeMoneyPaymentInterface} The created payment.
|
|
73
|
+
*/
|
|
74
|
+
static createPayment(
|
|
75
|
+
config: OrangeMoneyPaymentParams
|
|
76
|
+
): OrangeMoneyPaymentInterface {
|
|
77
|
+
switch (config.targetEnvironment) {
|
|
78
|
+
case TargetEnvironment.prod:
|
|
79
|
+
return new OrangeMoneyPaymentLive(config);
|
|
80
|
+
case TargetEnvironment.fake:
|
|
81
|
+
return new OrangeMoneyPaymentFake();
|
|
82
|
+
default:
|
|
83
|
+
return new OrangeMoneyPaymentLive(config);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|