import Switchyard from "@switchyard/js-sdk"
export const sdk = new Medusa({
baseUrl: import.meta.env.VITE_BACKEND_URL || "/",
debug: import.meta.env.DEV,
auth: {
type: "session",
},
})
sdk.admin.paymentCollection.create({
order_id: "order_123"
})
.then(({ payment_collection }) => {
console.log(payment_collection)
}){
"payment_collection": {
"id": "<string>",
"currency_code": "<string>",
"amount": 123,
"status": "canceled",
"payment_providers": [
{
"id": "<string>",
"is_enabled": true
}
],
"authorized_amount": 123,
"captured_amount": 123,
"refunded_amount": 123,
"completed_at": "2023-11-07T05:31:56Z",
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"metadata": {},
"payment_sessions": [
{
"id": "<string>",
"amount": 123,
"currency_code": "usd",
"provider_id": "<string>",
"data": {},
"status": "authorized",
"context": {
"customer": {
"id": "cus_123"
}
},
"authorized_at": "2023-11-07T05:31:56Z",
"payment_collection": {},
"payment": {
"id": "<string>",
"amount": 123,
"currency_code": "<string>",
"provider_id": "<string>",
"authorized_amount": 123,
"data": {},
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"captured_at": "2023-11-07T05:31:56Z",
"canceled_at": "2023-11-07T05:31:56Z",
"captured_amount": 123,
"refunded_amount": 123,
"captures": [
{
"id": "<string>",
"amount": 123,
"created_at": "2023-11-07T05:31:56Z",
"payment": {},
"created_by": "<string>"
}
],
"refunds": [
{
"id": "<string>",
"amount": 123,
"created_at": "2023-11-07T05:31:56Z",
"payment": {},
"refund_reason_id": "<string>",
"note": "<string>",
"created_by": "<string>",
"refund_reason": {
"id": "<string>",
"label": "<string>",
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"code": "<string>",
"description": "<string>",
"metadata": {}
}
}
],
"payment_collection": {},
"payment_session": {}
}
}
],
"payments": [
{
"id": "<string>",
"amount": 123,
"currency_code": "<string>",
"provider_id": "<string>",
"authorized_amount": 123,
"data": {},
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"captured_at": "2023-11-07T05:31:56Z",
"canceled_at": "2023-11-07T05:31:56Z",
"captured_amount": 123,
"refunded_amount": 123,
"captures": [
{
"id": "<string>",
"amount": 123,
"created_at": "2023-11-07T05:31:56Z",
"payment": {},
"created_by": "<string>"
}
],
"refunds": [
{
"id": "<string>",
"amount": 123,
"created_at": "2023-11-07T05:31:56Z",
"payment": {
"id": "<string>",
"amount": 123,
"currency_code": "<string>",
"provider_id": "<string>",
"authorized_amount": 123,
"data": {},
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"captured_at": "2023-11-07T05:31:56Z",
"canceled_at": "2023-11-07T05:31:56Z",
"captured_amount": 123,
"refunded_amount": 123,
"captures": [
{
"id": "<string>",
"amount": 123,
"created_at": "2023-11-07T05:31:56Z",
"payment": {},
"created_by": "<string>"
}
],
"refunds": [
{
"id": "<string>",
"amount": 123,
"created_at": "2023-11-07T05:31:56Z",
"payment": {},
"refund_reason_id": "<string>",
"note": "<string>",
"created_by": "<string>",
"refund_reason": {
"id": "<string>",
"label": "<string>",
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"code": "<string>",
"description": "<string>",
"metadata": {}
}
}
],
"payment_collection": {},
"payment_session": {}
},
"refund_reason_id": "<string>",
"note": "<string>",
"created_by": "<string>",
"refund_reason": {
"id": "<string>",
"label": "<string>",
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"code": "<string>",
"description": "<string>",
"metadata": {}
}
}
],
"payment_collection": {},
"payment_session": {
"id": "<string>",
"amount": 123,
"currency_code": "usd",
"provider_id": "<string>",
"data": {},
"status": "authorized",
"context": {
"customer": {
"id": "cus_123"
}
},
"authorized_at": "2023-11-07T05:31:56Z",
"payment_collection": {},
"payment": {
"id": "<string>",
"amount": 123,
"currency_code": "<string>",
"provider_id": "<string>",
"authorized_amount": 123,
"data": {},
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"captured_at": "2023-11-07T05:31:56Z",
"canceled_at": "2023-11-07T05:31:56Z",
"captured_amount": 123,
"refunded_amount": 123,
"captures": [
{
"id": "<string>",
"amount": 123,
"created_at": "2023-11-07T05:31:56Z",
"payment": {},
"created_by": "<string>"
}
],
"refunds": [
{
"id": "<string>",
"amount": 123,
"created_at": "2023-11-07T05:31:56Z",
"payment": {},
"refund_reason_id": "<string>",
"note": "<string>",
"created_by": "<string>",
"refund_reason": {
"id": "<string>",
"label": "<string>",
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"code": "<string>",
"description": "<string>",
"metadata": {}
}
}
],
"payment_collection": {},
"payment_session": {}
}
}
}
]
}
}Create a payment collection.
import Switchyard from "@switchyard/js-sdk"
export const sdk = new Medusa({
baseUrl: import.meta.env.VITE_BACKEND_URL || "/",
debug: import.meta.env.DEV,
auth: {
type: "session",
},
})
sdk.admin.paymentCollection.create({
order_id: "order_123"
})
.then(({ payment_collection }) => {
console.log(payment_collection)
}){
"payment_collection": {
"id": "<string>",
"currency_code": "<string>",
"amount": 123,
"status": "canceled",
"payment_providers": [
{
"id": "<string>",
"is_enabled": true
}
],
"authorized_amount": 123,
"captured_amount": 123,
"refunded_amount": 123,
"completed_at": "2023-11-07T05:31:56Z",
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"metadata": {},
"payment_sessions": [
{
"id": "<string>",
"amount": 123,
"currency_code": "usd",
"provider_id": "<string>",
"data": {},
"status": "authorized",
"context": {
"customer": {
"id": "cus_123"
}
},
"authorized_at": "2023-11-07T05:31:56Z",
"payment_collection": {},
"payment": {
"id": "<string>",
"amount": 123,
"currency_code": "<string>",
"provider_id": "<string>",
"authorized_amount": 123,
"data": {},
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"captured_at": "2023-11-07T05:31:56Z",
"canceled_at": "2023-11-07T05:31:56Z",
"captured_amount": 123,
"refunded_amount": 123,
"captures": [
{
"id": "<string>",
"amount": 123,
"created_at": "2023-11-07T05:31:56Z",
"payment": {},
"created_by": "<string>"
}
],
"refunds": [
{
"id": "<string>",
"amount": 123,
"created_at": "2023-11-07T05:31:56Z",
"payment": {},
"refund_reason_id": "<string>",
"note": "<string>",
"created_by": "<string>",
"refund_reason": {
"id": "<string>",
"label": "<string>",
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"code": "<string>",
"description": "<string>",
"metadata": {}
}
}
],
"payment_collection": {},
"payment_session": {}
}
}
],
"payments": [
{
"id": "<string>",
"amount": 123,
"currency_code": "<string>",
"provider_id": "<string>",
"authorized_amount": 123,
"data": {},
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"captured_at": "2023-11-07T05:31:56Z",
"canceled_at": "2023-11-07T05:31:56Z",
"captured_amount": 123,
"refunded_amount": 123,
"captures": [
{
"id": "<string>",
"amount": 123,
"created_at": "2023-11-07T05:31:56Z",
"payment": {},
"created_by": "<string>"
}
],
"refunds": [
{
"id": "<string>",
"amount": 123,
"created_at": "2023-11-07T05:31:56Z",
"payment": {
"id": "<string>",
"amount": 123,
"currency_code": "<string>",
"provider_id": "<string>",
"authorized_amount": 123,
"data": {},
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"captured_at": "2023-11-07T05:31:56Z",
"canceled_at": "2023-11-07T05:31:56Z",
"captured_amount": 123,
"refunded_amount": 123,
"captures": [
{
"id": "<string>",
"amount": 123,
"created_at": "2023-11-07T05:31:56Z",
"payment": {},
"created_by": "<string>"
}
],
"refunds": [
{
"id": "<string>",
"amount": 123,
"created_at": "2023-11-07T05:31:56Z",
"payment": {},
"refund_reason_id": "<string>",
"note": "<string>",
"created_by": "<string>",
"refund_reason": {
"id": "<string>",
"label": "<string>",
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"code": "<string>",
"description": "<string>",
"metadata": {}
}
}
],
"payment_collection": {},
"payment_session": {}
},
"refund_reason_id": "<string>",
"note": "<string>",
"created_by": "<string>",
"refund_reason": {
"id": "<string>",
"label": "<string>",
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"code": "<string>",
"description": "<string>",
"metadata": {}
}
}
],
"payment_collection": {},
"payment_session": {
"id": "<string>",
"amount": 123,
"currency_code": "usd",
"provider_id": "<string>",
"data": {},
"status": "authorized",
"context": {
"customer": {
"id": "cus_123"
}
},
"authorized_at": "2023-11-07T05:31:56Z",
"payment_collection": {},
"payment": {
"id": "<string>",
"amount": 123,
"currency_code": "<string>",
"provider_id": "<string>",
"authorized_amount": 123,
"data": {},
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"captured_at": "2023-11-07T05:31:56Z",
"canceled_at": "2023-11-07T05:31:56Z",
"captured_amount": 123,
"refunded_amount": 123,
"captures": [
{
"id": "<string>",
"amount": 123,
"created_at": "2023-11-07T05:31:56Z",
"payment": {},
"created_by": "<string>"
}
],
"refunds": [
{
"id": "<string>",
"amount": 123,
"created_at": "2023-11-07T05:31:56Z",
"payment": {},
"refund_reason_id": "<string>",
"note": "<string>",
"created_by": "<string>",
"refund_reason": {
"id": "<string>",
"label": "<string>",
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"code": "<string>",
"description": "<string>",
"metadata": {}
}
}
],
"payment_collection": {},
"payment_session": {}
}
}
}
]
}
}Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Comma-separated fields that should be included in the returned data. if a field is prefixed with + it will be added to the default fields, using - will remove it from the default fields. without prefix it will replace the entire default fields.
OK
The payment collection's details.
The payment collection's details.
Show child attributes
The payment collection's ID.
The payment collection's currency code.
The total amount to be paid.
The payment collection's status.
canceled, not_paid, awaiting, authorized, partially_authorized The total authorized amount of the collection's payments.
The total captured amount of the collection's payments.
The total refunded amount of the collection's payments.
The date the payment collection was completed.
The date the payment collection was created.
The date the payment collection was updated.
The payment collection's metadata, can hold custom key-value pairs.
The payment collection's payment sessions.
Show child attributes
The payment session's ID.
The payment session's amount.
The payment session's currency code.
"usd"
The ID of the payment provider processing this session.
The payment session's data, useful for the payment provider processing the payment.
The payment session's status.
authorized, captured, canceled, pending, requires_more, error The context around the payment, such as the customer's details.
{ "customer": { "id": "cus_123" } }The date the payment session was authorized.
The payment's details.
Show child attributes
The payment's ID.
The payment's amount.
The payment's currency code.
The ID of the payment provider used to process this payment.
The amount authorized of the payment.
The payment's data, useful for processing by the payment provider.
The date the payment was created.
The date the payment was updated.
The date the payment was captured.
The date the payment was canceled.
The captured amount of the payment.
The refunded amount of the payment.
The details of payment captures.
Show child attributes
The payment capture's ID.
The captured amount.
The date the capture was created.
The ID of the user that captured the payment.
The details of payment refunds.
Show child attributes
The refund's ID.
The refund's amount.
The date the refund was created.
The ID of the refund reason.
More details about the refund.
The ID of the user that created the refund.
The refund reason's details.
Show child attributes
The refund reason's ID.
The refund reason's label.
The date the refund reason was created.
The date the refund reason was updated.
The refund reason's code.
The refund reason's description.
The refund reason's metadata, can hold custom key-value pairs.
The payment collection's payments.
Show child attributes
The payment's ID.
The payment's amount.
The payment's currency code.
The ID of the payment provider used to process this payment.
The amount authorized of the payment.
The payment's data, useful for processing by the payment provider.
The date the payment was created.
The date the payment was updated.
The date the payment was captured.
The date the payment was canceled.
The captured amount of the payment.
The refunded amount of the payment.
The details of payment captures.
Show child attributes
The payment capture's ID.
The captured amount.
The date the capture was created.
The ID of the user that captured the payment.
The details of payment refunds.
Show child attributes
The refund's ID.
The refund's amount.
The date the refund was created.
The payment's details.
Show child attributes
The payment's ID.
The payment's amount.
The payment's currency code.
The ID of the payment provider used to process this payment.
The amount authorized of the payment.
The payment's data, useful for processing by the payment provider.
The date the payment was created.
The date the payment was updated.
The date the payment was captured.
The date the payment was canceled.
The captured amount of the payment.
The refunded amount of the payment.
The details of payment captures.
Show child attributes
The payment capture's ID.
The captured amount.
The date the capture was created.
The ID of the user that captured the payment.
The details of payment refunds.
Show child attributes
The refund's ID.
The refund's amount.
The date the refund was created.
The ID of the refund reason.
More details about the refund.
The ID of the user that created the refund.
The refund reason's details.
Show child attributes
The refund reason's ID.
The refund reason's label.
The date the refund reason was created.
The date the refund reason was updated.
The refund reason's code.
The refund reason's description.
The refund reason's metadata, can hold custom key-value pairs.
The ID of the refund reason.
More details about the refund.
The ID of the user that created the refund.
The refund reason's details.
Show child attributes
The refund reason's ID.
The refund reason's label.
The date the refund reason was created.
The date the refund reason was updated.
The refund reason's code.
The refund reason's description.
The refund reason's metadata, can hold custom key-value pairs.
The payment session's details.
Show child attributes
The payment session's ID.
The payment session's amount.
The payment session's currency code.
"usd"
The ID of the payment provider processing this session.
The payment session's data, useful for the payment provider processing the payment.
The payment session's status.
authorized, captured, canceled, pending, requires_more, error The context around the payment, such as the customer's details.
{ "customer": { "id": "cus_123" } }The date the payment session was authorized.
The payment's details.
Show child attributes
The payment's ID.
The payment's amount.
The payment's currency code.
The ID of the payment provider used to process this payment.
The amount authorized of the payment.
The payment's data, useful for processing by the payment provider.
The date the payment was created.
The date the payment was updated.
The date the payment was captured.
The date the payment was canceled.
The captured amount of the payment.
The refunded amount of the payment.
The details of payment captures.
Show child attributes
The payment capture's ID.
The captured amount.
The date the capture was created.
The ID of the user that captured the payment.
The details of payment refunds.
Show child attributes
The refund's ID.
The refund's amount.
The date the refund was created.
The ID of the refund reason.
More details about the refund.
The ID of the user that created the refund.
The refund reason's details.
Show child attributes
The refund reason's ID.
The refund reason's label.
The date the refund reason was created.
The date the refund reason was updated.
The refund reason's code.
The refund reason's description.
The refund reason's metadata, can hold custom key-value pairs.