Skip to main content
Skip to main content

AdminPaymentCollectionsResource

This class is used to send requests to Admin Payment Collection API Routes. All its method are available in the JS Client under the medusa.admin.paymentCollections property.

All methods in this class require user authentication.

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

Methods

delete

Delete a payment collection. Only payment collections with the statuses canceled or not_paid can be deleted.

Example

import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.paymentCollections.delete(paymentCollectionId)
.then(({ id, object, deleted }) => {
console.log(id)
})

Parameters

idstringRequired
The ID of the payment collection.
customHeadersRecord<string, any>Required
Custom headers to attach to the request.

Default: {}

Returns

ResponsePromiseResponsePromise<AdminPaymentCollectionDeleteRes>Required
Resolves to the deletion operation's details.

markAsAuthorized

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

Example

import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.paymentCollections.markAsAuthorized(paymentCollectionId)
.then(({ payment_collection }) => {
console.log(payment_collection.id)
})

Parameters

idstringRequired
The ID of the payment collection.
customHeadersRecord<string, any>Required
Custom headers to attach to the request.

Default: {}

Returns

ResponsePromiseResponsePromise<AdminPaymentCollectionsRes>Required
Resolves to the payment collection's details.

retrieve

Retrieve a Payment Collection's details.

Example

A simple example that retrieves a payment collection by its ID:

import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.paymentCollections.retrieve(paymentCollectionId)
.then(({ payment_collection }) => {
console.log(payment_collection.id)
})

To specify relations that should be retrieved:

import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.paymentCollections.retrieve(paymentCollectionId, {
expand: "currency"
})
.then(({ payment_collection }) => {
console.log(payment_collection.id)
})

Parameters

idstringRequired
The ID of the payment collection.
Configurations to apply on the retrieved payment collection.
customHeadersRecord<string, any>Required
Custom headers to attach to the request.

Default: {}

Returns

ResponsePromiseResponsePromise<AdminPaymentCollectionsRes>Required
Resolves to the payment collection's details.

update

Update a payment collection's details.

Example

import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.paymentCollections.update(paymentCollectionId, {
description
})
.then(({ payment_collection }) => {
console.log(payment_collection.id)
})

Parameters

idstringRequired
The ID of the payment collection.
The attributes to update in the payment collection.
customHeadersRecord<string, any>Required
Custom headers to attach to the request.

Default: {}

Returns

ResponsePromiseResponsePromise<AdminPaymentCollectionsRes>Required
Resolves to the payment collection's details.
Was this section helpful?