Skip to content

mollie Logo

:::

Vue components for Mollie Payments (Nuxt module) ​

Features ​

  • β›° Β useMollie & useMollieCreditCard composable function
  • 🚠 Β MollieCreditCardComponent.vue component to use in a Vue project
  • 🌲 Β ShopwareFrontendsCreditCard.vue component to use in a Nuxt Shopware Powered project

Requirements ​

Setup ​

Backend: Shopware 6 admin panel ​

Install the Mollie Payments in your Shopware 6 instance and set it up

Frontend: Nuxt 3 project ​

  1. Install the dependencies

    run pnpm i command.

  2. Configure Mollie module in runtimeConfig > public section of nuxt.config.ts

js
// ./nuxt.config.ts
mollie: {
    defaultLocale: "en_US", // fallback locale
    profileId: "pfl_E5EmGZ98YT", // from Mollie's dashboard
    testMode: true,
},

Use Credit Card components ​

  1. For Shopware Frontends aware projects (with shopware-pwa/nuxt3-module enabled)
html
<script setup lang="ts">
  import { useCheckout } from "@shopware-pwa/composables-next/dist";
  const { selectedPaymentMethod } = useCheckout();
  // the name may vary, so first, please check what comes from API
  const showMollieCreditCardComponent = computed(
    () =>
      selectedPaymentMethod.value?.shortName ===
      "mollie_payments_app_mollie_creditcard",
  );
</script>
<template>
  <!-- show credit card component conditionally -->
  <ShopwareFrontendsCreditCard :v-if="showMollieCreditCardComponent" />
</template>

In this case, by clicking a submit / save button under the credit card form, there will be an additional request made to the mollie's endpoint in your Shopware 6 instance.

  1. For plain Nuxt 3 project
html
<MollieCreditCardComponent />

Events and properties ​

Control credit card form and react on events using events and properties:

ts
const props = defineProps<{
  locale?: MollieLocale;
  submitButtonLabel?: string;
  submitDisabled?: boolean;
}>();

const emits = defineEmits<{
  (e: "submit", token: string | undefined): void;
  (e: "error", error: string | undefined): void;
}>();

Example:

html
<ShopwareFrontendsCreditCard
  submit-button-label="Save"
  locale="en_US"
  :submit-disabled="!!CreditCardToken"
  @submit="
      (token) => {
        CreditCardToken = `${token} βœ”οΈ`;
        CreditCardError = null;
      }
    "
  @error="
      (message) => {
        CreditCardError = `${message} ❌`;
      }
    "
/>

Development ​

Run a playground project with configured Mollie module from current dir.

bash
# Run a playground (nuxt 3) project in dev mode
pnpm dev

Auto-generated

This page is generated from an external markdown file. In case of any issues or dead links, please visit the source file.

Vue components for Mollie Payments (Nuxt module) has loaded