Skip to main content

This library purpose is helper for dinger payment encryption

Project description

Dinger Prebuild Checkout From for generate URL

Usage

Encryption

import json
from urllib.parse import urlencode, quote_plus

from dinger_payment import get_prebuild_form_url

if __name__ == '__main__':
    items = [
        {"name": "DiorAct Sandal", "amount": 250, "quantity": 1},
        {"name": "Aime Leon Dore", "amount": 250, "quantity": 1},
    ]
    data = {
        # items must be string
        "items": json.dumps(items),
        "customerName": "James",
        "totalAmount": 500,
        "merchantOrderId": "123456",
        # get from checkout-form page
        "clientId": "xxxx",
        # get from data-dashboard page
        "publicKey": "xxxx",
        # get from data-dashboard page
        "merchantKey": "xxxx",
        # your project name
        "projectName": "xxxx",
        # your account username
        "merchantName": "xxxx",
    }
    secretkey = "xxxx"
    public_key = "-----BEGIN PUBLIC KEY-----\n"
                 + "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCFD4IL1suUt/TsJu6zScnvsEdLPuACgBdjX82QQf8NQlFHu2v/84dztaJEyljv3TGPuEgUftpC9OEOuEG29z7z1uOw7c9T/luRhgRrkH7AwOj4U1+eK3T1R+8LVYATtPCkqAAiomkTU+aC5Y2vfMInZMgjX0DdKMctUur8tQtvkwIDAQAB"
                 + "\n-----END PUBLIC KEY-----"
    encrypted_payload, hash_value = get_prebuild_form_url(public_key=public_key, secretkey=secretkey, **data)
    host = "form.dinger.asia"  # for production
    # host = "prebuilt.dinger.asia" # for staging
    url = f"https://{host}?{urlencode({'payload': encrypted_payload, 'hashValue': hash_value}, quote_via=quote_plus)}"
    print(url)

Decryption

    from dinger_payment import decrypt_aes_ecb
    data = {'paymentResult': 'xxxx',
            'checksum': 'xxxx'}
    merchant_callback_key = "xxxx"
    
    # Example usage
    secret_key = callback_key  # Must be 32 characters or will be padded
    encrypted_data = data['paymentResult']  # Replace with actual encrypted data
    
    decrypted_value = decrypt_aes_ecb(encrypted_data, secret_key)
    print(decrypted_value)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dinger_payment-2.0.7.tar.gz (5.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dinger_payment-2.0.7-py3-none-any.whl (3.8 kB view details)

Uploaded Python 3

File details

Details for the file dinger_payment-2.0.7.tar.gz.

File metadata

  • Download URL: dinger_payment-2.0.7.tar.gz
  • Upload date:
  • Size: 5.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.1

File hashes

Hashes for dinger_payment-2.0.7.tar.gz
Algorithm Hash digest
SHA256 f0d980382f6f061321d54c1731dc66054b906bdf096915fccac1471623f08859
MD5 009297a0b81bdb678b186d880415aa71
BLAKE2b-256 e9f091c6ae01a3d0c670894e1acc32cefeafe02af2af31db12ec5a499b16ffad

See more details on using hashes here.

File details

Details for the file dinger_payment-2.0.7-py3-none-any.whl.

File metadata

File hashes

Hashes for dinger_payment-2.0.7-py3-none-any.whl
Algorithm Hash digest
SHA256 aa8b4b9d4bc5fb8aa0cb836d4b677d68e3615227220ece826fac742dd043ce79
MD5 47eea2b2d52bf5aba938330851e8a211
BLAKE2b-256 e0858fc2465b5e727308cbcdcae6a944e483f277c88e1c7d012a50e347ebec75

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page