|
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) |