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.6.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.6-py3-none-any.whl (3.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: dinger_payment-2.0.6.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.6.tar.gz
Algorithm Hash digest
SHA256 5a19636da36eab715fef79017af7104a00a0fffbbb3aa986742506904b14c409
MD5 e9b8ae0c76fdbaf5317c5e773f85e9e5
BLAKE2b-256 c529c55c4f632629bea9d2c5183b27c51a6052621747d4222e0b67066de9c435

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for dinger_payment-2.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 41c757858441167d0f29ad3c8f492540cfe9cb16b38b8ecff0169627173aa48e
MD5 0a53d73cbbe469c87f9b79d585db1af9
BLAKE2b-256 ef75030fb0e0cde8f5b4abed540578727991f1718180553558899fda76c4eaba

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