Payment Collections API Routes

A cart must have a payment collection with an authorized payment session.

Use these API routes during checkout to set the cart's payment provider and authorize its payment session.

POST /store/payment-collections#

Create Payment Collection

Create a payment collection for a cart. This is used during checkout, where the payment collection holds the cart's payment sessions.

Authentication: none.

Header parameters

x-publishable-api-keystring
Publishable API Key created in the Medusa Admin.
x-medusa-localestringOptional
The locale in BCP 47 format to retrieve localized content.
Example: en-US

Query parameters

fieldsstringOptional
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.
localestringOptional
The locale in BCP 47 format to retrieve localized content.
Example: en-US

Request body (application/json)

cart_idstring
The ID of the cart this payment collection is for.

Request examples

Responses

200 OK

payment_collectionobject
The payment collection's details.

400, 401, 404, 409, 422, 500: an error response is returned.


POST /store/payment-collections/{id}/payment-sessions#

Initialize Payment Session of a Payment Collection

Initialize and add a payment session to a payment collection. This is used during checkout, where you create a payment collection for the cart, then initialize a payment session for the payment provider that the customer chooses. It's highly recommended to have an amount greater than 0 in the payment collection, as some payment providers, such as Stripe, require a non-zero amount to create a payment session. Otherwise, an error will be thrown on the payment provider's side. In cases where you want to create a payment session for a payment collection with an amount of 0, you can use the Manual System Payment Provider instead of third-party payment providers. The Manual System Payment Provider is built into Medusa and allows you to create payment sessions without interacting with an external payment provider. Make sure to configure the Manual System Payment Provider in your store's region. Learn more in the Manage Region user guide.

Authentication: none.

Path parameters

idstring
The payment collection's ID.

Header parameters

x-publishable-api-keystring
Publishable API Key created in the Medusa Admin.
x-medusa-localestringOptional
The locale in BCP 47 format to retrieve localized content.
Example: en-US

Query parameters

fieldsstringOptional
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.
localestringOptional
The locale in BCP 47 format to retrieve localized content.
Example: en-US

Request body (application/json)

provider_idstring
The ID of the payment provider the customer chose.
Example: pp_stripe_stripe
dataobjectOptional
Any data necessary for the payment provider to process the payment.

Request examples

Responses

200 OK

payment_collectionobject
The payment collection's details.

400, 401, 404, 409, 422, 500: an error response is returned.


POST /store/payment-collections/{id}/payment-sessions/{session_id}#

Update Payment Session

Update a payment session's client data, such as payment details collected by the payment provider's checkout component. The data is merged into the session's data.client.

Authentication: none.

Path parameters

idstring
The payment collection's ID.
session_idstring
The payment session's ID.

Header parameters

x-publishable-api-keystring
Publishable API Key created in the Medusa Admin.
x-medusa-localestringOptional
The locale in BCP 47 format to retrieve localized content.
Example: en-US

Query parameters

localestringOptional
The locale in BCP 47 format to retrieve localized content.
Example: en-US
fieldsstringOptional
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.

Request body (application/json)

client_dataobject
Data to merge into the session's data.client, such as payment details collected by the provider's checkout component. Set a property to null to remove it.

Request examples

Responses

200 OK

payment_collectionobject
The payment collection's details.

400, 401, 404, 409, 422, 500: an error response is returned.

Found a problem with this page?Report Issue
Edited Nov 14·Edit this page