@mitumba/sdk 1.28.0 → 1.30.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -102,16 +102,30 @@ const trending = await mitumba.search.getTrending('nbi_01')
102
102
 
103
103
  ### 4. Orders & Pay Modules (`mitumba.orders`, `mitumba.pay`)
104
104
 
105
- End-to-end checkout and M-Pesa integration.
105
+ End-to-end checkout with provider-neutral payment initiation.
106
+
107
+ > `pay.initiateCheckout()` is available on the production API. Payment initiation can be temporarily paused and return `payment_initiation_paused`.
106
108
 
107
109
  ```typescript
108
110
  // 1. Create an order
109
111
  const { order_id, total } = await mitumba.orders.create({ listing_id: 'lst_123' })
110
112
 
111
- // 2. Initiate M-Pesa STK Push
112
- await mitumba.pay.initiateStk({ order_id, phone: '+254700000000' })
113
+ // 2. Select a payment method; the API selects the provider
114
+ const initiation = await mitumba.pay.initiateCheckout({
115
+ order_id,
116
+ idempotency_key: 'checkout-attempt-123',
117
+ method: { type: 'mobile_money', phone: '+254700000000' }
118
+ })
113
119
 
114
- // 3. Poll the aggregate checkout lifecycle
120
+ // 3. Continue only through the returned action
121
+ if (initiation.next_action.type === 'redirect') {
122
+ const { url, expires_at } = initiation.next_action
123
+ // Open the absolute HTTPS URL in your app's navigation layer.
124
+ } else {
125
+ // Wait for out-of-band confirmation on the buyer's device.
126
+ }
127
+
128
+ // 4. Initiation is not payment success; poll the checkout lifecycle
115
129
  const checkout = await mitumba.pay.getCheckoutStatus(order_id)
116
130
 
117
131
  if (!checkout.terminal) {
@@ -123,7 +137,9 @@ if (checkout.checkout_status === 'paid') {
123
137
  }
124
138
  ```
125
139
 
126
- `pay.getStatus(orderId)` remains available for existing consumers but is deprecated because its legacy response does not represent the aggregate retail/bale checkout lifecycle. New integrations should use `getCheckoutStatus()` and follow `terminal`, `retryable`, and `poll_after_ms` rather than interpreting an individual payment attempt as order success.
140
+ If an initiation request is cancelled or its result is lost, retry the identical input with the same `idempotency_key` to recover the authoritative result. Reusing the key with different input returns `idempotency_conflict`.
141
+
142
+ `pay.initMpesa()`, `pay.initPaystack()`, and `pay.initiateStk()` remain source- and runtime-compatible while the provider-neutral endpoint is introduced. `pay.getStatus(orderId)` also remains available, but is deprecated because its legacy response does not represent the aggregate retail/bale checkout lifecycle. New integrations should use `getCheckoutStatus()` and follow `terminal`, `retryable`, and `poll_after_ms` rather than interpreting an individual payment attempt as order success.
127
143
 
128
144
  ### 5. Vazi Module (`mitumba.vazi`)
129
145