Files
medusa-store/www/apps/docs/content/references/js-client/classes/AdminPaymentCollectionsResource.mdx
Shahed Nasser c51dce164d docs: general fixes to references (#5653)
* fixed typedoc plugin's escape strategy

* move props comments to the associated property

* regenerate references
2023-11-17 19:36:58 +02:00

875 lines
29 KiB
Plaintext

---
displayed_sidebar: jsClientSidebar
slug: /references/js-client/AdminPaymentCollectionsResource
---
import ParameterTypes from "@site/src/components/ParameterTypes"
# AdminPaymentCollectionsResource
This class is used to send requests to [Admin Payment Collection API Routes](https://docs.medusajs.com/api/admin#payment-collections). All its method
are available in the JS Client under the `medusa.admin.paymentCollections` property.
All methods in this class require [user authentication](AdminAuthResource.mdx#createsession).
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
```ts
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
<ParameterTypes parameters={[
{
"name": "id",
"type": "`string`",
"description": "The ID of the payment collection.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "customHeaders",
"type": "`Record<string, any>`",
"description": "Custom headers to attach to the request.",
"optional": false,
"defaultValue": "{}",
"expandable": false,
"children": []
}
]} />
#### Returns
<ParameterTypes parameters={[
{
"name": "ResponsePromise",
"type": "[ResponsePromise](../internal/types/internal.ResponsePromise.mdx)&#60;[AdminPaymentCollectionDeleteRes](../internal/types/internal.AdminPaymentCollectionDeleteRes.mdx)&#62;",
"optional": false,
"defaultValue": "",
"description": "Resolves to the deletion operation's details.",
"expandable": false,
"children": [
{
"name": "AdminPaymentCollectionDeleteRes",
"type": "`object`",
"description": "The details of deleting a payment collection.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": [
{
"name": "deleted",
"type": "`boolean`",
"description": "Whether or not the Payment Collection was deleted.",
"optional": false,
"defaultValue": "true",
"expandable": false,
"children": []
},
{
"name": "id",
"type": "`string`",
"description": "The ID of the deleted Payment Collection.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "object",
"type": "`\"payment_collection\"`",
"description": "The type of the object that was deleted.",
"optional": false,
"defaultValue": "payment_collection",
"expandable": false,
"children": []
}
]
}
]
}
]} />
___
### markAsAuthorized
Set the status of a payment collection as `authorized`. This will also change the `authorized_amount` of the payment collection.
#### Example
```ts
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
<ParameterTypes parameters={[
{
"name": "id",
"type": "`string`",
"description": "The ID of the payment collection.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "customHeaders",
"type": "`Record<string, any>`",
"description": "Custom headers to attach to the request.",
"optional": false,
"defaultValue": "{}",
"expandable": false,
"children": []
}
]} />
#### Returns
<ParameterTypes parameters={[
{
"name": "ResponsePromise",
"type": "[ResponsePromise](../internal/types/internal.ResponsePromise.mdx)&#60;[AdminPaymentCollectionsRes](../internal/types/internal.AdminPaymentCollectionsRes.mdx)&#62;",
"optional": false,
"defaultValue": "",
"description": "Resolves to the payment collection's details.",
"expandable": false,
"children": [
{
"name": "AdminPaymentCollectionsRes",
"type": "`object`",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": [
{
"name": "payment_collection",
"type": "[PaymentCollection](../internal/classes/internal.PaymentCollection.mdx)",
"description": "Payment Collection details.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": [
{
"name": "amount",
"type": "`number`",
"description": "Amount of the payment collection.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "authorized_amount",
"type": "`null` \\| `number`",
"description": "Authorized amount of the payment collection.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "created_at",
"type": "`Date`",
"description": "The date with timezone at which the resource was created.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "created_by",
"type": "`string`",
"description": "The ID of the user that created the payment collection.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "currency",
"type": "[Currency](../internal/classes/internal.Currency.mdx)",
"description": "The details of the currency this payment collection is associated with.",
"optional": false,
"defaultValue": "",
"expandable": true,
"children": []
},
{
"name": "currency_code",
"type": "`string`",
"description": "The three character ISO code for the currency this payment collection is associated with.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "deleted_at",
"type": "`null` \\| `Date`",
"description": "The date with timezone at which the resource was deleted.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "description",
"type": "`null` \\| `string`",
"description": "Description of the payment collection",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "id",
"type": "`string`",
"description": "The payment collection's ID",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "metadata",
"type": "`Record<string, unknown>`",
"description": "An optional key-value map with additional details",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "payment_sessions",
"type": "[PaymentSession](../internal/classes/internal.PaymentSession.mdx)[]",
"description": "The details of the payment sessions created as part of the payment collection.",
"optional": false,
"defaultValue": "",
"expandable": true,
"children": []
},
{
"name": "payments",
"type": "[Payment](../internal/classes/internal.Payment.mdx)[]",
"description": "The details of the payments created as part of the payment collection.",
"optional": false,
"defaultValue": "",
"expandable": true,
"children": []
},
{
"name": "region",
"type": "[Region](../internal/classes/internal.Region.mdx)",
"description": "The details of the region this payment collection is associated with.",
"optional": false,
"defaultValue": "",
"expandable": true,
"children": []
},
{
"name": "region_id",
"type": "`string`",
"description": "The ID of the region this payment collection is associated with.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "status",
"type": "[PaymentCollectionStatus](../internal/enums/internal.PaymentCollectionStatus.mdx)",
"description": "The type of the payment collection",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "type",
"type": "[ORDER_EDIT](../modules/internal.mdx#order_edit)",
"description": "The type of the payment collection",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "updated_at",
"type": "`Date`",
"description": "The date with timezone at which the resource was updated.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
}
]
}
]
}
]
}
]} />
___
### retrieve
Retrieve a Payment Collection's details.
#### Example
A simple example that retrieves a payment collection by its ID:
```ts
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:
```ts
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
<ParameterTypes parameters={[
{
"name": "id",
"type": "`string`",
"description": "The ID of the payment collection.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "query",
"type": "[AdminGetPaymentCollectionsParams](../internal/classes/internal.AdminGetPaymentCollectionsParams.mdx)",
"description": "Configurations to apply on the retrieved payment collection.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": [
{
"name": "expand",
"type": "`string`",
"description": "Comma-separated relations that should be expanded in the returned data.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "fields",
"type": "`string`",
"description": "Comma-separated fields that should be included in the returned data.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
}
]
},
{
"name": "customHeaders",
"type": "`Record<string, any>`",
"description": "Custom headers to attach to the request.",
"optional": false,
"defaultValue": "{}",
"expandable": false,
"children": []
}
]} />
#### Returns
<ParameterTypes parameters={[
{
"name": "ResponsePromise",
"type": "[ResponsePromise](../internal/types/internal.ResponsePromise.mdx)&#60;[AdminPaymentCollectionsRes](../internal/types/internal.AdminPaymentCollectionsRes.mdx)&#62;",
"optional": false,
"defaultValue": "",
"description": "Resolves to the payment collection's details.",
"expandable": false,
"children": [
{
"name": "AdminPaymentCollectionsRes",
"type": "`object`",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": [
{
"name": "payment_collection",
"type": "[PaymentCollection](../internal/classes/internal.PaymentCollection.mdx)",
"description": "Payment Collection details.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": [
{
"name": "amount",
"type": "`number`",
"description": "Amount of the payment collection.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "authorized_amount",
"type": "`null` \\| `number`",
"description": "Authorized amount of the payment collection.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "created_at",
"type": "`Date`",
"description": "The date with timezone at which the resource was created.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "created_by",
"type": "`string`",
"description": "The ID of the user that created the payment collection.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "currency",
"type": "[Currency](../internal/classes/internal.Currency.mdx)",
"description": "The details of the currency this payment collection is associated with.",
"optional": false,
"defaultValue": "",
"expandable": true,
"children": []
},
{
"name": "currency_code",
"type": "`string`",
"description": "The three character ISO code for the currency this payment collection is associated with.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "deleted_at",
"type": "`null` \\| `Date`",
"description": "The date with timezone at which the resource was deleted.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "description",
"type": "`null` \\| `string`",
"description": "Description of the payment collection",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "id",
"type": "`string`",
"description": "The payment collection's ID",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "metadata",
"type": "`Record<string, unknown>`",
"description": "An optional key-value map with additional details",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "payment_sessions",
"type": "[PaymentSession](../internal/classes/internal.PaymentSession.mdx)[]",
"description": "The details of the payment sessions created as part of the payment collection.",
"optional": false,
"defaultValue": "",
"expandable": true,
"children": []
},
{
"name": "payments",
"type": "[Payment](../internal/classes/internal.Payment.mdx)[]",
"description": "The details of the payments created as part of the payment collection.",
"optional": false,
"defaultValue": "",
"expandable": true,
"children": []
},
{
"name": "region",
"type": "[Region](../internal/classes/internal.Region.mdx)",
"description": "The details of the region this payment collection is associated with.",
"optional": false,
"defaultValue": "",
"expandable": true,
"children": []
},
{
"name": "region_id",
"type": "`string`",
"description": "The ID of the region this payment collection is associated with.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "status",
"type": "[PaymentCollectionStatus](../internal/enums/internal.PaymentCollectionStatus.mdx)",
"description": "The type of the payment collection",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "type",
"type": "[ORDER_EDIT](../modules/internal.mdx#order_edit)",
"description": "The type of the payment collection",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "updated_at",
"type": "`Date`",
"description": "The date with timezone at which the resource was updated.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
}
]
}
]
}
]
}
]} />
___
### update
Update a payment collection's details.
#### Example
```ts
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
<ParameterTypes parameters={[
{
"name": "id",
"type": "`string`",
"description": "The ID of the payment collection.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "payload",
"type": "[AdminUpdatePaymentCollectionsReq](../internal/classes/internal.AdminUpdatePaymentCollectionsReq.mdx)",
"description": "The attributes to update in the payment collection.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": [
{
"name": "description",
"type": "`string`",
"description": "A description to create or update the payment collection.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "metadata",
"type": "`Record<string, unknown>`",
"description": "A set of key-value pairs to hold additional information.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
}
]
},
{
"name": "customHeaders",
"type": "`Record<string, any>`",
"description": "Custom headers to attach to the request.",
"optional": false,
"defaultValue": "{}",
"expandable": false,
"children": []
}
]} />
#### Returns
<ParameterTypes parameters={[
{
"name": "ResponsePromise",
"type": "[ResponsePromise](../internal/types/internal.ResponsePromise.mdx)&#60;[AdminPaymentCollectionsRes](../internal/types/internal.AdminPaymentCollectionsRes.mdx)&#62;",
"optional": false,
"defaultValue": "",
"description": "Resolves to the payment collection's details.",
"expandable": false,
"children": [
{
"name": "AdminPaymentCollectionsRes",
"type": "`object`",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": [
{
"name": "payment_collection",
"type": "[PaymentCollection](../internal/classes/internal.PaymentCollection.mdx)",
"description": "Payment Collection details.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": [
{
"name": "amount",
"type": "`number`",
"description": "Amount of the payment collection.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "authorized_amount",
"type": "`null` \\| `number`",
"description": "Authorized amount of the payment collection.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "created_at",
"type": "`Date`",
"description": "The date with timezone at which the resource was created.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "created_by",
"type": "`string`",
"description": "The ID of the user that created the payment collection.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "currency",
"type": "[Currency](../internal/classes/internal.Currency.mdx)",
"description": "The details of the currency this payment collection is associated with.",
"optional": false,
"defaultValue": "",
"expandable": true,
"children": []
},
{
"name": "currency_code",
"type": "`string`",
"description": "The three character ISO code for the currency this payment collection is associated with.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "deleted_at",
"type": "`null` \\| `Date`",
"description": "The date with timezone at which the resource was deleted.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "description",
"type": "`null` \\| `string`",
"description": "Description of the payment collection",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "id",
"type": "`string`",
"description": "The payment collection's ID",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "metadata",
"type": "`Record<string, unknown>`",
"description": "An optional key-value map with additional details",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "payment_sessions",
"type": "[PaymentSession](../internal/classes/internal.PaymentSession.mdx)[]",
"description": "The details of the payment sessions created as part of the payment collection.",
"optional": false,
"defaultValue": "",
"expandable": true,
"children": []
},
{
"name": "payments",
"type": "[Payment](../internal/classes/internal.Payment.mdx)[]",
"description": "The details of the payments created as part of the payment collection.",
"optional": false,
"defaultValue": "",
"expandable": true,
"children": []
},
{
"name": "region",
"type": "[Region](../internal/classes/internal.Region.mdx)",
"description": "The details of the region this payment collection is associated with.",
"optional": false,
"defaultValue": "",
"expandable": true,
"children": []
},
{
"name": "region_id",
"type": "`string`",
"description": "The ID of the region this payment collection is associated with.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "status",
"type": "[PaymentCollectionStatus](../internal/enums/internal.PaymentCollectionStatus.mdx)",
"description": "The type of the payment collection",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "type",
"type": "[ORDER_EDIT](../modules/internal.mdx#order_edit)",
"description": "The type of the payment collection",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "updated_at",
"type": "`Date`",
"description": "The date with timezone at which the resource was updated.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
}
]
}
]
}
]
}
]} />