This is my personal experience integrating the new PayPal Smart Payment Buttons with a reactive Vue.js framework called Quasar — I ran into problems and found solutions.
Today let’s code a PayPal Smart Payment Button Checkout.
At quick glance everything looks great; copy the code into your project and mission complete.
What if you are using reactive UI components such as QBtnDropdown for a shopping cart list?
Some developer background: my sandbox songxy.com uses Quasar (thanks to creator Razvan Stoenescu) a reactive Vue.js framework. It supports many platforms and browsers out of the box.
Understanding my requirements I continued with the PayPal example to step 3: render the button into my UI element.
Attempt #1 call PayPal render button function to render <div id=“paypal-button-container” /> inside of the drop down box whenever @click event was triggered by drop down button.
As you can see from the screenshot and the error message below this did not work.
It turns out <div id=“paypal-button-container” /> in my dropdown box is rendered dynamically and reactive on click events meaning it only exists when it dropped down. The PayPal smart buttons cannot find the div to render into.
Attempt #2 clicking a checkout button inside the dialog box calling the PayPal render button.
That worked because the button and div existed in the drop down when clicked. However, an extra click reduces customer conversion rates.
There must be a better way…
Attempt #3 add some more code Vue function $nextTick with PayPal render button.
But what happens when you run this on an iOS device such as iPad or iPhone?
Every time your drop down box drops you will get a new blank space at the top that pushes your new working button down.
It keeps moving down indefinitely.
How do we solve this problem?