{"id":8771,"library":"wallet-py3k","title":"wallet-py3k (Apple Passbook Generator)","description":"wallet-py3k is a Python 3 library designed to generate Apple Wallet (.pkpass) files. It is a fork of the `devartis/passbook` library, specifically updated to support Python 3. The library enables programmatic creation of various pass types by assembling content, signing with required Apple certificates, and packaging them into the `.pkpass` format. The last release (0.0.4) was in December 2018, indicating the library is no longer actively maintained.","status":"abandoned","version":"0.0.4","language":"en","source_language":"en","source_url":"https://github.com/oeegor/wallet-py3k","tags":["apple wallet","passbook","pkpass","mobile wallet","certificates"],"install":[{"cmd":"pip install wallet-py3k","lang":"bash","label":"Install with pip"}],"dependencies":[],"imports":[{"note":"Directly importing 'wallet' does not expose the necessary models. Always import specific classes from `wallet.models`.","wrong":"import wallet","symbol":"Pass, Barcode, StoreCard","correct":"from wallet.models import Pass, Barcode, StoreCard"}],"quickstart":{"code":"import os\nfrom wallet.models import Pass, Barcode, StoreCard\n\n# --- Prerequisites: Generate .pem files from your Apple Pass Type ID certificate ---\n# 1. Obtain a Pass Type ID certificate from Apple's developer portal (.p12).\n# 2. Convert it to .pem files using OpenSSL (replace \"Certificates.p12\" with your file):\n#    openssl pkcs12 -in \"Certificates.p12\" -clcerts -nokeys -out certificate.pem\n#    openssl pkcs12 -in \"Certificates.p12\" -nocerts -out key.pem -passout pass:YOUR_KEY_PASSWORD\n# 3. Download the Apple Worldwide Developer Relations Certification Authority (WWDR) certificate\n#    from Apple's website (http://developer.apple.com/certificationauthority/AppleWWDRCA.cer)\n#    and convert it to .pem (e.g., wwdr.pem).\n\n# Ensure these files exist in your working directory or provide full paths.\ncertificate_path = 'certificate.pem'\nkey_path = 'key.pem'\nwwdr_path = 'wwdr.pem'\nkey_password = os.environ.get('WALLET_KEY_PASSWORD', 'YOUR_KEY_PASSWORD') # Replace with your actual key password or use env var\n\n# Define pass details\norganization_name = 'Your Organization'\npass_type_identifier = 'pass.com.your.organization'\nteam_identifier = 'AGK5BZEN3E' # Replace with your Apple Team ID\n\n# Create card information\ncard_info = StoreCard()\ncard_info.addPrimaryField('name', 'John Doe', 'Name')\ncard_info.addAuxiliaryField('member_id', '12345', 'Member ID')\n\n# Create the Pass object\npassfile = Pass(card_info,\n                passTypeIdentifier=pass_type_identifier,\n                organizationName=organization_name,\n                teamIdentifier=team_identifier)\n\npassfile.serialNumber = '1234567'\npassfile.barcode = Barcode(message='Barcode message content', format='PKBarcodeFormatQR')\n\n# Add required assets (icon and logo are mandatory for a valid pass)\n# Ensure 'images/icon.png' and 'images/logo.png' exist relative to your script\ntry:\n    with open('images/icon.png', 'rb') as f_icon:\n        passfile.addFile('icon.png', f_icon)\n    with open('images/logo.png', 'rb') as f_logo:\n        passfile.addFile('logo.png', f_logo)\nexcept FileNotFoundError:\n    print(\"Error: icon.png or logo.png not found. Please create 'images/' directory and place the files.\")\n    exit(1)\n\noutput_filename = 'test.pkpass'\n\n# Create and output the Passbook file\ntry:\n    passfile.create(\n        certificate_path, \n        key_path, \n        wwdr_path, \n        key_password, \n        output_filename\n    )\n    print(f\"Successfully created {output_filename}\")\nexcept Exception as e:\n    print(f\"Error creating pass: {e}\")\n    print(\"Ensure your .pem files are correct and the key_password is accurate.\")\n","lang":"python","description":"This quickstart demonstrates how to create a simple StoreCard pass. It requires pre-generated `.pem` certificate files and `wwdr.pem`, along with `icon.png` and `logo.png` image assets. The `create` method then generates the `.pkpass` file."},"warnings":[{"fix":"Thoroughly test generated passes on current iOS devices. Consider alternative, actively maintained libraries or direct Apple PassKit API interaction if full compatibility is critical.","message":"The library has not been updated since December 2018 and is effectively abandoned. Apple's PassKit requirements and APIs may have evolved, potentially rendering passes generated by this library invalid or incompatible with modern Apple Wallet versions or iOS versions.","severity":"breaking","affected_versions":"0.0.4 and earlier"},{"fix":"Carefully follow the `openssl` commands provided in the quickstart or similar documentation to generate `certificate.pem`, `key.pem`, and `wwdr.pem`. Ensure the `key.pem` is generated with a password, and this password is correctly supplied to the `passfile.create` method.","message":"Generating valid `.pem` certificate files from your Apple Developer account `.p12` file is a complex and error-prone process involving `openssl` commands. Incorrectly formatted or expired certificates will lead to pass creation failures.","severity":"gotcha","affected_versions":"All"},{"fix":"When running `openssl pkcs12 -in \"Certificates.p12\" -nocerts -out key.pem`, ensure you set a strong password. Then, pass this exact password to the `passfile.create` method via the `key_password` argument.","message":"The `key.pem` file, generated from your `.p12` certificate, *must* be secured with a password during its creation via `openssl`. Failing to provide a password when prompted by `openssl` will result in an unusable key and subsequent errors during pass signing.","severity":"gotcha","affected_versions":"All"},{"fix":"Always include `icon.png` (29x29pt @1x, @2x, @3x) and `logo.png` (160x50pt @1x, @2x, @3x) using `passfile.addFile('icon.png', open('path/to/icon.png', 'rb'))` and similarly for `logo.png`.","message":"Apple Wallet passes strictly require `icon.png` and `logo.png` files to be included within the pass bundle to be considered valid. Omission of these files will cause the pass to fail validation or display correctly.","severity":"gotcha","affected_versions":"All"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Ensure that the `zip` utility is installed and available in your system's PATH. On Debian/Ubuntu: `sudo apt-get install zip`. On macOS: `zip` is usually pre-installed. For Windows, you might need to install a `zip` utility or a WSL environment.","cause":"This error usually indicates that the `zip` command-line utility, which `wallet-py3k` uses internally, is not found or not executable in the environment where the Python script is run.","error":"Error creating pass: Command '['/usr/bin/zip', '--version']' returned non-zero exit status 1."},{"fix":"Double-check the password passed to `passfile.create`. Verify that `key.pem` was generated with the correct `openssl` command and that you provided a password when it was created. Regenerate `key.pem` and `certificate.pem` if necessary, ensuring to set a password for the key.","cause":"This error typically means the password provided for the `key.pem` file is incorrect or the `key.pem` itself is corrupted/invalid. This is a common issue during the `passfile.create` step.","error":"Error creating pass: [SSL: BAD_DECRYPT] bad decrypt (_ssl.c:2722)"},{"fix":"Ensure that the `icon.png` and `logo.png` files exist in the location specified in your `passfile.addFile` calls. If they are in a subdirectory (e.g., 'images/'), make sure that subdirectory exists and contains the files.","cause":"The `addFile` method for `icon.png` or `logo.png` failed because the specified image file could not be found at the given path.","error":"Error creating pass: [Errno 2] No such file or directory: 'icon.png'"},{"fix":"Always import specific classes from `wallet.models` using `from wallet.models import Pass, Barcode, StoreCard`.","cause":"This happens when you try to import `wallet` directly and then access `wallet.models`. The `models` submodule is not directly exposed this way.","error":"AttributeError: module 'wallet' has no attribute 'models'"}]}