inttegro.resources.orders

Generated public typing surface. Do not edit by hand.

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

Orders(http: inttegro.http_client.HttpClient)
58    def __init__(self, http: HttpClient):
59        """Initialize Orders resource with HTTP client."""
60        self.http = http

Initialize Orders resource with HTTP client.

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

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

def lookup(self, order_id: str, **options: object) -> inttegro.order.Order:
166    def lookup(self, order_id: str, **options):
167        """
168        Retrieve an existing order by ID.
169
170        Fetches full details of an order including its current status, payment information,
171        line items, and customer data. Use this to check order status, retrieve payment
172        details, or display order history to customers.
173
174        Args:
175            order_id: The order ID (e.g., "or_abc123")
176            **options: Additional options:
177                - expand: List of fields to expand (e.g., ["customer", "payment"])
178
179        Returns:
180            The complete Order.
181
182        Raises:
183            ApiError: If order not found or request fails
184
185        Example:
186            ```python
187            # Basic lookup
188            order = client.orders.lookup("or_abc123")
189            print(f"Order status: {order.status}")
190
191            # Lookup with expanded fields
192            order = client.orders.lookup(
193                "or_abc123",
194                expand=["customer", "payment", "line_items"]
195            )
196            ```
197
198        See Also:
199            - page(): List multiple orders with pagination
200            - https://studio.inttegro.com/api/orders/lookup
201        """
202        body = {"order_id": order_id, **options}
203        return _resource(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:
def update( self, payload: inttegro.order.UpdateRequest) -> inttegro.order.Order:
205    def update(self, payload: dict):
206        """
207        Update mutable fields on an existing order.
208
209        Args:
210            payload: Update parameters including order_id and fields to change.
211
212        Returns:
213            The updated Order.
214        """
215        return _resource(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.

def pay( self, payload: inttegro.order.PayRequest) -> inttegro.order.Order:
217    def pay(self, payload: dict):
218        """
219        Charge a payment method for an existing order.
220
221        Processes payment for an order using a payment method (saved or new). For mobile
222        money payments, the customer typically receives an OTP prompt on their phone.
223        If the payment method requires confirmation (confirms_use=True), you'll need to
224        call confirm_payment() with the OTP.
225
226        Args:
227            payload: Payment parameters including:
228                - order_id: The order to charge (required)
229                - payment_method_id or payment_method_data: Payment method (required)
230                - request_meta.idempotency_key: Unique key to prevent duplicate charges (optional)
231
232        Returns:
233            The updated Order, including its typed payment and next-action state.
234
235        Raises:
236            ApiError: If payment fails or parameters are invalid
237
238        Example:
239            ```python
240            # Pay with saved payment method
241            order = client.orders.pay({
242                "order_id": "or_abc123",
243                "payment_method_id": "pm_xyz789"
244            })
245
246            # Check if confirmation is needed
247            if order.payment and order.payment.next_action and order.payment.next_action.type == "confirm_payment":
248                print("OTP sent to customer's phone")
249                # Prompt customer for OTP and call confirm_payment()
250
251            # Pay with new mobile money number
252            order = client.orders.pay({
253                "order_id": "or_abc123",
254                "payment_method_data": {
255                    "type": "mobile_money",
256                    "mobile_money": {
257                        "network": "mtn",
258                        "account_number": "0241234567"
259                    }
260                }
261            })
262
263            # Idempotent payment (safe to retry)
264            order = client.orders.pay({
265                "order_id": "or_abc123",
266                "payment_method_id": "pm_xyz789",
267                "request_meta": {
268                    "idempotency_key": "order_abc123_initial_charge"
269                }
270            })
271            ```
272
273        See Also:
274            - confirm_payment(): Submit OTP for payments requiring confirmation
275            - create(): Create and pay order in one step with execute_payment=True
276            - https://studio.inttegro.com/charge-repeat-customers
277        """
278        return _resource(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:
def confirm_payment( self, payload: inttegro.payment.ConfirmRequest) -> inttegro.order.Order:
280    def confirm_payment(self, payload: dict):
281        """
282        Submit OTP confirmation token to complete a payment.
283
284        After calling pay() on a payment method that requires confirmation (confirms_use=True),
285        the customer receives an OTP on their mobile device. Collect this OTP from the customer
286        and submit it via this method to complete the payment.
287
288        Args:
289            payload: Confirmation parameters including:
290                - order_id: The order being paid (required)
291                - token: The OTP code from customer (required, 6 digits)
292
293        Returns:
294            The updated Order with its final payment status.
295
296        Raises:
297            ApiError: If OTP is invalid, expired, or payment fails
298
299        Example:
300            ```python
301            # Step 1: Initiate payment
302            order = client.orders.pay({
303                "order_id": "or_abc123",
304                "payment_method_id": "pm_xyz789"
305            })
306
307            # Step 2: Check if confirmation needed
308            if order.payment and order.payment.next_action and order.payment.next_action.type == "confirm_payment":
309                # Display OTP input form to customer
310                otp = input("Enter the OTP sent to your phone: ")
311
312                # Step 3: Submit OTP
313                order = client.orders.confirm_payment({
314                    "order_id": "or_abc123",
315                    "token": otp
316                })
317
318                if order.payment and order.payment.status == "paid":
319                    print("Payment successful!")
320            ```
321
322        See Also:
323            - pay(): Initiate payment that may require confirmation
324            - request_confirmation(): Resend OTP if customer didn't receive it
325            - https://studio.inttegro.com/charge-repeat-customers
326        """
327        return _resource(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:
def request_confirmation( self, order_id: str, request_meta: dict[str, str] | None = None) -> inttegro.order.Order:
329    def request_confirmation(self, order_id: str, request_meta: dict | None = None):
330        """
331        Resend OTP confirmation code to customer.
332
333        If a customer didn't receive the initial OTP or it expired, use this method to
334        trigger a new OTP to be sent to their mobile device. The payment must be in a
335        state awaiting confirmation.
336
337        Args:
338            order_id: The order ID with pending payment confirmation
339            request_meta: Request controls such as idempotency_key
340
341        Returns:
342            The updated Order.
343
344        Raises:
345            ApiError: If order has no pending confirmation or request fails
346
347        Example:
348            ```python
349            # Customer didn't receive OTP
350            result = client.orders.request_confirmation("or_abc123")
351            print("New OTP sent to customer's phone")
352
353            # Now prompt customer for the new OTP
354            otp = input("Enter the OTP: ")
355            client.orders.confirm_payment({
356                "order_id": "or_abc123",
357                "token": otp
358            })
359            ```
360
361        See Also:
362            - confirm_payment(): Submit the OTP code
363            - pay(): Initial payment that triggers OTP
364        """
365        return _resource(
366            self.http.post(
367                "/orders/request_confirmation",
368                {
369                    "order_id": order_id,
370                    "request_meta": request_meta or _stable_order_request_meta(
371                        "request_confirmation", order_id
372                    ),
373                },
374            ),
375            "order",
376            Order,
377        )

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
def finalize( self, order_id: str, request_meta: dict[str, str] | None = None) -> inttegro.order.Order:
379    def finalize(self, order_id: str, request_meta: dict | None = None):
380        """
381        Finalize an order to make it available in reports and analytics.
382
383        Finalizing an order locks its line items and amounts, making it appear in financial
384        reports, dashboards, and analytics. Only paid orders can be finalized. This is
385        typically done automatically but can be called manually if needed.
386
387        Most applications don't need to call this explicitly as orders finalize automatically
388        after successful payment.
389
390        Args:
391            order_id: The order ID to finalize
392            request_meta: Request controls such as idempotency_key
393
394        Returns:
395            The finalized Order.
396
397        Raises:
398            ApiError: If order is not paid or cannot be finalized
399
400        Example:
401            ```python
402            # Finalize order manually
403            order = client.orders.finalize("or_abc123")
404            print(f"Order finalized at: {order.sealed_at}")
405            ```
406
407        See Also:
408            - complete(): Mark order as fulfilled (separate from finalization)
409            - https://studio.inttegro.com/api/orders/finalize
410        """
411        return _resource(
412            self.http.post(
413                "/orders/finalize",
414                {
415                    "order_id": order_id,
416                    "request_meta": request_meta or _stable_order_request_meta("finalize", order_id),
417                },
418            ),
419            "order",
420            Order,
421        )

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:
def send_invoice( self, payload: inttegro.order.DocumentDeliveryRequest) -> inttegro.order.DocumentDeliveryResult:
423    def send_invoice(self, payload: dict):
424        """
425        Send the hosted invoice link for an existing order.
426
427        Args:
428            payload: Send invoice parameters including:
429                - order_id: The order whose invoice should be sent (required)
430
431        Returns:
432            An OrderDocumentDeliveryResult containing the order and delivery details.
433        """
434        return 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.

def send_receipt( self, payload: inttegro.order.DocumentDeliveryRequest) -> inttegro.order.DocumentDeliveryResult:
436    def send_receipt(self, payload: dict):
437        """
438        Send the hosted receipt link for a paid order.
439
440        Args:
441            payload: Send receipt parameters including:
442                - order_id: The paid order whose receipt should be sent (required)
443
444        Returns:
445            An OrderDocumentDeliveryResult containing the order and delivery details.
446        """
447        return 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.

def complete( self, payload: inttegro.order.CompleteRequest) -> inttegro.order.Order:
449    def complete(self, payload: dict):
450        """
451        Mark an order as complete after fulfillment.
452
453        Call this method after you've fulfilled the order (shipped goods, delivered service,
454        etc.). Completing an order is separate from payment—it indicates that your
455        obligations to the customer are fulfilled. This affects refund eligibility and
456        dispute windows.
457
458        Args:
459            payload: Completion parameters including:
460                - order_id: The order to mark as complete (required)
461                - proof: Optional fulfillment proof (tracking number, photo URL, etc.)
462
463        Returns:
464            The completed Order.
465
466        Raises:
467            ApiError: If order cannot be completed (not paid, already completed, etc.)
468
469        Example:
470            ```python
471            # Complete physical goods order
472            order = client.orders.complete({
473                "order_id": "or_abc123",
474                "proof": "TRACKING123456"
475            })
476
477            # Complete digital order
478            order = client.orders.complete({
479                "order_id": "or_abc123"
480            })
481
482            print(f"Order completed at: {order.completed_at}")
483            ```
484
485        See Also:
486            - finalize(): Financial finalization (different from completion)
487            - refund(): Issue refund (easier before completion)
488            - https://studio.inttegro.com/api/orders/complete
489        """
490        return _resource(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:
def cancel( self, order_id: str, request_meta: dict[str, str] | None = None) -> inttegro.order.Order:
492    def cancel(self, order_id: str, request_meta: dict | None = None):
493        """
494        Cancel an unpaid order.
495
496        Cancels an order that hasn't been paid yet. Once cancelled, the order cannot be
497        paid or modified. This is useful for abandonment flows, expired carts, or when
498        customers explicitly cancel before payment.
499
500        You cannot cancel orders that have been paid. Use refund() instead for paid orders.
501
502        Args:
503            order_id: The order ID to cancel
504            request_meta: Request controls such as idempotency_key
505
506        Returns:
507            The cancelled Order.
508
509        Raises:
510            ApiError: If order is already paid or cannot be cancelled
511
512        Example:
513            ```python
514            # Cancel abandoned order
515            order = client.orders.cancel("or_abc123")
516            print(f"Order status: {order.status}")  # "canceled"
517
518            # Cancellation flow with expiration
519            import time
520
521            # Create order
522            order = client.orders.create({...})
523            order_id = order.id
524
525            # Wait for payment (with timeout)
526            time.sleep(300)  # 5 minutes
527
528            # Check if still unpaid
529            order = client.orders.lookup(order_id)
530            if order.status == "preparing":
531                # Cancel expired order
532                client.orders.cancel(order_id)
533            ```
534
535        See Also:
536            - refund(): Return money for paid orders
537            - https://studio.inttegro.com/api/orders/cancel
538        """
539        return _resource(
540            self.http.post(
541                "/orders/cancel",
542                {
543                    "order_id": order_id,
544                    "request_meta": request_meta or _stable_order_request_meta("cancel", order_id),
545                },
546            ),
547            "order",
548            Order,
549        )

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:
def page( self, payload: inttegro.order.PageRequest | None = None) -> inttegro.order.Page:
551    def page(self, payload: dict | None = None):
552        """
553        List orders with page-based pagination.
554
555        Retrieves a paginated list of orders for your application. Use this to build
556        order history views, display transaction data, or export reports. Results are
557        sorted by creation date (most recent first).
558
559        Args:
560            payload: Pagination parameters including:
561                - page_number: Zero-based page index to fetch (0-10 inclusive)
562                - page_size: Number of orders per page (1-256)
563                - customer_id: Optional customer whose orders should be returned
564
565        Returns:
566            A typed Page.
567
568        Example:
569            ```python
570            # Get first page of orders
571            page = client.orders.page({"page_number": 0, "page_size": 20})
572
573            for order in page.orders:
574                print(f"{order.id}: {order.status}")
575
576            # Get second page
577            next_page = client.orders.page({
578                "page_number": 1,
579                "page_size": 20
580            })
581
582            # Retrieve more orders per page
583            large_page = client.orders.page({
584                "page_number": 0,
585                "page_size": 100
586            })
587
588            # Iterate through all pages
589            for page_num in range(0, 11):
590                page = client.orders.page({
591                    "page_number": page_num,
592                    "page_size": 50
593                })
594
595                if page.size == 0:
596                    break
597
598                for order in page.orders:
599                    print(f"Order: {order.id}")
600            ```
601
602        See Also:
603            - lookup(): Get a single order by ID
604            - https://studio.inttegro.com/api/orders/page
605        """
606        return _resource(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:
def search( self, payload: inttegro.search.Request) -> inttegro.search.Page:
608    def search(self, payload: SearchRequest) -> SearchPage:
609        """Search order projections owned by the authenticated application."""
610        return self.http.post("/orders/search", payload)

Search order projections owned by the authenticated application.