UNPKG

@spot-flow/vue-spotflow-checkout

Version:

This **Spotflow Vue.js library** wraps around the [inline library](https://github.com/Spotflow-One/spotflow-checkout-inline), which enables users to make payments seamlessly. It integrates smoothly into your Vue.js application, providing a streamlined ch

2 lines (1 loc) 1.55 kB
(function(n,o){typeof exports=="object"&&typeof module<"u"?module.exports=o(require("vue")):typeof define=="function"&&define.amd?define(["vue"],o):(n=typeof globalThis<"u"?globalThis:n||self,n.SpotflowVue=o(n.Vue))})(this,function(n){"use strict";const o={name:"VueSpotflow",props:{merchantKey:{type:String,required:!0},email:{type:String,required:!0},amount:{type:Number,required:!0},encryptionKey:{type:String,required:!0},planId:{type:String,required:!0},currency:{type:String},localCurrency:{type:String},metadata:{type:Object},callBackUrl:{type:String}},beforeMount(){function t(){const e=document.createElement("script"),r="https://dr4h9151gox1m.cloudfront.net/dist/checkout-inline.js";e.src=r,e.onload=()=>{},document.querySelector(`[src="${r}"]`)||document.head.appendChild(e)}t()},methods:{makePayment(){if(this.merchantKey===void 0||this.email===void 0||this.encryptionKey===void 0)throw new Error("Merchant key, Email and Encryption key are required");const t=window.SpotflowCheckout;if(t){const e={merchantKey:this.merchantKey,encryptionKey:this.encryptionKey,planId:this.planId,email:this.email,amount:this.amount||0,currency:this.currency,localCurrency:this.localCurrency,metadata:this.metadata,callBackUrl:this.callBackUrl};new t.CheckoutForm(e).setup(e)}}}},u=(t,e)=>{const r=t.__vccOpts||t;for(const[c,i]of e)r[c]=i;return r};function d(t,e,r,c,i,a){return n.openBlock(),n.createElementBlock("button",{onClick:e[0]||(e[0]=(...s)=>a.makePayment&&a.makePayment(...s))},[n.renderSlot(t.$slots,"default")])}return u(o,[["render",d]])});