Files
medusa-store/www/apps/docs/content/references/js-client/classes/PaymentCollectionsResource.mdx
github-actions[bot] f35fcb810f chore(docs): Generated References (#5593)
* chore(docs): Generated References (automated)

* fix sidebar and links

* removed reflection path section

---------

Co-authored-by: shahednasser <shahednasser@users.noreply.github.com>
Co-authored-by: Shahed nasser <shahednasser@gmail.com>
2023-11-09 20:23:25 +02:00

1538 lines
51 KiB
Plaintext

---
displayed_sidebar: jsClientSidebar
slug: /references/js-client/PaymentCollectionsResource
---
import ParameterTypes from "@site/src/components/ParameterTypes"
# PaymentCollectionsResource
This class is used to send requests to [Store Payment Collection API Routes](https://docs.medusajs.com/api/store#payment-collections). All its method
are available in the JS Client under the `medusa.paymentCollections` property.
A payment collection is useful for managing additional payments, such as for Order Edits, or installment payments.
## Methods
### authorizePaymentSession
Authorize a Payment Session of a 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.paymentCollections
.authorize(paymentId, sessionId)
.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": "session_id",
"type": "`string`",
"description": "The ID of the payment session.",
"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`](../modules/internal.mdx#responsepromise)<[`StorePaymentCollectionsRes`](../modules/internal.mdx#storepaymentcollectionsres)\\>",
"optional": false,
"defaultValue": "",
"description": "Resolves to the payment collection's details.",
"expandable": false,
"children": [
{
"name": "StorePaymentCollectionsRes",
"type": "`object`",
"description": "The payment collection's details.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": [
{
"name": "payment_collection",
"type": "[`PaymentCollection`](../internal/classes/internal.PaymentCollection.mdx)",
"description": "Payment collection's 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": []
}
]
}
]
}
]
}
]} />
___
### authorizePaymentSessionsBatch
Authorize the Payment Sessions of a 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.paymentCollections
.authorize(paymentId)
.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": "[`StorePostPaymentCollectionsBatchSessionsAuthorizeReq`](../internal/classes/internal.StorePostPaymentCollectionsBatchSessionsAuthorizeReq.mdx)",
"description": "The list of payment session IDs to authorize.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": [
{
"name": "session_ids",
"type": "`string`[]",
"description": "List of Payment Session IDs to authorize.",
"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`](../modules/internal.mdx#responsepromise)<[`StorePaymentCollectionsRes`](../modules/internal.mdx#storepaymentcollectionsres)\\>",
"optional": false,
"defaultValue": "",
"description": "Resolves to the payment collection's details.",
"expandable": false,
"children": [
{
"name": "StorePaymentCollectionsRes",
"type": "`object`",
"description": "The payment collection's details.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": [
{
"name": "payment_collection",
"type": "[`PaymentCollection`](../internal/classes/internal.PaymentCollection.mdx)",
"description": "Payment collection's 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": []
}
]
}
]
}
]
}
]} />
___
### managePaymentSession
Create a Payment Session for a payment provider in a 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.paymentCollections
.managePaymentSession(payment_id, { provider_id: "stripe" })
.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": "[`StorePaymentCollectionSessionsReq`](../internal/classes/internal.StorePaymentCollectionSessionsReq.mdx)",
"description": "The payment session to create.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": [
{
"name": "provider_id",
"type": "`string`",
"description": "The ID of the Payment Provider.",
"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`](../modules/internal.mdx#responsepromise)<[`StorePaymentCollectionsRes`](../modules/internal.mdx#storepaymentcollectionsres)\\>",
"optional": false,
"defaultValue": "",
"description": "Resolves to the payment collection's details.",
"expandable": false,
"children": [
{
"name": "StorePaymentCollectionsRes",
"type": "`object`",
"description": "The payment collection's details.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": [
{
"name": "payment_collection",
"type": "[`PaymentCollection`](../internal/classes/internal.PaymentCollection.mdx)",
"description": "Payment collection's 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": []
}
]
}
]
}
]
}
]} />
___
### managePaymentSessionsBatch
Create, update, or delete a list of payment sessions of a Payment Collections. If a payment session is not provided in the `sessions` array, it's deleted.
#### Example
To add two new payment sessions:
```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
// Total amount = 10000
medusa.paymentCollections
.managePaymentSessionsBatch(paymentId, {
sessions: [
{
provider_id: "stripe",
amount: 5000,
},
{
provider_id: "manual",
amount: 5000,
},
],
})
.then(({ payment_collection }) => {
console.log(payment_collection.id)
})
```
To update a payment session and another one by not including it in the payload:
```ts
medusa.paymentCollections
.managePaymentSessionsBatch(paymentId, {
sessions: [
{
provider_id: "stripe",
amount: 10000,
session_id: "ps_123456",
},
],
})
.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": "[`StorePostPaymentCollectionsBatchSessionsReq`](../internal/classes/internal.StorePostPaymentCollectionsBatchSessionsReq.mdx)",
"description": "The attributes of each session to update.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": [
{
"name": "sessions",
"type": "[`StorePostPaymentCollectionsSessionsReq`](../internal/classes/internal.StorePostPaymentCollectionsSessionsReq.mdx)[]",
"description": "Payment sessions related to the Payment Collection. Existing sessions that are not added in this array will be deleted.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": [
{
"name": "amount",
"type": "`number`",
"description": "The payment amount",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "provider_id",
"type": "`string`",
"description": "The ID of the Payment Provider.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "session_id",
"type": "`string`",
"description": "The ID of the Payment Session to be updated. If no ID is provided, a new payment session is created.",
"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`](../modules/internal.mdx#responsepromise)<[`StorePaymentCollectionsRes`](../modules/internal.mdx#storepaymentcollectionsres)\\>",
"optional": false,
"defaultValue": "",
"description": "Resolves to the payment collection's details.",
"expandable": false,
"children": [
{
"name": "StorePaymentCollectionsRes",
"type": "`object`",
"description": "The payment collection's details.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": [
{
"name": "payment_collection",
"type": "[`PaymentCollection`](../internal/classes/internal.PaymentCollection.mdx)",
"description": "Payment collection's 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": []
}
]
}
]
}
]
}
]} />
___
### refreshPaymentSession
Refresh a Payment Session's data to ensure that it is in sync with the Payment Collection.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
medusa.paymentCollections
.refreshPaymentSession(paymentCollectionId, sessionId)
.then(({ payment_session }) => {
console.log(payment_session.id)
})
```
#### Parameters
<ParameterTypes parameters={[
{
"name": "id",
"type": "`string`",
"description": "The ID of the payment collection.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "session_id",
"type": "`string`",
"description": "The ID of the payment session.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "customHeaders",
"type": "Record<`string`, `any`\\>",
"description": "",
"optional": false,
"defaultValue": "{}",
"expandable": false,
"children": []
}
]} />
#### Returns
<ParameterTypes parameters={[
{
"name": "ResponsePromise",
"type": "[`ResponsePromise`](../modules/internal.mdx#responsepromise)<[`StorePaymentCollectionsSessionRes`](../modules/internal.mdx#storepaymentcollectionssessionres)\\>",
"optional": false,
"defaultValue": "",
"description": "Resolves to the refreshed payment session's details.",
"expandable": false,
"children": [
{
"name": "StorePaymentCollectionsSessionRes",
"type": "`object`",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": [
{
"name": "payment_session",
"type": "[`PaymentSession`](../internal/classes/internal.PaymentSession.mdx)",
"description": "Payment session's details.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": [
{
"name": "amount",
"type": "`number`",
"description": "The amount that the Payment Session has been authorized for.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "cart",
"type": "[`Cart`](../internal/classes/internal.Cart.mdx)",
"description": "The details of the cart that the payment session was created for.",
"optional": false,
"defaultValue": "",
"expandable": true,
"children": []
},
{
"name": "cart_id",
"type": "``null`` \\| `string`",
"description": "The ID of the cart that the payment session was created for.",
"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": "data",
"type": "Record<`string`, `unknown`\\>",
"description": "The data required for the Payment Provider to identify, modify and process the Payment Session. Typically this will be an object that holds an id to the external payment session, but can be an empty object if the Payment Provider doesn't hold any state.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "id",
"type": "`string`",
"description": "The payment session's ID",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "idempotency_key",
"type": "`string`",
"description": "Randomly generated key used to continue the completion of a cart in case of failure.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "is_initiated",
"type": "`boolean`",
"description": "A flag to indicate if a communication with the third party provider has been initiated.",
"optional": false,
"defaultValue": "false",
"expandable": false,
"children": []
},
{
"name": "is_selected",
"type": "``null`` \\| `boolean`",
"description": "A flag to indicate if the Payment Session has been selected as the method that will be used to complete the purchase.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "payment_authorized_at",
"type": "`Date`",
"description": "The date with timezone at which the Payment Session was authorized.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "provider_id",
"type": "`string`",
"description": "The ID of the Payment Provider that is responsible for the Payment Session",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "status",
"type": "`string`",
"description": "Indicates the status of the Payment Session. Will default to `pending`, and will eventually become `authorized`. Payment Sessions may have the status of `requires_more` to indicate that further actions are to be completed by the Customer.",
"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.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.paymentCollections
.retrieve(paymentCollectionId, {
expand: "region",
})
.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": "[`StoreGetPaymentCollectionsParams`](../internal/classes/internal.StoreGetPaymentCollectionsParams.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`](../modules/internal.mdx#responsepromise)<[`StorePaymentCollectionsRes`](../modules/internal.mdx#storepaymentcollectionsres)\\>",
"optional": false,
"defaultValue": "",
"description": "Resolves to the payment collection's details.",
"expandable": false,
"children": [
{
"name": "StorePaymentCollectionsRes",
"type": "`object`",
"description": "The payment collection's details.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": [
{
"name": "payment_collection",
"type": "[`PaymentCollection`](../internal/classes/internal.PaymentCollection.mdx)",
"description": "Payment collection's 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": []
}
]
}
]
}
]
}
]} />