Skip to content Skip to sidebar Skip to footer

Toggle Between Paypal Order And Paypal Subscription

I've been working on a paypal checkout and am having difficulties, my company is offering services that can be purchased one time, or on a recurring basis, and I have the checkout

Solution 1:

You can use a helper function such as the following to load/reload the SDK dynamically:

functionloadAsync(url, callback) {
  var s = document.createElement('script');
  s.setAttribute('src', url); s.onload = callback;
  document.head.insertBefore(s, document.head.firstElementChild);
}

// Usage Example:loadAsync('https://www.paypal.com/sdk/js?client-id=test&currency=USD', function() {
  paypal.Buttons({

    // Set up the transactioncreateOrder: function(data, actions) {
        return actions.order.create({
            purchase_units: [{
                amount: {
                    value: '0.01'
                }
            }]
        });
    },

    // Finalize the transactiononApprove: function(data, actions) {
        return actions.order.capture().then(function(details) {
            // Show a success message to the buyeralert('Transaction completed by ' + details.payer.name.given_name);
        });
    }

  }).render('body');  // Replace with selector of desired container to render in
});

(Your callback can of course be a named function such as your paypalsingle rather than an anonymous one as in the above usage example)

Post a Comment for "Toggle Between Paypal Order And Paypal Subscription"