@spreeloop/orange_money 1.0.7 → 1.0.8

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.
Files changed (214) hide show
  1. package/dist/logging/src/log_level.d.ts +24 -0
  2. package/dist/logging/src/log_level.d.ts.map +1 -0
  3. package/dist/logging/src/log_level.js +34 -0
  4. package/dist/logging/src/log_level.js.map +1 -0
  5. package/dist/logging/src/logging.d.ts +50 -0
  6. package/dist/logging/src/logging.d.ts.map +1 -0
  7. package/dist/logging/src/logging.js +87 -0
  8. package/dist/logging/src/logging.js.map +1 -0
  9. package/dist/logging/src/printer.d.ts +10 -0
  10. package/dist/logging/src/printer.d.ts.map +1 -0
  11. package/dist/logging/src/printer.js +3 -0
  12. package/dist/logging/src/printer.js.map +1 -0
  13. package/dist/orange_money/index.d.ts +2 -0
  14. package/dist/orange_money/index.d.ts.map +1 -0
  15. package/dist/orange_money/index.js +18 -0
  16. package/dist/orange_money/index.js.map +1 -0
  17. package/dist/orange_money/src/disbursements/implementations/disbursement_service.d.ts +62 -0
  18. package/dist/orange_money/src/disbursements/implementations/disbursement_service.d.ts.map +1 -0
  19. package/dist/orange_money/src/disbursements/implementations/disbursement_service.js +84 -0
  20. package/dist/orange_money/src/disbursements/implementations/disbursement_service.js.map +1 -0
  21. package/dist/orange_money/src/disbursements/implementations/src/live.d.ts +40 -0
  22. package/dist/orange_money/src/disbursements/implementations/src/live.d.ts.map +1 -0
  23. package/dist/orange_money/src/disbursements/implementations/src/live.js +61 -0
  24. package/dist/orange_money/src/disbursements/implementations/src/live.js.map +1 -0
  25. package/dist/orange_money/src/disbursements/implementations/src/sandbox.d.ts +40 -0
  26. package/dist/orange_money/src/disbursements/implementations/src/sandbox.d.ts.map +1 -0
  27. package/dist/orange_money/src/disbursements/implementations/src/sandbox.js +110 -0
  28. package/dist/orange_money/src/disbursements/implementations/src/sandbox.js.map +1 -0
  29. package/dist/orange_money/src/disbursements/operations/create_access_token.d.ts +28 -0
  30. package/dist/orange_money/src/disbursements/operations/create_access_token.d.ts.map +1 -0
  31. package/dist/orange_money/src/disbursements/operations/create_access_token.js +45 -0
  32. package/dist/orange_money/src/disbursements/operations/create_access_token.js.map +1 -0
  33. package/dist/orange_money/src/disbursements/operations/create_access_token.spec.d.ts +2 -0
  34. package/dist/orange_money/src/disbursements/operations/create_access_token.spec.d.ts.map +1 -0
  35. package/dist/orange_money/src/disbursements/operations/create_access_token.spec.js +106 -0
  36. package/dist/orange_money/src/disbursements/operations/create_access_token.spec.js.map +1 -0
  37. package/dist/orange_money/src/disbursements/operations/get_transfer_status.d.ts +114 -0
  38. package/dist/orange_money/src/disbursements/operations/get_transfer_status.d.ts.map +1 -0
  39. package/dist/orange_money/src/disbursements/operations/get_transfer_status.js +128 -0
  40. package/dist/orange_money/src/disbursements/operations/get_transfer_status.js.map +1 -0
  41. package/dist/orange_money/src/disbursements/operations/get_transfer_status.spec.d.ts +2 -0
  42. package/dist/orange_money/src/disbursements/operations/get_transfer_status.spec.d.ts.map +1 -0
  43. package/dist/orange_money/src/disbursements/operations/get_transfer_status.spec.js +148 -0
  44. package/dist/orange_money/src/disbursements/operations/get_transfer_status.spec.js.map +1 -0
  45. package/dist/orange_money/src/disbursements/operations/transfer.d.ts +44 -0
  46. package/dist/orange_money/src/disbursements/operations/transfer.d.ts.map +1 -0
  47. package/dist/orange_money/src/disbursements/operations/transfer.js +74 -0
  48. package/dist/orange_money/src/disbursements/operations/transfer.js.map +1 -0
  49. package/dist/orange_money/src/disbursements/operations/transfer.spec.d.ts +2 -0
  50. package/dist/orange_money/src/disbursements/operations/transfer.spec.d.ts.map +1 -0
  51. package/dist/orange_money/src/disbursements/operations/transfer.spec.js +178 -0
  52. package/dist/orange_money/src/disbursements/operations/transfer.spec.js.map +1 -0
  53. package/dist/orange_money/src/disbursements/routes/routes.d.ts +38 -0
  54. package/dist/orange_money/src/disbursements/routes/routes.d.ts.map +1 -0
  55. package/dist/orange_money/src/disbursements/routes/routes.js +53 -0
  56. package/dist/orange_money/src/disbursements/routes/routes.js.map +1 -0
  57. package/dist/orange_money/src/disbursements/utils/constants.d.ts +5 -0
  58. package/dist/orange_money/src/disbursements/utils/constants.d.ts.map +1 -0
  59. package/dist/orange_money/src/disbursements/utils/constants.js +9 -0
  60. package/dist/orange_money/src/disbursements/utils/constants.js.map +1 -0
  61. package/{src/disbursements/utils/regex.ts → dist/orange_money/src/disbursements/utils/regex.d.ts} +3 -4
  62. package/dist/orange_money/src/disbursements/utils/regex.d.ts.map +1 -0
  63. package/dist/orange_money/src/disbursements/utils/regex.js +12 -0
  64. package/dist/orange_money/src/disbursements/utils/regex.js.map +1 -0
  65. package/dist/orange_money/src/disbursements/utils/regex.spec.d.ts +2 -0
  66. package/dist/orange_money/src/disbursements/utils/regex.spec.d.ts.map +1 -0
  67. package/dist/orange_money/src/disbursements/utils/regex.spec.js +32 -0
  68. package/dist/orange_money/src/disbursements/utils/regex.spec.js.map +1 -0
  69. package/dist/orange_money/src/disbursements/utils/status.d.ts +53 -0
  70. package/dist/orange_money/src/disbursements/utils/status.d.ts.map +1 -0
  71. package/dist/orange_money/src/disbursements/utils/status.js +58 -0
  72. package/dist/orange_money/src/disbursements/utils/status.js.map +1 -0
  73. package/dist/orange_money/src/disbursements/utils/utils.d.ts +9 -0
  74. package/dist/orange_money/src/disbursements/utils/utils.d.ts.map +1 -0
  75. package/dist/orange_money/src/disbursements/utils/utils.js +26 -0
  76. package/dist/orange_money/src/disbursements/utils/utils.js.map +1 -0
  77. package/dist/orange_money/src/disbursements/utils/utils.spec.d.ts +2 -0
  78. package/dist/orange_money/src/disbursements/utils/utils.spec.d.ts.map +1 -0
  79. package/dist/orange_money/src/disbursements/utils/utils.spec.js +43 -0
  80. package/dist/orange_money/src/disbursements/utils/utils.spec.js.map +1 -0
  81. package/{src/index.ts → dist/orange_money/src/index.d.ts} +3 -8
  82. package/dist/orange_money/src/index.d.ts.map +1 -0
  83. package/dist/orange_money/src/index.js +15 -0
  84. package/dist/orange_money/src/index.js.map +1 -0
  85. package/dist/orange_money/src/payments/implementations/fake.d.ts +33 -0
  86. package/dist/orange_money/src/payments/implementations/fake.d.ts.map +1 -0
  87. package/dist/orange_money/src/payments/implementations/fake.js +110 -0
  88. package/dist/orange_money/src/payments/implementations/fake.js.map +1 -0
  89. package/dist/orange_money/src/payments/implementations/live.d.ts +45 -0
  90. package/dist/orange_money/src/payments/implementations/live.d.ts.map +1 -0
  91. package/dist/orange_money/src/payments/implementations/live.js +69 -0
  92. package/dist/orange_money/src/payments/implementations/live.js.map +1 -0
  93. package/dist/orange_money/src/payments/operations/get_access_token.d.ts +11 -0
  94. package/dist/orange_money/src/payments/operations/get_access_token.d.ts.map +1 -0
  95. package/dist/orange_money/src/payments/operations/get_access_token.js +47 -0
  96. package/dist/orange_money/src/payments/operations/get_access_token.js.map +1 -0
  97. package/dist/orange_money/src/payments/operations/get_access_token.spec.d.ts +2 -0
  98. package/dist/orange_money/src/payments/operations/get_access_token.spec.d.ts.map +1 -0
  99. package/dist/orange_money/src/payments/operations/get_access_token.spec.js +74 -0
  100. package/dist/orange_money/src/payments/operations/get_access_token.spec.js.map +1 -0
  101. package/dist/orange_money/src/payments/operations/get_pay_token.d.ts +12 -0
  102. package/dist/orange_money/src/payments/operations/get_pay_token.d.ts.map +1 -0
  103. package/dist/orange_money/src/payments/operations/get_pay_token.js +43 -0
  104. package/dist/orange_money/src/payments/operations/get_pay_token.js.map +1 -0
  105. package/dist/orange_money/src/payments/operations/get_pay_token.spec.d.ts +2 -0
  106. package/dist/orange_money/src/payments/operations/get_pay_token.spec.d.ts.map +1 -0
  107. package/dist/orange_money/src/payments/operations/get_pay_token.spec.js +74 -0
  108. package/dist/orange_money/src/payments/operations/get_pay_token.spec.js.map +1 -0
  109. package/dist/orange_money/src/payments/operations/get_payment_status.d.ts +23 -0
  110. package/dist/orange_money/src/payments/operations/get_payment_status.d.ts.map +1 -0
  111. package/dist/orange_money/src/payments/operations/get_payment_status.js +51 -0
  112. package/dist/orange_money/src/payments/operations/get_payment_status.js.map +1 -0
  113. package/dist/orange_money/src/payments/operations/get_payment_status.spec.d.ts +2 -0
  114. package/dist/orange_money/src/payments/operations/get_payment_status.spec.d.ts.map +1 -0
  115. package/dist/orange_money/src/payments/operations/get_payment_status.spec.js +101 -0
  116. package/dist/orange_money/src/payments/operations/get_payment_status.spec.js.map +1 -0
  117. package/dist/orange_money/src/payments/operations/initialize_om_payment.d.ts +22 -0
  118. package/dist/orange_money/src/payments/operations/initialize_om_payment.d.ts.map +1 -0
  119. package/dist/orange_money/src/payments/operations/initialize_om_payment.js +124 -0
  120. package/dist/orange_money/src/payments/operations/initialize_om_payment.js.map +1 -0
  121. package/dist/orange_money/src/payments/operations/initialize_om_payment.spec.d.ts +2 -0
  122. package/dist/orange_money/src/payments/operations/initialize_om_payment.spec.d.ts.map +1 -0
  123. package/dist/orange_money/src/payments/operations/initialize_om_payment.spec.js +245 -0
  124. package/dist/orange_money/src/payments/operations/initialize_om_payment.spec.js.map +1 -0
  125. package/dist/orange_money/src/payments/payments.d.ts +57 -0
  126. package/dist/orange_money/src/payments/payments.d.ts.map +1 -0
  127. package/dist/orange_money/src/payments/payments.js +36 -0
  128. package/dist/orange_money/src/payments/payments.js.map +1 -0
  129. package/dist/orange_money/src/payments/routes/routes.d.ts +48 -0
  130. package/dist/orange_money/src/payments/routes/routes.d.ts.map +1 -0
  131. package/dist/orange_money/src/payments/routes/routes.js +61 -0
  132. package/dist/orange_money/src/payments/routes/routes.js.map +1 -0
  133. package/dist/orange_money/src/payments/utils/constants.d.ts +96 -0
  134. package/dist/orange_money/src/payments/utils/constants.d.ts.map +1 -0
  135. package/dist/orange_money/src/payments/utils/constants.js +112 -0
  136. package/dist/orange_money/src/payments/utils/constants.js.map +1 -0
  137. package/dist/orange_money/src/payments/utils/joi_schema.d.ts +70 -0
  138. package/dist/orange_money/src/payments/utils/joi_schema.d.ts.map +1 -0
  139. package/dist/orange_money/src/payments/utils/joi_schema.js +44 -0
  140. package/dist/orange_money/src/payments/utils/joi_schema.js.map +1 -0
  141. package/dist/orange_money/src/payments/utils/request_model.d.ts +75 -0
  142. package/dist/orange_money/src/payments/utils/request_model.d.ts.map +1 -0
  143. package/dist/orange_money/src/payments/utils/request_model.js +3 -0
  144. package/dist/orange_money/src/payments/utils/request_model.js.map +1 -0
  145. package/dist/orange_money/src/payments/utils/utils.d.ts +15 -0
  146. package/dist/orange_money/src/payments/utils/utils.d.ts.map +1 -0
  147. package/dist/orange_money/src/payments/utils/utils.js +27 -0
  148. package/dist/orange_money/src/payments/utils/utils.js.map +1 -0
  149. package/dist/orange_money/src/utils/https.d.ts +77 -0
  150. package/dist/orange_money/src/utils/https.d.ts.map +1 -0
  151. package/dist/orange_money/src/utils/https.js +240 -0
  152. package/dist/orange_money/src/utils/https.js.map +1 -0
  153. package/dist/orange_money/src/utils/https.spec.d.ts +2 -0
  154. package/dist/orange_money/src/utils/https.spec.d.ts.map +1 -0
  155. package/dist/orange_money/src/utils/https.spec.js +77 -0
  156. package/dist/orange_money/src/utils/https.spec.js.map +1 -0
  157. package/dist/orange_money/src/utils/logging_interface.d.ts +23 -0
  158. package/dist/orange_money/src/utils/logging_interface.d.ts.map +1 -0
  159. package/dist/orange_money/src/utils/logging_interface.js +3 -0
  160. package/dist/orange_money/src/utils/logging_interface.js.map +1 -0
  161. package/{src/utils/operation_response.ts → dist/orange_money/src/utils/operation_response.d.ts} +9 -10
  162. package/dist/orange_money/src/utils/operation_response.d.ts.map +1 -0
  163. package/dist/orange_money/src/utils/operation_response.js +3 -0
  164. package/dist/orange_money/src/utils/operation_response.js.map +1 -0
  165. package/dist/orange_money/src/utils/utils.d.ts +6 -0
  166. package/dist/orange_money/src/utils/utils.d.ts.map +1 -0
  167. package/dist/orange_money/src/utils/utils.js +10 -0
  168. package/dist/orange_money/src/utils/utils.js.map +1 -0
  169. package/package.json +6 -2
  170. package/.eslintrc.js +0 -47
  171. package/.prettierrc +0 -6
  172. package/babel.config.js +0 -3
  173. package/index.spec.ts +0 -9
  174. package/index.ts +0 -1
  175. package/jest.before-test.ts +0 -3
  176. package/jest.config.ts +0 -54
  177. package/src/disbursements/implementations/disbursement_service.ts +0 -133
  178. package/src/disbursements/implementations/src/live.ts +0 -79
  179. package/src/disbursements/implementations/src/sandbox.ts +0 -124
  180. package/src/disbursements/operations/create_access_token.spec.ts +0 -87
  181. package/src/disbursements/operations/create_access_token.ts +0 -83
  182. package/src/disbursements/operations/get_transfer_status.spec.ts +0 -132
  183. package/src/disbursements/operations/get_transfer_status.ts +0 -265
  184. package/src/disbursements/operations/transfer.spec.ts +0 -158
  185. package/src/disbursements/operations/transfer.ts +0 -125
  186. package/src/disbursements/routes/routes.ts +0 -54
  187. package/src/disbursements/utils/constants.ts +0 -4
  188. package/src/disbursements/utils/regex.spec.ts +0 -39
  189. package/src/disbursements/utils/status.ts +0 -62
  190. package/src/disbursements/utils/utils.spec.ts +0 -42
  191. package/src/disbursements/utils/utils.ts +0 -24
  192. package/src/payments/implementations/fake.ts +0 -133
  193. package/src/payments/implementations/live.ts +0 -87
  194. package/src/payments/operations/get_access_token.spec.ts +0 -60
  195. package/src/payments/operations/get_access_token.ts +0 -77
  196. package/src/payments/operations/get_pay_token.spec.ts +0 -65
  197. package/src/payments/operations/get_pay_token.ts +0 -66
  198. package/src/payments/operations/get_payment_status.spec.ts +0 -82
  199. package/src/payments/operations/get_payment_status.ts +0 -78
  200. package/src/payments/operations/initialize_om_payment.spec.ts +0 -234
  201. package/src/payments/operations/initialize_om_payment.ts +0 -191
  202. package/src/payments/payments.ts +0 -86
  203. package/src/payments/routes/routes.ts +0 -61
  204. package/src/payments/utils/constants.ts +0 -120
  205. package/src/payments/utils/joi_schema.ts +0 -117
  206. package/src/payments/utils/request_model.ts +0 -103
  207. package/src/payments/utils/utils.ts +0 -31
  208. package/src/utils/https.spec.ts +0 -101
  209. package/src/utils/https.ts +0 -266
  210. package/src/utils/logging_interface.ts +0 -25
  211. package/src/utils/utils.ts +0 -5
  212. package/tsconfig.build.json +0 -4
  213. package/tsconfig.dev.json +0 -4
  214. package/tsconfig.json +0 -27
@@ -1,120 +0,0 @@
1
- export enum ApiKey {
2
- keyAuthorization = 'Authorization',
3
- keyGrantType = 'grant_type',
4
- keyContentType = 'Content-Type',
5
- keyXAuthToken = 'X-AUTH-TOKEN',
6
- keyMerchantKey = 'merchant_key',
7
- keyCurrency = 'currency',
8
- keyOrderId = 'order_id',
9
- keyReturnUrl = 'return_url',
10
- keyCancelUrl = 'cancel_url',
11
- keyWebNotifyUrl = 'notif_url',
12
- keyLang = 'lang',
13
- keyReference = 'reference',
14
- keyAmount = 'amount',
15
- keyPayToken = 'pay_token',
16
- keySubscriberMsisdn = 'subscriberMsisdn',
17
- keyChannelUserMsisdn = 'channelUserMsisdn',
18
- keyDescription = 'description',
19
- keyMobileOrderId = 'orderId',
20
- keyPin = 'pin',
21
- keyMobilePayToken = 'payToken',
22
- keyMobileNotifUrl = 'notifUrl',
23
- }
24
-
25
- /**
26
- * Contains request fields.
27
- */
28
- export class ConstantRequestField {
29
- // The content type field.
30
- public static readonly typeJson = 'application/json';
31
-
32
- // The url encode form.
33
- public static readonly TypeWwwFrom = 'application/x-www-form-urlencoded';
34
-
35
- // The basic authorization field.
36
- public static readonly basic = 'Basic ';
37
-
38
- // The authorization field.
39
- public static readonly authorization = 'AUTHORIZATION';
40
-
41
- // The bearer field.
42
- public static readonly bearer = 'Bearer ';
43
-
44
- // The grant type field.
45
- public static readonly grantType = 'grant_type';
46
-
47
- // The client credentials field.
48
- public static readonly clientCredentials = 'client_credentials';
49
-
50
- // The X-AUTH-TOKEN field.
51
- public static readonly xAuthToken = 'X-AUTH-TOKEN';
52
- }
53
-
54
- /**
55
- * The orange money payment status.
56
- */
57
- export enum OrangeMoneyPaymentStatus {
58
- /**
59
- * User has clicked on “Confirmed”, transaction
60
- * is in progress on Orange system.
61
- */
62
- PENDING_PAYMENT = 'PENDING',
63
-
64
- /**
65
- * The user canceled the payment.
66
- */
67
- CANCELLED_PAYMENT = 'CANCELLED',
68
-
69
- /**
70
- * Waiting for user entry.
71
- * Specially for web.
72
- */
73
- INITIATE_PAYMENT = 'INITIATED',
74
-
75
- /**
76
- * Payment is done for mobile.
77
- */
78
- SUCCESSFULL_MOBILE_PAYMENT = 'SUCCESSFULL',
79
-
80
- /**
81
- * Payment is done for web.
82
- */
83
- SUCCESS_WEB_PAYMENT = 'SUCCESS',
84
-
85
- /**
86
- * Payment has failed.
87
- * On web, the status can failed when user press to confirm payment too
88
- * late or when user enter a wrong validation code.
89
- * On mobile, it may fail when the user does not have a mooney orange wallet
90
- * or the account balance is insufficient.
91
- */
92
- FAILED_PAYMENT = 'FAILED',
93
-
94
- /**
95
- * User has clicked on “Confirmed” too late (after token’s validity), or the
96
- * delay token timeout has expired.
97
- * Note that the minimum token expiration time is 7 min.
98
- */
99
- EXPIRED_PAYMENT = 'EXPIRED',
100
- }
101
-
102
- export enum ApiErrorType {
103
- insufficientFunds = 'insufficientFunds',
104
- invalidOrangeMoneyNumber = 'invalidOrangeMoneyNumber',
105
- invalidData = 'invalidData',
106
- failedToInitiateThePayment = 'failedToInitiateThePayment',
107
- failedToGenerateAccessToken = 'failedToGenerateAccessToken',
108
- failedToCheckPaymentStatus = 'failedToCheckPaymentStatus',
109
- failedToGeneratePayToken = 'failedToGeneratePayToken',
110
- accountLocked = 'accountLocked',
111
- invalidPaymentAmount = 'invalidPaymentAmount',
112
- unauthorized = 'unauthorized',
113
- }
114
-
115
- export enum OrangeMoneyErrorMessage {
116
- beneficiaryNotFound = 'Beneficiaire introuvable',
117
- insufficientFunds = 'Le solde du compte du payeur est insuffisant',
118
- accountLocked = 'Utilisateur bloque',
119
- invalidPaymentAmount = 'Vous avez saisi un montant superieur au montant maximum autorise',
120
- }
@@ -1,117 +0,0 @@
1
- import Joi from 'joi';
2
- import { LoggerInterface } from '../../utils/logging_interface';
3
- import { TargetEnvironment } from '../../utils/utils';
4
- import { OrangeMoneyPaymentStatus } from './constants';
5
-
6
- /**
7
- * The provider generic response data of payment request of status verification request.
8
- */
9
- export type GenericRequestResponseData = {
10
- message: string;
11
- data: {
12
- id: number;
13
- createtime: string | null;
14
- subscriberMsisdn: string;
15
- amount: number;
16
- payToken: string;
17
- txnid: string | null;
18
- txnmode: string | null;
19
- inittxnmessage: string;
20
- inittxnstatus: string;
21
- confirmtxnstatus: string | null;
22
- confirmtxnmessage: string | null;
23
- status: OrangeMoneyPaymentStatus;
24
- notifUrl: string | null;
25
- description: string | null;
26
- channelUserMsisdn: string;
27
- };
28
- };
29
-
30
- /**
31
- * The provider generic response data of payment request of status verification request.
32
- * We only make validation off fields that are required.
33
- */
34
- export const genericRequestResponseSchema =
35
- Joi.object<GenericRequestResponseData>({
36
- message: Joi.string().required(),
37
- data: Joi.object({
38
- subscriberMsisdn: Joi.string().required(),
39
- amount: Joi.number().required(),
40
- inittxnmessage: Joi.string().allow(null).allow('').required(),
41
- status: Joi.string()
42
- .valid(
43
- OrangeMoneyPaymentStatus.FAILED_PAYMENT,
44
- OrangeMoneyPaymentStatus.PENDING_PAYMENT,
45
- OrangeMoneyPaymentStatus.CANCELLED_PAYMENT,
46
- OrangeMoneyPaymentStatus.EXPIRED_PAYMENT,
47
- OrangeMoneyPaymentStatus.SUCCESSFULL_MOBILE_PAYMENT
48
- )
49
- .required(),
50
- channelUserMsisdn: Joi.string().required(),
51
- })
52
- .required()
53
- .unknown(true),
54
- });
55
-
56
- export type InitPaymentBodySchema = {
57
- orderId: string;
58
- description: string;
59
- orangeMoneyVersion?: string;
60
- notifUrl: string;
61
- pin: string;
62
- payToken: string;
63
- amount: number;
64
- channelUserMsisdn: string;
65
- subscriberMsisdn: string;
66
- };
67
-
68
- export const initPaymentBodySchema = Joi.object<InitPaymentBodySchema>({
69
- subscriberMsisdn: Joi.string()
70
- .required()
71
- .pattern(/^(69\d{7}$|65[5-9]\d{6}$)/)
72
- .message(
73
- '[subscriberMsisdn] Invalid orange number. Format of valid number: 69******* or 65[5-9]******'
74
- ),
75
- channelUserMsisdn: Joi.string()
76
- .required()
77
- .pattern(/^(69\d{7}$|65[5-9]\d{6}$)/)
78
- .message(
79
- '[channelUserMsisdn] Invalid orange number. Format of valid number: 69******* or 65[5-9]******'
80
- ),
81
- amount: Joi.string().required(),
82
- payToken: Joi.string().required(),
83
- pin: Joi.string().max(4).required(),
84
- notifUrl: Joi.string().allow('').default(''),
85
- orangeMoneyVersion: Joi.string().optional(),
86
- description: Joi.string().allow('').max(125).default('payment'),
87
- orderId: Joi.string().max(20).required(),
88
- });
89
-
90
- export interface OrangeMoneyPaymentParams {
91
- targetEnvironment: TargetEnvironment;
92
- logger: LoggerInterface;
93
- apiUserName: string;
94
- apiPassword: string;
95
- xAuthToken: string;
96
- orangeMoneyVersion?: string;
97
- }
98
-
99
- /**
100
- * The provider access token request response from the OM server.
101
- */
102
- export type AccessTokenRequestResponse = {
103
- access_token: string;
104
- scope: string;
105
- token_type: string;
106
- expires_in: number;
107
- };
108
-
109
- /**
110
- * The provider payToken request response from the OM server.
111
- */
112
- export type PayTokenRequestResponse = {
113
- message: string;
114
- data: {
115
- payToken: string;
116
- };
117
- };
@@ -1,103 +0,0 @@
1
- import { OperationResponse } from '../../utils/operation_response';
2
- import { ApiErrorType, OrangeMoneyPaymentStatus } from './constants';
3
- import {
4
- AccessTokenRequestResponse,
5
- GenericRequestResponseData,
6
- PayTokenRequestResponse,
7
- } from './joi_schema';
8
-
9
- export type InitializeOrangeMoneyRequest = {
10
- /**
11
- * The phone number of the user making the payment.
12
- */
13
- subscriberNumber: string;
14
- /**
15
- * The phone number of the user receiving the payment.
16
- */
17
- channelUserNumber: string;
18
- /**
19
- * Unique identifier of the customer transaction.
20
- */
21
- transactionId: string;
22
- /**
23
- * The amount of the transaction.
24
- */
25
- amount: number;
26
- /**
27
- * The Pin code of the ChannelUser.
28
- */
29
- pinCode: string;
30
- /**
31
- * An http endpoint able to receive a post request with the following json body.
32
- * {
33
- * ”payToken” : ”payToken”,
34
- * ”status” : status”,
35
- * ”message” : ”message”
36
- * }
37
- */
38
- notifUrl?: string;
39
- /**
40
- * The payment description.
41
- */
42
- description?: string;
43
-
44
- /**
45
- * The payToken value useful to make payment
46
- * and track the status of payment.
47
- */
48
- payToken: string;
49
-
50
- /**
51
- * The access token for authorize the request.
52
- */
53
- accessToken: string;
54
- };
55
-
56
- export type GetOrangeMoneyPaymentRequest = {
57
- /**
58
- * The access token for authorize the request.
59
- */
60
- accessToken: string;
61
-
62
- /**
63
- * unique identifier used to obtain payment status.
64
- */
65
- payToken: string;
66
- };
67
-
68
- /**
69
- * This response is obtained when we initiate a mobile payment request,
70
- * the request would generate a payToken useful to make payment
71
- * and track the status of payment.
72
- */
73
- export type InitializeOrangeMoneyResponse = OperationResponse<
74
- {
75
- /**
76
- * The payToken value useful to make payment
77
- * and track the status of payment.
78
- */
79
- payToken: string;
80
- },
81
- GenericRequestResponseData,
82
- ApiErrorType
83
- >;
84
-
85
- export type GetOrangeMoneyPaymentResponse = OperationResponse<
86
- {
87
- status: OrangeMoneyPaymentStatus;
88
- },
89
- GenericRequestResponseData,
90
- ApiErrorType
91
- >;
92
-
93
- export type GetAccessTokenResponse = OperationResponse<
94
- string,
95
- AccessTokenRequestResponse | undefined,
96
- ApiErrorType
97
- >;
98
-
99
- export type GetPayTokenResponse = OperationResponse<
100
- string,
101
- PayTokenRequestResponse | undefined,
102
- ApiErrorType
103
- >;
@@ -1,31 +0,0 @@
1
- import Joi from 'joi';
2
-
3
- /**
4
- * Checks if the data is valid type.
5
- * @param {Record<string, unknown>} data .
6
- * @param {Joi.PartialSchemaMap<T>} schema .
7
- * @return {Record<string, unknown>}
8
- */
9
- export function validateData<T>(
10
- data: unknown,
11
- schema: Joi.ObjectSchema<T>
12
- ): { isValidData: true; data: T } | { isValidData: false; message: string } {
13
- const { error, value } = schema.unknown(true).validate(data, {
14
- abortEarly: false,
15
- convert: false,
16
- });
17
- if (error) {
18
- return {
19
- isValidData: false,
20
- message: JSON.stringify(
21
- error.details.map((e) => e.message),
22
- null,
23
- ' '
24
- ),
25
- };
26
- }
27
- return {
28
- isValidData: true,
29
- data: value,
30
- };
31
- }
@@ -1,101 +0,0 @@
1
- import {
2
- encodeTheBodyOfRequest,
3
- encodeToBase64,
4
- hash,
5
- parseAxiosError,
6
- } from './https';
7
- import { AxiosError, AxiosResponse } from 'axios';
8
-
9
- describe('hash', () => {
10
- const btoaRef = global.btoa;
11
- it('should still Hash if the btao function is not available', () => {
12
- global.btoa = undefined as unknown as typeof btoaRef;
13
- const hashResponse = hash('key', 'secret');
14
- expect(hashResponse).toBe('a2V5OnNlY3JldA==');
15
- global.btoa = btoaRef;
16
- });
17
- });
18
-
19
- describe('parseAxiosError', () => {
20
- it('should return initial obj if not instance of axios error', () => {
21
- const initialObj = { key: 'ERROR_100' };
22
- const parsedResponse = parseAxiosError(initialObj);
23
- expect(parsedResponse).toBe(initialObj);
24
- });
25
-
26
- it('should have the configuration failed message when config failed', () => {
27
- const message = 'configuration failed';
28
- const parsedResponse = parseAxiosError(
29
- new AxiosError(message) as unknown as Record<string, unknown>
30
- );
31
- expect(parsedResponse).toEqual({
32
- configFailed: message,
33
- });
34
- });
35
-
36
- it('should return request failed when axios is unable to send the request.', () => {
37
- const request = {
38
- headers: {
39
- 'Content-Type': 'application/json',
40
- },
41
- };
42
- const parsedResponse = parseAxiosError(
43
- new AxiosError('message', '400', undefined, request) as unknown as Record<
44
- string,
45
- unknown
46
- >
47
- );
48
- expect(parsedResponse).toEqual({
49
- requestFailed: { data: undefined, headers: undefined },
50
- });
51
- });
52
-
53
- it('should return response error when the request response fail to be retrieve.', () => {
54
- const request = {
55
- headers: {
56
- 'Content-Type': 'application/json',
57
- },
58
- body: '',
59
- };
60
- const response = <AxiosResponse>{
61
- data: '',
62
- status: 201,
63
- statusText: 'created',
64
- headers: {},
65
- request: request,
66
- };
67
-
68
- const parsedResponse = parseAxiosError(
69
- new AxiosError(
70
- 'message',
71
- '400',
72
- undefined,
73
- request,
74
- response
75
- ) as unknown as Record<string, unknown>
76
- );
77
- expect(parsedResponse).toEqual({
78
- responseError: {
79
- data: response.data,
80
- status: response.status,
81
- statusText: response.statusText,
82
- headers: response.headers,
83
- },
84
- requestBody: request.body,
85
- });
86
- });
87
- });
88
-
89
- describe('Test the utils function', () => {
90
- it('Generate the base 64 encoding', async () => {
91
- const value = encodeToBase64('123', '123');
92
- expect(value).toEqual('MTIzOjEyMw');
93
- });
94
- it('encode the body request', async () => {
95
- const body = {
96
- amount: '123',
97
- };
98
- const value = encodeTheBodyOfRequest(body);
99
- expect(value).toEqual('amount=123');
100
- });
101
- });