Skip to content

useOrderPayment

useOrderPayment

Composable for managing an existing order.

Types

ts
export function useOrderPayment(
  order: ComputedRef<Schemas["Order"] | null | undefined>,
): UseOrderPaymentReturn

source code

ts
export type UseOrderPaymentReturn = {
  /**
   * If the payment can be done after the order is placed
   */
  isAsynchronous: ComputedRef<boolean | undefined>;
  /**
   * Active payment transaction
   */
  activeTransaction: ComputedRef<Schemas["OrderTransaction"] | undefined>;
  /**
   * Payment status
   */
  state: ComputedRef<Schemas["StateMachineState"] | null | undefined>;
  paymentUrl: Ref<null | string>;
  /**
   * Payment method set for the order
   */
  paymentMethod: ComputedRef<Schemas["PaymentMethod"] | undefined | null>;

  /**
   * Invokes the payment process for the order in the backend
   */
  handlePayment(
    /**
     * URL to redirect after successful payment
     */
    successUrl?: string,
    /**
     * URL to redirect after failed payment
     */
    errorUrl?: string,
    /**
     * additional payment details to provide
     */
    paymentDetails?: unknown,
  ): Promise<undefined | unknown>;
  /**
   * Change a payment method for the order
   */
  changePaymentMethod(
    paymentMethodId: string,
  ): Promise<Schemas["SuccessResponse"] | undefined>;
};

source code