Giter VIP home page Giter VIP logo

vue-paystack's Introduction

Paystack Component for Vue 3.x

A Vue Plugin for Paystack payment gateway.

Demo

Demo Image

Install

NPM

npm install vue vue-paystack --save

Javascript via CDN

<!-- Vue -->
  <script src="https://unpkg.com/vue@next"></script>
<!-- Vue-Paystack -->
<script src="https://unpkg.com/vue-paystack/dist/paystack.umd.min.js"></script>

Usage

Via NPM

my-compnent.vue sample
<template>
  <paystack
    :amount="amount"
    :email="email"
    :paystackkey="paystackkey"
    :reference="reference"
    :callback="callback"
    :close="close"
    :embed="false"
  >
    <i class="fas fa-money-bill-alt"></i>
    Make Payment
  </paystack>
</template>

<script type="text/javascript">
import paystack from "vue-paystack";
export default {
  components: {
    paystack,
  },
  data() {
    return {
      paystackkey: "pk_test_xxxxxxxxxxxxxxxxxxxxxxx", //paystack public key
      email: "[email protected]", // Customer email
      amount: 1000000, // in kobo
    };
  },
  computed: {
    reference() {
      let text = "";
      let possible =
        "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";

      for (let i = 0; i < 10; i++)
        text += possible.charAt(Math.floor(Math.random() * possible.length));

      return text;
    },
  },
  methods: {
    callback: function (response) {
      console.log(response);
    },
    close: function () {
      console.log("Payment closed");
    },
  },
};
</script>

Usage Example via NPM or Yarn

via CDN

const app = Vue.createApp({
  components: { PayStack: Paystack.default },
  setup() {
    const paystackkey = Vue.ref("pk_test_xxxxxxxxxxxxxxxxxxxxxx");
    const email = Vue.ref("[email protected]");
    const amount = Vue.ref(1000000);
    let reference = Vue.computed(() => {
      let text = "";
      let possible =
        "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";

      for (let i = 0; i < 10; i++)
        text += possible.charAt(Math.floor(Math.random() * possible.length));

      return text;
    });
    let callback = (response) => {
      console.log({ response });
    };
    let close = () => {
      console.log("payment closed");
    };
    return {
      reference: reference,
      callback: callback,
      close: close,
      paystackkey: paystackkey.value,
      email: email.value,
      amount: amount.value,
    };
  },
});

app.mount("#app");

Usage Example via CDN

Please checkout Paystack Documentation for other available options you can add to the

Deployment

REMEMBER TO CHANGE THE KEY WHEN DEPLOYING ON A LIVE/PRODUCTION SYSTEM

Contributing

  1. Fork it!
  2. Create your feature branch: git checkout -b feature-name
  3. Commit your changes: git commit -am 'Some commit message'
  4. Push to the branch: git push origin feature-name
  5. Submit a pull request πŸ˜‰πŸ˜‰

How can I thank you?

Why not star the github repo? I'd love the attention! Why not share the link for this repository on Twitter or Any Social Media? Spread the word!

Don't forget to follow me on twitter!

Thanks! Ayeni Olusegun.

License

This project is licensed under the MIT License - see the LICENSE.md file for details

vue-paystack's People

Contributors

copy-ninja1 avatar damilola-paystack avatar dependabot[bot] avatar iamraphson avatar lukman-paystack avatar olaoluwa-98 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

vue-paystack's Issues

Rename Paystack key to public_key

First of all, great work mate.

Just a tiny correction, the paystack key required for inline initialization is the public key. Kindly rename the paystack key variable to public_key or at least, just add a comment somewhere to notify users that it's the public key they need to use there.

Regards,

not working with vue 3

Paystack vue components not working on the latest vue app. it returns cannot define _c in the console.

Mobile money option activation in vuejs

We used the paystack payment on a php project and it had the option for mobile money.
image

And we are using the same paystack for a vue project ,How do we activate the mobile money option in vuejs.
image

PaystackPop is not defined

I'm getting this warning after integrating your plugin.

PaystackPop is not defined.

Using Vuejs 2.

Thank you for such a great plugin.

window is not defined

Just trying out this plugin on my nuxtjs app I got "Reference Error! window is not defined" in "node_modules/vue-paystack/dist/paystack.min.js", please anyone with a workaround this?

Can we remove bundling minification from this library?

Minifying the built output makes it hard to know when what's up when something goes wrong.

Can we remove the minification, or leave it for CDN imports if necessary, and provide a non-minified version for when importing with ESM?

Please inform when version `3.0.0` will be released.

Many thanks for this library!

Currently, "normal" installation with npm/yarn supports only version 2.0.2 (the last release), but as I can see in the master branch you already have version 3.0.0.

Note:

  • When installed as yarn add https://github.com/iamraphson/vue-paystack (version 3.0.0) it normally works with vue3.

Meta data

How can I attach extra information, that will be received from webhook?

Amount not correct

So here's the thing. On entering an amount, for some reason it is divided by 100. That is if inputted amount is 32000, paystack shows 320.
Is it a test mode thing? Or is this expected?
I'm using test key

Enable adding custom elements to paystack button.

A user should be allowed to include custom html elements into the button, e.g. a glyphicon etc.

A solution: is to use the <slot> ... </slot> available in VueJS as follows:

<button v-if="!embed" v-text="text" class="payButton" @click="payWithPaystack">
      <slot></slot>
</button>

Although this would mean two things:

  1. To support backward compatibilty, props text can still remain, but users will have to pass in an empty string to it (Although, notice: if a user doesn't, it will use the default string you set which is Make Payment. This can then conflict somehow with the html a user might include inside the button)

  2. We can completely remove out the text props, and allow users to add any text to the button by including whatever html they want into the paystack button. e.g.

<paystack-button> // add props except from `:text`
    <i class="clock icon"></i> // add some icons
    Make Payment
</paystack-button>

This can work using the solution I proferred above.

Based on what you decide, I could submit a PR implementing this small change.

May be security issue?

Our components are available on client side

 <paystack
        :amount="amount"
        :email="email"
        :paystackkey="paystackkey"
        :reference="reference"
        :callback="callback"
        :close="close"
        :embed="false"
    ></paystack>

say the item is of 100 Naira and using devtools or anything i changed it to 10 Naira.

Now there are two scenario
1.
Using 10 Naira i purchased the item loss to website is 90Naira and hacker are enjoying . If large commercial site it is even worst

Server may validate that item was 100 Naira but user paid 90 Naira. Now hacker will say they were charged but didn't receive and would settle with site owner. Site owner have to give them 10 naira and would have to deal with settlement fees etc.

Both side hacker won admin loss :(

Fluctuation in Nuxt app

Thank you for this awesome component πŸ‘πŸΌπŸ‘πŸΌ, I'm currently using it on my nuxt app and I noticed that it will work well whenever I import paystack directly from the page and after a while it throw a "Window is not defined" error. Please advice.

TypeScript Support

Hello guys, I really love the work you guys have done with the Vue Paystack component and I say thank you for making it very easy to accept payment through the front end of an application securely πŸ™‚. I wanted to know if the component will support typescript cause I when I import the plugin inside my app, I keep on getting cannot find the declaration file.

PaystackPop not defined error

after adding this <script src="https://js.paystack.co/v1/inline.js"></script> to my react-rails application im unable to use Paystackpop please is there a solution to this?

LACK OF CUSTOMIZATION FOR THIS MODULE

Though this dependency is good i a also want to complain of a lack of customization.

a person cannot put his own custom element by default the default clicking element in the module is the button element.

i am trying to add customization to it be making a pull request soon

Plan not found

I tested this a while back and it was working fine. And then, today, it keeps showing me plan not found.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.