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` - https://developer.paypal.com/docs/checkout/integrate/#4-set-up-the-transaction and the subscription integration for monthly donations with `createSubscription` - https://developer.paypal.com/docs/subscriptions/integrate/#4-create-a-subscription.
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="https://www.paypal.com/sdk/js?client-id=BLAH&currency=AUD&vault=true&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?