Showing results for 
Search instead for 
Did you mean: 

Who Me Too'd this topic

Who Me Too'd this topic

Posted on

We're a not-for-profit offering our donors the ability to donate via PayPal. Currently we're using PayPal buttons with a server-side integration with the old Ruby SDK. If the donor selects a once-off donation, we create a payment, if they select a monthly donation, we create a billing agreement.  Either way, the process is triggered by the same `createOrder` callback on the PayPal button.


We're trying to upgrade to the latest version of the PayPal buttons integration where the transaction is completed on the client side. We think that this means we'll need to use the basic order integration for once off donations with `createOrder` - and the subscription integration for monthly donations with `createSubscription` -


We'd like to be able to include both these options on one page, switching between the two based on what the user selects, but it doesn't seem to be possible, because each option requires us to load the JS SDK with different parameters. The `createOrder` version (implicitly) requires loading the SDK with `intent=capture`, whilst the `createSubscription` version requires `intent=subscription&vault=true`. I've investigated the option of loading the SDK twice on the one page with different parameters (inefficient, I know), using the `data-namespace` attribute to differentiate them, but the PayPal server responded with a 400 when we tried to load the script the second time:


<script src=";currency=AUD"></script>

<script src=";currency=AUD&amp;vault=true&amp;intent=subscription..." data-namespace="paypal_subscriptions"></script>


`window.paypal` was defined, but `window.paypal_subscriptions` was not.


If I can't load the first SDK on the page, I don't think I can put a `createOrder` callback on the PayPal button. If I can't load the second SDK, I don't think I can put a `createSubscription` callback on the button.


Does anybody have any expertise to offer as to how to combine two types of button on the same page like this?

Who Me Too'd this topic