vue-paystack
Version:
Vue Paystack Component for Vue 2.x.
1 lines • 4.33 kB
JavaScript
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define("VuePaystack",[],e):"object"==typeof exports?exports.VuePaystack=e():t.VuePaystack=e()}(window,function(){return a={},r.m=n=[function(t,e,n){"use strict";n.r(e);var a,r,i,o,c,u,s,d,l,p,f,n=(o=!(i=[]),s=u=c=null,f="function"==typeof(a={props:{embed:{type:Boolean,default:!1},paystackkey:{type:String,required:!0},email:{type:String,required:!0},firstname:{type:String,default:""},lastname:{type:String,default:""},amount:{type:Number,required:!0},reference:{type:String,required:!0},channels:{type:Array,default:function(){return["card","bank"]}},accessCode:{type:String,default:""},callback:{type:Function,required:!0,default:function(){}},close:{type:Function,required:!0,default:function(){}},metadata:{type:Object,default:function(){return{}}},currency:{type:String,default:"NGN"},plan:{type:String,default:""},quantity:{type:String,default:""},subaccount:{type:String,default:""},split:{type:Object,default:function(){return{}}},splitCode:{type:String,default:""},transactionCharge:{type:Number,default:0},bearer:{type:String,default:""}},data:function(){return{scriptLoaded:null}},created:function(){var e=this;this.scriptLoaded=new Promise(function(t){e.loadScript(function(){t()})})},mounted:function(){this.embed&&this.payWithPaystack()},methods:{loadScript:function(t){var e=document.createElement("script");e.src="https://js.paystack.co/v1/inline.js",document.getElementsByTagName("head")[0].appendChild(e),e.readyState?e.onreadystatechange=function(){"loaded"!==e.readyState&&"complete"!==e.readyState||(e.onreadystatechange=null,t())}:e.onload=function(){t()}},isDynamicSplit:function(){return this.split.constructor===Object&&0<Object.keys(this.split).length},payWithPaystack:function(){var e=this;this.scriptLoaded&&this.scriptLoaded.then(function(){var t={key:e.paystackkey,email:e.email,firstname:e.firstname,lastname:e.lastname,channels:e.channels,amount:e.amount,access_code:e.accessCode,ref:e.reference,callback:function(t){e.callback(t)},onClose:function(){e.close()},metadata:e.metadata,currency:e.currency,plan:e.plan,quantity:e.quantity,subaccount:e.isDynamicSplit()?"":e.subaccount,split:e.isDynamicSplit()?e.split:null,split_code:e.isDynamicSplit()?"":e.splitCode,transaction_charge:e.isDynamicSplit()?0:e.transactionCharge,bearer:e.isDynamicSplit()?"":e.bearer};e.embed&&(t.container="paystackEmbedContainer");t=window.PaystackPop.setup(t);e.embed||t.openIframe()})}}})?a.options:a,(r=function(){var t=this,e=t._self._c||t.$createElement;return t.embed?e("div",{attrs:{id:"paystackEmbedContainer"}}):e("button",{staticClass:"payButton",on:{click:t.payWithPaystack}},[t._t("default",[t._v("Make Payment")])],2)})&&(f.render=r,f.staticRenderFns=i,f._compiled=!0),o&&(f.functional=!0),u&&(f._scopeId="data-v-"+u),s?f._ssrRegister=l=function(t){(t=t||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext)||"undefined"==typeof __VUE_SSR_CONTEXT__||(t=__VUE_SSR_CONTEXT__),c&&c.call(this,t),t&&t._registeredComponents&&t._registeredComponents.add(s)}:c&&(l=d?function(){c.call(this,(f.functional?this.parent:this).$root.$options.shadowRoot)}:c),l&&(f.functional?(f._injectStyles=l,p=f.render,f.render=function(t,e){return l.call(e),p(t,e)}):f.beforeCreate=(d=f.beforeCreate)?[].concat(d,l):[l]),{exports:a,options:f});e.default=n.exports}],r.c=a,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var a in e)r.d(n,a,function(t){return e[t]}.bind(null,a));return n},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="/dist/",r(r.s=0);function r(t){if(a[t])return a[t].exports;var e=a[t]={i:t,l:!1,exports:{}};return n[t].call(e.exports,e,e.exports,r),e.l=!0,e.exports}var n,a});