@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,265 @@
|
|
|
1
|
+
import Joi from 'joi';
|
|
2
|
+
import { getRequest } from '../../utils/https';
|
|
3
|
+
import { OperationResponse } from '../../utils/operation_response';
|
|
4
|
+
import {
|
|
5
|
+
DisbursementServiceConfig,
|
|
6
|
+
DisbursementServiceConfigSchema,
|
|
7
|
+
} from '../implementations/disbursement_service';
|
|
8
|
+
import { DisbursementApiRawStatus, DisbursementStatus } from '../utils/status';
|
|
9
|
+
import { getStatusFromProviderRawStatus } from '../utils/utils';
|
|
10
|
+
export interface GetTransferStatusRequest {
|
|
11
|
+
token: string;
|
|
12
|
+
messageId: string;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const GetTransferStatusRequestSchema = Joi.object<GetTransferStatusRequest>({
|
|
16
|
+
token: Joi.string().required(),
|
|
17
|
+
messageId: Joi.string().required(),
|
|
18
|
+
}).required();
|
|
19
|
+
|
|
20
|
+
type GetTransferStatusResponseRawData =
|
|
21
|
+
| {
|
|
22
|
+
result: {
|
|
23
|
+
message: string;
|
|
24
|
+
data: {
|
|
25
|
+
createtime: string;
|
|
26
|
+
subscriberMsisdn: string;
|
|
27
|
+
amount: number;
|
|
28
|
+
payToken: string;
|
|
29
|
+
txnid: string;
|
|
30
|
+
txnmode: string;
|
|
31
|
+
txnstatus: string;
|
|
32
|
+
orderId: string;
|
|
33
|
+
status: DisbursementApiRawStatus;
|
|
34
|
+
channelUserMsisdn: string;
|
|
35
|
+
description: string;
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
parameters?: {
|
|
39
|
+
amount: string;
|
|
40
|
+
xauth: string;
|
|
41
|
+
channel_user_msisdn: string;
|
|
42
|
+
customer_key: string;
|
|
43
|
+
customer_secret: string | null;
|
|
44
|
+
final_customer_name: string;
|
|
45
|
+
final_customer_phone: string;
|
|
46
|
+
};
|
|
47
|
+
CreateAt: string;
|
|
48
|
+
MessageId: string;
|
|
49
|
+
RefundStep: DisbursementStep;
|
|
50
|
+
}
|
|
51
|
+
| {
|
|
52
|
+
parameters?: {
|
|
53
|
+
amount: string;
|
|
54
|
+
xauth: string;
|
|
55
|
+
channel_user_msisdn: string;
|
|
56
|
+
customer_key: string;
|
|
57
|
+
customer_secret: string | null;
|
|
58
|
+
final_customer_name: string;
|
|
59
|
+
final_customer_phone: string;
|
|
60
|
+
};
|
|
61
|
+
message: string;
|
|
62
|
+
RefundStep: DisbursementStep;
|
|
63
|
+
}
|
|
64
|
+
| {
|
|
65
|
+
ErrorCode: number;
|
|
66
|
+
body: string;
|
|
67
|
+
ErrorMessage: string;
|
|
68
|
+
parameters?: {
|
|
69
|
+
amount: string;
|
|
70
|
+
xauth: string;
|
|
71
|
+
channel_user_msisdn: string;
|
|
72
|
+
customer_key: string;
|
|
73
|
+
customer_secret: string | null;
|
|
74
|
+
final_customer_name: string;
|
|
75
|
+
final_customer_phone: string;
|
|
76
|
+
};
|
|
77
|
+
CreateAt: string;
|
|
78
|
+
MessageId: string;
|
|
79
|
+
RefundStep: DisbursementStep;
|
|
80
|
+
}
|
|
81
|
+
| {
|
|
82
|
+
result: {
|
|
83
|
+
createtime: string;
|
|
84
|
+
toChannelMsisdn: string;
|
|
85
|
+
amount: 498925;
|
|
86
|
+
payToken: string;
|
|
87
|
+
txnid: string;
|
|
88
|
+
txnmode: string;
|
|
89
|
+
txnmessage: string;
|
|
90
|
+
txnstatus: string;
|
|
91
|
+
orderId: string;
|
|
92
|
+
status: DisbursementApiRawStatus;
|
|
93
|
+
fromChannelMsisdn: string;
|
|
94
|
+
description: string;
|
|
95
|
+
};
|
|
96
|
+
parameters: {
|
|
97
|
+
amount: string;
|
|
98
|
+
xauth: string;
|
|
99
|
+
channel_user_msisdn: string;
|
|
100
|
+
customer_key: string;
|
|
101
|
+
customer_secret: string | null;
|
|
102
|
+
final_customer_name: string;
|
|
103
|
+
final_customer_phone: string;
|
|
104
|
+
};
|
|
105
|
+
CreateAt: string;
|
|
106
|
+
RefundStep: DisbursementStep;
|
|
107
|
+
}
|
|
108
|
+
| string;
|
|
109
|
+
|
|
110
|
+
export enum DisbursementStep {
|
|
111
|
+
TransferSent = '2',
|
|
112
|
+
InitializingTransfer = '1',
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export interface responseData {
|
|
116
|
+
status?: DisbursementStatus;
|
|
117
|
+
refundStep?: DisbursementStep;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
export type GetTransferStatusResponse = OperationResponse<
|
|
121
|
+
responseData,
|
|
122
|
+
GetTransferStatusResponseRawData
|
|
123
|
+
>;
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Retrieves the transfer status of a transaction.
|
|
127
|
+
*
|
|
128
|
+
* @param {DisbursementServiceConfig} configs - The disbursement service config.
|
|
129
|
+
* @param {GetTransferStatusRequest} params - The parameters for retrieving the transfer status.
|
|
130
|
+
* @return {GetTransferStatusResponse} - The method response containing the transfer status.
|
|
131
|
+
*/
|
|
132
|
+
export async function getTransferStatus({
|
|
133
|
+
configs,
|
|
134
|
+
params,
|
|
135
|
+
endPoint,
|
|
136
|
+
}: {
|
|
137
|
+
configs: DisbursementServiceConfig;
|
|
138
|
+
params: GetTransferStatusRequest;
|
|
139
|
+
endPoint: string;
|
|
140
|
+
}): GetTransferStatusResponse {
|
|
141
|
+
const logger = configs.logger;
|
|
142
|
+
logger.info(
|
|
143
|
+
`getTransferStatus is running with params : ${JSON.stringify(params)}`
|
|
144
|
+
);
|
|
145
|
+
|
|
146
|
+
const { error: configsValidationError, value: configsValues } =
|
|
147
|
+
DisbursementServiceConfigSchema.validate(configs);
|
|
148
|
+
|
|
149
|
+
if (configsValidationError) {
|
|
150
|
+
logger.error(
|
|
151
|
+
`Invalid DisbursementServiceConfig request parameters. params : ${JSON.stringify(
|
|
152
|
+
configsValidationError.details
|
|
153
|
+
)}`
|
|
154
|
+
);
|
|
155
|
+
return { error: configsValidationError.details };
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
const { error: paramsValidationError, value: paramsValue } =
|
|
159
|
+
GetTransferStatusRequestSchema.validate(params);
|
|
160
|
+
|
|
161
|
+
if (paramsValidationError) {
|
|
162
|
+
logger.error(
|
|
163
|
+
`Invalid getTransferStatus request parameters. params : ${JSON.stringify(
|
|
164
|
+
paramsValidationError
|
|
165
|
+
)}`
|
|
166
|
+
);
|
|
167
|
+
return { error: paramsValidationError };
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
const headers = {
|
|
171
|
+
Authorization: `Bearer ${paramsValue.token}`,
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
const body = {
|
|
175
|
+
customerkey: configsValues.customerKey,
|
|
176
|
+
customersecret: configsValues.customerSecret,
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
const response = await getRequest<GetTransferStatusResponseRawData>({
|
|
180
|
+
logger: configsValues.logger,
|
|
181
|
+
route: endPoint,
|
|
182
|
+
headers: headers,
|
|
183
|
+
data: body,
|
|
184
|
+
rejectUnauthorized: false,
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
if (!response.response) {
|
|
188
|
+
return { error: response.error };
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
const data = response.response.data;
|
|
192
|
+
|
|
193
|
+
if (typeof data === 'string') {
|
|
194
|
+
// Handle string response.
|
|
195
|
+
return { error: data };
|
|
196
|
+
} else if ('result' in data) {
|
|
197
|
+
// Remove the customer secret from the raw data, because
|
|
198
|
+
// it is a very sensitive secret.
|
|
199
|
+
if (data.parameters) {
|
|
200
|
+
data.parameters.customer_secret = null;
|
|
201
|
+
}
|
|
202
|
+
const rawStatus: DisbursementApiRawStatus =
|
|
203
|
+
'status' in data.result ? data.result.status : data.result.data.status;
|
|
204
|
+
const status = getStatusFromProviderRawStatus(rawStatus);
|
|
205
|
+
|
|
206
|
+
if (data.RefundStep === DisbursementStep.InitializingTransfer) {
|
|
207
|
+
return {
|
|
208
|
+
data: {
|
|
209
|
+
status:
|
|
210
|
+
status === DisbursementStatus.succeeded
|
|
211
|
+
? DisbursementStatus.pending
|
|
212
|
+
: status,
|
|
213
|
+
refundStep: data.RefundStep,
|
|
214
|
+
},
|
|
215
|
+
raw: data,
|
|
216
|
+
};
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
return {
|
|
220
|
+
data: {
|
|
221
|
+
status: status,
|
|
222
|
+
refundStep: data.RefundStep,
|
|
223
|
+
},
|
|
224
|
+
raw: data,
|
|
225
|
+
};
|
|
226
|
+
} else if ('ErrorCode' in data) {
|
|
227
|
+
if (data.parameters) {
|
|
228
|
+
data.parameters.customer_secret = null;
|
|
229
|
+
}
|
|
230
|
+
if (data.ErrorCode === 5019) {
|
|
231
|
+
return {
|
|
232
|
+
data: {
|
|
233
|
+
status: DisbursementStatus.failed,
|
|
234
|
+
refundStep: data.RefundStep,
|
|
235
|
+
},
|
|
236
|
+
raw: data,
|
|
237
|
+
};
|
|
238
|
+
}
|
|
239
|
+
configsValues.logger.error(
|
|
240
|
+
`Unexpected ErrorCode : ${JSON.stringify(data)}`
|
|
241
|
+
);
|
|
242
|
+
|
|
243
|
+
return {
|
|
244
|
+
data: {
|
|
245
|
+
status: DisbursementStatus.pending,
|
|
246
|
+
refundStep: data.RefundStep,
|
|
247
|
+
},
|
|
248
|
+
raw: data,
|
|
249
|
+
};
|
|
250
|
+
} else if (data.RefundStep === DisbursementStep.InitializingTransfer) {
|
|
251
|
+
if (data.parameters) {
|
|
252
|
+
data.parameters.customer_secret = null;
|
|
253
|
+
}
|
|
254
|
+
return {
|
|
255
|
+
data: {
|
|
256
|
+
status: DisbursementStatus.pending,
|
|
257
|
+
refundStep: data.RefundStep,
|
|
258
|
+
},
|
|
259
|
+
raw: data,
|
|
260
|
+
};
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
// By default, assume we failed to retrieve the disbursement status.
|
|
264
|
+
return { error: data };
|
|
265
|
+
}
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import { AxiosResponse } from 'axios';
|
|
2
|
+
import { Logger } from '../../../../logging/src/logging';
|
|
3
|
+
import * as requests from '../../utils/https';
|
|
4
|
+
import { DisbursementXTargetEnvironmentType } from '../utils/constants';
|
|
5
|
+
import { transfer } from './transfer';
|
|
6
|
+
|
|
7
|
+
describe('transfer', () => {
|
|
8
|
+
it('should fail on invalid parameter provided', async () => {
|
|
9
|
+
const { error, data, raw } = await transfer({
|
|
10
|
+
configs: {
|
|
11
|
+
channelUserMsisdn: '',
|
|
12
|
+
clientId: '',
|
|
13
|
+
clientSecret: '',
|
|
14
|
+
customerKey: '',
|
|
15
|
+
customerSecret: '',
|
|
16
|
+
pin: '',
|
|
17
|
+
environment: DisbursementXTargetEnvironmentType.sandbox,
|
|
18
|
+
logger: new Logger(),
|
|
19
|
+
},
|
|
20
|
+
params: {
|
|
21
|
+
webhook: '',
|
|
22
|
+
amount: 0,
|
|
23
|
+
customerPhone: '',
|
|
24
|
+
customerName: '',
|
|
25
|
+
token: '',
|
|
26
|
+
},
|
|
27
|
+
endPoint: '',
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
expect(data).not.toBeDefined();
|
|
31
|
+
expect(raw).not.toBeDefined();
|
|
32
|
+
expect(error).toBeDefined();
|
|
33
|
+
});
|
|
34
|
+
it('should fail on invalid phone number provided provided', async () => {
|
|
35
|
+
const { error, data, raw } = await transfer({
|
|
36
|
+
configs: {
|
|
37
|
+
channelUserMsisdn: '237699947943',
|
|
38
|
+
clientId: 'clientId',
|
|
39
|
+
clientSecret: 'clientSecret',
|
|
40
|
+
customerKey: 'customerKey',
|
|
41
|
+
customerSecret: 'customerSecret',
|
|
42
|
+
pin: 'pin',
|
|
43
|
+
environment: DisbursementXTargetEnvironmentType.sandbox,
|
|
44
|
+
logger: new Logger(),
|
|
45
|
+
},
|
|
46
|
+
params: {
|
|
47
|
+
webhook: 'https://example.com',
|
|
48
|
+
amount: 100,
|
|
49
|
+
customerPhone: '69532652',
|
|
50
|
+
customerName: 'itachi uchiwa',
|
|
51
|
+
token: 'token',
|
|
52
|
+
},
|
|
53
|
+
endPoint: 'https://example.com',
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
expect(data).not.toBeDefined();
|
|
57
|
+
expect(raw).not.toBeDefined();
|
|
58
|
+
expect(error).toBeDefined();
|
|
59
|
+
});
|
|
60
|
+
it('should fail on request failure', async () => {
|
|
61
|
+
const postSpy = jest
|
|
62
|
+
.spyOn(requests, 'postRequest')
|
|
63
|
+
.mockImplementation()
|
|
64
|
+
.mockResolvedValue({
|
|
65
|
+
error: {},
|
|
66
|
+
});
|
|
67
|
+
const { error, data, raw } = await transfer({
|
|
68
|
+
configs: {
|
|
69
|
+
channelUserMsisdn: '237699947943',
|
|
70
|
+
clientId: 'clientId',
|
|
71
|
+
clientSecret: 'clientSecret',
|
|
72
|
+
customerKey: 'customerKey',
|
|
73
|
+
customerSecret: 'customerSecret',
|
|
74
|
+
pin: 'pin',
|
|
75
|
+
environment: DisbursementXTargetEnvironmentType.sandbox,
|
|
76
|
+
logger: new Logger(),
|
|
77
|
+
},
|
|
78
|
+
params: {
|
|
79
|
+
webhook: 'https://example.com',
|
|
80
|
+
amount: 100,
|
|
81
|
+
customerPhone: '695326522',
|
|
82
|
+
customerName: 'itachi uchiwa',
|
|
83
|
+
token: 'token',
|
|
84
|
+
},
|
|
85
|
+
endPoint: 'https://example.com',
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
expect(data).not.toBeDefined();
|
|
89
|
+
expect(raw).not.toBeDefined();
|
|
90
|
+
expect(postSpy).toHaveBeenCalledTimes(1);
|
|
91
|
+
expect(error).toBeDefined();
|
|
92
|
+
});
|
|
93
|
+
it('should succeed on request succeed', async () => {
|
|
94
|
+
const postSpy = jest
|
|
95
|
+
.spyOn(requests, 'postRequest')
|
|
96
|
+
.mockImplementation()
|
|
97
|
+
.mockResolvedValue({
|
|
98
|
+
response: <AxiosResponse>{
|
|
99
|
+
data: {
|
|
100
|
+
MD5OfMessageBody: 'MD5OfMessageBody',
|
|
101
|
+
MD5OfMessageAttributes: 'MD5OfMessageAttributes',
|
|
102
|
+
MessageId: 'MessageId',
|
|
103
|
+
ResponseMetadata: {
|
|
104
|
+
RequestId: 'RequestId',
|
|
105
|
+
HTTPStatusCode: 200,
|
|
106
|
+
HTTPHeaders: {
|
|
107
|
+
'x-amzn-requestid': 'x-amzn-requestid',
|
|
108
|
+
'x-amzn-trace-id': 'x-amzn-trace-id',
|
|
109
|
+
'content-type': 'content-type',
|
|
110
|
+
'content-length': 'content-length',
|
|
111
|
+
},
|
|
112
|
+
RetryAttempts: 2,
|
|
113
|
+
},
|
|
114
|
+
},
|
|
115
|
+
},
|
|
116
|
+
});
|
|
117
|
+
const { error, data, raw } = await transfer({
|
|
118
|
+
configs: {
|
|
119
|
+
channelUserMsisdn: '237699947943',
|
|
120
|
+
clientId: 'clientId',
|
|
121
|
+
clientSecret: 'clientSecret',
|
|
122
|
+
customerKey: 'customerKey',
|
|
123
|
+
customerSecret: 'customerSecret',
|
|
124
|
+
pin: 'pin',
|
|
125
|
+
environment: DisbursementXTargetEnvironmentType.sandbox,
|
|
126
|
+
logger: new Logger(),
|
|
127
|
+
},
|
|
128
|
+
params: {
|
|
129
|
+
webhook: 'https://example.com',
|
|
130
|
+
amount: 100,
|
|
131
|
+
customerPhone: '695326522',
|
|
132
|
+
customerName: 'itachi uchiwa',
|
|
133
|
+
token: 'token',
|
|
134
|
+
},
|
|
135
|
+
endPoint: 'https://example.com',
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
expect(error).not.toBeDefined();
|
|
139
|
+
expect(postSpy).toHaveBeenCalledTimes(1);
|
|
140
|
+
expect(raw).toEqual({
|
|
141
|
+
MD5OfMessageBody: 'MD5OfMessageBody',
|
|
142
|
+
MD5OfMessageAttributes: 'MD5OfMessageAttributes',
|
|
143
|
+
MessageId: 'MessageId',
|
|
144
|
+
ResponseMetadata: {
|
|
145
|
+
RequestId: 'RequestId',
|
|
146
|
+
HTTPStatusCode: 200,
|
|
147
|
+
HTTPHeaders: {
|
|
148
|
+
'x-amzn-requestid': 'x-amzn-requestid',
|
|
149
|
+
'x-amzn-trace-id': 'x-amzn-trace-id',
|
|
150
|
+
'content-type': 'content-type',
|
|
151
|
+
'content-length': 'content-length',
|
|
152
|
+
},
|
|
153
|
+
RetryAttempts: 2,
|
|
154
|
+
},
|
|
155
|
+
});
|
|
156
|
+
expect(data).toBe('MessageId');
|
|
157
|
+
});
|
|
158
|
+
});
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import Joi from 'joi';
|
|
2
|
+
import { RequestResponse, postRequest } from '../../utils/https';
|
|
3
|
+
import { OperationResponse } from '../../utils/operation_response';
|
|
4
|
+
import {
|
|
5
|
+
DisbursementServiceConfig,
|
|
6
|
+
DisbursementServiceConfigSchema,
|
|
7
|
+
} from '../implementations/disbursement_service';
|
|
8
|
+
import { orangeMoneyPhoneNumberWithoutCountryCodeRegex } from '../utils/regex';
|
|
9
|
+
|
|
10
|
+
export enum TransferMethod {
|
|
11
|
+
OrangeMoney = 'OrangeMoney',
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface TransferRequest {
|
|
15
|
+
webhook: string;
|
|
16
|
+
amount: number;
|
|
17
|
+
customerPhone: string;
|
|
18
|
+
customerName: string;
|
|
19
|
+
token: string;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export const TransferRequestSchema = Joi.object<TransferRequest>({
|
|
23
|
+
webhook: Joi.string().uri().required(),
|
|
24
|
+
amount: Joi.number().integer().min(1).required(),
|
|
25
|
+
customerPhone: Joi.string()
|
|
26
|
+
.pattern(orangeMoneyPhoneNumberWithoutCountryCodeRegex)
|
|
27
|
+
.required(),
|
|
28
|
+
customerName: Joi.string().required(),
|
|
29
|
+
token: Joi.string().required(),
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
export type TransferResponseRawData = {
|
|
33
|
+
MD5OfMessageBody: string;
|
|
34
|
+
MD5OfMessageAttributes: string;
|
|
35
|
+
MessageId: string;
|
|
36
|
+
ResponseMetadata: {
|
|
37
|
+
RequestId: string;
|
|
38
|
+
HTTPStatusCode: number;
|
|
39
|
+
HTTPHeaders: {
|
|
40
|
+
'x-amzn-requestid': string;
|
|
41
|
+
'x-amzn-trace-id': string;
|
|
42
|
+
date: string;
|
|
43
|
+
'content-type': string;
|
|
44
|
+
'content-length': string;
|
|
45
|
+
};
|
|
46
|
+
RetryAttempts: number;
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
export type TransferResponse = OperationResponse<
|
|
51
|
+
string,
|
|
52
|
+
TransferResponseRawData
|
|
53
|
+
>;
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Transfers the specified amount of currency to the specified party.
|
|
57
|
+
*
|
|
58
|
+
* @param {DisbursementServiceConfig} configs - The disbursement service config.
|
|
59
|
+
* @param {TransferRequest} params - The transfer parameters.
|
|
60
|
+
* @return {MethodResponse<string, TransferRawData>} - The method response.
|
|
61
|
+
*/
|
|
62
|
+
export async function transfer({
|
|
63
|
+
configs,
|
|
64
|
+
params,
|
|
65
|
+
endPoint,
|
|
66
|
+
}: {
|
|
67
|
+
configs: DisbursementServiceConfig;
|
|
68
|
+
params: TransferRequest;
|
|
69
|
+
endPoint: string;
|
|
70
|
+
}): TransferResponse {
|
|
71
|
+
const logger = configs.logger;
|
|
72
|
+
logger.info(`transfer is running with params : ${JSON.stringify(params)}`);
|
|
73
|
+
|
|
74
|
+
const { error: configsValidationError, value: configValues } =
|
|
75
|
+
DisbursementServiceConfigSchema.validate(configs);
|
|
76
|
+
|
|
77
|
+
if (configsValidationError) {
|
|
78
|
+
logger.error(
|
|
79
|
+
`Invalid DisbursementServiceConfig request parameters. params : ${JSON.stringify(
|
|
80
|
+
configsValidationError.details
|
|
81
|
+
)}`
|
|
82
|
+
);
|
|
83
|
+
return { error: configsValidationError.details };
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const { error: paramsValidationError, value: paramsValues } =
|
|
87
|
+
TransferRequestSchema.validate(params);
|
|
88
|
+
if (paramsValidationError) {
|
|
89
|
+
return {
|
|
90
|
+
error: `Invalid transfer request parameters. params : ${JSON.stringify(
|
|
91
|
+
params
|
|
92
|
+
)}`,
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
const header = {
|
|
96
|
+
Authorization: `Bearer ${paramsValues.token}`,
|
|
97
|
+
};
|
|
98
|
+
const body = {
|
|
99
|
+
customerkey: configValues.customerKey,
|
|
100
|
+
customersecret: configValues.customerSecret,
|
|
101
|
+
channelUserMsisdn: configValues.channelUserMsisdn,
|
|
102
|
+
pin: configValues.pin,
|
|
103
|
+
webhook: paramsValues.webhook,
|
|
104
|
+
amount: `${paramsValues.amount}`,
|
|
105
|
+
final_customer_phone: paramsValues.customerPhone,
|
|
106
|
+
final_customer_name: paramsValues.customerName,
|
|
107
|
+
refund_method: TransferMethod.OrangeMoney,
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
const response: RequestResponse<TransferResponseRawData> = await postRequest({
|
|
111
|
+
logger: logger,
|
|
112
|
+
route: endPoint,
|
|
113
|
+
data: body,
|
|
114
|
+
headers: header,
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
if (!response.response) {
|
|
118
|
+
return { error: response.error };
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
return {
|
|
122
|
+
data: response.response.data.MessageId,
|
|
123
|
+
raw: response.response.data,
|
|
124
|
+
};
|
|
125
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { DisbursementXTargetEnvironmentType } from '../utils/constants';
|
|
2
|
+
|
|
3
|
+
const apiHost = 'https://omapi.ynote.africa';
|
|
4
|
+
const apiTokenHost = 'https://omapi-token.ynote.africa/oauth2/token';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Orange Money API routes builder.
|
|
8
|
+
* @class
|
|
9
|
+
*/
|
|
10
|
+
export class Routes {
|
|
11
|
+
/**
|
|
12
|
+
* Constructs a new {CommonRoutes}.
|
|
13
|
+
* @constructor
|
|
14
|
+
* @param {RoutesParams} config - The required global route configuration.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Returns the base route for the API.
|
|
19
|
+
* e.g: https://docs.google.com/document/d/1h-gMj7PSGAALxRSofOvLa2g5vF3IpDkUufNrU1hX6Yk/edit?pli=1
|
|
20
|
+
* @return {string} The base route.
|
|
21
|
+
*/
|
|
22
|
+
private baseRoute(): string {
|
|
23
|
+
return `${apiHost}/${DisbursementXTargetEnvironmentType.prod}`;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* This route is used to create an access token which can then be used to authorize and authenticate towards the other end-points of the API.
|
|
28
|
+
* e.g : https://docs.google.com/document/d/1h-gMj7PSGAALxRSofOvLa2g5vF3IpDkUufNrU1hX6Yk/edit?pli=1 page 2
|
|
29
|
+
* @return {string}
|
|
30
|
+
*/
|
|
31
|
+
createAccessToken(): string {
|
|
32
|
+
return apiTokenHost;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* This route is used to transfer an amount from the owner’s account to a payee account (customer).
|
|
37
|
+
* e.g : https://docs.google.com/document/d/1h-gMj7PSGAALxRSofOvLa2g5vF3IpDkUufNrU1hX6Yk/edit?pli=1 page 4
|
|
38
|
+
* @return {string} - The transfer route.
|
|
39
|
+
*/
|
|
40
|
+
transfer(): string {
|
|
41
|
+
return `${this.baseRoute()}/refund`;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* This route is used to get the status of a transfer.
|
|
46
|
+
*
|
|
47
|
+
* @param {string} Id - The reference of the transfer.
|
|
48
|
+
* e.g : https://docs.google.com/document/d/1h-gMj7PSGAALxRSofOvLa2g5vF3IpDkUufNrU1hX6Yk/edit?pli=1 page 9
|
|
49
|
+
* @return {string} - The transfer status route.
|
|
50
|
+
*/
|
|
51
|
+
transferStatus(Id: string): string {
|
|
52
|
+
return `${this.baseRoute()}/refund/status/${Id}`;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import {
|
|
2
|
+
merchantPhoneNumberRegex,
|
|
3
|
+
orangeMoneyPhoneNumberWithoutCountryCodeRegex,
|
|
4
|
+
} from './regex';
|
|
5
|
+
|
|
6
|
+
describe('Test regex merchant phone number', () => {
|
|
7
|
+
test('Merchant phone number regex matches valid numbers', () => {
|
|
8
|
+
const validNumbers = ['699947943', '237699947943'];
|
|
9
|
+
validNumbers.forEach((number) => {
|
|
10
|
+
expect(merchantPhoneNumberRegex.test(number)).toBe(true);
|
|
11
|
+
});
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
test('Merchant phone number regex does not match invalid numbers', () => {
|
|
15
|
+
const invalidNumbers = ['12345', '23712345', 'abc'];
|
|
16
|
+
invalidNumbers.forEach((number) => {
|
|
17
|
+
expect(merchantPhoneNumberRegex.test(number)).toBe(false);
|
|
18
|
+
});
|
|
19
|
+
});
|
|
20
|
+
});
|
|
21
|
+
describe('Test regex orange money phone number without country code', () => {
|
|
22
|
+
test('Oman phone number without country code regex matches valid numbers', () => {
|
|
23
|
+
const validNumbers = ['696512345', '696898765'];
|
|
24
|
+
validNumbers.forEach((number) => {
|
|
25
|
+
expect(orangeMoneyPhoneNumberWithoutCountryCodeRegex.test(number)).toBe(
|
|
26
|
+
true
|
|
27
|
+
);
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
test('Orange money phone number without country code regex does not match invalid numbers', () => {
|
|
32
|
+
const invalidNumbers = ['12345', '96812345', 'abc'];
|
|
33
|
+
invalidNumbers.forEach((number) => {
|
|
34
|
+
expect(orangeMoneyPhoneNumberWithoutCountryCodeRegex.test(number)).toBe(
|
|
35
|
+
false
|
|
36
|
+
);
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The merchant number regExp authorized for numbers by y-note.
|
|
3
|
+
*/
|
|
4
|
+
export const merchantPhoneNumberRegex = /^(237)?(69\d{7}$|65[5-9]\d{6}$)/;
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The orange money phone number regex for orange money numbers without the country code.
|
|
8
|
+
*/
|
|
9
|
+
export const orangeMoneyPhoneNumberWithoutCountryCodeRegex =
|
|
10
|
+
/^(69\d{7}$|65[5-9]\d{6}$)/;
|