Applepay
a Python library for decrypting Apple Pay payment tokens.
Install / Use
/learn @halturin/ApplepayREADME
A Python library for decrypting Apple Pay payment tokens.
ApplePay reference https://developer.apple.com/library/ios/documentation/PassKit/Reference/PaymentTokenJSON/PaymentTokenJSON.html
Apple's intermediate and root certificates
$ wget 'https://www.apple.com/certificateauthority/AppleAAICAG3.cer'
$ wget 'https://www.apple.com/certificateauthority/AppleRootCA-G3.cer'
Install
Installing library into your environment:
$ pip install applepay
Usage
Step by step:
from applepay import payment as apple
# payment_json value example:
#
# {"data":"<<Base64EncodedData>>",
# "header":
# {"publicKeyHash":"<<Base64EncodedData>>",
# "ephemeralPublicKey":"<<Base64EncodedData>>",
# "transactionId":"<<HexifiedData>>"},
# "version":"EC_v1"}
certificate_pem = open('merchant_cert.pem', 'rb').read()
private_key_pem = open('merchant_private_key', 'rb').read()
payment = apple.Payment(certificate_pem, private_key_pem)
decrypted_json = payment.decrypt(payment_json['header']['ephemeralPublicKey'], payment_json['data'])
# decrypted_json value example
# {
# "applicationPrimaryAccountNumber"=>"4804123456789012",
# "applicationExpirationDate"=>"190123",
# "currencyCode"=>"123",
# "transactionAmount"=>700,
# "deviceManufacturerIdentifier"=>"123456789012",
# "paymentDataType"=>"3DSecure",
# "paymentData"=> {
# "onlinePaymentCryptogram"=>"<<Base64EncodedData>>",
# "eciIndicator"=>"5"
# }
# }
Testing
$ python setup.py test
Contributors
Related Skills
node-connect
345.4kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
claude-opus-4-5-migration
104.6kMigrate prompts and code from Claude Sonnet 4.0, Sonnet 4.5, or Opus 4.1 to Opus 4.5
frontend-design
104.6kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
model-usage
345.4kUse CodexBar CLI local cost usage to summarize per-model usage for Codex or Claude, including the current (most recent) model or a full model breakdown. Trigger when asked for model-level usage/cost data from codexbar, or when you need a scriptable per-model summary from codexbar cost JSON.
