### Install CoralPay SDK and Dependencies Source: https://context7.com/beloved23/coralpay/llms.txt Commands to install the required Python packages and configure the GnuPG environment for PGP key management. ```bash pip install CoralPay pip install pretty_bad_protocol gpg --import coralpay.public.txt gpg --import your_privatekey.txt ``` -------------------------------- ### Python Package Configuration with setup.py Source: https://github.com/beloved23/coralpay/blob/master/CoralPay.egg-info/SOURCES.txt The setup.py file is used to define the package metadata, dependencies, and installation requirements. It is the standard entry point for building and distributing the Python package. ```python from setuptools import setup, find_packages setup( name="CoralPay", version="0.1.0", packages=find_packages(), install_requires=[], ) ``` -------------------------------- ### Initialize CoralPay SDK Source: https://context7.com/beloved23/coralpay/llms.txt Sets up the CoralPay client by providing the GnuPG home directory and the CoralPay public key fingerprint. ```python from coralpay_pkg import CoralPay gpg = CoralPay( homedir='/Users/username/.gnupg', key_id="CORALPAY_KEY_FINGERPRINT" ) ``` -------------------------------- ### Encrypt and Send Request with CoralPay SDK Source: https://github.com/beloved23/coralpay/blob/master/README.md Demonstrates how to initialize the CoralPay client, encrypt a transaction message using a public PGP key, and send it to the C'Gate endpoint. ```python message = { "RequestHeader": { "Username": "****", "Password": "******"}, "RequestDetails": { "TerminalId": "*****", "Channel": "USSD", "Amount": 50.0, "MerchantId": "*****", "TransactionType": "0", "SubMerchantName": "******", "TraceID": "" } } # Initiate gpg = CoralPay(homedir='/Users/oluwasemilore/.gnupg', key_id="CORALPAY_FINGERPRINT") data = gpg.coral_encrypt(message, hex=True) URL = "CORALPAY_ENDPOINT" res = gpg.call_coray_pay(URL, data) ``` -------------------------------- ### Execute Complete CoralPay Payment Flow Source: https://context7.com/beloved23/coralpay/llms.txt Demonstrates the end-to-end process of initializing the CoralPay SDK, encrypting a payment request, sending it to the C'Gate endpoint, and decrypting the response. This covers the full lifecycle of a secure USSD transaction. ```python from coralpay_pkg import CoralPay gpg = CoralPay( homedir='/Users/username/.gnupg', key_id="CORALPAY_KEY_FINGERPRINT" ) payment_request = { "RequestHeader": { "Username": "merchant_user", "Password": "secure_password" }, "RequestDetails": { "TerminalId": "TERM001", "Channel": "USSD", "Amount": 250.0, "MerchantId": "MERCH001", "TransactionType": "0", "SubMerchantName": "OnlineStore", "TraceID": "UNIQUE_TRACE_ID_001" } } encrypted_request = gpg.coral_encrypt(payment_request, hex=True) CGATE_ENDPOINT = "https://cgate.coralpay.com/api/payment" encrypted_response = gpg.call_coray_pay(CGATE_ENDPOINT, encrypted_request) decrypted_response = gpg.coral_decrypt( encrypted_response, passphrase="your-private-key-passphrase", always_trust=True, hex=True ) print(f"Payment Response: {decrypted_response}") ``` -------------------------------- ### Encrypt Payment Request Source: https://context7.com/beloved23/coralpay/llms.txt Demonstrates how to encrypt a dictionary-based payment payload into a hex-encoded string using the SDK's encryption method. ```python message = { "RequestHeader": {"Username": "merchant_username", "Password": "merchant_password"}, "RequestDetails": {"TerminalId": "TERM001", "Channel": "USSD", "Amount": 50.0, "MerchantId": "MERCH001", "TransactionType": "0", "SubMerchantName": "MyStore", "TraceID": "TXN123456789"} } encrypted_data = gpg.coral_encrypt(message, hex=True) print(f"Encrypted payload: {encrypted_data}") ``` -------------------------------- ### Decrypt Response with CoralPay SDK Source: https://github.com/beloved23/coralpay/blob/master/README.md Shows how to decrypt an encrypted response string from the C'Gate gateway using a private PGP key and passphrase. ```python data = "85010C0363B256F42F0382020108009EA68E0FECCA50539E34D51ED22232D2C3CD16E7C70CBD928A09EF7FFEE928E47BFC4455E3C83FF7B8BE533A88BAB554246B75C1C94C22073B2EBA392C187F9DEC4B3B10DB9C0272C9969DE96B3E0D6EA70919B80843491E99BEC2D7033FE53DB471838CF3D01FFEBA2F9F12102049C63F1F168BCE7E69C406ED56957841F41102738314A3F23191A768A53CA1DF6A3A063F5E8DE38E1733F4965C028A309242E0391DEB0B27AF79E170E0161D2A405D82BEDDB93A4885C181C4C298F1505F0232A1403EA3BE61009DEB65F6B777778BC238871B196A3BC21033EF0D59BF5EA899379C66D3F39CA93694D26F275090F642F71DFD4D4A8C4C5B2E926220D6BC15C9A3587B91FD054705D4AA026054DDF66923EAB1233C68DE15F97B26E6B0933DB4067B34EA510E22AF25E6FDF78CCEDB99E0785D3A90523948C671687889034F6DCE18809C3683004039DFAB19EFF02CAA6A3AF19AA81F2FB8BAD54D33441904A7CED65D73ACE83F4CB869ABC6534A6949C1962F70046F399EAA1A2209A58921BAD5F86F0BFE5638722BA081462C74E9B1F34D4485A474595D1B62F8E35D0DA2BD4719895D" gpg = CoralPay(homedir='/Users/oluwasemilore/.gnupg', key_id="CORALPAY_FINGERPRINT") coral_response = gpg.coral_decrypt( res, passphrase="the-passphrase-for-your-private-key-here", always_trust=True, hex=True) print(coral_response) ``` -------------------------------- ### Send Encrypted Request to C'Gate Source: https://context7.com/beloved23/coralpay/llms.txt Sends the encrypted payment data to the CoralPay C'Gate endpoint and captures the encrypted response. ```python CGATE_URL = "https://cgate.coralpay.com/api/payment" encrypted_response = gpg.call_coray_pay(CGATE_URL, encrypted_data) print(f"Encrypted response received: {encrypted_response}") ``` -------------------------------- ### Decrypt CoralPay Response Source: https://context7.com/beloved23/coralpay/llms.txt Decrypts an encrypted response from the CoralPay gateway using a private key passphrase. This function requires the encrypted string and a valid passphrase, returning the decrypted payment data. ```python decrypted_response = gpg.coral_decrypt( encrypted_response, passphrase="your-private-key-passphrase", always_trust=True, hex=True ) print(f"Decrypted response: {decrypted_response}") ``` -------------------------------- ### Decrypt C'Gate Response Source: https://context7.com/beloved23/coralpay/llms.txt Decrypts a hex-encoded encrypted response from the C'Gate gateway using the configured private PGP key. ```python decrypted_data = gpg.coral_decrypt(encrypted_response, hex=True, always_trust=True) print(decrypted_data) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.