Building a Custom Shopify Invoice PDF App with Guest Checkout and Arabic Support

How I developed a custom Shopify app to make PDF invoices accessible to every customer — without requiring an account login, featuring dynamic PDFKit generation, Arabic RTL typography, and HMAC security.
Introduction#
A smooth checkout experience doesn't end when a customer completes an order. Customers also expect to access their invoices easily, whether they have a registered account or checked out as guests.
While working on a Shopify e-commerce project, I encountered an issue with the store's existing invoice solution. Customers who completed checkout as guests couldn't download their PDF invoices directly. The existing app relied on customer verification for secure downloads, which made the invoice download experience unavailable to a large portion of the store's customers.
The store also needed invoices to be automatically delivered through email, along with support for both English and Arabic.
Instead of relying on the limitations of an existing solution, I decided to build a custom Shopify app: a custom Shopify Invoice PDF App.
The goal was simple: make invoice generation and delivery accessible, secure, and convenient for every customer.
The Challenge: Invoice Downloads for Guest Customers#
The existing invoice solution worked for customers who could authenticate through Shopify's customer account system. However, guest customers faced a different experience.
The main challenges were:
- Guest customers couldn't access the PDF invoice download functionality.
- Invoice download links weren't available in order confirmation emails with the existing secure download configuration.
- Customers needed a simple way to download invoices immediately after checkout.
- Store administrators needed access to invoice downloads directly from the Shopify order details.
- The invoice needed to support both English and Arabic, including proper Arabic text rendering.
These requirements made a custom solution more suitable than continuing with the existing invoice application.
The Solution: Custom Shopify Invoice PDF App#
I developed a custom Shopify app with a Node.js backend and Shopify UI extensions.
The application provides four main invoice access points:
1. Invoice Download on the Thank You Page#
After completing checkout, customers can download their PDF invoice directly from the Thank You page.
The functionality is available to both guest customers and registered customers, without requiring an additional login.
2. Invoice Download on the Order Status Page#
Customers can also access their invoices later through the Shopify Order Status page.
This provides a convenient way to retrieve an invoice after leaving the checkout confirmation screen.
3. Automatic Invoice Email#
As soon as an order is created, the application generates its PDF invoice and sends it as an email attachment.
Customers don't need to visit the website or manually request an invoice. The PDF is delivered directly to their email address.
4. Admin Invoice Download#
I also implemented an invoice download option inside the Shopify admin order details.
This allows authorized store staff to retrieve invoices directly from the order management interface.
Technology Stack#
The application was built using the following technologies:
| Technology | Purpose |
|---|---|
| Shopify | E-commerce platform |
| Shopify UI Extensions | Thank You, Order Status and Admin interfaces |
| Node.js | Backend processing |
| Vercel | Serverless backend deployment |
| PDFKit | Dynamic PDF invoice generation |
| Resend | Transactional email delivery |
| Shopify Admin REST API | Order information retrieval |
| Shopify GraphQL Admin API | Product translation retrieval |
| Noto Sans Arabic | Arabic font rendering |
| HMAC-SHA256 | Secure invoice download links |
How the Architecture Works#
The application follows two main workflows: on-demand invoice downloads and automatic invoice email delivery.
On-Demand Invoice Generation#
When a customer requests an invoice:
- The Shopify extension retrieves the relevant order information and requests an invoice link from the backend.
- The backend verifies the Shopify session token.
- After validation, the backend generates a signed, time-limited download URL.
- When the customer opens the link, the backend validates its signature and expiration.
- The application retrieves the order details from Shopify.
- PDFKit generates the invoice dynamically.
- The generated PDF is streamed to the customer as a downloadable file.
This approach avoids storing a separate PDF file for every order.
Automatic Invoice Email Workflow#
For automatic email delivery, I implemented a Shopify order creation webhook (orders/create). The workflow:
- Shopify sends an
orders/createwebhook when a new order is placed. - The backend verifies the webhook using Shopify's HMAC signature.
- The application retrieves the order information.
- PDFKit generates the invoice.
- Resend sends the generated PDF as an email attachment.
- An idempotency mechanism prevents duplicate emails when Shopify retries webhook delivery.
This ensures the email workflow remains reliable even when webhook requests are retried.
Security: Making Guest Invoice Downloads Safe#
One of the important engineering considerations was allowing customers to download invoices without requiring account authentication.
Removing the login requirement should not mean removing access control.
I implemented multiple security measures:
Signed and Expiring Download Links#
Invoice URLs are signed using HMAC-SHA256 with a server-side secret.
Each link has an expiration time, configured to seven days by default. The signature prevents customers from modifying the URL to access another order's invoice.
Guest Order Validation#
For guest customers, the backend applies an additional restriction: the order must have been created within the configured 60-minute window before a download link can be issued.
For registered customers, the customer identity in the verified session must match the order's customer.
Webhook Verification#
Every incoming order creation webhook is verified using Shopify's HMAC signature before processing.
Admin Access Protection#
The admin invoice endpoint accepts verified Shopify admin session tokens and rejects customer or checkout session tokens.
Together, these measures provide controlled invoice access without forcing customers to create an account.
The Most Interesting Challenge: Arabic Text in PDF Generation#
One of the most technically interesting parts of this project was implementing proper Arabic support.
The store serves both English-speaking and Arabic-speaking customers, so the invoice needed to support bilingual content.
However, generating Arabic text in PDFs is not straightforward.
PDFKit doesn't provide complete built-in Arabic right-to-left text shaping and layout support. During initial implementation, Arabic characters appeared in the wrong order, and spacing between words wasn't rendered correctly.
How I Solved It#
I implemented a custom text-layout routine and embedded Noto Sans Arabic fonts into the generated PDF.
The implementation handles:
- Arabic right-to-left text direction.
- English left-to-right text direction.
- Mixed Arabic and English content within the same invoice.
- Arabic-Indic digits.
- Bilingual invoice labels and captions.
- Translated payment status labels.
The custom layout routine processes text word by word, identifies text direction, groups consecutive words with the same direction, and handles the layout accordingly.
This made it possible to generate invoices containing both Arabic and English content within the same PDF.
Handling Product Translations#
Another challenge was retrieving Arabic product names. I integrated Shopify's GraphQL Admin API to retrieve product translations using translatableResourcesByIds.
During testing, I noticed that some automatically translated Arabic product names did not accurately match the original English product names.
Rather than displaying potentially incorrect translations, I introduced a feature flag: SHOW_ARABIC_PRODUCT_NAMES.
It is disabled by default. Once the content team finalizes the Arabic product names, the feature can be enabled without changing the invoice generation architecture.
This was an important lesson: internationalization is not just about supporting multiple languages; translation accuracy matters just as much as technical implementation.
Deployment and Performance Considerations#
The backend was deployed to Vercel using Node.js serverless functions.
Some deployment considerations included:
- Configuring function memory and execution limits.
- Bundling Arabic fonts and other required assets into the serverless functions.
- Using Vercel's
includeFilesconfiguration to ensure PDF generation assets are available at runtime. - Managing environment variables securely.
- Handling unwanted characters such as BOMs and non-breaking spaces in copied environment variable values.
- Adding a smoke test script to verify essential application functionality.
The production deployment was configured with 512 MB memory and a 10-second function execution limit.
Key Engineering Challenges and Lessons Learned#
Working on this project involved more than generating a PDF. Some of the key lessons were:
1. Designing for Guest Checkout
A feature that works for registered customers isn't necessarily suitable for guest customers. The user experience should account for both.
2. Security Without Mandatory Login
Signed URLs, expiration checks, ownership validation, and verified Shopify sessions can provide controlled access without introducing unnecessary login friction.
3. Reliable Webhook Processing
Webhook retries are expected behavior. Idempotency is essential when processing events that trigger actions such as sending emails.
4. Arabic PDF Rendering
Supporting right-to-left languages in PDFs requires more than embedding a font. Text direction, shaping, word grouping, and mixed-language layout must also be considered.
5. Feature Flags for Translation Quality
Machine-generated translations should not automatically be treated as production-ready content. Feature flags provide flexibility while content is reviewed and finalized.
Final Thoughts#
Building this custom Shopify invoice PDF app was a valuable opportunity to solve a practical e-commerce problem through custom Shopify development.
The project combined Shopify UI extensions, Node.js serverless architecture, dynamic PDF generation, transactional email integration, secure download mechanisms, and bilingual document rendering.
Most importantly, it improved invoice accessibility by allowing both guest and registered customers to receive and download their invoices without unnecessary login steps.
This project reinforced an important principle in software development: the best solution isn't always adding another feature to an existing tool. Sometimes, it's understanding the actual business problem and building a solution around it.
Project: Custom Shopify Invoice PDF Application
Role: Full-Stack Developer
Platform: Shopify (UI Extensions, Admin REST & GraphQL APIs)
Backend: Node.js Serverless (Vercel), PDFKit, Resend Email
Key Focus: Guest Checkout Access, HMAC-SHA256 Tokenization, Bilingual Arabic/English PDF Layout

