npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@headlesscommerce/vsf-magento-stripe

v1.1.0

Published

Stripe Payment module for Vue Storefront Magento

Downloads

32

Readme

Stripe Payment Module for Vue Storefront 2

Stripe Payments integration for Vue Storefront with Magento 2. Supports Payment Element and 3D Secure.

Requirements for Magento 2

On Magento's side install the official Stripe Magento 2 module.

Integration to theme

Install the package npm -i @headlesscommerce/vsf-magento-stripe or yarn add @headlesscommerce/vsf-magento-stripe.

Add Stripe Key

Add the Stripe publishable key to nuxt.config.js in publicRuntimeConfig.

publicRuntimeConfig: {
  stripePublishableKey: process.env.NODE_ENV === 'production' ? 'pk_live' : 'pk_test',
}

Include Stripe.js

In modules/checkout/pages/Checkout.vue(file) include the stripe.js script in head.

head() {
  return {
    script: [
      {
        src: 'https://js.stripe.com/v3'
      }
    ],
  }
}

Update processOrder in Checkout/Payment

In modules/checkout/pages/Checkout/Payment.vue(file) add a ref to the VsfPaymentProvider component e.g: <VsfPaymentProvider ref="VsfPaymentProviderRef" @status="isPaymentReady = true" />

Then access the triggerStripe from the VsfPaymentProvider component and overide the processOrder function by removing the order.value = await make(); with const stripeStatus = await VsfPaymentProviderRef.value.triggerStripe(); and order.value.order.order_number with stripeStatus.order_number.

  const processOrder = async () => {
  const stripeStatus = await VsfPaymentProviderRef.value.triggerStripe();
  if (!stripeStatus) {
    return;
  }
  setCart(null);
  app.$vsf.$magento.config.state.removeCartId();
  await load();
  await removeItem('checkout');
  const thankYouRoute = app.localeRoute({
    name: 'thank-you',
    query: {
      order: stripeStatus.order_number,
    },
  });
  await router.push(thankYouRoute);
};

Add Stripe component to VsfPaymentProvider

In modules/checkout/components/VsfPaymentProvider.vue (file) import the Stripe component and override the details slot of SfRadio component to add the Stripe component.

Example:

<template>
    <SfRadio v-for="method in paymentMethods">
       <template #details>
         <Stripe ref="StripeRef" v-if="method.code === 'stripe_payments'" @status="paymentStatus" />
       </template>
    </SfRadio>
 </template>
 <script lang="ts">
    import { Stripe } from '@headlesscommerce/vsf-magento-stripe';
    export default defineComponent({
      name: 'VsfPaymentProvider',
        components: {
        ...
        Stripe
      },
    });
 </script>

Set useStripe composable

In modules/checkout/components/VsfPaymentProvider.vue (file) set a ref for the Stripe component then to validate and initiate the Stripe useStripe composable.

export default defineComponent({
  name: 'VsfPaymentProvider',
  ...
  setup(_props, { emit }) {
    const StripeRef = ref(null);
    const definePaymentMethods = async (paymentMethodCode: string) => {
      if (paymentMethodCode !== 'stripe_payments') {
        // Avoid emitting just yet, see paymentStatus function
        emit('status', paymentMethodCode);
      }
    };
    // Validate and initiate stripe
    const triggerStripe = async () => {
      if (selectedPaymentMethodCode.value == 'stripe_payments') {
        return await StripeRef.value[0].useStripe();
      } else {
        return;
      }
    }
    const paymentStatus = () => {
      emit('status', 'true');
    };
    return {
      ...
      paymentStatus,
      triggerStripe,
      StripeRef
    };
  },
});