When you have multiple elements on the page set to broadcast, the vue-stripe.success handler is called multiple times (once for each element on the page)
<stripe-checkout
button-class="btn btn-primary"
button="Product 1"
:stripe-key="stripeKey"
product="product"
formId="PRODUCT_1"
:options="PurchaseStripeOptions"
on-success="broadcast">
<stripe-checkout
button-class="btn btn-primary"
button="Product 2"
:stripe-key="stripeKey"
product="product"
formId="PRODUCT_2"
:options="PurchaseStripeOptions"
on-success="broadcast">
.....
mounted: function () {
// Trigger stripe success callbacks
Bus.$on('vue-stripe.success', payload => {
console.log('vue-stripe.success', payload) // called twice
switch (payload.formId) {
case 'PRODUCT_1':
console.log('PRODUCT_1') // called twice
break
case 'PRODUCT_2':
console.log('PRODUCT_2') // called twice
break
}
})
},
....
When you have multiple elements on the page set to broadcast, the
vue-stripe.success
handler is called multiple times (once for each element on the page)