This project is an Express.js-based web service designed to generate Apple Wallet Passes that incorporate mobile barcodes compliant with Taiwan's Ministry of Finance regulations. It seamlessly embeds the officially recognized e-invoice carrier into Apple's mobile pass ecosystem.
- Clone the repository:
git clone https://github.com/jiahan-wu/mobile-barcode-pass-server.git
cd mobile-barcode-pass-server
- Install dependencies:
npm ci
- Set up environment variables:
MBP_PORT
: The port number on which the application will run.MBP_APPLE_WWDR_CERTIFICATE
: The Apple Worldwide Developer Relations (WWDR) certificate in PEM format.MBP_CERTIFICATE
: The Apple Wallet Pass certificate in PEM format.MBP_PRIVATE_KEY
: The private key for signing Apple Wallet Passes in PEM format.
- Start the application:
npm start
Here's an example of sending a POST request using cURL to generate an Apple Wallet Pass:
curl -X "POST" "http://localhost/api/mobile-barcode-passes" \
-H 'Content-Type: application/json; charset=utf-8' \
-d $'{ "mobile_barcode": "/RDCSMV2" }'
This request is sent to the /api/mobile-barcode-passes
endpoint and includes a JSON object in the request body with a mobile_barcode
field containing the Ministry of Finance compliant mobile barcode.
On success, the API will directly return a .pkpass file. This file can be added directly to Apple Wallet.
Note
Make sure to replace localhost with your actual server address, and adjust the URL if your service is running on a different port.