How to import and use external python APIS and packages

Greetings,
I want to import and use py-authorize an API for Authorize.net payment gateway
For example:

import py-authorize

but don’t know how to use it. How such API’s or python packages could be used in ERPNext development or customization?

Thanks.

The specific part of your question:
Add py-authorize to requirements.txt of what ever app you’re working in.
Then run bench update -- requirements to add py-authorize to the bench’s virtual environment.

The general part of your question:
The API piece is a little more complicated and there are lots of ways to do it. If the API action is associated with a human-initiated document, you probably don’t need anything else (I’m assuming that py-authorize has a library for making http requests as a dependency like requests or urllib). If you want a design that polls for information on authorize.net’s server, you should leverage the scheduler and long worker queues. If you can give more background on your design , we can point you in a better direction.

2 Likes

@tmatteson thanks a lot. I will try it