Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

new js paypal button #221

Open
newearthmartin opened this issue Jan 16, 2020 · 3 comments
Open

new js paypal button #221

newearthmartin opened this issue Jan 16, 2020 · 3 comments

Comments

@newearthmartin
Copy link

newearthmartin commented Jan 16, 2020

Hi! I was contacted by PayPal to implement a new type of button that includes also credit card payments. The button is now initialized via some javascript calls. Did you guys know about this?

Apart from the js calls, the main difference is that it doesnt include a return URL, which is a very annoying change that they made. Rather, you need to configure a URL for IPN notifications for the whole PayPal account in the PayPal website.

Are you working on integrating it into django-paypal? I have made my own implementation which I can submit here. Im only not sure how to go about adding the js code into the library, but we can have a talk about it.

@spookylukey
Copy link
Owner

I'm not working on integrating anything. Is it necessary to change anything to get credit card payments? The normal buttons allow you to do credit card payments - but maybe you are talking about something else.

If there are straightforward changes that can be made to integrate this into django-paypal, I would be interested in adding it, but I have no personal need for it so would be very unlikely to write the code myself.

@newearthmartin
Copy link
Author

You can check a live example here https://www.temporary-url.com/26CC9

Basically it's created via javascript like this, all CAPS are things to be customized

<script src="https://www.paypal.com/sdk/js?currency=USD&client-id=CLIENT_ID_HERE"></script>

and

<script>
  var order_data = {
    purchase_units: [{
      invoice_id: 'INVOICE_ID',
      description: 'DESCRIPTION',
      amount: { value: VALUE }
    }],
  };
  var style = { // some styling options
    color: 'gold',
    label: 'pay',
    layout: 'vertical',
    ...
  };

  paypal.Buttons({
    style: style,
    createOrder: function(data, actions) { return actions.order.create(order_data) },
    onApprove: function(data, actions) {
      return actions.order.capture().then(function() {
        location.href = 'https://MY_RETURN_URL';
      });
    }
  }).render('#SELECTOR_FOR_BUTTON');

</script>

I'm not sure how is the best way to add javascript code to be rendered in django. Maybe to create an object in much the same way that we use PayPalPaymentsForm that will have one render for the <script> tag and another render for the code.

I can submit the base structure that works (for my case) but I also dont have enough mental space to go into all the variables that are already working in django-paypal and make sure they work here.

@spookylukey
Copy link
Owner

Thanks for compiling that info.

I'm going to leave this ticket open in case someone has the time/motivation etc. to put the pieces together in a reusable way for django-paypal, which I don't have at the moment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants