Subscription and Smart Buttons on Same Page - Need to load different SDKs
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am building a custom Wordpress theme and I have a Donate page that that contains multiple donation types - one-time payments and automatic monthly payments (subscriptions). When the user clicks the Continue button for a donation type, it calls one of the two javascript functions specific to that payment type and then renders the appropriate PayPal buttons to complete the payment process.
The issue I'm running into is that I need to use two different PayPal SDK scripts depending on the payment type:
https://www.paypal.com/sdk/js?client-id=ID-OMITTED¤cy=USD&commit=false&debug=true
or
https://www.paypal.com/sdk/js?client-id=ID-OMITTED&vault=true&intent=subscription
Since the one-time payment button is the first on the page, when I call the function to render the paypal buttons it works as expected. The problem comes in when I try to test the subscription option. Since the one-time SDK was loaded first, it will call that and the PayPal buttons won't render.
I am trying to figure out how to choose which script to load. I have tried appending the correct SDK src to the head after an onclick event and even though I can see that it's there it still give me a "paypal is not defined" error.
I am hoping someone has come across this and can make some suggestions. I'm using PHP and Javascript and I can provide code examples if necessary, thanks.
- Labels:
-
PayPal Here SDK
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The only way I was able to solve this was with https://github.com/paypal/paypal-js and the example at https://codepen.io/gregjopa/pen/RwagNWR?editors=1010
Haven't Found your Answer?
It happens. Hit the "Login to Ask the community" button to create a question for the PayPal community.
- PayPal Buttons not visible in Sandbox Environment
- Add Others data in SDKs
- Get error message "Someting went wrong" when the sandbox account tap "Agree and Connect" button. in Sandbox Environment
- can we assign a unique detail to every subscription creation? in NVP/SOAP APIs
- Button in PayPal Payments Standard