pi-spi-sdk 0.1.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.
Files changed (208) hide show
  1. package/CHANGELOG.md +33 -0
  2. package/LICENSE +22 -0
  3. package/README.md +300 -0
  4. package/dist/config.d.ts +35 -0
  5. package/dist/config.js +4 -0
  6. package/dist/error-handler.d.ts +7 -0
  7. package/dist/error-handler.js +52 -0
  8. package/dist/errors.d.ts +25 -0
  9. package/dist/errors.js +40 -0
  10. package/dist/examples.d.ts +8 -0
  11. package/dist/examples.js +91 -0
  12. package/dist/generated/core/ApiError.d.ts +10 -0
  13. package/dist/generated/core/ApiError.js +11 -0
  14. package/dist/generated/core/ApiRequestOptions.d.ts +13 -0
  15. package/dist/generated/core/ApiRequestOptions.js +1 -0
  16. package/dist/generated/core/ApiResult.d.ts +7 -0
  17. package/dist/generated/core/ApiResult.js +1 -0
  18. package/dist/generated/core/CancelablePromise.d.ts +20 -0
  19. package/dist/generated/core/CancelablePromise.js +111 -0
  20. package/dist/generated/core/OpenAPI.d.ts +16 -0
  21. package/dist/generated/core/OpenAPI.js +11 -0
  22. package/dist/generated/core/request.d.ts +34 -0
  23. package/dist/generated/core/request.js +269 -0
  24. package/dist/generated/index.d.ts +78 -0
  25. package/dist/generated/index.js +43 -0
  26. package/dist/generated/models/AliasCreationReponse.d.ts +22 -0
  27. package/dist/generated/models/AliasCreationReponse.js +1 -0
  28. package/dist/generated/models/AliasCreationRequest.d.ts +11 -0
  29. package/dist/generated/models/AliasCreationRequest.js +1 -0
  30. package/dist/generated/models/AliasReponseListe.d.ts +26 -0
  31. package/dist/generated/models/AliasReponseListe.js +1 -0
  32. package/dist/generated/models/AnnulationStatut.d.ts +13 -0
  33. package/dist/generated/models/AnnulationStatut.js +18 -0
  34. package/dist/generated/models/Champs.d.ts +1 -0
  35. package/dist/generated/models/Champs.js +1 -0
  36. package/dist/generated/models/CompteOperation.d.ts +72 -0
  37. package/dist/generated/models/CompteOperation.js +24 -0
  38. package/dist/generated/models/CompteOperationListe.d.ts +18 -0
  39. package/dist/generated/models/CompteOperationListe.js +1 -0
  40. package/dist/generated/models/CompteSolde.d.ts +129 -0
  41. package/dist/generated/models/CompteSolde.js +71 -0
  42. package/dist/generated/models/CompteTransfertIntraReponse.d.ts +33 -0
  43. package/dist/generated/models/CompteTransfertIntraReponse.js +12 -0
  44. package/dist/generated/models/CompteTransfertIntraRequest.d.ts +9 -0
  45. package/dist/generated/models/CompteTransfertIntraRequest.js +1 -0
  46. package/dist/generated/models/DemandePaiementConfirmationAnnulationRaison.d.ts +14 -0
  47. package/dist/generated/models/DemandePaiementConfirmationAnnulationRaison.js +19 -0
  48. package/dist/generated/models/DemandePaiementConfirmationReponse.d.ts +41 -0
  49. package/dist/generated/models/DemandePaiementConfirmationReponse.js +13 -0
  50. package/dist/generated/models/DemandePaiementConfirmationRequest.d.ts +3 -0
  51. package/dist/generated/models/DemandePaiementConfirmationRequest.js +1 -0
  52. package/dist/generated/models/DemandePaiementConfirmationRequestAccepter.d.ts +9 -0
  53. package/dist/generated/models/DemandePaiementConfirmationRequestAccepter.js +1 -0
  54. package/dist/generated/models/DemandePaiementConfirmationRequestRejeter.d.ts +9 -0
  55. package/dist/generated/models/DemandePaiementConfirmationRequestRejeter.js +1 -0
  56. package/dist/generated/models/DemandePaiementConsultationReponse.d.ts +151 -0
  57. package/dist/generated/models/DemandePaiementConsultationReponse.js +27 -0
  58. package/dist/generated/models/DemandePaiementEnMasseConfirmationRequest.d.ts +3 -0
  59. package/dist/generated/models/DemandePaiementEnMasseConfirmationRequest.js +1 -0
  60. package/dist/generated/models/DemandePaiementEnMasseConfirmationRequestAccepter.d.ts +9 -0
  61. package/dist/generated/models/DemandePaiementEnMasseConfirmationRequestAccepter.js +1 -0
  62. package/dist/generated/models/DemandePaiementEnMasseConfirmationRequestRejeter.d.ts +9 -0
  63. package/dist/generated/models/DemandePaiementEnMasseConfirmationRequestRejeter.js +1 -0
  64. package/dist/generated/models/DemandePaiementEnMasseRequest.d.ts +74 -0
  65. package/dist/generated/models/DemandePaiementEnMasseRequest.js +1 -0
  66. package/dist/generated/models/DemandePaiementEnMasseStatutReponse.d.ts +98 -0
  67. package/dist/generated/models/DemandePaiementEnMasseStatutReponse.js +20 -0
  68. package/dist/generated/models/DemandePaiementListe.d.ts +26 -0
  69. package/dist/generated/models/DemandePaiementListe.js +1 -0
  70. package/dist/generated/models/DemandePaiementListeItem.d.ts +163 -0
  71. package/dist/generated/models/DemandePaiementListeItem.js +27 -0
  72. package/dist/generated/models/DemandePaiementReponse.d.ts +129 -0
  73. package/dist/generated/models/DemandePaiementReponse.js +1 -0
  74. package/dist/generated/models/DemandePaiementReponseRequest.d.ts +21 -0
  75. package/dist/generated/models/DemandePaiementReponseRequest.js +11 -0
  76. package/dist/generated/models/DemandePaiementRequest.d.ts +98 -0
  77. package/dist/generated/models/DemandePaiementRequest.js +7 -0
  78. package/dist/generated/models/DemandePaiementRequestBase.d.ts +42 -0
  79. package/dist/generated/models/DemandePaiementRequestBase.js +1 -0
  80. package/dist/generated/models/DemandePaiementRequestCategorie.d.ts +12 -0
  81. package/dist/generated/models/DemandePaiementRequestCategorie.js +17 -0
  82. package/dist/generated/models/DemandePaiementStatut.d.ts +13 -0
  83. package/dist/generated/models/DemandePaiementStatut.js +18 -0
  84. package/dist/generated/models/DemandePaiementStatutRaison.d.ts +46 -0
  85. package/dist/generated/models/DemandePaiementStatutRaison.js +51 -0
  86. package/dist/generated/models/ListeMeta.d.ts +14 -0
  87. package/dist/generated/models/ListeMeta.js +1 -0
  88. package/dist/generated/models/Paiement.d.ts +156 -0
  89. package/dist/generated/models/Paiement.js +28 -0
  90. package/dist/generated/models/PaiementAnnulationMotif.d.ts +17 -0
  91. package/dist/generated/models/PaiementAnnulationMotif.js +22 -0
  92. package/dist/generated/models/PaiementAnnulationReponseRequest.d.ts +11 -0
  93. package/dist/generated/models/PaiementAnnulationReponseRequest.js +1 -0
  94. package/dist/generated/models/PaiementAnnulationReponseRequestAccepter.d.ts +9 -0
  95. package/dist/generated/models/PaiementAnnulationReponseRequestAccepter.js +1 -0
  96. package/dist/generated/models/PaiementAnnulationReponseRequestRejeter.d.ts +9 -0
  97. package/dist/generated/models/PaiementAnnulationReponseRequestRejeter.js +1 -0
  98. package/dist/generated/models/PaiementAnnulationRequest.d.ts +4 -0
  99. package/dist/generated/models/PaiementAnnulationRequest.js +1 -0
  100. package/dist/generated/models/PaiementAnnulationStatutRaison.d.ts +21 -0
  101. package/dist/generated/models/PaiementAnnulationStatutRaison.js +26 -0
  102. package/dist/generated/models/PaiementEnMasseConfirmationRequest.d.ts +3 -0
  103. package/dist/generated/models/PaiementEnMasseConfirmationRequest.js +1 -0
  104. package/dist/generated/models/PaiementEnMasseConfirmationRequestAccepter.d.ts +9 -0
  105. package/dist/generated/models/PaiementEnMasseConfirmationRequestAccepter.js +1 -0
  106. package/dist/generated/models/PaiementEnMasseConfirmationRequestRejeter.d.ts +9 -0
  107. package/dist/generated/models/PaiementEnMasseConfirmationRequestRejeter.js +1 -0
  108. package/dist/generated/models/PaiementEnMasseReponseStatut.d.ts +97 -0
  109. package/dist/generated/models/PaiementEnMasseReponseStatut.js +20 -0
  110. package/dist/generated/models/PaiementEnMasseRequest.d.ts +54 -0
  111. package/dist/generated/models/PaiementEnMasseRequest.js +1 -0
  112. package/dist/generated/models/PaiementImmediatConfirmationReponse.d.ts +31 -0
  113. package/dist/generated/models/PaiementImmediatConfirmationReponse.js +7 -0
  114. package/dist/generated/models/PaiementImmediatConfirmationRequest.d.ts +3 -0
  115. package/dist/generated/models/PaiementImmediatConfirmationRequest.js +1 -0
  116. package/dist/generated/models/PaiementImmediatConfirmationRequestAccepter.d.ts +9 -0
  117. package/dist/generated/models/PaiementImmediatConfirmationRequestAccepter.js +1 -0
  118. package/dist/generated/models/PaiementImmediatConfirmationRequestRejeter.d.ts +9 -0
  119. package/dist/generated/models/PaiementImmediatConfirmationRequestRejeter.js +1 -0
  120. package/dist/generated/models/PaiementImmediatReponse.d.ts +98 -0
  121. package/dist/generated/models/PaiementImmediatReponse.js +7 -0
  122. package/dist/generated/models/PaiementImmediatRequest.d.ts +13 -0
  123. package/dist/generated/models/PaiementImmediatRequest.js +1 -0
  124. package/dist/generated/models/PaiementListe.d.ts +6 -0
  125. package/dist/generated/models/PaiementListe.js +1 -0
  126. package/dist/generated/models/PaiementRequest.d.ts +33 -0
  127. package/dist/generated/models/PaiementRequest.js +1 -0
  128. package/dist/generated/models/PaiementStatut.d.ts +13 -0
  129. package/dist/generated/models/PaiementStatut.js +18 -0
  130. package/dist/generated/models/PaiementStatutRaison.d.ts +56 -0
  131. package/dist/generated/models/PaiementStatutRaison.js +61 -0
  132. package/dist/generated/models/Problem7807.d.ts +31 -0
  133. package/dist/generated/models/Problem7807.js +1 -0
  134. package/dist/generated/models/RefDocType.d.ts +38 -0
  135. package/dist/generated/models/RefDocType.js +43 -0
  136. package/dist/generated/models/RetourStatut.d.ts +13 -0
  137. package/dist/generated/models/RetourStatut.js +18 -0
  138. package/dist/generated/models/RetourStatutRaison.d.ts +25 -0
  139. package/dist/generated/models/RetourStatutRaison.js +30 -0
  140. package/dist/generated/models/WebhookCreationRequest.d.ts +14 -0
  141. package/dist/generated/models/WebhookCreationRequest.js +1 -0
  142. package/dist/generated/models/WebhookCreationResponse.d.ts +12 -0
  143. package/dist/generated/models/WebhookCreationResponse.js +1 -0
  144. package/dist/generated/models/WebhookData.d.ts +8 -0
  145. package/dist/generated/models/WebhookData.js +1 -0
  146. package/dist/generated/models/WebhookEvent.d.ts +191 -0
  147. package/dist/generated/models/WebhookEvent.js +42 -0
  148. package/dist/generated/models/WebhookEventsList.d.ts +13 -0
  149. package/dist/generated/models/WebhookEventsList.js +1 -0
  150. package/dist/generated/models/WebhookList.d.ts +13 -0
  151. package/dist/generated/models/WebhookList.js +1 -0
  152. package/dist/generated/models/WebhookModificationRequest.d.ts +4 -0
  153. package/dist/generated/models/WebhookModificationRequest.js +1 -0
  154. package/dist/generated/models/WebhooksEvents.d.ts +12 -0
  155. package/dist/generated/models/WebhooksEvents.js +17 -0
  156. package/dist/generated/services/AliasService.d.ts +63 -0
  157. package/dist/generated/services/AliasService.js +84 -0
  158. package/dist/generated/services/ComptesService.d.ts +64 -0
  159. package/dist/generated/services/ComptesService.js +86 -0
  160. package/dist/generated/services/DemandeAnnulationService.d.ts +84 -0
  161. package/dist/generated/services/DemandeAnnulationService.js +99 -0
  162. package/dist/generated/services/DemandesDePaiementEnMasseService.d.ts +161 -0
  163. package/dist/generated/services/DemandesDePaiementEnMasseService.js +189 -0
  164. package/dist/generated/services/DemandesDePaiementService.d.ts +123 -0
  165. package/dist/generated/services/DemandesDePaiementService.js +161 -0
  166. package/dist/generated/services/NotificationService.d.ts +80 -0
  167. package/dist/generated/services/NotificationService.js +132 -0
  168. package/dist/generated/services/PaiementEnMasseService.d.ts +159 -0
  169. package/dist/generated/services/PaiementEnMasseService.js +187 -0
  170. package/dist/generated/services/PaiementImmediatService.d.ts +135 -0
  171. package/dist/generated/services/PaiementImmediatService.js +176 -0
  172. package/dist/generated/services/RetoursdeFondsService.d.ts +28 -0
  173. package/dist/generated/services/RetoursdeFondsService.js +37 -0
  174. package/dist/index.d.ts +14 -0
  175. package/dist/index.js +23 -0
  176. package/dist/query-builder.d.ts +91 -0
  177. package/dist/query-builder.js +187 -0
  178. package/dist/sdk.d.ts +88 -0
  179. package/dist/sdk.js +107 -0
  180. package/dist/services/alias.d.ts +72 -0
  181. package/dist/services/alias.js +82 -0
  182. package/dist/services/base.d.ts +9 -0
  183. package/dist/services/base.js +17 -0
  184. package/dist/services/comptes.d.ts +149 -0
  185. package/dist/services/comptes.js +158 -0
  186. package/dist/services/demandes-annulation.d.ts +97 -0
  187. package/dist/services/demandes-annulation.js +104 -0
  188. package/dist/services/demandes-paiement-en-masse.d.ts +139 -0
  189. package/dist/services/demandes-paiement-en-masse.js +139 -0
  190. package/dist/services/demandes-paiement.d.ts +144 -0
  191. package/dist/services/demandes-paiement.js +151 -0
  192. package/dist/services/paiements-en-masse.d.ts +152 -0
  193. package/dist/services/paiements-en-masse.js +153 -0
  194. package/dist/services/paiements.d.ts +135 -0
  195. package/dist/services/paiements.js +135 -0
  196. package/dist/services/retours-fonds.d.ts +94 -0
  197. package/dist/services/retours-fonds.js +100 -0
  198. package/dist/services/webhooks.d.ts +131 -0
  199. package/dist/services/webhooks.js +142 -0
  200. package/dist/types/alias.d.ts +64 -0
  201. package/dist/types/alias.js +73 -0
  202. package/dist/utils/constants.d.ts +93 -0
  203. package/dist/utils/constants.js +93 -0
  204. package/dist/utils/index.d.ts +60 -0
  205. package/dist/utils/index.js +115 -0
  206. package/package.json +81 -0
  207. package/scripts/post-generate.js +129 -0
  208. package/scripts/pre-generate.js +106 -0
@@ -0,0 +1,131 @@
1
+ /**
2
+ * Webhooks (Notifications) service wrapper
3
+ *
4
+ * Provides methods for managing webhook configurations to receive real-time notifications
5
+ * about payment events, payment requests, and fund returns.
6
+ *
7
+ * **Supported Events:**
8
+ * - Payment events: `PAIEMENT_RECU`, `PAIEMENT_ENVOYE`, `PAIEMENT_REJETE`
9
+ * - Payment request events: `RTP_RECU`, `RTP_REJETE`
10
+ * - Fund return events: `RETOUR_ENVOYE`, `RETOUR_REJETE`, `RETOUR_RECU`
11
+ * - Cancellation events: `ANNULATION_DEMANDE`, `ANNULATION_REJETE`
12
+ *
13
+ * **Webhook Security:**
14
+ * - All communications must use SSL/TLS
15
+ * - mTLS authentication required (certificate from BCEAO CA)
16
+ * - Events are signed with HMAC for data integrity
17
+ *
18
+ * @example
19
+ * ```typescript
20
+ * // Create webhook for payment notifications
21
+ * const webhook = await sdk.webhooks.create({
22
+ * callbackUrl: 'https://business.example.com/api/webhooks/pi-spi',
23
+ * events: ['PAIEMENT_RECU', 'PAIEMENT_ENVOYE']
24
+ * });
25
+ * ```
26
+ */
27
+ import { BaseService } from './base';
28
+ import type { QueryParams } from '../query-builder';
29
+ export declare class WebhooksService extends BaseService {
30
+ /**
31
+ * Create a webhook configuration
32
+ *
33
+ * **Webhook Setup:**
34
+ * - URL must be HTTPS
35
+ * - Server must support mTLS with BCEAO-issued certificate
36
+ * - Server must validate HMAC signatures
37
+ * - Server must respond with 2xx status code
38
+ *
39
+ * **Event Types:**
40
+ * - `PAIEMENT_RECU`: Payment received
41
+ * - `PAIEMENT_ENVOYE`: Payment sent (irreversible)
42
+ * - `PAIEMENT_REJETE`: Payment rejected
43
+ * - `RTP_RECU`: Payment request received
44
+ * - `RTP_REJETE`: Payment request rejected
45
+ * - `RETOUR_ENVOYE`: Fund return sent
46
+ * - `RETOUR_REJETE`: Fund return rejected
47
+ * - `RETOUR_RECU`: Fund return received
48
+ * - `ANNULATION_DEMANDE`: Cancellation request received
49
+ * - `ANNULATION_REJETE`: Cancellation request rejected
50
+ *
51
+ * @param webhook - Webhook configuration
52
+ * @param webhook.callbackUrl - HTTPS URL to receive notifications (must support mTLS)
53
+ * @param webhook.events - Array of event types to subscribe to
54
+ * @param webhook.alias - Optional: Alias-specific webhook (only notifications for this alias)
55
+ * @returns Created webhook configuration
56
+ * @throws {PiSpiValidationError} If URL is invalid or events array is empty
57
+ *
58
+ * @example
59
+ * ```typescript
60
+ * // Webhook for all payment events
61
+ * await sdk.webhooks.create({
62
+ * callbackUrl: 'https://business.example.com/api/webhooks/pi-spi',
63
+ * events: ['PAIEMENT_RECU', 'PAIEMENT_ENVOYE', 'PAIEMENT_REJETE']
64
+ * });
65
+ *
66
+ * // Alias-specific webhook
67
+ * await sdk.webhooks.create({
68
+ * callbackUrl: 'https://business.example.com/api/webhooks/pi-spi',
69
+ * events: ['PAIEMENT_RECU'],
70
+ * alias: '8b1b2499-3e50-435b-b757-ac7a83d8aa7f'
71
+ * });
72
+ * ```
73
+ */
74
+ create(webhook: {
75
+ callbackUrl: string;
76
+ events: string[];
77
+ alias?: string;
78
+ }): Promise<never>;
79
+ /**
80
+ * List all configured webhooks
81
+ *
82
+ * @param params - Query parameters for pagination
83
+ * @returns Paginated list of webhooks
84
+ *
85
+ * @example
86
+ * ```typescript
87
+ * const webhooks = await sdk.webhooks.list({ page: 1, size: 20 });
88
+ * ```
89
+ */
90
+ list(params?: QueryParams): Promise<never>;
91
+ /**
92
+ * Get webhook details by ID
93
+ *
94
+ * @param id - Webhook ID
95
+ * @returns Webhook details
96
+ * @throws {PiSpiNotFoundError} If webhook not found
97
+ */
98
+ get(id: string): Promise<never>;
99
+ /**
100
+ * Update webhook configuration
101
+ *
102
+ * @param id - Webhook ID
103
+ * @param webhook - Updated webhook configuration
104
+ * @param webhook.callbackUrl - New callback URL (optional)
105
+ * @param webhook.events - New event subscriptions (optional)
106
+ * @param webhook.alias - New alias filter (optional)
107
+ * @returns Updated webhook configuration
108
+ * @throws {PiSpiNotFoundError} If webhook not found
109
+ * @throws {PiSpiValidationError} If update fails validation
110
+ *
111
+ * @example
112
+ * ```typescript
113
+ * await sdk.webhooks.update('webhook-001', {
114
+ * callbackUrl: 'https://updated-url.com/webhooks/pi-spi',
115
+ * events: ['PAIEMENT_RECU', 'RTP_RECU']
116
+ * });
117
+ * ```
118
+ */
119
+ update(id: string, webhook: {
120
+ callbackUrl?: string;
121
+ events?: string[];
122
+ alias?: string;
123
+ }): Promise<never>;
124
+ /**
125
+ * Delete a webhook configuration
126
+ *
127
+ * @param id - Webhook ID
128
+ * @throws {PiSpiNotFoundError} If webhook not found
129
+ */
130
+ delete(id: string): Promise<never>;
131
+ }
@@ -0,0 +1,142 @@
1
+ /**
2
+ * Webhooks (Notifications) service wrapper
3
+ *
4
+ * Provides methods for managing webhook configurations to receive real-time notifications
5
+ * about payment events, payment requests, and fund returns.
6
+ *
7
+ * **Supported Events:**
8
+ * - Payment events: `PAIEMENT_RECU`, `PAIEMENT_ENVOYE`, `PAIEMENT_REJETE`
9
+ * - Payment request events: `RTP_RECU`, `RTP_REJETE`
10
+ * - Fund return events: `RETOUR_ENVOYE`, `RETOUR_REJETE`, `RETOUR_RECU`
11
+ * - Cancellation events: `ANNULATION_DEMANDE`, `ANNULATION_REJETE`
12
+ *
13
+ * **Webhook Security:**
14
+ * - All communications must use SSL/TLS
15
+ * - mTLS authentication required (certificate from BCEAO CA)
16
+ * - Events are signed with HMAC for data integrity
17
+ *
18
+ * @example
19
+ * ```typescript
20
+ * // Create webhook for payment notifications
21
+ * const webhook = await sdk.webhooks.create({
22
+ * callbackUrl: 'https://business.example.com/api/webhooks/pi-spi',
23
+ * events: ['PAIEMENT_RECU', 'PAIEMENT_ENVOYE']
24
+ * });
25
+ * ```
26
+ */
27
+ import { BaseService } from './base';
28
+ export class WebhooksService extends BaseService {
29
+ /**
30
+ * Create a webhook configuration
31
+ *
32
+ * **Webhook Setup:**
33
+ * - URL must be HTTPS
34
+ * - Server must support mTLS with BCEAO-issued certificate
35
+ * - Server must validate HMAC signatures
36
+ * - Server must respond with 2xx status code
37
+ *
38
+ * **Event Types:**
39
+ * - `PAIEMENT_RECU`: Payment received
40
+ * - `PAIEMENT_ENVOYE`: Payment sent (irreversible)
41
+ * - `PAIEMENT_REJETE`: Payment rejected
42
+ * - `RTP_RECU`: Payment request received
43
+ * - `RTP_REJETE`: Payment request rejected
44
+ * - `RETOUR_ENVOYE`: Fund return sent
45
+ * - `RETOUR_REJETE`: Fund return rejected
46
+ * - `RETOUR_RECU`: Fund return received
47
+ * - `ANNULATION_DEMANDE`: Cancellation request received
48
+ * - `ANNULATION_REJETE`: Cancellation request rejected
49
+ *
50
+ * @param webhook - Webhook configuration
51
+ * @param webhook.callbackUrl - HTTPS URL to receive notifications (must support mTLS)
52
+ * @param webhook.events - Array of event types to subscribe to
53
+ * @param webhook.alias - Optional: Alias-specific webhook (only notifications for this alias)
54
+ * @returns Created webhook configuration
55
+ * @throws {PiSpiValidationError} If URL is invalid or events array is empty
56
+ *
57
+ * @example
58
+ * ```typescript
59
+ * // Webhook for all payment events
60
+ * await sdk.webhooks.create({
61
+ * callbackUrl: 'https://business.example.com/api/webhooks/pi-spi',
62
+ * events: ['PAIEMENT_RECU', 'PAIEMENT_ENVOYE', 'PAIEMENT_REJETE']
63
+ * });
64
+ *
65
+ * // Alias-specific webhook
66
+ * await sdk.webhooks.create({
67
+ * callbackUrl: 'https://business.example.com/api/webhooks/pi-spi',
68
+ * events: ['PAIEMENT_RECU'],
69
+ * alias: '8b1b2499-3e50-435b-b757-ac7a83d8aa7f'
70
+ * });
71
+ * ```
72
+ */
73
+ async create(webhook) {
74
+ return this.execute(async () => {
75
+ throw new Error('Service not yet generated. Run "pnpm run generate" first.');
76
+ });
77
+ }
78
+ /**
79
+ * List all configured webhooks
80
+ *
81
+ * @param params - Query parameters for pagination
82
+ * @returns Paginated list of webhooks
83
+ *
84
+ * @example
85
+ * ```typescript
86
+ * const webhooks = await sdk.webhooks.list({ page: 1, size: 20 });
87
+ * ```
88
+ */
89
+ async list(params) {
90
+ return this.execute(async () => {
91
+ throw new Error('Service not yet generated. Run "pnpm run generate" first.');
92
+ });
93
+ }
94
+ /**
95
+ * Get webhook details by ID
96
+ *
97
+ * @param id - Webhook ID
98
+ * @returns Webhook details
99
+ * @throws {PiSpiNotFoundError} If webhook not found
100
+ */
101
+ async get(id) {
102
+ return this.execute(async () => {
103
+ throw new Error('Service not yet generated. Run "pnpm run generate" first.');
104
+ });
105
+ }
106
+ /**
107
+ * Update webhook configuration
108
+ *
109
+ * @param id - Webhook ID
110
+ * @param webhook - Updated webhook configuration
111
+ * @param webhook.callbackUrl - New callback URL (optional)
112
+ * @param webhook.events - New event subscriptions (optional)
113
+ * @param webhook.alias - New alias filter (optional)
114
+ * @returns Updated webhook configuration
115
+ * @throws {PiSpiNotFoundError} If webhook not found
116
+ * @throws {PiSpiValidationError} If update fails validation
117
+ *
118
+ * @example
119
+ * ```typescript
120
+ * await sdk.webhooks.update('webhook-001', {
121
+ * callbackUrl: 'https://updated-url.com/webhooks/pi-spi',
122
+ * events: ['PAIEMENT_RECU', 'RTP_RECU']
123
+ * });
124
+ * ```
125
+ */
126
+ async update(id, webhook) {
127
+ return this.execute(async () => {
128
+ throw new Error('Service not yet generated. Run "pnpm run generate" first.');
129
+ });
130
+ }
131
+ /**
132
+ * Delete a webhook configuration
133
+ *
134
+ * @param id - Webhook ID
135
+ * @throws {PiSpiNotFoundError} If webhook not found
136
+ */
137
+ async delete(id) {
138
+ return this.execute(async () => {
139
+ throw new Error('Service not yet generated. Run "pnpm run generate" first.');
140
+ });
141
+ }
142
+ }
@@ -0,0 +1,64 @@
1
+ /**
2
+ * Alias Types for PI-SPI
3
+ *
4
+ * The PI-SPI platform supports different types of account aliases:
5
+ *
6
+ * - **SHID**: A randomly generated 36-character unique payment address (UUID format).
7
+ * Generated by the system when created. Available for all client types (P, C, B, G).
8
+ * Example: `8b1b2499-3e50-435b-b757-ac7a83d8aa7f`
9
+ *
10
+ * - **MCOD**: Merchant code identifier for USSD payment support.
11
+ * Available for business clients only (C, B, G). Format: alphanumeric code.
12
+ * Example: `SNF00_2E4TY`
13
+ *
14
+ * - **MBNO**: Mobile phone number alias.
15
+ * Available for individual clients (P) only. Format: phone number.
16
+ * Example: `+221771234567`
17
+ *
18
+ * **Client Type Restrictions:**
19
+ * - Type P (Individuals): Can create MBNO and SHID aliases
20
+ * - Types C, B, G (Businesses): Can create SHID and MCOD aliases
21
+ *
22
+ * **Limits:**
23
+ * - Default limit: 20 aliases per account
24
+ * - Limit can be increased based on client needs
25
+ */
26
+ /**
27
+ * Alias type values as defined in the PI-SPI API specification
28
+ */
29
+ export declare const AliasType: {
30
+ /**
31
+ * SHID - System-generated unique payment address (UUID format, 36 characters)
32
+ * Available for all client types: P, C, B, G
33
+ */
34
+ readonly SHID: "SHID";
35
+ /**
36
+ * MCOD - Merchant code for USSD payment support
37
+ * Available for business clients only: C, B, G
38
+ */
39
+ readonly MCOD: "MCOD";
40
+ /**
41
+ * MBNO - Mobile phone number alias
42
+ * Available for individual clients only: P
43
+ */
44
+ readonly MBNO: "MBNO";
45
+ };
46
+ /**
47
+ * Type representing a valid alias type
48
+ */
49
+ export type AliasType = (typeof AliasType)[keyof typeof AliasType];
50
+ /**
51
+ * Valid alias types as a tuple for runtime validation
52
+ */
53
+ export declare const ALIAS_TYPES: readonly ["SHID", "MCOD", "MBNO"];
54
+ /**
55
+ * Check if a string is a valid alias type
56
+ */
57
+ export declare function isValidAliasType(value: string): value is AliasType;
58
+ /**
59
+ * Get available alias types for a client type
60
+ *
61
+ * @param clientType - Client type: 'P' (Individual), 'C' (Merchant), 'B' (Business), 'G' (Government)
62
+ * @returns Array of available alias types for the client type
63
+ */
64
+ export declare function getAvailableAliasTypes(clientType: 'P' | 'C' | 'B' | 'G'): AliasType[];
@@ -0,0 +1,73 @@
1
+ /**
2
+ * Alias Types for PI-SPI
3
+ *
4
+ * The PI-SPI platform supports different types of account aliases:
5
+ *
6
+ * - **SHID**: A randomly generated 36-character unique payment address (UUID format).
7
+ * Generated by the system when created. Available for all client types (P, C, B, G).
8
+ * Example: `8b1b2499-3e50-435b-b757-ac7a83d8aa7f`
9
+ *
10
+ * - **MCOD**: Merchant code identifier for USSD payment support.
11
+ * Available for business clients only (C, B, G). Format: alphanumeric code.
12
+ * Example: `SNF00_2E4TY`
13
+ *
14
+ * - **MBNO**: Mobile phone number alias.
15
+ * Available for individual clients (P) only. Format: phone number.
16
+ * Example: `+221771234567`
17
+ *
18
+ * **Client Type Restrictions:**
19
+ * - Type P (Individuals): Can create MBNO and SHID aliases
20
+ * - Types C, B, G (Businesses): Can create SHID and MCOD aliases
21
+ *
22
+ * **Limits:**
23
+ * - Default limit: 20 aliases per account
24
+ * - Limit can be increased based on client needs
25
+ */
26
+ /**
27
+ * Alias type values as defined in the PI-SPI API specification
28
+ */
29
+ export const AliasType = {
30
+ /**
31
+ * SHID - System-generated unique payment address (UUID format, 36 characters)
32
+ * Available for all client types: P, C, B, G
33
+ */
34
+ SHID: 'SHID',
35
+ /**
36
+ * MCOD - Merchant code for USSD payment support
37
+ * Available for business clients only: C, B, G
38
+ */
39
+ MCOD: 'MCOD',
40
+ /**
41
+ * MBNO - Mobile phone number alias
42
+ * Available for individual clients only: P
43
+ */
44
+ MBNO: 'MBNO',
45
+ };
46
+ /**
47
+ * Valid alias types as a tuple for runtime validation
48
+ */
49
+ export const ALIAS_TYPES = [AliasType.SHID, AliasType.MCOD, AliasType.MBNO];
50
+ /**
51
+ * Check if a string is a valid alias type
52
+ */
53
+ export function isValidAliasType(value) {
54
+ return ALIAS_TYPES.includes(value);
55
+ }
56
+ /**
57
+ * Get available alias types for a client type
58
+ *
59
+ * @param clientType - Client type: 'P' (Individual), 'C' (Merchant), 'B' (Business), 'G' (Government)
60
+ * @returns Array of available alias types for the client type
61
+ */
62
+ export function getAvailableAliasTypes(clientType) {
63
+ switch (clientType) {
64
+ case 'P':
65
+ return [AliasType.MBNO, AliasType.SHID];
66
+ case 'C':
67
+ case 'B':
68
+ case 'G':
69
+ return [AliasType.SHID, AliasType.MCOD];
70
+ default:
71
+ return [];
72
+ }
73
+ }
@@ -0,0 +1,93 @@
1
+ /**
2
+ * PI-SPI Constants
3
+ *
4
+ * Centralized constants for API endpoints, status codes, and configuration values
5
+ */
6
+ export declare const PI_SPI_ENDPOINTS: {
7
+ /** Production API endpoint */
8
+ PRODUCTION: string;
9
+ /** Sandbox API endpoint */
10
+ SANDBOX: string;
11
+ /** Default endpoint (sandbox) */
12
+ DEFAULT: string;
13
+ };
14
+ export declare const PAYMENT_STATUS: {
15
+ /** Payment initiated (awaiting confirmation after alias lookup) */
16
+ INITIE: string;
17
+ /** Payment sent (validations passed, PSP has sent the request) */
18
+ ENVOYE: string;
19
+ /** Payment is confirmed/irreversible */
20
+ IRREVOCABLE: string;
21
+ /** Payment has been rejected */
22
+ REJETE: string;
23
+ };
24
+ export declare const ACCOUNT_STATUS: {
25
+ /** Account is open */
26
+ OPEN: string;
27
+ /** Account is blocked */
28
+ BLOCKED: string;
29
+ /** Account is closed */
30
+ CLOSED: string;
31
+ };
32
+ export declare const ACCOUNT_TYPE: {
33
+ /** Current account */
34
+ CURRENT: string;
35
+ /** Savings account */
36
+ SAVINGS: string;
37
+ };
38
+ export declare const CLIENT_TYPE: {
39
+ /** Individual person */
40
+ INDIVIDUAL: string;
41
+ /** Merchant */
42
+ MERCHANT: string;
43
+ /** Business */
44
+ BUSINESS: string;
45
+ /** Government */
46
+ GOVERNMENT: string;
47
+ };
48
+ export declare const UEMOA_COUNTRIES: {
49
+ BENIN: string;
50
+ BURKINA_FASO: string;
51
+ IVORY_COAST: string;
52
+ GUINEA_BISSAU: string;
53
+ MALI: string;
54
+ NIGER: string;
55
+ SENEGAL: string;
56
+ TOGO: string;
57
+ };
58
+ export declare const CURRENCY: {
59
+ /** West African CFA Franc */
60
+ XOF: string;
61
+ /** Amounts are specified in centimes (1 XOF = 100 centimes) */
62
+ CENTIMES_PER_XOF: number;
63
+ };
64
+ export declare const DEFAULT_LIMITS: {
65
+ /** Maximum page size for paginated requests */
66
+ MAX_PAGE_SIZE: number;
67
+ /** Default page size */
68
+ DEFAULT_PAGE_SIZE: number;
69
+ /** Default aliases per account */
70
+ DEFAULT_ALIASES_PER_ACCOUNT: number;
71
+ };
72
+ export declare const WEBHOOK_EVENTS: {
73
+ /** Payment received */
74
+ PAIEMENT_RECU: string;
75
+ /** Payment sent */
76
+ PAIEMENT_ENVOYE: string;
77
+ /** Payment rejected */
78
+ PAIEMENT_REJETE: string;
79
+ /** Payment request (RTP) received */
80
+ RTP_RECU: string;
81
+ /** Payment request (RTP) rejected */
82
+ RTP_REJETE: string;
83
+ /** Cancellation requested */
84
+ ANNULATION_DEMANDE: string;
85
+ /** Cancellation rejected */
86
+ ANNULATION_REJETE: string;
87
+ /** Fund return sent */
88
+ RETOUR_ENVOYE: string;
89
+ /** Fund return rejected */
90
+ RETOUR_REJETE: string;
91
+ /** Fund return received */
92
+ RETOUR_RECU: string;
93
+ };
@@ -0,0 +1,93 @@
1
+ /**
2
+ * PI-SPI Constants
3
+ *
4
+ * Centralized constants for API endpoints, status codes, and configuration values
5
+ */
6
+ export const PI_SPI_ENDPOINTS = {
7
+ /** Production API endpoint */
8
+ PRODUCTION: 'https://api.pi-bceao.com/piz/v1',
9
+ /** Sandbox API endpoint */
10
+ SANDBOX: 'https://sandbox.api.pi-bceao.com/piz/v1',
11
+ /** Default endpoint (sandbox) */
12
+ DEFAULT: 'https://sandbox.api.pi-bceao.com/piz/v1',
13
+ };
14
+ export const PAYMENT_STATUS = {
15
+ /** Payment initiated (awaiting confirmation after alias lookup) */
16
+ INITIE: 'INITIE',
17
+ /** Payment sent (validations passed, PSP has sent the request) */
18
+ ENVOYE: 'ENVOYE',
19
+ /** Payment is confirmed/irreversible */
20
+ IRREVOCABLE: 'IRREVOCABLE',
21
+ /** Payment has been rejected */
22
+ REJETE: 'REJETE',
23
+ };
24
+ export const ACCOUNT_STATUS = {
25
+ /** Account is open */
26
+ OPEN: 'OUVERT',
27
+ /** Account is blocked */
28
+ BLOCKED: 'BLOQUE',
29
+ /** Account is closed */
30
+ CLOSED: 'CLOTURE',
31
+ };
32
+ export const ACCOUNT_TYPE = {
33
+ /** Current account */
34
+ CURRENT: 'CACC',
35
+ /** Savings account */
36
+ SAVINGS: 'SVGS',
37
+ };
38
+ export const CLIENT_TYPE = {
39
+ /** Individual person */
40
+ INDIVIDUAL: 'P',
41
+ /** Merchant */
42
+ MERCHANT: 'C',
43
+ /** Business */
44
+ BUSINESS: 'B',
45
+ /** Government */
46
+ GOVERNMENT: 'G',
47
+ };
48
+ export const UEMOA_COUNTRIES = {
49
+ BENIN: 'BJ',
50
+ BURKINA_FASO: 'BF',
51
+ IVORY_COAST: 'CI',
52
+ GUINEA_BISSAU: 'GW',
53
+ MALI: 'ML',
54
+ NIGER: 'NE',
55
+ SENEGAL: 'SN',
56
+ TOGO: 'TG',
57
+ };
58
+ export const CURRENCY = {
59
+ /** West African CFA Franc */
60
+ XOF: 'XOF',
61
+ /** Amounts are specified in centimes (1 XOF = 100 centimes) */
62
+ CENTIMES_PER_XOF: 100,
63
+ };
64
+ export const DEFAULT_LIMITS = {
65
+ /** Maximum page size for paginated requests */
66
+ MAX_PAGE_SIZE: 100,
67
+ /** Default page size */
68
+ DEFAULT_PAGE_SIZE: 20,
69
+ /** Default aliases per account */
70
+ DEFAULT_ALIASES_PER_ACCOUNT: 20,
71
+ };
72
+ export const WEBHOOK_EVENTS = {
73
+ /** Payment received */
74
+ PAIEMENT_RECU: 'PAIEMENT_RECU',
75
+ /** Payment sent */
76
+ PAIEMENT_ENVOYE: 'PAIEMENT_ENVOYE',
77
+ /** Payment rejected */
78
+ PAIEMENT_REJETE: 'PAIEMENT_REJETE',
79
+ /** Payment request (RTP) received */
80
+ RTP_RECU: 'RTP_RECU',
81
+ /** Payment request (RTP) rejected */
82
+ RTP_REJETE: 'RTP_REJETE',
83
+ /** Cancellation requested */
84
+ ANNULATION_DEMANDE: 'ANNULATION_DEMANDE',
85
+ /** Cancellation rejected */
86
+ ANNULATION_REJETE: 'ANNULATION_REJETE',
87
+ /** Fund return sent */
88
+ RETOUR_ENVOYE: 'RETOUR_ENVOYE',
89
+ /** Fund return rejected */
90
+ RETOUR_REJETE: 'RETOUR_REJETE',
91
+ /** Fund return received */
92
+ RETOUR_RECU: 'RETOUR_RECU',
93
+ };
@@ -0,0 +1,60 @@
1
+ /**
2
+ * Utility functions for PI-SPI operations
3
+ *
4
+ * Common helper functions for formatting amounts, validating inputs,
5
+ * and other utility operations.
6
+ */
7
+ /**
8
+ * Format amount from centimes to XOF
9
+ * @param centimes - Amount in centimes
10
+ * @returns Formatted amount string (e.g., "1 500 XOF")
11
+ */
12
+ export declare function formatAmount(centimes: number): string;
13
+ /**
14
+ * Convert XOF to centimes
15
+ * @param xof - Amount in XOF
16
+ * @returns Amount in centimes
17
+ */
18
+ export declare function xofToCentimes(xof: number): number;
19
+ /**
20
+ * Convert centimes to XOF
21
+ * @param centimes - Amount in centimes
22
+ * @returns Amount in XOF
23
+ */
24
+ export declare function centimesToXof(centimes: number): number;
25
+ /**
26
+ * Validate account number format
27
+ * @param accountNumber - Account number to validate
28
+ * @returns True if valid format
29
+ */
30
+ export declare function isValidAccountNumber(accountNumber: string): boolean;
31
+ /**
32
+ * Validate SHID alias format (UUID)
33
+ * @param alias - Alias to validate
34
+ * @returns True if valid UUID format
35
+ */
36
+ export declare function isValidShidAlias(alias: string): boolean;
37
+ /**
38
+ * Validate phone number format (for MBNO alias)
39
+ * @param phoneNumber - Phone number to validate
40
+ * @returns True if valid format
41
+ */
42
+ export declare function isValidPhoneNumber(phoneNumber: string): boolean;
43
+ /**
44
+ * Extract country code from account number
45
+ * @param accountNumber - Account number
46
+ * @returns Country code or null
47
+ */
48
+ export declare function getCountryFromAccount(accountNumber: string): string | null;
49
+ /**
50
+ * Sleep/delay utility
51
+ * @param ms - Milliseconds to wait
52
+ */
53
+ export declare function sleep(ms: number): Promise<void>;
54
+ /**
55
+ * Retry a function with exponential backoff
56
+ * @param fn - Function to retry
57
+ * @param maxRetries - Maximum number of retries
58
+ * @param initialDelay - Initial delay in milliseconds
59
+ */
60
+ export declare function retryWithBackoff<T>(fn: () => Promise<T>, maxRetries?: number, initialDelay?: number): Promise<T>;