Docs
Medusa plugins
P

Pay payments medusa

The Pay.nl payment provider plugin for Medusa v2

Need customizations for this plugin?

Get in touch
npm install @webbers/pay-payments-medusa
Category
payment
Built by
webbers
Type
unknown
Last updated
1 month ago

Getting Started

Donโ€™t have an account with Pay. yet? Register now!

[!CAUTION] If you have subscribers listening to the event, update them to listen to the event instead. See below.

[!WARNING] This plugin creates orders in Medusa immediately, even if the payment has not yet been captured. If a payment expires, the associated order will be automatically canceled.

This change in flow is required to support asynchronous payment methods (e.g., SprayPay), where payment confirmation can take hours depending on customer input.

Table of Contents

Demo store

Visit the demo store here: https://pay-demo.webbers.com

Pay. payment methods

Card payment methods

  • Mastercard
  • VISA
  • American Express
  • Carte Bancaire
  • Maestro
  • PostePay
  • DanKort
  • Nexi
  • Visa Mastercard

Digital wallets

  • Apple Pay
  • Google Pay

Afterpay methods / Buy now pay later

  • iDEAL IN3
  • Billink
  • SprayPay
  • Riverty
  • Mondu
  • AlmaPAY
  • Klarna

Other

  • PayPal

Recurring payments

  • SEPA Direct Debit
  • Card-on-file / recurring card payments (tokenisation) [Coming soon]

Region specific payment methods

Payment MethodRegion(s)
iDEAL๐Ÿ‡ณ๐Ÿ‡ฑ Netherlands
Bancontact๐Ÿ‡ง๐Ÿ‡ช Belgium
Vipps๐Ÿ‡ณ๐Ÿ‡ด Norway๐Ÿ‡ธ๐Ÿ‡ช Sweden
Bizum๐Ÿ‡ช๐Ÿ‡ธ Spain
Payconiq๐Ÿ‡ง๐Ÿ‡ช Belgium๐Ÿ‡ฑ๐Ÿ‡บ Luxembourg
Twint๐Ÿ‡จ๐Ÿ‡ญ Switzerland
MB Way๐Ÿ‡ต๐Ÿ‡น Portugal
Pay By Bank๐Ÿ‡ง๐Ÿ‡ช Belgium๐Ÿ‡ฉ๐Ÿ‡ช Germany๐Ÿ‡ฎ๐Ÿ‡น Italy๐Ÿ‡ฑ๐Ÿ‡บ Luxembourg๐Ÿ‡ณ๐Ÿ‡ฑ Netherlands๐Ÿ‡ช๐Ÿ‡ธ Spain
WeChat Pay๐Ÿ‡จ๐Ÿ‡ณ China
Payment MethodRegion(s)
Alipay Plus๐Ÿ‡จ๐Ÿ‡ณ China๐Ÿ‡ญ๐Ÿ‡ฐ Hong Kong
MultiBanco๐Ÿ‡ต๐Ÿ‡น Portugal
Swish๐Ÿ‡ธ๐Ÿ‡ช Sweden
Satispay๐Ÿ‡ฎ๐Ÿ‡น Italy
Blik๐Ÿ‡ต๐Ÿ‡ฑ Poland
EPS๐Ÿ‡ฆ๐Ÿ‡น Austria
Przelewy24๐Ÿ‡ต๐Ÿ‡ฑ Poland
MobilePay๐Ÿ‡ฉ๐Ÿ‡ฐ Denmark๐Ÿ‡ซ๐Ÿ‡ฎ Finland

InStore / SoftPOS payments

Would you like to integrate Pay. (Soft)P0S? Get in touch!

Features

  • Easily Extendable: The modular architecture makes it easy to add support for additional Pay payment methods.
  • Webhook Support: Full support for Pay webhooks for real-time payment status updates.
  • Automatic Capture: Configurable automatic capture of payments.

Prerequisites

  • Medusa server v2.20.1 or later
  • Node.js v20 or later
  • A Pay account and token & secret with payment methods enabled.

Installation

pnpm add @webbers/pay-payments-medusa

Configuration

Add the provider to the module in your file & add it as plugin:

module.exports = defineConfig({
projectConfig: {
// ...
},
plugins: [
// ... other plugins
'@webbers/pay-payments-medusa'
],
modules: [
// ... other modules
{
resolve: "@medusajs/medusa/payment",
options: {
providers: [
{
resolve: "@webbers/pay-payments-medusa/providers/pay",
id: "pay",
options: {
paymentDescription: "Your description", // optional
atCode: process.env.PAY_AT_CODE,
apiToken: process.env.PAY_API_TOKEN,
slCode: process.env.PAY_SL_CODE,
slSecret: process.env.PAY_SL_SECRET,
returnUrl: process.env.PAY_RETURN_URL,
testMode: process.env.PAY_TEST_MODE === 'true',
tguApiUrl: process.env.PAY_TGU_API_URL, // defaults to https://connect.pay.nl/v1
otherSlCodes: process.env.PAY_OTHER_SL_CODE ? JSON.parse(process.env.PAY_OTHER_SL_CODE) : undefined,
},
},
]
}
}
]
})

Configuration Options

[!NOTE] You can get the API token & secret from your Pay dashboard: click Settings > Click sales channel > Copy api tokens

OptionDescriptionDefault
Your Pay AT codeRequired
Your Pay API tokenRequired
Your Pay sales channel codeRequired
Your Pay sales channel secretRequired
The URL to return to after paymentRequired
The URL of your Medusa serverRequired
Whether to enable test paymentsOptional
Pay TGU API UrlOptional, use if you want to use a specific or private TGU, see here.
Your other Pay sales channel code and secretsOptional, used for webhook signature validation when using multiple Pay. sales channels. Format

Environment Variables

Create or update your file with the following variables:

PAY_AT_CODE="<your-pay-at-code>"
PAY_API_TOKEN="<your-pay-api-token>"
PAY_SL_CODE="<your-pay-sl-code>"
PAY_SL_SECRET="<your-pay-sl-secret>"
#PAY_TEST_MODE="true"
PAY_EXCHANGE_URL="https://your-store.com/checkout/payment"

Usage

Once installed and configured, the Pay payment methods will be available in your Medusa admin. To enable them, log in to you Medusa Admin, browse to Settings > Regions, add or edit a region and select the desired Pay providers from the dropdown.

Make sure that the selected payment methods are enabled in your Pay origanization settings as well.

Supported Payment Methods

The plugin currently supports the following Pay payment methods:

Payment MethodProvider ID
Pay. hosted checkout
CreditcardsMastercard / VISA / American Express/ Carte Bancaire / Maestro / PostePay / DanKort / Nexi / Visa Mastercard
Card-on-file / recurring card payments (tokenisation)Coming soon
Apple Pay
Google Pay
iDEAL IN3
Billink
SprayPay
Riverty
Mondu
AlmaPAY
Klarna
PayPal
SEPA Direct Debit
iDEAL
Bancontact
VippsGet in touch
BizumGet in touch
Payconiq
Twint
MB WayGet in touch
Pay by Bank
WeChat Pay
AliPay PlusGet in touch
MultiBancoGet in touch
SwishGet in touch
SatispayGet in touch
Blik
EPS
Przelewy24
MobilePAY
SoftPOS
Gift Card

Client-Side Integration

To integrate with your storefront, you'll need to implement the payment flow according to Pay's and Medusa's documentation. Here's a basic example:

  1. Create a payment session in your checkout flow
  2. Redirect the customer to the Pay payment page
  3. Handle the webhook notifications to update the payment status

Example integration using the Medusa Next.js Starter:

https://github.com/user-attachments/assets/742ee261-5e41-4e33-9a72-faf1a424fc52

Duplicate cart endpoint

[!TIP] Use the duplicate cart endpoint in your storefront

When a customer cancels a payment or returns to the storefront without completing the Pay. checkout, a new duplicate cart should automatically be created. This allows the customer to easily start a new transaction without losing the items they had selected.

API Route:

Alter your storefront retrieve cart function(s) and check if the returned cart.completed_at value is set. If so request a new cart with the duplicate cart endpoint and update cart id in cookies accordingly.

The duplicate cart endpoint is idempotent, so it can be called multiple times with the same cart id.

Adding payment method icons

  1. Download the latest payment images from here: https://github.com/paynl/payment-images
  2. Add these to your storefront public assets
  3. In your checkout, create the mapping from the provider id to the icon.
  4. You can also utilize the exported from this plugin to find the corresponding ID.
  5. I.e.

Extending the Plugin

To add one of the missing Pay payment methods, create a new service in that extends the class:

import {PaymentMethod} from "@Pay/api-client";
import PayBase from "../core/Pay-base";
import {PaymentOptions, PaymentProviderKeys} from "../types";
class PayNewMethodService extends PayBase {
static identifier = "Pay-new-method";
get paymentCreateOptions(): PaymentOptions {
return {
method: PaymentMethod.newMethod,
};
}
}
export default PayNewMethodService;

Make sure to replace with the actual Pay payment method ID.

Export your new service from . Then add your new service to the list of services in .

We will be working on providing all the available Pay. options in the near future.

Medusa v1 Support

Searching for support for Medusa v1, we have a legacy plugin available. Get in touch

Medusa - Pay payments medusa