pi-spi-sdk 0.1.2 → 0.2.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 (215) hide show
  1. package/CHANGELOG.md +48 -0
  2. package/README.md +23 -1
  3. package/dist/chunk-7W56NW2S.mjs +2066 -0
  4. package/dist/generated-FM5EVVHH.mjs +84 -0
  5. package/dist/index.cjs +4754 -0
  6. package/dist/index.d.cts +4940 -0
  7. package/dist/index.d.ts +4937 -11
  8. package/dist/index.mjs +2359 -0
  9. package/dist/index.umd.js +2 -0
  10. package/dist/qrcode/index.cjs +757 -0
  11. package/dist/qrcode/index.d.cts +68 -0
  12. package/dist/qrcode/index.d.ts +68 -0
  13. package/dist/qrcode/index.mjs +712 -0
  14. package/package.json +25 -8
  15. package/dist/config.d.ts +0 -35
  16. package/dist/config.js +0 -4
  17. package/dist/error-handler.d.ts +0 -7
  18. package/dist/error-handler.js +0 -52
  19. package/dist/errors.d.ts +0 -25
  20. package/dist/errors.js +0 -40
  21. package/dist/examples.d.ts +0 -8
  22. package/dist/examples.js +0 -91
  23. package/dist/generated/core/ApiError.d.ts +0 -10
  24. package/dist/generated/core/ApiError.js +0 -11
  25. package/dist/generated/core/ApiRequestOptions.d.ts +0 -13
  26. package/dist/generated/core/ApiRequestOptions.js +0 -1
  27. package/dist/generated/core/ApiResult.d.ts +0 -7
  28. package/dist/generated/core/ApiResult.js +0 -1
  29. package/dist/generated/core/CancelablePromise.d.ts +0 -20
  30. package/dist/generated/core/CancelablePromise.js +0 -111
  31. package/dist/generated/core/OpenAPI.d.ts +0 -16
  32. package/dist/generated/core/OpenAPI.js +0 -11
  33. package/dist/generated/core/request.d.ts +0 -34
  34. package/dist/generated/core/request.js +0 -269
  35. package/dist/generated/index.d.ts +0 -78
  36. package/dist/generated/index.js +0 -43
  37. package/dist/generated/models/AliasCreationReponse.d.ts +0 -22
  38. package/dist/generated/models/AliasCreationReponse.js +0 -1
  39. package/dist/generated/models/AliasCreationRequest.d.ts +0 -11
  40. package/dist/generated/models/AliasCreationRequest.js +0 -1
  41. package/dist/generated/models/AliasReponseListe.d.ts +0 -26
  42. package/dist/generated/models/AliasReponseListe.js +0 -1
  43. package/dist/generated/models/AnnulationStatut.d.ts +0 -13
  44. package/dist/generated/models/AnnulationStatut.js +0 -18
  45. package/dist/generated/models/Champs.d.ts +0 -1
  46. package/dist/generated/models/Champs.js +0 -1
  47. package/dist/generated/models/CompteOperation.d.ts +0 -72
  48. package/dist/generated/models/CompteOperation.js +0 -24
  49. package/dist/generated/models/CompteOperationListe.d.ts +0 -18
  50. package/dist/generated/models/CompteOperationListe.js +0 -1
  51. package/dist/generated/models/CompteSolde.d.ts +0 -129
  52. package/dist/generated/models/CompteSolde.js +0 -71
  53. package/dist/generated/models/CompteTransfertIntraReponse.d.ts +0 -33
  54. package/dist/generated/models/CompteTransfertIntraReponse.js +0 -12
  55. package/dist/generated/models/CompteTransfertIntraRequest.d.ts +0 -9
  56. package/dist/generated/models/CompteTransfertIntraRequest.js +0 -1
  57. package/dist/generated/models/DemandePaiementConfirmationAnnulationRaison.d.ts +0 -14
  58. package/dist/generated/models/DemandePaiementConfirmationAnnulationRaison.js +0 -19
  59. package/dist/generated/models/DemandePaiementConfirmationReponse.d.ts +0 -41
  60. package/dist/generated/models/DemandePaiementConfirmationReponse.js +0 -13
  61. package/dist/generated/models/DemandePaiementConfirmationRequest.d.ts +0 -3
  62. package/dist/generated/models/DemandePaiementConfirmationRequest.js +0 -1
  63. package/dist/generated/models/DemandePaiementConfirmationRequestAccepter.d.ts +0 -9
  64. package/dist/generated/models/DemandePaiementConfirmationRequestAccepter.js +0 -1
  65. package/dist/generated/models/DemandePaiementConfirmationRequestRejeter.d.ts +0 -9
  66. package/dist/generated/models/DemandePaiementConfirmationRequestRejeter.js +0 -1
  67. package/dist/generated/models/DemandePaiementConsultationReponse.d.ts +0 -151
  68. package/dist/generated/models/DemandePaiementConsultationReponse.js +0 -27
  69. package/dist/generated/models/DemandePaiementEnMasseConfirmationRequest.d.ts +0 -3
  70. package/dist/generated/models/DemandePaiementEnMasseConfirmationRequest.js +0 -1
  71. package/dist/generated/models/DemandePaiementEnMasseConfirmationRequestAccepter.d.ts +0 -9
  72. package/dist/generated/models/DemandePaiementEnMasseConfirmationRequestAccepter.js +0 -1
  73. package/dist/generated/models/DemandePaiementEnMasseConfirmationRequestRejeter.d.ts +0 -9
  74. package/dist/generated/models/DemandePaiementEnMasseConfirmationRequestRejeter.js +0 -1
  75. package/dist/generated/models/DemandePaiementEnMasseRequest.d.ts +0 -74
  76. package/dist/generated/models/DemandePaiementEnMasseRequest.js +0 -1
  77. package/dist/generated/models/DemandePaiementEnMasseStatutReponse.d.ts +0 -98
  78. package/dist/generated/models/DemandePaiementEnMasseStatutReponse.js +0 -20
  79. package/dist/generated/models/DemandePaiementListe.d.ts +0 -26
  80. package/dist/generated/models/DemandePaiementListe.js +0 -1
  81. package/dist/generated/models/DemandePaiementListeItem.d.ts +0 -163
  82. package/dist/generated/models/DemandePaiementListeItem.js +0 -27
  83. package/dist/generated/models/DemandePaiementReponse.d.ts +0 -129
  84. package/dist/generated/models/DemandePaiementReponse.js +0 -1
  85. package/dist/generated/models/DemandePaiementReponseRequest.d.ts +0 -21
  86. package/dist/generated/models/DemandePaiementReponseRequest.js +0 -11
  87. package/dist/generated/models/DemandePaiementRequest.d.ts +0 -98
  88. package/dist/generated/models/DemandePaiementRequest.js +0 -7
  89. package/dist/generated/models/DemandePaiementRequestBase.d.ts +0 -42
  90. package/dist/generated/models/DemandePaiementRequestBase.js +0 -1
  91. package/dist/generated/models/DemandePaiementRequestCategorie.d.ts +0 -12
  92. package/dist/generated/models/DemandePaiementRequestCategorie.js +0 -17
  93. package/dist/generated/models/DemandePaiementStatut.d.ts +0 -13
  94. package/dist/generated/models/DemandePaiementStatut.js +0 -18
  95. package/dist/generated/models/DemandePaiementStatutRaison.d.ts +0 -46
  96. package/dist/generated/models/DemandePaiementStatutRaison.js +0 -51
  97. package/dist/generated/models/ListeMeta.d.ts +0 -14
  98. package/dist/generated/models/ListeMeta.js +0 -1
  99. package/dist/generated/models/Paiement.d.ts +0 -156
  100. package/dist/generated/models/Paiement.js +0 -28
  101. package/dist/generated/models/PaiementAnnulationMotif.d.ts +0 -17
  102. package/dist/generated/models/PaiementAnnulationMotif.js +0 -22
  103. package/dist/generated/models/PaiementAnnulationReponseRequest.d.ts +0 -11
  104. package/dist/generated/models/PaiementAnnulationReponseRequest.js +0 -1
  105. package/dist/generated/models/PaiementAnnulationReponseRequestAccepter.d.ts +0 -9
  106. package/dist/generated/models/PaiementAnnulationReponseRequestAccepter.js +0 -1
  107. package/dist/generated/models/PaiementAnnulationReponseRequestRejeter.d.ts +0 -9
  108. package/dist/generated/models/PaiementAnnulationReponseRequestRejeter.js +0 -1
  109. package/dist/generated/models/PaiementAnnulationRequest.d.ts +0 -4
  110. package/dist/generated/models/PaiementAnnulationRequest.js +0 -1
  111. package/dist/generated/models/PaiementAnnulationStatutRaison.d.ts +0 -21
  112. package/dist/generated/models/PaiementAnnulationStatutRaison.js +0 -26
  113. package/dist/generated/models/PaiementEnMasseConfirmationRequest.d.ts +0 -3
  114. package/dist/generated/models/PaiementEnMasseConfirmationRequest.js +0 -1
  115. package/dist/generated/models/PaiementEnMasseConfirmationRequestAccepter.d.ts +0 -9
  116. package/dist/generated/models/PaiementEnMasseConfirmationRequestAccepter.js +0 -1
  117. package/dist/generated/models/PaiementEnMasseConfirmationRequestRejeter.d.ts +0 -9
  118. package/dist/generated/models/PaiementEnMasseConfirmationRequestRejeter.js +0 -1
  119. package/dist/generated/models/PaiementEnMasseReponseStatut.d.ts +0 -97
  120. package/dist/generated/models/PaiementEnMasseReponseStatut.js +0 -20
  121. package/dist/generated/models/PaiementEnMasseRequest.d.ts +0 -54
  122. package/dist/generated/models/PaiementEnMasseRequest.js +0 -1
  123. package/dist/generated/models/PaiementImmediatConfirmationReponse.d.ts +0 -31
  124. package/dist/generated/models/PaiementImmediatConfirmationReponse.js +0 -7
  125. package/dist/generated/models/PaiementImmediatConfirmationRequest.d.ts +0 -3
  126. package/dist/generated/models/PaiementImmediatConfirmationRequest.js +0 -1
  127. package/dist/generated/models/PaiementImmediatConfirmationRequestAccepter.d.ts +0 -9
  128. package/dist/generated/models/PaiementImmediatConfirmationRequestAccepter.js +0 -1
  129. package/dist/generated/models/PaiementImmediatConfirmationRequestRejeter.d.ts +0 -9
  130. package/dist/generated/models/PaiementImmediatConfirmationRequestRejeter.js +0 -1
  131. package/dist/generated/models/PaiementImmediatReponse.d.ts +0 -98
  132. package/dist/generated/models/PaiementImmediatReponse.js +0 -7
  133. package/dist/generated/models/PaiementImmediatRequest.d.ts +0 -13
  134. package/dist/generated/models/PaiementImmediatRequest.js +0 -1
  135. package/dist/generated/models/PaiementListe.d.ts +0 -6
  136. package/dist/generated/models/PaiementListe.js +0 -1
  137. package/dist/generated/models/PaiementRequest.d.ts +0 -33
  138. package/dist/generated/models/PaiementRequest.js +0 -1
  139. package/dist/generated/models/PaiementStatut.d.ts +0 -13
  140. package/dist/generated/models/PaiementStatut.js +0 -18
  141. package/dist/generated/models/PaiementStatutRaison.d.ts +0 -56
  142. package/dist/generated/models/PaiementStatutRaison.js +0 -61
  143. package/dist/generated/models/Problem7807.d.ts +0 -31
  144. package/dist/generated/models/Problem7807.js +0 -1
  145. package/dist/generated/models/RefDocType.d.ts +0 -38
  146. package/dist/generated/models/RefDocType.js +0 -43
  147. package/dist/generated/models/RetourStatut.d.ts +0 -13
  148. package/dist/generated/models/RetourStatut.js +0 -18
  149. package/dist/generated/models/RetourStatutRaison.d.ts +0 -25
  150. package/dist/generated/models/RetourStatutRaison.js +0 -30
  151. package/dist/generated/models/WebhookCreationRequest.d.ts +0 -14
  152. package/dist/generated/models/WebhookCreationRequest.js +0 -1
  153. package/dist/generated/models/WebhookCreationResponse.d.ts +0 -12
  154. package/dist/generated/models/WebhookCreationResponse.js +0 -1
  155. package/dist/generated/models/WebhookData.d.ts +0 -8
  156. package/dist/generated/models/WebhookData.js +0 -1
  157. package/dist/generated/models/WebhookEvent.d.ts +0 -191
  158. package/dist/generated/models/WebhookEvent.js +0 -42
  159. package/dist/generated/models/WebhookEventsList.d.ts +0 -13
  160. package/dist/generated/models/WebhookEventsList.js +0 -1
  161. package/dist/generated/models/WebhookList.d.ts +0 -13
  162. package/dist/generated/models/WebhookList.js +0 -1
  163. package/dist/generated/models/WebhookModificationRequest.d.ts +0 -4
  164. package/dist/generated/models/WebhookModificationRequest.js +0 -1
  165. package/dist/generated/models/WebhooksEvents.d.ts +0 -12
  166. package/dist/generated/models/WebhooksEvents.js +0 -17
  167. package/dist/generated/services/AliasService.d.ts +0 -63
  168. package/dist/generated/services/AliasService.js +0 -84
  169. package/dist/generated/services/ComptesService.d.ts +0 -64
  170. package/dist/generated/services/ComptesService.js +0 -86
  171. package/dist/generated/services/DemandeAnnulationService.d.ts +0 -84
  172. package/dist/generated/services/DemandeAnnulationService.js +0 -99
  173. package/dist/generated/services/DemandesDePaiementEnMasseService.d.ts +0 -161
  174. package/dist/generated/services/DemandesDePaiementEnMasseService.js +0 -189
  175. package/dist/generated/services/DemandesDePaiementService.d.ts +0 -123
  176. package/dist/generated/services/DemandesDePaiementService.js +0 -161
  177. package/dist/generated/services/NotificationService.d.ts +0 -80
  178. package/dist/generated/services/NotificationService.js +0 -132
  179. package/dist/generated/services/PaiementEnMasseService.d.ts +0 -159
  180. package/dist/generated/services/PaiementEnMasseService.js +0 -187
  181. package/dist/generated/services/PaiementImmediatService.d.ts +0 -135
  182. package/dist/generated/services/PaiementImmediatService.js +0 -176
  183. package/dist/generated/services/RetoursdeFondsService.d.ts +0 -28
  184. package/dist/generated/services/RetoursdeFondsService.js +0 -37
  185. package/dist/index.js +0 -23
  186. package/dist/query-builder.d.ts +0 -91
  187. package/dist/query-builder.js +0 -187
  188. package/dist/sdk.d.ts +0 -88
  189. package/dist/sdk.js +0 -107
  190. package/dist/services/alias.d.ts +0 -72
  191. package/dist/services/alias.js +0 -82
  192. package/dist/services/base.d.ts +0 -9
  193. package/dist/services/base.js +0 -17
  194. package/dist/services/comptes.d.ts +0 -149
  195. package/dist/services/comptes.js +0 -158
  196. package/dist/services/demandes-annulation.d.ts +0 -97
  197. package/dist/services/demandes-annulation.js +0 -104
  198. package/dist/services/demandes-paiement-en-masse.d.ts +0 -139
  199. package/dist/services/demandes-paiement-en-masse.js +0 -139
  200. package/dist/services/demandes-paiement.d.ts +0 -144
  201. package/dist/services/demandes-paiement.js +0 -151
  202. package/dist/services/paiements-en-masse.d.ts +0 -152
  203. package/dist/services/paiements-en-masse.js +0 -153
  204. package/dist/services/paiements.d.ts +0 -135
  205. package/dist/services/paiements.js +0 -135
  206. package/dist/services/retours-fonds.d.ts +0 -94
  207. package/dist/services/retours-fonds.js +0 -100
  208. package/dist/services/webhooks.d.ts +0 -131
  209. package/dist/services/webhooks.js +0 -142
  210. package/dist/types/alias.d.ts +0 -64
  211. package/dist/types/alias.js +0 -73
  212. package/dist/utils/constants.d.ts +0 -93
  213. package/dist/utils/constants.js +0 -93
  214. package/dist/utils/index.d.ts +0 -60
  215. package/dist/utils/index.js +0 -115
@@ -1,100 +0,0 @@
1
- /**
2
- * Fund Returns (Retours de Fonds) service wrapper
3
- *
4
- * Provides methods for returning funds from received payments.
5
- *
6
- * **Return Rules:**
7
- * - Can only return funds from payments received
8
- * - Must be initiated within 90 days of original payment
9
- * - After 90 days, returns are no longer possible
10
- * - Returns are processed instantly when sent
11
- *
12
- * **Use Cases:**
13
- * - Refunds for returned goods
14
- * - Cancellation of services
15
- * - Error corrections
16
- * - Customer disputes
17
- *
18
- * @example
19
- * ```typescript
20
- * // Return funds from a received payment
21
- * const returnFunds = await sdk.retoursFonds.create({
22
- * comptePaye: 'CIC2344256727788288822',
23
- * txId: '23552722', // Original payment transaction ID
24
- * montant: 150000, // Amount to return (1,500 XOF)
25
- * motif: 'CUST' // Customer request reason code
26
- * });
27
- * ```
28
- */
29
- import { BaseService } from './base';
30
- export class RetoursFondsService extends BaseService {
31
- /**
32
- * Create a fund return
33
- *
34
- * **Return Process:**
35
- * 1. Business identifies original payment transaction
36
- * 2. Creates return request (must be within 90 days)
37
- * 3. Return is processed immediately
38
- * 4. Funds are returned to original payer
39
- *
40
- * **Status Values:**
41
- * - `ENVOYE`: Return sent successfully
42
- * - `IRREVOCABLE`: Return confirmed and cannot be reversed
43
- * - `REJETE`: Return rejected (check `statutRaison` for error code)
44
- *
45
- * **Rejection Reasons:**
46
- * - `AM04`: Insufficient guarantee funds
47
- * - `AM09`: Wrong amount
48
- * - `AC06`: Blocked account
49
- * - `FR01`: Fraud suspicion
50
- * - `RR04`: Regulatory reason
51
- *
52
- * @param returnRequest - Fund return request data
53
- * @param returnRequest.comptePaye - Business account number (original payee)
54
- * @param returnRequest.txId - Original payment transaction ID
55
- * @param returnRequest.montant - Amount to return in centimes (e.g., 150000 = 1,500 XOF)
56
- * @param returnRequest.motif - Return reason code (e.g., 'CUST' for customer request)
57
- * @returns Fund return response
58
- * @throws {PiSpiValidationError} If return fails validation (e.g., > 90 days, invalid txId)
59
- * @throws {PiSpiError} If account blocked or insufficient funds
60
- *
61
- * @example
62
- * ```typescript
63
- * // Return full payment amount
64
- * await sdk.retoursFonds.create({
65
- * comptePaye: 'CIC2344256727788288822',
66
- * txId: '23552722', // Original payment ID
67
- * montant: 150000, // 1,500 XOF
68
- * motif: 'CUST' // Customer request
69
- * });
70
- * ```
71
- */
72
- async create(returnRequest) {
73
- return this.execute(async () => {
74
- throw new Error('Service not yet generated. Run "pnpm run generate" first.');
75
- });
76
- }
77
- /**
78
- * Get fund return details by transaction ID
79
- *
80
- * @param id - Fund return transaction ID
81
- * @returns Fund return details
82
- * @throws {PiSpiNotFoundError} If return not found
83
- */
84
- async get(id) {
85
- return this.execute(async () => {
86
- throw new Error('Service not yet generated. Run "pnpm run generate" first.');
87
- });
88
- }
89
- /**
90
- * List fund returns with filtering and pagination
91
- *
92
- * @param params - Query parameters for filtering and pagination
93
- * @returns Paginated list of fund returns
94
- */
95
- async list(params) {
96
- return this.execute(async () => {
97
- throw new Error('Service not yet generated. Run "pnpm run generate" first.');
98
- });
99
- }
100
- }
@@ -1,131 +0,0 @@
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
- }
@@ -1,142 +0,0 @@
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
- }
@@ -1,64 +0,0 @@
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[];
@@ -1,73 +0,0 @@
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
- }
@@ -1,93 +0,0 @@
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
- };
@@ -1,93 +0,0 @@
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
- };