Skip to content

Commit

Permalink
feat: add order confirm hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
field123 committed Jan 12, 2024
1 parent c9ba27a commit 9956b1c
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/react-shopper-hooks/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ export * from "./account"
export * from "./elasticpath"
export * from "./payments"
export * from "./currency"
export * from "./order"
export * from "@elasticpath/shopper-common"
1 change: 1 addition & 0 deletions packages/react-shopper-hooks/src/order/hooks/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "./use-order-confirm"
29 changes: 29 additions & 0 deletions packages/react-shopper-hooks/src/order/hooks/use-order-confirm.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { useMutation, UseMutationOptions } from "@tanstack/react-query"
import { useElasticPath } from "../../elasticpath"
import { ConfirmPaymentResponse, ConfirmPaymentBody } from "@moltin/sdk"

export type UseOrderConfirmReq = {
orderId: string
transactionId: string
options: ConfirmPaymentBody
}

export const useOrderConfirm = (
options?: UseMutationOptions<
ConfirmPaymentResponse,
Error,
UseOrderConfirmReq
>,
) => {
const { client } = useElasticPath()
return useMutation({
mutationFn: async ({
orderId,
transactionId,
options,
}: UseOrderConfirmReq) => {
return client.Orders.Confirm(orderId, transactionId, options)
},
...options,
})
}
1 change: 1 addition & 0 deletions packages/react-shopper-hooks/src/order/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "./hooks"

0 comments on commit 9956b1c

Please sign in to comment.