Skip to content

Vue components for Mollie Payments (Nuxt module)

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.