Installing a self made payment plugin


#1

Hello,
I took the payment_paypal plugin, forked it and made modifications for another paypemts API.

How do I install the plugin now? I found this topic, but I dont seem to have the build-wheel.py anywhere.

Can I get a short explanation or a link to a tutorial on how do I install my plugin to the Indico system?


#2

build-wheel.py is part of the main indico repo, You can find it in bin/maintenance/. In the end it’s just python setup.py bdist_wheel on steroids (it also builds i18n dictionaries if there are any, ensures the source tree is clean before building, etc.)

Once you built your plugin, copy the *.whl file to the machine where you want to install the plugin and use pip install whatever.whl to actually install it (make sure your Python virtualenv is active).

Note: During initial development/testing you do not need to build a wheel. Simply use pip install -e . to install it in your development environment - like this any changes you make to the files will be used immediately without having to rebuild/reinstall all the time.


#3

Thank you for the quick answer. Yes, so far I’m working only in development environment.

So far I did this:

[root@luconfdev payment_lupayments]# su - indico
[indico@luconfdev ~]$ source ~/.venv/bin/activate
(.venv)[indico@luconfdev ~]$ cd /opt/indico/.venv/lib/python2.7/payment_lupayments/
(.venv)[indico@luconfdev payment_lupayments]$ pip install -e .
Obtaining file:///opt/indico/.venv/lib/python2.7/payment_lupayments
    Complete output from command python setup.py egg_info:
    running egg_info
    creating indico_plugin_payment_lupayments.egg-info
    error: could not create 'indico_plugin_payment_lupayments.egg-info': Permission denied

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /opt/indico/.venv/lib/python2.7/payment_lupayments/
(.venv)[indico@luconfdev payment_lupayments]$

Just wanna know if I understood it correctly, before moving this issue to the administrator.


#4

You are mixing up things… pip install -e . is something you run in your source directory, NOT inside the virtualenv (you really never need to cd in there)

In case your source is actually in /opt/indico/.venv/lib/python2.7/payment_lupayments/, then move it somewhere else, e.g. ~/dev/indico_payment_lupayments.

The “permission denied” error seems strange. Did you accidentally create the virtualenv as root?


#5

I’m not the admin, just the dev. And yes, it was created with root.

It got fixed and I managed to install my plugin on the development system. No idea how I will set up it on prod since I don’t have the maintenance directory with build-wheel.py in it, but that will be for a bit later.

Thank you for now.


#6

That’s not what the setup guide does… :wink:

The idea is to build the wheel on your development system and only copy the *.whl file to production and then pip install whatever.whl there. The script is part of the Indico repo but not part of the indico python package, since it’s not supposed to be used on a production machine.


#7

Another short question: does the paypal plugin actually set a status if the payman was succesfull or not?

If I understand it correctly, after a success the provided return_url is opened and this method is called (name is remade for my plugin of course):

class RHLUPaymentsSuccess(RHLUPaymentsIPN):
"""Confirmation message after successful payment"""

def _process(self):
    flash(_('Your payment request has been processed.'), 'success')
    return redirect(url_for('event_registration.display_regform', self.registration.locator.registrant))

What this does is - it adds a message about the payment and opens the registration form again. But it does not save the status of the payment as successful. Thus, I end up in the same registration screen with the message, that the payment was successful, but the status of the registration is still Not paid.

Did I miss something or is this intended behavior?


#8

As far as I can remember, PayPal does that asynchronously (IPN). PayPal sends an out-of-band request to Indico telling the payment was OK.


#9

Right, so if you are testing it make sure that the machine running Indico is accessible from the public internet and is using a proper SSL certificate (LetsEncrypt is OK, self-signed isn’t).

I think paypal is supposed to send the request before redirecting you back, but I guess it can take longer in some cases (for sure if the payment is not accepted automatically but pending manual verification from the recipient).