Skip to content

Commit 5527d95

Browse files
authored
docs: add a troubleshooting section on creating a payment session with zero total (medusajs#12974)
1 parent 1797f02 commit 5527d95

File tree

11 files changed

+129
-6
lines changed

11 files changed

+129
-6
lines changed

www/apps/api-reference/specs/store/openapi.full.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5114,7 +5114,11 @@ paths:
51145114
operationId: PostPaymentCollectionsIdPaymentSessions
51155115
summary: Initialize Payment Session of a Payment Collection
51165116
x-sidebar-summary: Initialize Payment Session
5117-
description: 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.
5117+
description: |
5118+
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.
5119+
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.
5120+
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.
5121+
Make sure to configure the Manual System Payment Provider in your store's region. Learn more in the [Manage Region](https://docs.medusajs.com/user-guide/settings/regions#edit-region-details) user guide.
51185122
externalDocs:
51195123
url: https://docs.medusajs.com/v2/resources/storefront-development/checkout/payment
51205124
description: 'Storefront guide: How to implement payment during checkout.'

www/apps/api-reference/specs/store/paths/store_payment-collections_{id}_payment-sessions.yaml

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,27 @@ post:
22
operationId: PostPaymentCollectionsIdPaymentSessions
33
summary: Initialize Payment Session of a Payment Collection
44
x-sidebar-summary: Initialize Payment Session
5-
description: >-
5+
description: >
66
Initialize and add a payment session to a payment collection. This is used
77
during checkout, where you create a payment collection for the cart, then
88
initialize a payment session for the payment provider that the customer
99
chooses.
10+
11+
It's highly recommended to have an amount greater than `0` in the payment
12+
collection, as some payment providers, such as Stripe, require a non-zero
13+
amount to create a payment session. Otherwise, an error will be thrown on
14+
the payment provider's side.
15+
16+
In cases where you want to create a payment session for a payment collection
17+
with an amount of `0`, you can use the Manual System Payment Provider
18+
instead of third-party payment providers. The Manual System Payment Provider
19+
is built into Medusa and allows you to create payment sessions without
20+
interacting with an external payment provider.
21+
22+
Make sure to configure the Manual System Payment Provider in your store's
23+
region. Learn more in the [Manage
24+
Region](https://docs.medusajs.com/user-guide/settings/regions#edit-region-details)
25+
user guide.
1026
externalDocs:
1127
url: >-
1228
https://docs.medusajs.com/v2/resources/storefront-development/checkout/payment

www/apps/resources/app/storefront-development/checkout/payment/page.mdx

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,23 @@ In the `Fetch API` example, the `handlePayment` function implements this flow by
278278

279279
---
280280

281+
## Troubleshooting
282+
283+
### Unknown Error for Zero Cart Total
284+
285+
If your cart has a total of `0`, you might encounter an `unknown error` when trying to create a payment session.
286+
287+
Some payment providers, such as Stripe, require a non-zero amount to create a payment session. So, if your cart has a total of `0`, the error will be thrown on the payment provider's side.
288+
289+
In those cases, you can either:
290+
291+
- Make sure the payment session is only initialized when the cart has a total greater than `0`.
292+
- Use payment providers like the Manual System Payment Provider, which doesn't create a payment session with a third-party provider.
293+
- The Manual System Payment Provider is available by default in Medusa and can be used to handle payments without a third-party provider. It allows you to mark the order as paid without requiring any additional actions from the customer.
294+
- Make sure to configure the Manual System Payment Provider in your store's region. Learn more in the [Manage Region](!user-guide!/settings/regions#edit-region-details) user guide.
295+
296+
---
297+
281298
## Stripe Example
282299

283300
If you're integrating Stripe in your Medusa application and storefront, refer to the [Stripe guide](./stripe/page.mdx) for an example of how to handle the payment process using Stripe.

www/apps/resources/app/storefront-development/checkout/payment/stripe/page.mdx

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,23 @@ const getPaymentUi = useCallback(() => {
250250

251251
---
252252

253+
## Troubleshooting
254+
255+
### Unknown Error for Zero Cart Total
256+
257+
If your cart has a total of `0`, you might encounter an `unknown error` when trying to create a payment session.
258+
259+
Stripe requires a non-zero amount to create a payment session. So, if your cart has a total of `0`, the error will be thrown on Stripe's side.
260+
261+
In those cases, you can either:
262+
263+
- Make sure the payment session is only initialized when the cart has a total greater than `0`.
264+
- Use payment providers like the Manual System Payment Provider, which doesn't create a payment session with a third-party provider.
265+
- The Manual System Payment Provider is available by default in Medusa and can be used to handle payments without a third-party provider. It allows you to mark the order as paid without requiring any additional actions from the customer.
266+
- Make sure to configure the Manual System Payment Provider in your store's region. Learn more in the [Manage Region](!user-guide!/settings/regions#edit-region-details) user guide.
267+
268+
---
269+
253270
## More Resources
254271

255272
- [Stripe's documentation](https://docs.stripe.com/).
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
If your cart has a total of `0`, you might encounter an `unknown error` when trying to create a payment session.
2+
3+
## Why this Error Occurred
4+
5+
Some payment providers, such as Stripe, require a non-zero amount to create a payment session. So, if your cart has a total of `0`, the error will be thrown on the payment provider's side.
6+
7+
## Solutions
8+
9+
### Initialize Payment Session Only for Non-Zero Totals
10+
11+
Make sure the payment session is only initialized when the cart has a total greater than `0`. You can add a check before creating the payment session:
12+
13+
```ts
14+
if (cart.total > 0) {
15+
// TODO Initialize payment session
16+
}
17+
```
18+
19+
### Use Manual System Payment Provider
20+
21+
Use payment providers like the Manual System Payment Provider, which doesn't create a payment session with a third-party provider.
22+
23+
The Manual System Payment Provider is available by default in Medusa and can be used to handle payments without a third-party provider. It allows you to mark the order as paid without requiring any additional actions from the customer.
24+
25+
Make sure to configure the Manual System Payment Provider in your store's region. Learn more in the [Manage Region](!user-guide!/settings/regions#edit-region-details) user guide.
26+
27+
---
28+
29+
## Additional Resources
30+
31+
- [Payment Providers](../../../commerce-modules/payment/payment-provider/page.mdx)
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import ZeroTotalError from "../_sections/payment/zero-total.mdx"
2+
3+
export const metadata = {
4+
title: `Payment Provider Errors`,
5+
}
6+
7+
# {metadata.title}
8+
9+
## Unknown Error for Zero Cart Total
10+
11+
<ZeroTotalError />

www/apps/resources/generated/edit-dates.mjs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,8 @@ export const generatedEditDates = {
143143
"app/storefront-development/checkout/address/page.mdx": "2025-03-27T14:47:14.265Z",
144144
"app/storefront-development/checkout/complete-cart/page.mdx": "2025-03-27T14:47:14.277Z",
145145
"app/storefront-development/checkout/email/page.mdx": "2025-03-27T14:47:14.283Z",
146-
"app/storefront-development/checkout/payment/stripe/page.mdx": "2025-05-20T07:51:40.724Z",
147-
"app/storefront-development/checkout/payment/page.mdx": "2025-03-27T14:47:14.274Z",
146+
"app/storefront-development/checkout/payment/stripe/page.mdx": "2025-07-16T10:18:44.916Z",
147+
"app/storefront-development/checkout/payment/page.mdx": "2025-07-16T10:18:47.607Z",
148148
"app/storefront-development/checkout/shipping/page.mdx": "2025-03-27T14:47:14.270Z",
149149
"app/storefront-development/checkout/page.mdx": "2024-06-12T19:46:06+02:00",
150150
"app/storefront-development/customers/addresses/page.mdx": "2025-03-27T14:47:14.252Z",
@@ -6556,5 +6556,6 @@ export const generatedEditDates = {
65566556
"references/types/interfaces/types.UpdatePaymentOutput/page.mdx": "2025-06-25T10:11:39.945Z",
65576557
"app/how-to-tutorials/tutorials/gift-message/page.mdx": "2025-06-26T09:13:19.296Z",
65586558
"app/how-to-tutorials/tutorials/re-order/page.mdx": "2025-06-26T12:38:24.308Z",
6559-
"app/commerce-modules/promotion/promotion-taxes/page.mdx": "2025-06-27T15:44:46.638Z"
6559+
"app/commerce-modules/promotion/promotion-taxes/page.mdx": "2025-06-27T15:44:46.638Z",
6560+
"app/troubleshooting/payment/page.mdx": "2025-07-16T10:20:24.799Z"
65606561
}

www/apps/resources/generated/files-map.mjs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1383,6 +1383,10 @@ export const filesMap = [
13831383
"filePath": "/www/apps/resources/app/troubleshooting/page.mdx",
13841384
"pathname": "/troubleshooting"
13851385
},
1386+
{
1387+
"filePath": "/www/apps/resources/app/troubleshooting/payment/page.mdx",
1388+
"pathname": "/troubleshooting/payment"
1389+
},
13861390
{
13871391
"filePath": "/www/apps/resources/app/troubleshooting/query/expression-type-error/page.mdx",
13881392
"pathname": "/troubleshooting/query/expression-type-error"

www/apps/resources/generated/generated-troubleshooting-sidebar.mjs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,14 @@ const generatedgeneratedTroubleshootingSidebarSidebar = {
223223
"path": "/troubleshooting/s3",
224224
"title": "S3 Module Provider Errors",
225225
"children": []
226+
},
227+
{
228+
"loaded": true,
229+
"isPathHref": true,
230+
"type": "link",
231+
"path": "/troubleshooting/payment",
232+
"title": "Payment Provider Errors",
233+
"children": []
226234
}
227235
]
228236
},

www/apps/resources/sidebars/troubleshooting.mjs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,11 @@ export const troubleshootingSidebar = [
149149
path: "/troubleshooting/s3",
150150
title: "S3 Module Provider Errors",
151151
},
152+
{
153+
type: "link",
154+
path: "/troubleshooting/payment",
155+
title: "Payment Provider Errors",
156+
},
152157
],
153158
},
154159
{

0 commit comments

Comments
 (0)