Package: lipad-sdk
Lipad Python SDKIntroductionThe Lipad Python SDK facilitates the integration of Lipad's Direct API and Checkout features into your Python applications. This comprehensive guide will assist you in the setup and utilization of the Lipad SDK.PrerequisitesBefore getting started, ensure you have the following:Python: Ensure that you have Python installed on your system. You can download Python from theofficial Python website.You have installed: requests, aiohttp, pycryptodomeLipad API credentials, including the IV Key, Consumer Secret, Consumer Key.Environment: Decide whether you want to work in the production or sandbox environment. Lipad provides different URLs for each environment, so choose accordingly.InstallationDownload the Lipad SDK:Download the Lipad SDK and include it in your project.# Example using pippipinstalllipad-sdkImport the Lipad class and necessary libraries:fromlipadimportLipad
importjson
importayncioCreate an asynchronous main function.asyncdefmain():

//Replacethesevalueswithyouractualcredentialsiv_key="your_iv_key";consumer_secret="your_consumer_secret";consumer_key="your_consumer_key"environment="sandbox","production";charge_request_id="your_charge_request_id"Running the scriptTo execute the script and run the main function, add the following line at the end of your script:if__name__=="__main__":
asyncio.run(main())Checkout UsageTo initialize the Lipad class, provide the iv_key, consumer_key, consumer_secret, and environment parameters. The environment should be one of the following: 'production' or 'sandbox'.lipad=newLipad(iv_key,consumer_key,consumer_secret,environment);Validate Payload```bash
payload = {
    "msisdn": "",
    "account_number": "",
    "country_code": "",
    "currency_code": "",
    "client_code": "",
    "due_date": "",
    "customer_email": "",
    "customer_first_name": "",
    "customer_last_name": "",
    "merchant_transaction_id": "",
    "preferred_payment_option_code": "",
    "callback_url": "",
    "request_amount": "",
    "request_description": "",
    "success_redirect_url": "",
    "fail_redirect_url": "",
    "invoice_number": "",
    "language_code": "en",
    "service_code": "",
}
     lipad.validate_payload(payload)Convert payload to JSON String and encrypt Payloadpayload_json_string=json.dumps(payload)encrypted_payload=checkout.encrypt(payload_json_string)print("Encrypted Payload:",encrypted_payload)Get Checkout Statusmerchant_transaction_id=payload.get("merchant_transaction_id")print("Merchant Transaction ID:",merchant_transaction_id)checkout_data=awaitcheckout.check_checkout_status(merchant_transaction_id)print("Checkout Data:",checkout_data)Build Checkout URLcheckout_url=f"https://checkout2.dev.lipad.io/?access_key={access_key}&payload={encrypted_payload}"print("Checkout URL:",checkout_url)Direct API UsageTo initialize the Lipad class, provide the iv_key, consumer_key, consumer_secret, and environment parameters. The environment should be one of the following: 'production' or 'sandbox'.lipad=newLipad(iv_key,consumer_key,consumer_secret,environment);Direct Chargeawaitlipad.direct_charge(json.dumps(payload))Get Charge Request Statuscheckout_request_status=awaitcheckout.get_charge_request_status(chargeRequestId)print("Checkout Request Status",checkout_request_status)LicenseThis SDK is open-source and available under the MIT License.