Getting Started¶
Installation¶
The package is available on pypi.org <https://pypi.org/projects/pyjengahq>.
pip install pyjengahq
First Things First¶
Generating an openSSL private/public key pair.¶
Since v2 of the API, JengaHQ now requires some APIs to include signatures as a security measure. This signatures are usually generated by signing some request fields with a private key. In order to use JengaHQ you’ll have to upload your public key to the developer console on JengaHQ after you generate your key pair.
This Library provides a CLI command to help you generate those keys.
Note
The generated keys will be stored in your home directory under the .JengaAPI/keys/ folder and this is where by default the Library looks for your private key when initiating JengaRequest Objects.
After Installation, Generate Your Keys using the following command:
$ jenga_gen_key_pair
Note
Then copy the ~/.JengaApi/keys/publickey.pem to your developer console on JengaHq.
Using The APIs¶
Creating JengaAPI objects¶
By Design, interaction with all Jenga APIs functionality uses the jengahq.auth.JengaAPI class which takes the following parameters:
api_key: Your Jenga API Key
password: Your Jenga API Password
merchant_code:: the merchant code provided by JengaHQ
env:: the environment in which the API is to be used either sandbox or production
private_key:: the path to the merchant private key default is “~/.JengaAPI/keys/privatekey.pem”
sandbox_url:: the url used to access the Sandbox API
live_url:: the url used to access the Production API
Example
import jengahq
jengaApi = jengahq.JengaAPI(
api_key="Basic TofFGUeU9y448idLCKVAe35LmAtLU9y448idLCKVAe35LmAtL",
password="TofFGUeU9y448idLCKVAe35LmAtL",
merchant_code="4144142283",
env="sandbox",
)