chore: Merge master to develop (#3653)

This commit is contained in:
Oliver Windall Juhl authored and GitHub committed 2023-03-31 13:09:57 +02:00
1 parent b2e2eddcea
commit 809ab2e0eb
120 files changed
+2240 -585

No files matched your search

+68 -19
View File
@@ -1,27 +1,76 @@
# medusa-payment-stripe
# Stripe
Add Stripe as a Payment Provider.
Receive payments on your Medusa commerce application using Stripe.
Learn more about how you can use this plugin in the [documentaion](https://docs.medusajs.com/add-plugins/stripe).
[Stripe Plugin Documentation](https://docs.medusajs.com/plugins/payment/stripe) | [Medusa Website](https://medusajs.com/) | [Medusa Repository](https://github.com/medusajs/medusa)
## Options
The stripe plugin version `>=1.2.x` requires medusa `>=1.8.x`
```js
{
api_key: "STRIPE_API_KEY",
webhook_secret: "STRIPE_WEBHOOK_SECRET",
// automatic_payment_methods: true,
// This description will be used if the cart context does not provide one.
// payment_description: "custom description to apply",
}
```
## Features
## Automatic Payment Methods
- Authorize payments on orders from any sales channel.
- Support for Bancontact, BLIK, giropay, iDEAL, and Przelewy24.
- Capture payments from the admin dashboard.
- View payment analytics through Stripe's dashboard.
- Ready-integration with [Medusa's Next.js starter storefront](https://docs.medusajs.com/starters/nextjs-medusa-starter).
- Support for Stripe Webhooks.
If you wish to use [Stripe's automatic payment methods](https://stripe.com/docs/connect/automatic-payment-methods) set the `automatic_payment_methods` flag to true.
---
## Deprecation
## Prerequisites
The stripe plugin version `>=1.2.x` requires medusa `>=1.8.x`
- [Medusa backend](https://docs.medusajs.com/development/backend/install)
- [Stripe account](https://stripe.com/)
---
## How to Install
1\. Run the following command in the directory of the Medusa backend:
```bash
npm install medusa-payment-stripe
```
2\. Set the following environment variables in `.env`:
```bash
STRIPE_API_KEY=sk_...
# only necessary for production
STRIPE_WEBHOOK_SECRET=whsec_...
```
3\. In `medusa-config.js` add the following at the end of the `plugins` array:
```js
const plugins = [
// ...
{
resolve: `medusa-payment-stripe`,
options: {
api_key: process.env.STRIPE_API_KEY,
webhook_secret: process.env.STRIPE_WEBHOOK_SECRET,
},
},
]
```
---
## Test the Plugin
1\. Run the following command in the directory of the Medusa backend to run the backend:
```bash
npm run start
```
2\. Enable Stripe in a region in the admin. You can refer to [this User Guide](https://docs.medusajs.com/user-guide/regions/providers) to learn how to do that. Alternatively, you can use the [Admin APIs](https://docs.medusajs.com/api/admin#tag/Region/operation/PostRegionsRegion).
3\. Place an order using a storefront or the [Store APIs](https://docs.medusajs.com/api/store). You should be able to use Stripe as a payment method.
---
## Additional Resources
- [Stripe Plugin Documentation](https://docs.medusajs.com/plugins/payment/stripe)
@@ -1,13 +1,13 @@
import { AwilixContainer } from "awilix"
import Stripe from "stripe"
import {
AbstractCartCompletionStrategy,
CartService,
IdempotencyKeyService,
PostgresError,
} from "@medusajs/medusa"
import { EOL } from "os"
import { AwilixContainer } from "awilix"
import { MedusaError } from "medusa-core-utils"
import { EOL } from "os"
import Stripe from "stripe"
const PAYMENT_PROVIDER_KEY = "pp_stripe"
@@ -251,8 +251,8 @@ async function completeCartIfNecessary({
if (response_code !== 200) {
throw new MedusaError(
MedusaError.Types.UNEXPECTED_STATE,
response_body["message"],
response_body["code"].toString()
response_body["message"] as string,
response_body["code"] as string
)
}
}