Skip to main content
Skip to main content

Payment Collections

Queries and Mutations listed here are used to send requests to the Admin Payment Collection API Routes.

All hooks listed require authentication.

A payment collection is useful for managing additional payments, such as for Order Edits, or installment payments.

Mutations

useAdminDeletePaymentCollection

This hook deletes a payment collection. Only payment collections with the statuses canceled or not_paid can be deleted.

Example

import React from "react"
import { useAdminDeletePaymentCollection } from "medusa-react"

type Props = {
paymentCollectionId: string
}

const PaymentCollection = ({ paymentCollectionId }: Props) => {
const deleteCollection = useAdminDeletePaymentCollection(
paymentCollectionId
)
// ...

const handleDelete = () => {
deleteCollection.mutate(void 0, {
onSuccess: ({ id, object, deleted }) => {
console.log(id)
}
})
}

// ...
}

export default PaymentCollection

Hook Parameters

idstringRequired
The payment collection's ID.

Mutation Function Returned Data

AdminPaymentCollectionDeleteResAdminPaymentCollectionDeleteResRequired
The details of deleting a payment collection.

useAdminUpdatePaymentCollection

This hook updates a payment collection's details.

Example

import React from "react"
import { useAdminUpdatePaymentCollection } from "medusa-react"

type Props = {
paymentCollectionId: string
}

const PaymentCollection = ({ paymentCollectionId }: Props) => {
const updateCollection = useAdminUpdatePaymentCollection(
paymentCollectionId
)
// ...

const handleUpdate = (
description: string
) => {
updateCollection.mutate({
description
}, {
onSuccess: ({ payment_collection }) => {
console.log(payment_collection.description)
}
})
}

// ...
}

export default PaymentCollection

Hook Parameters

idstringRequired
The payment collection's ID.

Mutation Function Parameters

AdminUpdatePaymentCollectionsReqAdminUpdatePaymentCollectionsReqRequired
The details to update of the payment collection.

Mutation Function Returned Data

AdminPaymentCollectionsResAdminPaymentCollectionsResRequired
The payment collection's details.

useAdminMarkPaymentCollectionAsAuthorized

This hook sets the status of a payment collection as authorized. This will also change the authorized_amount of the payment collection.

Example

import React from "react"
import { useAdminMarkPaymentCollectionAsAuthorized } from "medusa-react"

type Props = {
paymentCollectionId: string
}

const PaymentCollection = ({ paymentCollectionId }: Props) => {
const markAsAuthorized = useAdminMarkPaymentCollectionAsAuthorized(
paymentCollectionId
)
// ...

const handleAuthorization = () => {
markAsAuthorized.mutate(void 0, {
onSuccess: ({ payment_collection }) => {
console.log(payment_collection.status)
}
})
}

// ...
}

export default PaymentCollection

Hook Parameters

idstringRequired
The payment collection's ID.

Mutation Function Returned Data

AdminPaymentCollectionsResAdminPaymentCollectionsResRequired
The payment collection's details.

Queries

useAdminPaymentCollection

This hook retrieves a Payment Collection's details.

Example

import React from "react"
import { useAdminPaymentCollection } from "medusa-react"

type Props = {
paymentCollectionId: string
}

const PaymentCollection = ({ paymentCollectionId }: Props) => {
const {
payment_collection,
isLoading,
} = useAdminPaymentCollection(paymentCollectionId)

return (
<div>
{isLoading && <span>Loading...</span>}
{payment_collection && (
<span>{payment_collection.status}</span>
)}

</div>
)
}

export default PaymentCollection

Hook Parameters

idstringRequired
The payment collection's ID.

Query Returned Data

payment_collectionPaymentCollectionRequired
Payment Collection details.
Was this section helpful?