inttegro.async_resources.orders

Generated public typing surface. Do not edit by hand.

  1# Generated by scripts/generate_async_resources.py; do not edit by hand.
  2"""Orders resource for creating and managing orders and payments."""
  3from __future__ import annotations
  4from typing import TypeVar
  5from .._model_base import ApiModel
  6from ..async_http_client import AsyncHttpClient
  7from ..response import InttegroResponse
  8from inttegro.order.order import Order
  9from inttegro.order.page import Page
 10from inttegro.search import Page as SearchPage, Request as SearchRequest
 11from .._dynamic_value import DynamicValue
 12ModelT = TypeVar('ModelT', bound=ApiModel)
 13
 14def _resource(response: ApiModel | DynamicValue, field: str, model_type: type[ModelT]) -> ModelT:
 15    """Extract a domain resource from an internal wire envelope."""
 16    if isinstance(response, model_type):
 17        return response
 18    value = getattr(response, field, None)
 19    if isinstance(value, model_type):
 20        return value
 21    if isinstance(response, DynamicValue):
 22        payload = response.to_dict()
 23        if isinstance(payload, dict) and isinstance(payload.get(field), dict):
 24            return model_type.from_dict(payload[field])
 25    raise TypeError(f'Inttegro returned an invalid {field} response')
 26
 27def _stable_order_request_meta(action: str, order_id: str) -> dict:
 28    return {'idempotency_key': f'orders_{action}_{order_id}'}
 29
 30class AsyncOrders:
 31    """
 32    Orders resource for creating orders, processing payments, and managing order lifecycle.
 33
 34    Orders are the central transaction object in Inttegro. They represent a purchase with
 35    line items, customer information, and payment details. Use this resource to create
 36    orders, charge customers, handle confirmations, and process refunds.
 37
 38    The typical order flow is:
 39    1. Create order with line items and customer details
 40    2. Pay order with a payment method (may require OTP confirmation)
 41    3. Finalize order to make it available in reporting
 42    4. Complete order when fulfillment is done (optional)
 43
 44    Order operations return typed domain models. The HTTP response envelope is
 45    decoded internally and does not leak into the public resource API.
 46
 47    See https://studio.inttegro.com/orders for detailed guides.
 48    """
 49
 50    def __init__(self, http: AsyncHttpClient):
 51        """Initialize Orders resource with HTTP client."""
 52        self.http = http
 53
 54    async def create(self, payload: dict):
 55        """
 56        Create a new order with line items, customer, and payment details.
 57
 58        Creates an order representing a purchase. You can create an order for a new or
 59        existing customer, include multiple line items, and optionally execute payment
 60        immediately. Orders must have at least one line item and billing details.
 61
 62        Args:
 63            payload: Order creation parameters including:
 64                - customer_data or customer_id: Customer information (required)
 65                - line_items: List of products/services being purchased (required)
 66                - billing_details: Billing contact information (required)
 67                - payment_method_id or payment_method_data: Payment method (optional)
 68                - execute_payment: Whether to immediately charge (default: False)
 69                - request_meta: Request controls such as idempotency_key (optional)
 70                - statement_descriptor_prefix: Static prefix, 2-10 characters, used to build prefix*order_id (optional)
 71                - success_url: Redirect URL after successful payment
 72                - cancel_url: Redirect URL if customer cancels
 73                - payout_settings: Order-specific payout destination configuration (optional)
 74                - custom_data: Key-value custom data (max 25KB)
 75
 76        Returns:
 77            The created Order.
 78
 79        Raises:
 80            ApiError: If request fails (invalid parameters, authentication error, etc.)
 81
 82        Example:
 83            ```python
 84            # Create order with new customer
 85            order = client.orders.create({
 86                "customer_data": {
 87                    "name": "Akua Asantewaa",
 88                    "phone_number": "+233541234567",
 89                    "email_address": "akua@example.com"
 90                },
 91                "line_items": [{
 92                    "type": "product",
 93                    "product": {
 94                        "type": "digital",
 95                        "name": "Premium Subscription",
 96                        "quantity": 1,
 97                        "price": {"currency": "ghs", "value": 5000}
 98                    }
 99                }],
100                "billing_details": {
101                    "name": "Akua Asantewaa",
102                    "phone_number": "+233541234567"
103                },
104                "request_meta": {
105                    "idempotency_key": "order_2025_001"
106                },
107                "execute_payment": True
108            })
109
110            print(f"Created order: {order.id}")
111            ```
112
113            ```python
114            # Create order with saved customer and payment method
115            result = client.orders.create({
116                "customer_id": "cu_abc123",
117                "payment_method_id": "pm_xyz789",
118                "line_items": [{
119                    "type": "product",
120                    "product": {
121                        "type": "physical",
122                        "name": "T-Shirt",
123                        "quantity": 2,
124                        "price": {"currency": "ghs", "value": 8000}
125                    }
126                }],
127                "billing_details": {
128                    "name": "Kwame Mensah",
129                    "phone_number": "+233241234567",
130                    "address": {
131                        "line1": "123 Independence Ave",
132                        "town": "Accra",
133                        "region": "Greater Accra",
134                        "country": "GH"
135                    }
136                },
137                "execute_payment": True
138            })
139            ```
140
141        See Also:
142            - pay(): Charge an order with a payment method
143            - https://studio.inttegro.com/create-your-first-order
144        """
145        return _resource(await self.http.post('/orders/create', payload), 'order', Order)
146
147    async def create_with_response(self, payload: dict) -> InttegroResponse[Order]:
148        """Create an order and keep HTTP response metadata with the decoded order."""
149        response = await self.http.post_resource_with_response('/orders/create', 'order', Order, payload)
150        return InttegroResponse(data=response.data, status=response.status, headers=response.headers, meta=response.meta)
151
152    async def lookup(self, order_id: str, **options):
153        """
154        Retrieve an existing order by ID.
155
156        Fetches full details of an order including its current status, payment information,
157        line items, and customer data. Use this to check order status, retrieve payment
158        details, or display order history to customers.
159
160        Args:
161            order_id: The order ID (e.g., "or_abc123")
162            **options: Additional options:
163                - expand: List of fields to expand (e.g., ["customer", "payment"])
164
165        Returns:
166            The complete Order.
167
168        Raises:
169            ApiError: If order not found or request fails
170
171        Example:
172            ```python
173            # Basic lookup
174            order = client.orders.lookup("or_abc123")
175            print(f"Order status: {order.status}")
176
177            # Lookup with expanded fields
178            order = client.orders.lookup(
179                "or_abc123",
180                expand=["customer", "payment", "line_items"]
181            )
182            ```
183
184        See Also:
185            - page(): List multiple orders with pagination
186            - https://studio.inttegro.com/api/orders/lookup
187        """
188        body = {'order_id': order_id, **options}
189        return _resource(await self.http.post('/orders/lookup', body), 'order', Order)
190
191    async def update(self, payload: dict):
192        """
193        Update mutable fields on an existing order.
194
195        Args:
196            payload: Update parameters including order_id and fields to change.
197
198        Returns:
199            The updated Order.
200        """
201        return _resource(await self.http.post('/orders/update', payload), 'order', Order)
202
203    async def pay(self, payload: dict):
204        """
205        Charge a payment method for an existing order.
206
207        Processes payment for an order using a payment method (saved or new). For mobile
208        money payments, the customer typically receives an OTP prompt on their phone.
209        If the payment method requires confirmation (confirms_use=True), you'll need to
210        call confirm_payment() with the OTP.
211
212        Args:
213            payload: Payment parameters including:
214                - order_id: The order to charge (required)
215                - payment_method_id or payment_method_data: Payment method (required)
216                - request_meta.idempotency_key: Unique key to prevent duplicate charges (optional)
217
218        Returns:
219            The updated Order, including its typed payment and next-action state.
220
221        Raises:
222            ApiError: If payment fails or parameters are invalid
223
224        Example:
225            ```python
226            # Pay with saved payment method
227            order = client.orders.pay({
228                "order_id": "or_abc123",
229                "payment_method_id": "pm_xyz789"
230            })
231
232            # Check if confirmation is needed
233            if order.payment and order.payment.next_action and order.payment.next_action.type == "confirm_payment":
234                print("OTP sent to customer's phone")
235                # Prompt customer for OTP and call confirm_payment()
236
237            # Pay with new mobile money number
238            order = client.orders.pay({
239                "order_id": "or_abc123",
240                "payment_method_data": {
241                    "type": "mobile_money",
242                    "mobile_money": {
243                        "network": "mtn",
244                        "account_number": "0241234567"
245                    }
246                }
247            })
248
249            # Idempotent payment (safe to retry)
250            order = client.orders.pay({
251                "order_id": "or_abc123",
252                "payment_method_id": "pm_xyz789",
253                "request_meta": {
254                    "idempotency_key": "order_abc123_initial_charge"
255                }
256            })
257            ```
258
259        See Also:
260            - confirm_payment(): Submit OTP for payments requiring confirmation
261            - create(): Create and pay order in one step with execute_payment=True
262            - https://studio.inttegro.com/charge-repeat-customers
263        """
264        return _resource(await self.http.post('/orders/pay', payload), 'order', Order)
265
266    async def confirm_payment(self, payload: dict):
267        """
268        Submit OTP confirmation token to complete a payment.
269
270        After calling pay() on a payment method that requires confirmation (confirms_use=True),
271        the customer receives an OTP on their mobile device. Collect this OTP from the customer
272        and submit it via this method to complete the payment.
273
274        Args:
275            payload: Confirmation parameters including:
276                - order_id: The order being paid (required)
277                - token: The OTP code from customer (required, 6 digits)
278
279        Returns:
280            The updated Order with its final payment status.
281
282        Raises:
283            ApiError: If OTP is invalid, expired, or payment fails
284
285        Example:
286            ```python
287            # Step 1: Initiate payment
288            order = client.orders.pay({
289                "order_id": "or_abc123",
290                "payment_method_id": "pm_xyz789"
291            })
292
293            # Step 2: Check if confirmation needed
294            if order.payment and order.payment.next_action and order.payment.next_action.type == "confirm_payment":
295                # Display OTP input form to customer
296                otp = input("Enter the OTP sent to your phone: ")
297
298                # Step 3: Submit OTP
299                order = client.orders.confirm_payment({
300                    "order_id": "or_abc123",
301                    "token": otp
302                })
303
304                if order.payment and order.payment.status == "paid":
305                    print("Payment successful!")
306            ```
307
308        See Also:
309            - pay(): Initiate payment that may require confirmation
310            - request_confirmation(): Resend OTP if customer didn't receive it
311            - https://studio.inttegro.com/charge-repeat-customers
312        """
313        return _resource(await self.http.post('/orders/confirm_payment', payload), 'order', Order)
314
315    async def request_confirmation(self, order_id: str, request_meta: dict | None=None):
316        """
317        Resend OTP confirmation code to customer.
318
319        If a customer didn't receive the initial OTP or it expired, use this method to
320        trigger a new OTP to be sent to their mobile device. The payment must be in a
321        state awaiting confirmation.
322
323        Args:
324            order_id: The order ID with pending payment confirmation
325            request_meta: Request controls such as idempotency_key
326
327        Returns:
328            The updated Order.
329
330        Raises:
331            ApiError: If order has no pending confirmation or request fails
332
333        Example:
334            ```python
335            # Customer didn't receive OTP
336            result = client.orders.request_confirmation("or_abc123")
337            print("New OTP sent to customer's phone")
338
339            # Now prompt customer for the new OTP
340            otp = input("Enter the OTP: ")
341            client.orders.confirm_payment({
342                "order_id": "or_abc123",
343                "token": otp
344            })
345            ```
346
347        See Also:
348            - confirm_payment(): Submit the OTP code
349            - pay(): Initial payment that triggers OTP
350        """
351        return _resource(await self.http.post('/orders/request_confirmation', {'order_id': order_id, 'request_meta': request_meta or _stable_order_request_meta('request_confirmation', order_id)}), 'order', Order)
352
353    async def finalize(self, order_id: str, request_meta: dict | None=None):
354        """
355        Finalize an order to make it available in reports and analytics.
356
357        Finalizing an order locks its line items and amounts, making it appear in financial
358        reports, dashboards, and analytics. Only paid orders can be finalized. This is
359        typically done automatically but can be called manually if needed.
360
361        Most applications don't need to call this explicitly as orders finalize automatically
362        after successful payment.
363
364        Args:
365            order_id: The order ID to finalize
366            request_meta: Request controls such as idempotency_key
367
368        Returns:
369            The finalized Order.
370
371        Raises:
372            ApiError: If order is not paid or cannot be finalized
373
374        Example:
375            ```python
376            # Finalize order manually
377            order = client.orders.finalize("or_abc123")
378            print(f"Order finalized at: {order.sealed_at}")
379            ```
380
381        See Also:
382            - complete(): Mark order as fulfilled (separate from finalization)
383            - https://studio.inttegro.com/api/orders/finalize
384        """
385        return _resource(await self.http.post('/orders/finalize', {'order_id': order_id, 'request_meta': request_meta or _stable_order_request_meta('finalize', order_id)}), 'order', Order)
386
387    async def send_invoice(self, payload: dict):
388        """
389        Send the hosted invoice link for an existing order.
390
391        Args:
392            payload: Send invoice parameters including:
393                - order_id: The order whose invoice should be sent (required)
394
395        Returns:
396            An OrderDocumentDeliveryResult containing the order and delivery details.
397        """
398        return await self.http.post('/orders/send_invoice', payload)
399
400    async def send_receipt(self, payload: dict):
401        """
402        Send the hosted receipt link for a paid order.
403
404        Args:
405            payload: Send receipt parameters including:
406                - order_id: The paid order whose receipt should be sent (required)
407
408        Returns:
409            An OrderDocumentDeliveryResult containing the order and delivery details.
410        """
411        return await self.http.post('/orders/send_receipt', payload)
412
413    async def complete(self, payload: dict):
414        """
415        Mark an order as complete after fulfillment.
416
417        Call this method after you've fulfilled the order (shipped goods, delivered service,
418        etc.). Completing an order is separate from payment—it indicates that your
419        obligations to the customer are fulfilled. This affects refund eligibility and
420        dispute windows.
421
422        Args:
423            payload: Completion parameters including:
424                - order_id: The order to mark as complete (required)
425                - proof: Optional fulfillment proof (tracking number, photo URL, etc.)
426
427        Returns:
428            The completed Order.
429
430        Raises:
431            ApiError: If order cannot be completed (not paid, already completed, etc.)
432
433        Example:
434            ```python
435            # Complete physical goods order
436            order = client.orders.complete({
437                "order_id": "or_abc123",
438                "proof": "TRACKING123456"
439            })
440
441            # Complete digital order
442            order = client.orders.complete({
443                "order_id": "or_abc123"
444            })
445
446            print(f"Order completed at: {order.completed_at}")
447            ```
448
449        See Also:
450            - finalize(): Financial finalization (different from completion)
451            - refund(): Issue refund (easier before completion)
452            - https://studio.inttegro.com/api/orders/complete
453        """
454        return _resource(await self.http.post('/orders/complete', payload), 'order', Order)
455
456    async def cancel(self, order_id: str, request_meta: dict | None=None):
457        """
458        Cancel an unpaid order.
459
460        Cancels an order that hasn't been paid yet. Once cancelled, the order cannot be
461        paid or modified. This is useful for abandonment flows, expired carts, or when
462        customers explicitly cancel before payment.
463
464        You cannot cancel orders that have been paid. Use refund() instead for paid orders.
465
466        Args:
467            order_id: The order ID to cancel
468            request_meta: Request controls such as idempotency_key
469
470        Returns:
471            The cancelled Order.
472
473        Raises:
474            ApiError: If order is already paid or cannot be cancelled
475
476        Example:
477            ```python
478            # Cancel abandoned order
479            order = client.orders.cancel("or_abc123")
480            print(f"Order status: {order.status}")  # "canceled"
481
482            # Cancellation flow with expiration
483            import time
484
485            # Create order
486            order = client.orders.create({...})
487            order_id = order.id
488
489            # Wait for payment (with timeout)
490            time.sleep(300)  # 5 minutes
491
492            # Check if still unpaid
493            order = client.orders.lookup(order_id)
494            if order.status == "preparing":
495                # Cancel expired order
496                client.orders.cancel(order_id)
497            ```
498
499        See Also:
500            - refund(): Return money for paid orders
501            - https://studio.inttegro.com/api/orders/cancel
502        """
503        return _resource(await self.http.post('/orders/cancel', {'order_id': order_id, 'request_meta': request_meta or _stable_order_request_meta('cancel', order_id)}), 'order', Order)
504
505    async def page(self, payload: dict | None=None):
506        """
507        List orders with page-based pagination.
508
509        Retrieves a paginated list of orders for your application. Use this to build
510        order history views, display transaction data, or export reports. Results are
511        sorted by creation date (most recent first).
512
513        Args:
514            payload: Pagination parameters including:
515                - page_number: Zero-based page index to fetch (0-10 inclusive)
516                - page_size: Number of orders per page (1-256)
517                - customer_id: Optional customer whose orders should be returned
518
519        Returns:
520            A typed Page.
521
522        Example:
523            ```python
524            # Get first page of orders
525            page = client.orders.page({"page_number": 0, "page_size": 20})
526
527            for order in page.orders:
528                print(f"{order.id}: {order.status}")
529
530            # Get second page
531            next_page = client.orders.page({
532                "page_number": 1,
533                "page_size": 20
534            })
535
536            # Retrieve more orders per page
537            large_page = client.orders.page({
538                "page_number": 0,
539                "page_size": 100
540            })
541
542            # Iterate through all pages
543            for page_num in range(0, 11):
544                page = client.orders.page({
545                    "page_number": page_num,
546                    "page_size": 50
547                })
548
549                if page.size == 0:
550                    break
551
552                for order in page.orders:
553                    print(f"Order: {order.id}")
554            ```
555
556        See Also:
557            - lookup(): Get a single order by ID
558            - https://studio.inttegro.com/api/orders/page
559        """
560        return _resource(await self.http.post('/orders/page', payload or {}), 'page', Page)
561
562    async def search(self, payload: SearchRequest) -> SearchPage:
563        """Search order projections owned by the authenticated application."""
564        return await self.http.post('/orders/search', payload)
class AsyncOrders:
 31class AsyncOrders:
 32    """
 33    Orders resource for creating orders, processing payments, and managing order lifecycle.
 34
 35    Orders are the central transaction object in Inttegro. They represent a purchase with
 36    line items, customer information, and payment details. Use this resource to create
 37    orders, charge customers, handle confirmations, and process refunds.
 38
 39    The typical order flow is:
 40    1. Create order with line items and customer details
 41    2. Pay order with a payment method (may require OTP confirmation)
 42    3. Finalize order to make it available in reporting
 43    4. Complete order when fulfillment is done (optional)
 44
 45    Order operations return typed domain models. The HTTP response envelope is
 46    decoded internally and does not leak into the public resource API.
 47
 48    See https://studio.inttegro.com/orders for detailed guides.
 49    """
 50
 51    def __init__(self, http: AsyncHttpClient):
 52        """Initialize Orders resource with HTTP client."""
 53        self.http = http
 54
 55    async def create(self, payload: dict):
 56        """
 57        Create a new order with line items, customer, and payment details.
 58
 59        Creates an order representing a purchase. You can create an order for a new or
 60        existing customer, include multiple line items, and optionally execute payment
 61        immediately. Orders must have at least one line item and billing details.
 62
 63        Args:
 64            payload: Order creation parameters including:
 65                - customer_data or customer_id: Customer information (required)
 66                - line_items: List of products/services being purchased (required)
 67                - billing_details: Billing contact information (required)
 68                - payment_method_id or payment_method_data: Payment method (optional)
 69                - execute_payment: Whether to immediately charge (default: False)
 70                - request_meta: Request controls such as idempotency_key (optional)
 71                - statement_descriptor_prefix: Static prefix, 2-10 characters, used to build prefix*order_id (optional)
 72                - success_url: Redirect URL after successful payment
 73                - cancel_url: Redirect URL if customer cancels
 74                - payout_settings: Order-specific payout destination configuration (optional)
 75                - custom_data: Key-value custom data (max 25KB)
 76
 77        Returns:
 78            The created Order.
 79
 80        Raises:
 81            ApiError: If request fails (invalid parameters, authentication error, etc.)
 82
 83        Example:
 84            ```python
 85            # Create order with new customer
 86            order = client.orders.create({
 87                "customer_data": {
 88                    "name": "Akua Asantewaa",
 89                    "phone_number": "+233541234567",
 90                    "email_address": "akua@example.com"
 91                },
 92                "line_items": [{
 93                    "type": "product",
 94                    "product": {
 95                        "type": "digital",
 96                        "name": "Premium Subscription",
 97                        "quantity": 1,
 98                        "price": {"currency": "ghs", "value": 5000}
 99                    }
100                }],
101                "billing_details": {
102                    "name": "Akua Asantewaa",
103                    "phone_number": "+233541234567"
104                },
105                "request_meta": {
106                    "idempotency_key": "order_2025_001"
107                },
108                "execute_payment": True
109            })
110
111            print(f"Created order: {order.id}")
112            ```
113
114            ```python
115            # Create order with saved customer and payment method
116            result = client.orders.create({
117                "customer_id": "cu_abc123",
118                "payment_method_id": "pm_xyz789",
119                "line_items": [{
120                    "type": "product",
121                    "product": {
122                        "type": "physical",
123                        "name": "T-Shirt",
124                        "quantity": 2,
125                        "price": {"currency": "ghs", "value": 8000}
126                    }
127                }],
128                "billing_details": {
129                    "name": "Kwame Mensah",
130                    "phone_number": "+233241234567",
131                    "address": {
132                        "line1": "123 Independence Ave",
133                        "town": "Accra",
134                        "region": "Greater Accra",
135                        "country": "GH"
136                    }
137                },
138                "execute_payment": True
139            })
140            ```
141
142        See Also:
143            - pay(): Charge an order with a payment method
144            - https://studio.inttegro.com/create-your-first-order
145        """
146        return _resource(await self.http.post('/orders/create', payload), 'order', Order)
147
148    async def create_with_response(self, payload: dict) -> InttegroResponse[Order]:
149        """Create an order and keep HTTP response metadata with the decoded order."""
150        response = await self.http.post_resource_with_response('/orders/create', 'order', Order, payload)
151        return InttegroResponse(data=response.data, status=response.status, headers=response.headers, meta=response.meta)
152
153    async def lookup(self, order_id: str, **options):
154        """
155        Retrieve an existing order by ID.
156
157        Fetches full details of an order including its current status, payment information,
158        line items, and customer data. Use this to check order status, retrieve payment
159        details, or display order history to customers.
160
161        Args:
162            order_id: The order ID (e.g., "or_abc123")
163            **options: Additional options:
164                - expand: List of fields to expand (e.g., ["customer", "payment"])
165
166        Returns:
167            The complete Order.
168
169        Raises:
170            ApiError: If order not found or request fails
171
172        Example:
173            ```python
174            # Basic lookup
175            order = client.orders.lookup("or_abc123")
176            print(f"Order status: {order.status}")
177
178            # Lookup with expanded fields
179            order = client.orders.lookup(
180                "or_abc123",
181                expand=["customer", "payment", "line_items"]
182            )
183            ```
184
185        See Also:
186            - page(): List multiple orders with pagination
187            - https://studio.inttegro.com/api/orders/lookup
188        """
189        body = {'order_id': order_id, **options}
190        return _resource(await self.http.post('/orders/lookup', body), 'order', Order)
191
192    async def update(self, payload: dict):
193        """
194        Update mutable fields on an existing order.
195
196        Args:
197            payload: Update parameters including order_id and fields to change.
198
199        Returns:
200            The updated Order.
201        """
202        return _resource(await self.http.post('/orders/update', payload), 'order', Order)
203
204    async def pay(self, payload: dict):
205        """
206        Charge a payment method for an existing order.
207
208        Processes payment for an order using a payment method (saved or new). For mobile
209        money payments, the customer typically receives an OTP prompt on their phone.
210        If the payment method requires confirmation (confirms_use=True), you'll need to
211        call confirm_payment() with the OTP.
212
213        Args:
214            payload: Payment parameters including:
215                - order_id: The order to charge (required)
216                - payment_method_id or payment_method_data: Payment method (required)
217                - request_meta.idempotency_key: Unique key to prevent duplicate charges (optional)
218
219        Returns:
220            The updated Order, including its typed payment and next-action state.
221
222        Raises:
223            ApiError: If payment fails or parameters are invalid
224
225        Example:
226            ```python
227            # Pay with saved payment method
228            order = client.orders.pay({
229                "order_id": "or_abc123",
230                "payment_method_id": "pm_xyz789"
231            })
232
233            # Check if confirmation is needed
234            if order.payment and order.payment.next_action and order.payment.next_action.type == "confirm_payment":
235                print("OTP sent to customer's phone")
236                # Prompt customer for OTP and call confirm_payment()
237
238            # Pay with new mobile money number
239            order = client.orders.pay({
240                "order_id": "or_abc123",
241                "payment_method_data": {
242                    "type": "mobile_money",
243                    "mobile_money": {
244                        "network": "mtn",
245                        "account_number": "0241234567"
246                    }
247                }
248            })
249
250            # Idempotent payment (safe to retry)
251            order = client.orders.pay({
252                "order_id": "or_abc123",
253                "payment_method_id": "pm_xyz789",
254                "request_meta": {
255                    "idempotency_key": "order_abc123_initial_charge"
256                }
257            })
258            ```
259
260        See Also:
261            - confirm_payment(): Submit OTP for payments requiring confirmation
262            - create(): Create and pay order in one step with execute_payment=True
263            - https://studio.inttegro.com/charge-repeat-customers
264        """
265        return _resource(await self.http.post('/orders/pay', payload), 'order', Order)
266
267    async def confirm_payment(self, payload: dict):
268        """
269        Submit OTP confirmation token to complete a payment.
270
271        After calling pay() on a payment method that requires confirmation (confirms_use=True),
272        the customer receives an OTP on their mobile device. Collect this OTP from the customer
273        and submit it via this method to complete the payment.
274
275        Args:
276            payload: Confirmation parameters including:
277                - order_id: The order being paid (required)
278                - token: The OTP code from customer (required, 6 digits)
279
280        Returns:
281            The updated Order with its final payment status.
282
283        Raises:
284            ApiError: If OTP is invalid, expired, or payment fails
285
286        Example:
287            ```python
288            # Step 1: Initiate payment
289            order = client.orders.pay({
290                "order_id": "or_abc123",
291                "payment_method_id": "pm_xyz789"
292            })
293
294            # Step 2: Check if confirmation needed
295            if order.payment and order.payment.next_action and order.payment.next_action.type == "confirm_payment":
296                # Display OTP input form to customer
297                otp = input("Enter the OTP sent to your phone: ")
298
299                # Step 3: Submit OTP
300                order = client.orders.confirm_payment({
301                    "order_id": "or_abc123",
302                    "token": otp
303                })
304
305                if order.payment and order.payment.status == "paid":
306                    print("Payment successful!")
307            ```
308
309        See Also:
310            - pay(): Initiate payment that may require confirmation
311            - request_confirmation(): Resend OTP if customer didn't receive it
312            - https://studio.inttegro.com/charge-repeat-customers
313        """
314        return _resource(await self.http.post('/orders/confirm_payment', payload), 'order', Order)
315
316    async def request_confirmation(self, order_id: str, request_meta: dict | None=None):
317        """
318        Resend OTP confirmation code to customer.
319
320        If a customer didn't receive the initial OTP or it expired, use this method to
321        trigger a new OTP to be sent to their mobile device. The payment must be in a
322        state awaiting confirmation.
323
324        Args:
325            order_id: The order ID with pending payment confirmation
326            request_meta: Request controls such as idempotency_key
327
328        Returns:
329            The updated Order.
330
331        Raises:
332            ApiError: If order has no pending confirmation or request fails
333
334        Example:
335            ```python
336            # Customer didn't receive OTP
337            result = client.orders.request_confirmation("or_abc123")
338            print("New OTP sent to customer's phone")
339
340            # Now prompt customer for the new OTP
341            otp = input("Enter the OTP: ")
342            client.orders.confirm_payment({
343                "order_id": "or_abc123",
344                "token": otp
345            })
346            ```
347
348        See Also:
349            - confirm_payment(): Submit the OTP code
350            - pay(): Initial payment that triggers OTP
351        """
352        return _resource(await self.http.post('/orders/request_confirmation', {'order_id': order_id, 'request_meta': request_meta or _stable_order_request_meta('request_confirmation', order_id)}), 'order', Order)
353
354    async def finalize(self, order_id: str, request_meta: dict | None=None):
355        """
356        Finalize an order to make it available in reports and analytics.
357
358        Finalizing an order locks its line items and amounts, making it appear in financial
359        reports, dashboards, and analytics. Only paid orders can be finalized. This is
360        typically done automatically but can be called manually if needed.
361
362        Most applications don't need to call this explicitly as orders finalize automatically
363        after successful payment.
364
365        Args:
366            order_id: The order ID to finalize
367            request_meta: Request controls such as idempotency_key
368
369        Returns:
370            The finalized Order.
371
372        Raises:
373            ApiError: If order is not paid or cannot be finalized
374
375        Example:
376            ```python
377            # Finalize order manually
378            order = client.orders.finalize("or_abc123")
379            print(f"Order finalized at: {order.sealed_at}")
380            ```
381
382        See Also:
383            - complete(): Mark order as fulfilled (separate from finalization)
384            - https://studio.inttegro.com/api/orders/finalize
385        """
386        return _resource(await self.http.post('/orders/finalize', {'order_id': order_id, 'request_meta': request_meta or _stable_order_request_meta('finalize', order_id)}), 'order', Order)
387
388    async def send_invoice(self, payload: dict):
389        """
390        Send the hosted invoice link for an existing order.
391
392        Args:
393            payload: Send invoice parameters including:
394                - order_id: The order whose invoice should be sent (required)
395
396        Returns:
397            An OrderDocumentDeliveryResult containing the order and delivery details.
398        """
399        return await self.http.post('/orders/send_invoice', payload)
400
401    async def send_receipt(self, payload: dict):
402        """
403        Send the hosted receipt link for a paid order.
404
405        Args:
406            payload: Send receipt parameters including:
407                - order_id: The paid order whose receipt should be sent (required)
408
409        Returns:
410            An OrderDocumentDeliveryResult containing the order and delivery details.
411        """
412        return await self.http.post('/orders/send_receipt', payload)
413
414    async def complete(self, payload: dict):
415        """
416        Mark an order as complete after fulfillment.
417
418        Call this method after you've fulfilled the order (shipped goods, delivered service,
419        etc.). Completing an order is separate from payment—it indicates that your
420        obligations to the customer are fulfilled. This affects refund eligibility and
421        dispute windows.
422
423        Args:
424            payload: Completion parameters including:
425                - order_id: The order to mark as complete (required)
426                - proof: Optional fulfillment proof (tracking number, photo URL, etc.)
427
428        Returns:
429            The completed Order.
430
431        Raises:
432            ApiError: If order cannot be completed (not paid, already completed, etc.)
433
434        Example:
435            ```python
436            # Complete physical goods order
437            order = client.orders.complete({
438                "order_id": "or_abc123",
439                "proof": "TRACKING123456"
440            })
441
442            # Complete digital order
443            order = client.orders.complete({
444                "order_id": "or_abc123"
445            })
446
447            print(f"Order completed at: {order.completed_at}")
448            ```
449
450        See Also:
451            - finalize(): Financial finalization (different from completion)
452            - refund(): Issue refund (easier before completion)
453            - https://studio.inttegro.com/api/orders/complete
454        """
455        return _resource(await self.http.post('/orders/complete', payload), 'order', Order)
456
457    async def cancel(self, order_id: str, request_meta: dict | None=None):
458        """
459        Cancel an unpaid order.
460
461        Cancels an order that hasn't been paid yet. Once cancelled, the order cannot be
462        paid or modified. This is useful for abandonment flows, expired carts, or when
463        customers explicitly cancel before payment.
464
465        You cannot cancel orders that have been paid. Use refund() instead for paid orders.
466
467        Args:
468            order_id: The order ID to cancel
469            request_meta: Request controls such as idempotency_key
470
471        Returns:
472            The cancelled Order.
473
474        Raises:
475            ApiError: If order is already paid or cannot be cancelled
476
477        Example:
478            ```python
479            # Cancel abandoned order
480            order = client.orders.cancel("or_abc123")
481            print(f"Order status: {order.status}")  # "canceled"
482
483            # Cancellation flow with expiration
484            import time
485
486            # Create order
487            order = client.orders.create({...})
488            order_id = order.id
489
490            # Wait for payment (with timeout)
491            time.sleep(300)  # 5 minutes
492
493            # Check if still unpaid
494            order = client.orders.lookup(order_id)
495            if order.status == "preparing":
496                # Cancel expired order
497                client.orders.cancel(order_id)
498            ```
499
500        See Also:
501            - refund(): Return money for paid orders
502            - https://studio.inttegro.com/api/orders/cancel
503        """
504        return _resource(await self.http.post('/orders/cancel', {'order_id': order_id, 'request_meta': request_meta or _stable_order_request_meta('cancel', order_id)}), 'order', Order)
505
506    async def page(self, payload: dict | None=None):
507        """
508        List orders with page-based pagination.
509
510        Retrieves a paginated list of orders for your application. Use this to build
511        order history views, display transaction data, or export reports. Results are
512        sorted by creation date (most recent first).
513
514        Args:
515            payload: Pagination parameters including:
516                - page_number: Zero-based page index to fetch (0-10 inclusive)
517                - page_size: Number of orders per page (1-256)
518                - customer_id: Optional customer whose orders should be returned
519
520        Returns:
521            A typed Page.
522
523        Example:
524            ```python
525            # Get first page of orders
526            page = client.orders.page({"page_number": 0, "page_size": 20})
527
528            for order in page.orders:
529                print(f"{order.id}: {order.status}")
530
531            # Get second page
532            next_page = client.orders.page({
533                "page_number": 1,
534                "page_size": 20
535            })
536
537            # Retrieve more orders per page
538            large_page = client.orders.page({
539                "page_number": 0,
540                "page_size": 100
541            })
542
543            # Iterate through all pages
544            for page_num in range(0, 11):
545                page = client.orders.page({
546                    "page_number": page_num,
547                    "page_size": 50
548                })
549
550                if page.size == 0:
551                    break
552
553                for order in page.orders:
554                    print(f"Order: {order.id}")
555            ```
556
557        See Also:
558            - lookup(): Get a single order by ID
559            - https://studio.inttegro.com/api/orders/page
560        """
561        return _resource(await self.http.post('/orders/page', payload or {}), 'page', Page)
562
563    async def search(self, payload: SearchRequest) -> SearchPage:
564        """Search order projections owned by the authenticated application."""
565        return await self.http.post('/orders/search', payload)

Orders resource for creating orders, processing payments, and managing order lifecycle.

Orders are the central transaction object in Inttegro. They represent a purchase with line items, customer information, and payment details. Use this resource to create orders, charge customers, handle confirmations, and process refunds.

The typical order flow is:

  1. Create order with line items and customer details
  2. Pay order with a payment method (may require OTP confirmation)
  3. Finalize order to make it available in reporting
  4. Complete order when fulfillment is done (optional)

Order operations return typed domain models. The HTTP response envelope is decoded internally and does not leak into the public resource API.

See https://studio.inttegro.com/orders for detailed guides.

AsyncOrders(http: inttegro.async_http_client.AsyncHttpClient)
51    def __init__(self, http: AsyncHttpClient):
52        """Initialize Orders resource with HTTP client."""
53        self.http = http

Initialize Orders resource with HTTP client.

http
 55    async def create(self, payload: dict):
 56        """
 57        Create a new order with line items, customer, and payment details.
 58
 59        Creates an order representing a purchase. You can create an order for a new or
 60        existing customer, include multiple line items, and optionally execute payment
 61        immediately. Orders must have at least one line item and billing details.
 62
 63        Args:
 64            payload: Order creation parameters including:
 65                - customer_data or customer_id: Customer information (required)
 66                - line_items: List of products/services being purchased (required)
 67                - billing_details: Billing contact information (required)
 68                - payment_method_id or payment_method_data: Payment method (optional)
 69                - execute_payment: Whether to immediately charge (default: False)
 70                - request_meta: Request controls such as idempotency_key (optional)
 71                - statement_descriptor_prefix: Static prefix, 2-10 characters, used to build prefix*order_id (optional)
 72                - success_url: Redirect URL after successful payment
 73                - cancel_url: Redirect URL if customer cancels
 74                - payout_settings: Order-specific payout destination configuration (optional)
 75                - custom_data: Key-value custom data (max 25KB)
 76
 77        Returns:
 78            The created Order.
 79
 80        Raises:
 81            ApiError: If request fails (invalid parameters, authentication error, etc.)
 82
 83        Example:
 84            ```python
 85            # Create order with new customer
 86            order = client.orders.create({
 87                "customer_data": {
 88                    "name": "Akua Asantewaa",
 89                    "phone_number": "+233541234567",
 90                    "email_address": "akua@example.com"
 91                },
 92                "line_items": [{
 93                    "type": "product",
 94                    "product": {
 95                        "type": "digital",
 96                        "name": "Premium Subscription",
 97                        "quantity": 1,
 98                        "price": {"currency": "ghs", "value": 5000}
 99                    }
100                }],
101                "billing_details": {
102                    "name": "Akua Asantewaa",
103                    "phone_number": "+233541234567"
104                },
105                "request_meta": {
106                    "idempotency_key": "order_2025_001"
107                },
108                "execute_payment": True
109            })
110
111            print(f"Created order: {order.id}")
112            ```
113
114            ```python
115            # Create order with saved customer and payment method
116            result = client.orders.create({
117                "customer_id": "cu_abc123",
118                "payment_method_id": "pm_xyz789",
119                "line_items": [{
120                    "type": "product",
121                    "product": {
122                        "type": "physical",
123                        "name": "T-Shirt",
124                        "quantity": 2,
125                        "price": {"currency": "ghs", "value": 8000}
126                    }
127                }],
128                "billing_details": {
129                    "name": "Kwame Mensah",
130                    "phone_number": "+233241234567",
131                    "address": {
132                        "line1": "123 Independence Ave",
133                        "town": "Accra",
134                        "region": "Greater Accra",
135                        "country": "GH"
136                    }
137                },
138                "execute_payment": True
139            })
140            ```
141
142        See Also:
143            - pay(): Charge an order with a payment method
144            - https://studio.inttegro.com/create-your-first-order
145        """
146        return _resource(await self.http.post('/orders/create', payload), 'order', Order)

Create a new order with line items, customer, and payment details.

Creates an order representing a purchase. You can create an order for a new or existing customer, include multiple line items, and optionally execute payment immediately. Orders must have at least one line item and billing details.

Arguments:
  • payload: Order creation parameters including:
    • customer_data or customer_id: Customer information (required)
    • line_items: List of products/services being purchased (required)
    • billing_details: Billing contact information (required)
    • payment_method_id or payment_method_data: Payment method (optional)
    • execute_payment: Whether to immediately charge (default: False)
    • request_meta: Request controls such as idempotency_key (optional)
    • statement_descriptor_prefix: Static prefix, 2-10 characters, used to build prefix*order_id (optional)
    • success_url: Redirect URL after successful payment
    • cancel_url: Redirect URL if customer cancels
    • payout_settings: Order-specific payout destination configuration (optional)
    • custom_data: Key-value custom data (max 25KB)
Returns:

The created Order.

Raises:
  • ApiError: If request fails (invalid parameters, authentication error, etc.)
Example:
# Create order with new customer
order = client.orders.create({
    "customer_data": {
        "name": "Akua Asantewaa",
        "phone_number": "+233541234567",
        "email_address": "akua@example.com"
    },
    "line_items": [{
        "type": "product",
        "product": {
            "type": "digital",
            "name": "Premium Subscription",
            "quantity": 1,
            "price": {"currency": "ghs", "value": 5000}
        }
    }],
    "billing_details": {
        "name": "Akua Asantewaa",
        "phone_number": "+233541234567"
    },
    "request_meta": {
        "idempotency_key": "order_2025_001"
    },
    "execute_payment": True
})

print(f"Created order: {order.id}")
# Create order with saved customer and payment method
result = client.orders.create({
    "customer_id": "cu_abc123",
    "payment_method_id": "pm_xyz789",
    "line_items": [{
        "type": "product",
        "product": {
            "type": "physical",
            "name": "T-Shirt",
            "quantity": 2,
            "price": {"currency": "ghs", "value": 8000}
        }
    }],
    "billing_details": {
        "name": "Kwame Mensah",
        "phone_number": "+233241234567",
        "address": {
            "line1": "123 Independence Ave",
            "town": "Accra",
            "region": "Greater Accra",
            "country": "GH"
        }
    },
    "execute_payment": True
})
See Also:
async def create_with_response( self, payload: dict) -> inttegro.InttegroResponse[inttegro.order.Order]:
148    async def create_with_response(self, payload: dict) -> InttegroResponse[Order]:
149        """Create an order and keep HTTP response metadata with the decoded order."""
150        response = await self.http.post_resource_with_response('/orders/create', 'order', Order, payload)
151        return InttegroResponse(data=response.data, status=response.status, headers=response.headers, meta=response.meta)

Create an order and keep HTTP response metadata with the decoded order.

async def lookup(self, order_id: str, **options: object) -> inttegro.order.Order:
153    async def lookup(self, order_id: str, **options):
154        """
155        Retrieve an existing order by ID.
156
157        Fetches full details of an order including its current status, payment information,
158        line items, and customer data. Use this to check order status, retrieve payment
159        details, or display order history to customers.
160
161        Args:
162            order_id: The order ID (e.g., "or_abc123")
163            **options: Additional options:
164                - expand: List of fields to expand (e.g., ["customer", "payment"])
165
166        Returns:
167            The complete Order.
168
169        Raises:
170            ApiError: If order not found or request fails
171
172        Example:
173            ```python
174            # Basic lookup
175            order = client.orders.lookup("or_abc123")
176            print(f"Order status: {order.status}")
177
178            # Lookup with expanded fields
179            order = client.orders.lookup(
180                "or_abc123",
181                expand=["customer", "payment", "line_items"]
182            )
183            ```
184
185        See Also:
186            - page(): List multiple orders with pagination
187            - https://studio.inttegro.com/api/orders/lookup
188        """
189        body = {'order_id': order_id, **options}
190        return _resource(await self.http.post('/orders/lookup', body), 'order', Order)

Retrieve an existing order by ID.

Fetches full details of an order including its current status, payment information, line items, and customer data. Use this to check order status, retrieve payment details, or display order history to customers.

Arguments:
  • order_id: The order ID (e.g., "or_abc123")
  • **options: Additional options:
    • expand: List of fields to expand (e.g., ["customer", "payment"])
Returns:

The complete Order.

Raises:
  • ApiError: If order not found or request fails
Example:
# Basic lookup
order = client.orders.lookup("or_abc123")
print(f"Order status: {order.status}")

# Lookup with expanded fields
order = client.orders.lookup(
    "or_abc123",
    expand=["customer", "payment", "line_items"]
)
See Also:
async def update( self, payload: inttegro.order.UpdateRequest) -> inttegro.order.Order:
192    async def update(self, payload: dict):
193        """
194        Update mutable fields on an existing order.
195
196        Args:
197            payload: Update parameters including order_id and fields to change.
198
199        Returns:
200            The updated Order.
201        """
202        return _resource(await self.http.post('/orders/update', payload), 'order', Order)

Update mutable fields on an existing order.

Arguments:
  • payload: Update parameters including order_id and fields to change.
Returns:

The updated Order.

async def pay( self, payload: inttegro.order.PayRequest) -> inttegro.order.Order:
204    async def pay(self, payload: dict):
205        """
206        Charge a payment method for an existing order.
207
208        Processes payment for an order using a payment method (saved or new). For mobile
209        money payments, the customer typically receives an OTP prompt on their phone.
210        If the payment method requires confirmation (confirms_use=True), you'll need to
211        call confirm_payment() with the OTP.
212
213        Args:
214            payload: Payment parameters including:
215                - order_id: The order to charge (required)
216                - payment_method_id or payment_method_data: Payment method (required)
217                - request_meta.idempotency_key: Unique key to prevent duplicate charges (optional)
218
219        Returns:
220            The updated Order, including its typed payment and next-action state.
221
222        Raises:
223            ApiError: If payment fails or parameters are invalid
224
225        Example:
226            ```python
227            # Pay with saved payment method
228            order = client.orders.pay({
229                "order_id": "or_abc123",
230                "payment_method_id": "pm_xyz789"
231            })
232
233            # Check if confirmation is needed
234            if order.payment and order.payment.next_action and order.payment.next_action.type == "confirm_payment":
235                print("OTP sent to customer's phone")
236                # Prompt customer for OTP and call confirm_payment()
237
238            # Pay with new mobile money number
239            order = client.orders.pay({
240                "order_id": "or_abc123",
241                "payment_method_data": {
242                    "type": "mobile_money",
243                    "mobile_money": {
244                        "network": "mtn",
245                        "account_number": "0241234567"
246                    }
247                }
248            })
249
250            # Idempotent payment (safe to retry)
251            order = client.orders.pay({
252                "order_id": "or_abc123",
253                "payment_method_id": "pm_xyz789",
254                "request_meta": {
255                    "idempotency_key": "order_abc123_initial_charge"
256                }
257            })
258            ```
259
260        See Also:
261            - confirm_payment(): Submit OTP for payments requiring confirmation
262            - create(): Create and pay order in one step with execute_payment=True
263            - https://studio.inttegro.com/charge-repeat-customers
264        """
265        return _resource(await self.http.post('/orders/pay', payload), 'order', Order)

Charge a payment method for an existing order.

Processes payment for an order using a payment method (saved or new). For mobile money payments, the customer typically receives an OTP prompt on their phone. If the payment method requires confirmation (confirms_use=True), you'll need to call confirm_payment() with the OTP.

Arguments:
  • payload: Payment parameters including:
    • order_id: The order to charge (required)
    • payment_method_id or payment_method_data: Payment method (required)
    • request_meta.idempotency_key: Unique key to prevent duplicate charges (optional)
Returns:

The updated Order, including its typed payment and next-action state.

Raises:
  • ApiError: If payment fails or parameters are invalid
Example:
# Pay with saved payment method
order = client.orders.pay({
    "order_id": "or_abc123",
    "payment_method_id": "pm_xyz789"
})

# Check if confirmation is needed
if order.payment and order.payment.next_action and order.payment.next_action.type == "confirm_payment":
    print("OTP sent to customer's phone")
    # Prompt customer for OTP and call confirm_payment()

# Pay with new mobile money number
order = client.orders.pay({
    "order_id": "or_abc123",
    "payment_method_data": {
        "type": "mobile_money",
        "mobile_money": {
            "network": "mtn",
            "account_number": "0241234567"
        }
    }
})

# Idempotent payment (safe to retry)
order = client.orders.pay({
    "order_id": "or_abc123",
    "payment_method_id": "pm_xyz789",
    "request_meta": {
        "idempotency_key": "order_abc123_initial_charge"
    }
})
See Also:
async def confirm_payment( self, payload: inttegro.payment.ConfirmRequest) -> inttegro.order.Order:
267    async def confirm_payment(self, payload: dict):
268        """
269        Submit OTP confirmation token to complete a payment.
270
271        After calling pay() on a payment method that requires confirmation (confirms_use=True),
272        the customer receives an OTP on their mobile device. Collect this OTP from the customer
273        and submit it via this method to complete the payment.
274
275        Args:
276            payload: Confirmation parameters including:
277                - order_id: The order being paid (required)
278                - token: The OTP code from customer (required, 6 digits)
279
280        Returns:
281            The updated Order with its final payment status.
282
283        Raises:
284            ApiError: If OTP is invalid, expired, or payment fails
285
286        Example:
287            ```python
288            # Step 1: Initiate payment
289            order = client.orders.pay({
290                "order_id": "or_abc123",
291                "payment_method_id": "pm_xyz789"
292            })
293
294            # Step 2: Check if confirmation needed
295            if order.payment and order.payment.next_action and order.payment.next_action.type == "confirm_payment":
296                # Display OTP input form to customer
297                otp = input("Enter the OTP sent to your phone: ")
298
299                # Step 3: Submit OTP
300                order = client.orders.confirm_payment({
301                    "order_id": "or_abc123",
302                    "token": otp
303                })
304
305                if order.payment and order.payment.status == "paid":
306                    print("Payment successful!")
307            ```
308
309        See Also:
310            - pay(): Initiate payment that may require confirmation
311            - request_confirmation(): Resend OTP if customer didn't receive it
312            - https://studio.inttegro.com/charge-repeat-customers
313        """
314        return _resource(await self.http.post('/orders/confirm_payment', payload), 'order', Order)

Submit OTP confirmation token to complete a payment.

After calling pay() on a payment method that requires confirmation (confirms_use=True), the customer receives an OTP on their mobile device. Collect this OTP from the customer and submit it via this method to complete the payment.

Arguments:
  • payload: Confirmation parameters including:
    • order_id: The order being paid (required)
    • token: The OTP code from customer (required, 6 digits)
Returns:

The updated Order with its final payment status.

Raises:
  • ApiError: If OTP is invalid, expired, or payment fails
Example:
# Step 1: Initiate payment
order = client.orders.pay({
    "order_id": "or_abc123",
    "payment_method_id": "pm_xyz789"
})

# Step 2: Check if confirmation needed
if order.payment and order.payment.next_action and order.payment.next_action.type == "confirm_payment":
    # Display OTP input form to customer
    otp = input("Enter the OTP sent to your phone: ")

    # Step 3: Submit OTP
    order = client.orders.confirm_payment({
        "order_id": "or_abc123",
        "token": otp
    })

    if order.payment and order.payment.status == "paid":
        print("Payment successful!")
See Also:
async def request_confirmation( self, order_id: str, request_meta: dict[str, str] | None = None) -> inttegro.order.Order:
316    async def request_confirmation(self, order_id: str, request_meta: dict | None=None):
317        """
318        Resend OTP confirmation code to customer.
319
320        If a customer didn't receive the initial OTP or it expired, use this method to
321        trigger a new OTP to be sent to their mobile device. The payment must be in a
322        state awaiting confirmation.
323
324        Args:
325            order_id: The order ID with pending payment confirmation
326            request_meta: Request controls such as idempotency_key
327
328        Returns:
329            The updated Order.
330
331        Raises:
332            ApiError: If order has no pending confirmation or request fails
333
334        Example:
335            ```python
336            # Customer didn't receive OTP
337            result = client.orders.request_confirmation("or_abc123")
338            print("New OTP sent to customer's phone")
339
340            # Now prompt customer for the new OTP
341            otp = input("Enter the OTP: ")
342            client.orders.confirm_payment({
343                "order_id": "or_abc123",
344                "token": otp
345            })
346            ```
347
348        See Also:
349            - confirm_payment(): Submit the OTP code
350            - pay(): Initial payment that triggers OTP
351        """
352        return _resource(await self.http.post('/orders/request_confirmation', {'order_id': order_id, 'request_meta': request_meta or _stable_order_request_meta('request_confirmation', order_id)}), 'order', Order)

Resend OTP confirmation code to customer.

If a customer didn't receive the initial OTP or it expired, use this method to trigger a new OTP to be sent to their mobile device. The payment must be in a state awaiting confirmation.

Arguments:
  • order_id: The order ID with pending payment confirmation
  • request_meta: Request controls such as idempotency_key
Returns:

The updated Order.

Raises:
  • ApiError: If order has no pending confirmation or request fails
Example:
# Customer didn't receive OTP
result = client.orders.request_confirmation("or_abc123")
print("New OTP sent to customer's phone")

# Now prompt customer for the new OTP
otp = input("Enter the OTP: ")
client.orders.confirm_payment({
    "order_id": "or_abc123",
    "token": otp
})
See Also:
  • confirm_payment(): Submit the OTP code
  • pay(): Initial payment that triggers OTP
async def finalize( self, order_id: str, request_meta: dict[str, str] | None = None) -> inttegro.order.Order:
354    async def finalize(self, order_id: str, request_meta: dict | None=None):
355        """
356        Finalize an order to make it available in reports and analytics.
357
358        Finalizing an order locks its line items and amounts, making it appear in financial
359        reports, dashboards, and analytics. Only paid orders can be finalized. This is
360        typically done automatically but can be called manually if needed.
361
362        Most applications don't need to call this explicitly as orders finalize automatically
363        after successful payment.
364
365        Args:
366            order_id: The order ID to finalize
367            request_meta: Request controls such as idempotency_key
368
369        Returns:
370            The finalized Order.
371
372        Raises:
373            ApiError: If order is not paid or cannot be finalized
374
375        Example:
376            ```python
377            # Finalize order manually
378            order = client.orders.finalize("or_abc123")
379            print(f"Order finalized at: {order.sealed_at}")
380            ```
381
382        See Also:
383            - complete(): Mark order as fulfilled (separate from finalization)
384            - https://studio.inttegro.com/api/orders/finalize
385        """
386        return _resource(await self.http.post('/orders/finalize', {'order_id': order_id, 'request_meta': request_meta or _stable_order_request_meta('finalize', order_id)}), 'order', Order)

Finalize an order to make it available in reports and analytics.

Finalizing an order locks its line items and amounts, making it appear in financial reports, dashboards, and analytics. Only paid orders can be finalized. This is typically done automatically but can be called manually if needed.

Most applications don't need to call this explicitly as orders finalize automatically after successful payment.

Arguments:
  • order_id: The order ID to finalize
  • request_meta: Request controls such as idempotency_key
Returns:

The finalized Order.

Raises:
  • ApiError: If order is not paid or cannot be finalized
Example:
# Finalize order manually
order = client.orders.finalize("or_abc123")
print(f"Order finalized at: {order.sealed_at}")
See Also:
async def send_invoice( self, payload: inttegro.order.DocumentDeliveryRequest) -> inttegro.order.DocumentDeliveryResult:
388    async def send_invoice(self, payload: dict):
389        """
390        Send the hosted invoice link for an existing order.
391
392        Args:
393            payload: Send invoice parameters including:
394                - order_id: The order whose invoice should be sent (required)
395
396        Returns:
397            An OrderDocumentDeliveryResult containing the order and delivery details.
398        """
399        return await self.http.post('/orders/send_invoice', payload)

Send the hosted invoice link for an existing order.

Arguments:
  • payload: Send invoice parameters including:
    • order_id: The order whose invoice should be sent (required)
Returns:

An OrderDocumentDeliveryResult containing the order and delivery details.

async def send_receipt( self, payload: inttegro.order.DocumentDeliveryRequest) -> inttegro.order.DocumentDeliveryResult:
401    async def send_receipt(self, payload: dict):
402        """
403        Send the hosted receipt link for a paid order.
404
405        Args:
406            payload: Send receipt parameters including:
407                - order_id: The paid order whose receipt should be sent (required)
408
409        Returns:
410            An OrderDocumentDeliveryResult containing the order and delivery details.
411        """
412        return await self.http.post('/orders/send_receipt', payload)

Send the hosted receipt link for a paid order.

Arguments:
  • payload: Send receipt parameters including:
    • order_id: The paid order whose receipt should be sent (required)
Returns:

An OrderDocumentDeliveryResult containing the order and delivery details.

async def complete( self, payload: inttegro.order.CompleteRequest) -> inttegro.order.Order:
414    async def complete(self, payload: dict):
415        """
416        Mark an order as complete after fulfillment.
417
418        Call this method after you've fulfilled the order (shipped goods, delivered service,
419        etc.). Completing an order is separate from payment—it indicates that your
420        obligations to the customer are fulfilled. This affects refund eligibility and
421        dispute windows.
422
423        Args:
424            payload: Completion parameters including:
425                - order_id: The order to mark as complete (required)
426                - proof: Optional fulfillment proof (tracking number, photo URL, etc.)
427
428        Returns:
429            The completed Order.
430
431        Raises:
432            ApiError: If order cannot be completed (not paid, already completed, etc.)
433
434        Example:
435            ```python
436            # Complete physical goods order
437            order = client.orders.complete({
438                "order_id": "or_abc123",
439                "proof": "TRACKING123456"
440            })
441
442            # Complete digital order
443            order = client.orders.complete({
444                "order_id": "or_abc123"
445            })
446
447            print(f"Order completed at: {order.completed_at}")
448            ```
449
450        See Also:
451            - finalize(): Financial finalization (different from completion)
452            - refund(): Issue refund (easier before completion)
453            - https://studio.inttegro.com/api/orders/complete
454        """
455        return _resource(await self.http.post('/orders/complete', payload), 'order', Order)

Mark an order as complete after fulfillment.

Call this method after you've fulfilled the order (shipped goods, delivered service, etc.). Completing an order is separate from payment—it indicates that your obligations to the customer are fulfilled. This affects refund eligibility and dispute windows.

Arguments:
  • payload: Completion parameters including:
    • order_id: The order to mark as complete (required)
    • proof: Optional fulfillment proof (tracking number, photo URL, etc.)
Returns:

The completed Order.

Raises:
  • ApiError: If order cannot be completed (not paid, already completed, etc.)
Example:
# Complete physical goods order
order = client.orders.complete({
    "order_id": "or_abc123",
    "proof": "TRACKING123456"
})

# Complete digital order
order = client.orders.complete({
    "order_id": "or_abc123"
})

print(f"Order completed at: {order.completed_at}")
See Also:
async def cancel( self, order_id: str, request_meta: dict[str, str] | None = None) -> inttegro.order.Order:
457    async def cancel(self, order_id: str, request_meta: dict | None=None):
458        """
459        Cancel an unpaid order.
460
461        Cancels an order that hasn't been paid yet. Once cancelled, the order cannot be
462        paid or modified. This is useful for abandonment flows, expired carts, or when
463        customers explicitly cancel before payment.
464
465        You cannot cancel orders that have been paid. Use refund() instead for paid orders.
466
467        Args:
468            order_id: The order ID to cancel
469            request_meta: Request controls such as idempotency_key
470
471        Returns:
472            The cancelled Order.
473
474        Raises:
475            ApiError: If order is already paid or cannot be cancelled
476
477        Example:
478            ```python
479            # Cancel abandoned order
480            order = client.orders.cancel("or_abc123")
481            print(f"Order status: {order.status}")  # "canceled"
482
483            # Cancellation flow with expiration
484            import time
485
486            # Create order
487            order = client.orders.create({...})
488            order_id = order.id
489
490            # Wait for payment (with timeout)
491            time.sleep(300)  # 5 minutes
492
493            # Check if still unpaid
494            order = client.orders.lookup(order_id)
495            if order.status == "preparing":
496                # Cancel expired order
497                client.orders.cancel(order_id)
498            ```
499
500        See Also:
501            - refund(): Return money for paid orders
502            - https://studio.inttegro.com/api/orders/cancel
503        """
504        return _resource(await self.http.post('/orders/cancel', {'order_id': order_id, 'request_meta': request_meta or _stable_order_request_meta('cancel', order_id)}), 'order', Order)

Cancel an unpaid order.

Cancels an order that hasn't been paid yet. Once cancelled, the order cannot be paid or modified. This is useful for abandonment flows, expired carts, or when customers explicitly cancel before payment.

You cannot cancel orders that have been paid. Use refund() instead for paid orders.

Arguments:
  • order_id: The order ID to cancel
  • request_meta: Request controls such as idempotency_key
Returns:

The cancelled Order.

Raises:
  • ApiError: If order is already paid or cannot be cancelled
Example:
# Cancel abandoned order
order = client.orders.cancel("or_abc123")
print(f"Order status: {order.status}")  # "canceled"

# Cancellation flow with expiration
import time

# Create order
order = client.orders.create({...})
order_id = order.id

# Wait for payment (with timeout)
time.sleep(300)  # 5 minutes

# Check if still unpaid
order = client.orders.lookup(order_id)
if order.status == "preparing":
    # Cancel expired order
    client.orders.cancel(order_id)
See Also:
async def page( self, payload: inttegro.order.PageRequest | None = None) -> inttegro.order.Page:
506    async def page(self, payload: dict | None=None):
507        """
508        List orders with page-based pagination.
509
510        Retrieves a paginated list of orders for your application. Use this to build
511        order history views, display transaction data, or export reports. Results are
512        sorted by creation date (most recent first).
513
514        Args:
515            payload: Pagination parameters including:
516                - page_number: Zero-based page index to fetch (0-10 inclusive)
517                - page_size: Number of orders per page (1-256)
518                - customer_id: Optional customer whose orders should be returned
519
520        Returns:
521            A typed Page.
522
523        Example:
524            ```python
525            # Get first page of orders
526            page = client.orders.page({"page_number": 0, "page_size": 20})
527
528            for order in page.orders:
529                print(f"{order.id}: {order.status}")
530
531            # Get second page
532            next_page = client.orders.page({
533                "page_number": 1,
534                "page_size": 20
535            })
536
537            # Retrieve more orders per page
538            large_page = client.orders.page({
539                "page_number": 0,
540                "page_size": 100
541            })
542
543            # Iterate through all pages
544            for page_num in range(0, 11):
545                page = client.orders.page({
546                    "page_number": page_num,
547                    "page_size": 50
548                })
549
550                if page.size == 0:
551                    break
552
553                for order in page.orders:
554                    print(f"Order: {order.id}")
555            ```
556
557        See Also:
558            - lookup(): Get a single order by ID
559            - https://studio.inttegro.com/api/orders/page
560        """
561        return _resource(await self.http.post('/orders/page', payload or {}), 'page', Page)

List orders with page-based pagination.

Retrieves a paginated list of orders for your application. Use this to build order history views, display transaction data, or export reports. Results are sorted by creation date (most recent first).

Arguments:
  • payload: Pagination parameters including:
    • page_number: Zero-based page index to fetch (0-10 inclusive)
    • page_size: Number of orders per page (1-256)
    • customer_id: Optional customer whose orders should be returned
Returns:

A typed Page.

Example:
# Get first page of orders
page = client.orders.page({"page_number": 0, "page_size": 20})

for order in page.orders:
    print(f"{order.id}: {order.status}")

# Get second page
next_page = client.orders.page({
    "page_number": 1,
    "page_size": 20
})

# Retrieve more orders per page
large_page = client.orders.page({
    "page_number": 0,
    "page_size": 100
})

# Iterate through all pages
for page_num in range(0, 11):
    page = client.orders.page({
        "page_number": page_num,
        "page_size": 50
    })

    if page.size == 0:
        break

    for order in page.orders:
        print(f"Order: {order.id}")
See Also:
async def search( self, payload: inttegro.search.Request) -> inttegro.search.Page:
563    async def search(self, payload: SearchRequest) -> SearchPage:
564        """Search order projections owned by the authenticated application."""
565        return await self.http.post('/orders/search', payload)

Search order projections owned by the authenticated application.