Inttegro TypeScript SDK - v8.2.0
    Preparing search index...

    Class Orders

    Orders resource for managing complete order lifecycle operations.

    Index
    • Cancel an order, stopping payment execution and preventing further processing.

      Canceling an order is irreversible and should be done when the customer requests cancellation or the order cannot be fulfilled. If payment was already captured, you'll need to refund it separately.

      Parameters

      • request: CancelOrderRequest

        Cancellation parameters

        Cancel order request

        • OptionalexecuteRefund?: boolean

          Record whether a refund was requested as part of the cancellation

        • orderId: string

          Order ID to cancel

        • Optionalreason?: string

          Optional cancellation reason

        • OptionalrequestMeta?: RequestMeta

          Request metadata such as idempotency controls

      Returns Promise<Order>

      Cancelled order object

      If order not found, already completed, or cannot be cancelled

      const order = await inttegro.orders.cancel({
      orderId: 'GKj7A8lM5wEGRUvbqpI4bkDFsQvpqVyh5fqePNnb',
      });

      console.log(`Order ${order.id} has been cancelled`);
    • Mark an order as completed, indicating fulfillment is done.

      Call this after you've shipped physical goods or delivered digital products to the customer. Completing an order transitions it to its final state and can optionally mark payment as received offline (out-of-band) if paidOutOfBand is set to true.

      Parameters

      • request: CompleteOrderRequest

        Completion parameters

        Complete order request

        • orderId: string

          Order ID to complete

        • OptionalpaidOutOfBand?: boolean

          Whether payment was collected out of band

      Returns Promise<Order>

      Completed order object

      If order not found, not paid, or already completed

      // Complete order after fulfillment
      const order = await inttegro.orders.complete({
      orderId: 'GKj7A8lM5wEGRUvbqpI4bkDFsQvpqVyh5fqePNnb',
      });

      console.log(`Order completed at: ${order.completedAt}`);
      // Complete order with offline payment
      const result = await inttegro.orders.complete({
      orderId: 'GKj7A8lM5wEGRUvbqpI4bkDFsQvpqVyh5fqePNnb',
      paidOutOfBand: true,
      });
    • Confirm a pending payment using a verification token (e.g., OTP sent to customer's phone).

      Call this method when a payment requires customer confirmation and you've collected the verification token from the customer. The token is typically a 6-digit OTP sent via SMS or email to the customer.

      Parameters

      • request: ConfirmPaymentRequest

        Confirmation parameters

        Confirm payment request

        • confirmationId: string

          Confirmation challenge being answered

        • orderId: string

          Order ID

        • paymentId: string

          Payment being confirmed

        • OptionalrequestMeta?: RequestMeta

          Request metadata such as idempotency controls

        • token: string

          Confirmation token (e.g., OTP)

      Returns Promise<Order>

      Updated order with payment status

      If token is invalid, expired, or order not found

      // After receiving OTP from customer
      const order = await inttegro.orders.confirmPayment({
      orderId: 'GKj7A8lM5wEGRUvbqpI4bkDFsQvpqVyh5fqePNnb',
      paymentId: 'py_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMN',
      confirmationId: 'pc_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMN',
      token: '123456',
      });

      if (order.payment?.status === 'paid') {
      console.log('Payment confirmed successfully!');
      }

      https://studio.inttegro.com/accept-a-payment for complete payment flow

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

      Creates an order representing a purchase. Supports two flows:

      1. New customer: Provide customerData to create a new customer and order
      2. Existing customer: Provide customerId and optionally paymentMethodId for known customers

      Set executePayment to true to immediately charge the customer after order creation. The order can be configured with checkout redirect URLs for hosted payment flows.

      Parameters

      Returns Promise<Order>

      Created order with customer, line items, payment intent (if applicable), and optional redirect URL

      If required fields are missing or invalid

      If the API request fails

      // Create order with new customer and execute payment
      const order = await inttegro.orders.create({
      requestMeta: {
      idempotencyKey: 'order_2025_001',
      },
      executePayment: true,
      customerData: {
      name: 'Gloria Kesewaa',
      emailAddress: 'gloria@example.com',
      phoneNumber: '+233544998605',
      },
      paymentMethodData: {
      type: 'mobile_money',
      mobileMoney: {
      network: 'mtn',
      accountNumber: '0544998605',
      },
      },
      lineItems: [{
      type: 'product',
      product: {
      type: 'physical',
      name: 'Utility Sneakers',
      quantity: 1,
      price: { currency: 'ghs', value: 20000 },
      },
      }],
      checkoutSettings: {
      redirectUrl: 'https://example.com/order/complete',
      cancelUrl: 'https://example.com/order/cancelled',
      },
      });

      console.log(`Created order: ${order.id}`);
      // Create order with existing customer for later payment
      const order = await inttegro.orders.create({
      customerId: 'cu_abc123',
      lineItems: [{
      type: 'product',
      product: {
      type: 'digital',
      name: 'Premium Subscription',
      quantity: 1,
      price: { currency: 'ghs', value: 5000 },
      },
      }],
      });
    • Finalize an order to make it immutable and ready for payment or fulfillment.

      Finalizing (sealing) an order locks its line items and totals, making it ready for payment execution or order completion. Most orders are finalized automatically, but you can explicitly finalize an order if needed.

      Parameters

      • request: FinalizeOrderRequest

        Finalization parameters

        Finalize order request

        • orderId: string

          Order ID to finalize

        • OptionalrequestMeta?: RequestMeta

          Request metadata such as idempotency controls

      Returns Promise<Order>

      Finalized order object

      If order not found or already finalized

      const order = await inttegro.orders.finalize({
      orderId: 'GKj7A8lM5wEGRUvbqpI4bkDFsQvpqVyh5fqePNnb',
      });

      console.log(`Order finalized at: ${order.sealedAt}`);
    • Retrieve an existing order by its ID.

      Returns full order details including customer, line items, payment state, and invoice information. Use this to check order status, retrieve payment details, or display order confirmation to customers.

      Parameters

      • request: LookupOrderRequest

        Lookup parameters

        Lookup order request

        • orderId: string

          Order ID to lookup

      Returns Promise<Order>

      Complete order object with all related data

      If order not found or request fails

      const order = await inttegro.orders.lookup({
      orderId: 'GKj7A8lM5wEGRUvbqpI4bkDFsQvpqVyh5fqePNnb',
      });

      console.log(`Order status: ${order.status}`);
      console.log(`Payment status: ${order.payment?.status}`);

      https://studio.inttegro.com/orders for API reference

    • Retrieve a paginated list of orders.

      Returns orders in reverse chronological order (most recent first).

      Parameters

      • request: PageOrdersRequest = {}

        Pagination and filter parameters (optional)

        Page orders request

        • OptionalcustomerId?: string
        • OptionalpageNumber?: number
        • OptionalpageSize?: number

      Returns Promise<OrderPage>

      Paginated list of orders with pagination details

      If pagination parameters are invalid

      // Get first page of orders
      const page = await inttegro.orders.page({
      pageSize: 25,
      pageNumber: 0,
      });

      console.log(`Retrieved ${page.orders?.length ?? 0} orders`);
      // Restrict the page to one customer
      const customerOrders = await inttegro.orders.page({
      customerId: 'cu_123',
      pageSize: 50,
      });
    • Initiate payment for an existing order.

      Supports three payment flows:

      1. Saved payment method: Provide only orderId to charge a previously saved payment method
      2. New payment method: Include paymentMethodData with inline payment details (mobile money, card, etc.)
      3. Offline payment: Set paidOutOfBand to true for cash, bank transfer, or check payments

      When payment requires customer confirmation (e.g., OTP), the returned order includes a nextAction field indicating what the customer needs to do. Call confirmPayment() once the customer provides the token.

      Parameters

      Returns Promise<Order>

      Updated order with typed payment and next-action state

      If order not found or payment fails

      // Pay with inline mobile money
      const order = await inttegro.orders.pay({
      orderId: 'GKj7A8lM5wEGRUvbqpI4bkDFsQvpqVyh5fqePNnb',
      paymentMethodData: {
      type: 'mobile_money',
      mobileMoney: {
      network: 'mtn',
      accountNumber: '0544998605',
      },
      },
      });

      if (order.payment?.nextAction?.type === 'confirm_payment') {
      // Customer needs to provide OTP sent to their phone
      const token = await promptCustomerForOTP();
      await inttegro.orders.confirmPayment({
      orderId: order.id,
      paymentId: order.payment.id,
      confirmationId: order.payment.nextAction.confirmPayment.request.id,
      token,
      });
      }
      // Pay with saved payment method
      const order = await inttegro.orders.pay({
      orderId: 'GKj7A8lM5wEGRUvbqpI4bkDFsQvpqVyh5fqePNnb',
      paymentMethodId: 'pm_xyz123abc456',
      requestMeta: {
      idempotencyKey: 'order_initial_charge_001',
      },
      });
      // Mark as paid offline (cash, bank transfer, etc.)
      const order = await inttegro.orders.pay({
      orderId: 'GKj7A8lM5wEGRUvbqpI4bkDFsQvpqVyh5fqePNnb',
      paidOutOfBand: true,
      });
    • Create a refund through the /orders/refund compatibility alias.

      This accepts the same line-item request as refunds.create and returns the created Refund directly. New integrations should prefer refunds.create.

      Parameters

      Returns Promise<Refund>

      The created refund

      If order not found, not paid, or refund fails

      const refund = await inttegro.orders.refund({
      orderId: 'or_0123456789abcdefghijklmnopqrstuvwxyzABCD',
      reason: 'requested_by_customer',
      lineItems: [{
      orderLineItemId: 'oli_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMN',
      refundAmount: { currency: 'ghs', value: 2500 },
      }],
      });

      console.log(`Refund created: ${refund.id}`);

      Prefer inttegro.refunds.create.

    • Request a new confirmation token to be sent to the customer (e.g., resend OTP).

      Use this when the customer didn't receive the original OTP or the token expired. A fresh verification token will be sent via SMS or email to the customer's registered contact information.

      Parameters

      • request: RequestConfirmationRequest

        Request parameters

        Request confirmation request

        • orderId: string

          Order ID

        • OptionalrequestMeta?: RequestMeta

          Request metadata such as idempotency controls

      Returns Promise<Order>

      Updated order

      If order not found or not in confirmable state

      // Resend OTP to customer
      const order = await inttegro.orders.requestConfirmation({
      orderId: 'GKj7A8lM5wEGRUvbqpI4bkDFsQvpqVyh5fqePNnb',
      });

      console.log('New OTP sent to customer');

      https://studio.inttegro.com/accept-a-payment for payment confirmation flow