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.8.tar.gz (6.1 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.8-py3-none-any.whl (3.9 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for dinger_payment-2.0.8.tar.gz
Algorithm Hash digest
SHA256 73ad99d413f69c2df5433bbc1edba6dd32c3d53d13a267b1ff29a68e14e707ee
MD5 0c3799d06254fc145c4f91bd8059b765
BLAKE2b-256 35e02d41a4c66f3066d9c94c769b4e507667b4faa2e0bbf055ace04868777d17

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for dinger_payment-2.0.8-py3-none-any.whl
Algorithm Hash digest
SHA256 71d4011c2a0d443af06cb135f701a67e420d6cb542d2e9121a948fec31800f80
MD5 816725e2a21a16731b0707e8da7aeacf
BLAKE2b-256 a933c6d39ec5b4fa269d401d4094b4ef6511c9671c084f654028bab7a9a5048c

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