This app integrates Saleor with Klarna payment gateway.
Required Saleor version: 3.15
Note
This is an example implementation. Only community support is available.
-
Node.js 20
-
pnpm 8.14.2
You need to have a Klarna playground account to run this app. You can create one here.
- Copy
.env.example
to.env
and fill in the required values. pnpm install
Important
The app needs to be tunneled in local development.
To run the app on port 3000, use the following command:
pnpm dev
Each time you modify a .graphql
file, you have to run:
pnpm generate
to regenerate the GraphQL types.
This app comes with a simple storefront example. To run it, follow these steps:
- Clone the repository.
- Copy
.env.example
to.env
and fill in the required values. pnpm install
pnpm dev
Each time you modify a .graphql
file, you have to run:
pnpm generate
The app implements the Hosted Payment Page flow through a custom Klarna API client. The client is located in generated/klarna.ts
.
- ✅ Authorize transactions
- ✅ Charge transactions
- ✅ Refund transactions
- ❌ Cancel transactions
- ✅ Initialize payment gateway
- ❌ Saved payment methods
- ✅ Storing config in metadata
- ✅ Two way webhook synchronization (Saleor → Klarna → Saleor)
- ✅ Front-end example (in external repository)
- Klarna (credit card)
- Execute
checkoutCreate
mutation from the front-end. - Execute
transactionInitialize
mutation from the front-end. In the app, thetransaction-initialize-session.ts
handler creates a session in Klarna. Depending on the chosenTransactionFlowStrategyEnum
, it will respond with eitherAUTHORIZATION_ACTION_REQUIRED
orCHARGE_ACTION_REQUIRED
.transaction-initialize-session
returns thedata
needed to render the Klarna component. - Render the Klarna component in the front-end.
- Once the payment process is finished, execute the
transactionProcess
mutation from the front-end. In the app, thetransaction-process-session.ts
handler creates an order in Klarna.
You will need to provide the following configuration:
- Username - your Klarna username
- Password - your Klarna password
Now, save the configuration and assign it to the channel you want to use it with.