### Java Payment Processing and QR Code Generation Source: https://context7.com/jomu78/epc-qr/llms.txt Demonstrates the complete workflow for generating SEPA payment QR codes. It covers creating payment data using `EpcBuilder`, validating it, and generating QR codes as base64 strings for web use or PNG files for printing. Includes error handling for `EpcException` and processes sample payments. ```java import de.muehlencord.epcqr.*; import de.muehlencord.epcqr.model.Currency; import java.math.BigDecimal; public class PaymentProcessor { public static void processPayment(String recipient, String iban, double amount, String purpose) { try { // Step 1: Create and configure payment data EpcBuilder paymentBuilder = new EpcBuilder() .withCurrency(Currency.EUR) .withRecipient(recipient) .withIban(iban) .withPaymentAmount(BigDecimal.valueOf(amount)) .withPurposeText(purpose) .withNote("Generated via API"); // Step 2: Validate by building EPC string String epcData = paymentBuilder.build(); System.out.println("EPC Data:\n" + epcData); // Step 3: Generate base64 QR code for web display Base64ImageGenerator webGenerator = new Base64ImageGenerator() .withWidth(300) .withHeight(300); String base64Qr = webGenerator.generate(paymentBuilder); System.out.println("\nBase64 QR (length): " + base64Qr.length()); // Step 4: Generate file-based QR code for printing ImageFileGenerator fileGenerator = new ImageFileGenerator() .withOutputFile("/tmp/payment_qr.png") .withWidth(600) .withHeight(600); String filePath = fileGenerator.generate(paymentBuilder); System.out.println("QR code file saved: " + filePath); // Step 5: Return results System.out.println("\nPayment QR code generated successfully!"); } catch (EpcException e) { System.err.println("Payment processing failed: " + e.getMessage()); e.printStackTrace(); } } public static void main(String[] args) { // Process a sample payment processPayment( "TechCorp Solutions GmbH", "DE89370400440532013000", 1599.99, "Software License Annual Subscription" ); // Process multiple payments String[][] payments = { {"Customer A", "AT611904300234573201", "250.00", "Invoice INV-001"}, {"Customer B", "CH9300762011623852957", "750.50", "Invoice INV-002"} }; for (String[] payment : payments) { processPayment(payment[0], payment[1], Double.parseDouble(payment[2]), payment[3]); } } } ``` -------------------------------- ### Maven Dependency for EPC QR Library Source: https://context7.com/jomu78/epc-qr/llms.txt Specifies the Maven dependency required to include the EPC QR code generator library in your project. This configuration should be added to the `` section of your `pom.xml` file. ```xml de.muehlencord.epcqr epc-qr 1.1.3 org.apache.maven.plugins maven-compiler-plugin 3.11.0 17 17 ``` -------------------------------- ### Build EPC Payment Data with EpcBuilder in Java Source: https://context7.com/jomu78/epc-qr/llms.txt Demonstrates how to construct EPC payment data using the EpcBuilder fluent API. It covers basic and advanced configurations, including recipient details, IBAN, amount, purpose, and optional fields like BIC. Input includes payment details, and output is the formatted EPC data string. Requires the epc-qr library. ```java import de.muehlencord.epcqr.EpcBuilder; import de.muehlencord.epcqr.EpcException; import de.muehlencord.epcqr.model.Currency; import de.muehlencord.epcqr.model.Version; import java.math.BigDecimal; try { // Basic payment with required fields EpcBuilder builder = new EpcBuilder() .withRecipient("Max Mustermann") .withIban("GB33BUKB20201555555555") .withPaymentAmount(48.81) .withPurposeText("Invoice 2024-001"); // Advanced configuration with all options EpcBuilder advancedBuilder = new EpcBuilder() .withVersion(Version.V002) .withCurrency(Currency.EUR) .withRecipient("Tech Solutions GmbH") .withIban("DE89370400440532013000") .withBic("COBADEFFXXX") // Optional for Version 2 .withPaymentAmount(new BigDecimal("1250.50")) .withPurposeText("Software license renewal") .withNote("Reference: LIC-2024-Q1"); // Build the EPC string String epcData = builder.build(); System.out.println(epcData); } catch (EpcException e) { System.err.println("Failed to build EPC data: " + e.getMessage()); } ``` -------------------------------- ### Maven Dependency for epc-qr (XML) Source: https://github.com/jomu78/epc-qr/blob/develop/README.md Provides the Maven dependency information required to include the epc-qr library in a Java project. This allows developers to use the library's functionality for generating EPC QR codes. ```xml de.muehlencord.epcqr epc-qr 1.1.3 ``` -------------------------------- ### Generate EPC QR Code as Base64 Image (Java) Source: https://github.com/jomu78/epc-qr/blob/develop/README.md Demonstrates how to use the EpcBuilder to specify payment details and then generate the EPC QR code as a base64 encoded image using Base64ImageGenerator. Requires the epc-qr library. ```java // specify data of the epc code var builder = new EpcBuilder() .withRecipient("Max Mustermann") .withIban("GB33BUKB20201555555555") .withPaymentAmount(48.81D) .withPurposeText("Test"); // get the epc-qr code as hase64 encoded image String base64 = new Base64ImageGenerator().generate(builder); ``` -------------------------------- ### Generate QR Code Image Files with Java Source: https://context7.com/jomu78/epc-qr/llms.txt Creates QR code images and saves them to the filesystem using ImageFileGenerator. Supports both default temporary directory storage and custom file paths with configurable dimensions. Requires epc-qr library dependencies and properly configured EpcBuilder payment data. ```java import de.muehlencord.epcqr.ImageFileGenerator; import de.muehlencord.epcqr.EpcBuilder; import de.muehlencord.epcqr.EpcException; import java.nio.file.Paths; try { // Build payment data EpcBuilder builder = new EpcBuilder() .withRecipient("Business Partners Ltd") .withIban("CH9300762011623852957") .withPaymentAmount(5000.00) .withPurposeText("Contract payment Q1 2024"); // Generate QR code and save to default location (temp directory) ImageFileGenerator defaultGenerator = new ImageFileGenerator(); String defaultFilePath = defaultGenerator.generate(builder); System.out.println("QR code saved to: " + defaultFilePath); // Generate with custom output path and size ImageFileGenerator customGenerator = new ImageFileGenerator() .withOutputFile("/home/user/payments/qr_payment_001.png") .withWidth(400) .withHeight(400); String customFilePath = customGenerator.generate(builder); // Verify file exists boolean exists = Paths.get(customFilePath).toFile().exists(); System.out.println("File created successfully: " + exists); } catch (EpcException e) { System.err.println("Failed to create QR code file: " + e.getMessage()); } ``` -------------------------------- ### Configure EPC QR Code Versions and Encodings with Java Source: https://context7.com/jomu78/epc-qr/llms.txt Demonstrates how to configure different EPC QR code specification versions and character encodings. Version 1 requires BIC codes while Version 2 makes them optional for SEPA transfers. Supports custom encodings like ISO-8859-1 for special characters. Requires proper epc-qr library imports for Version and Encoding enums. ```java import de.muehlencord.epcqr.EpcBuilder; import de.muehlencord.epcqr.EpcException; import de.muehlencord.epcqr.model.Version; import de.muehlencord.epcqr.model.Encoding; try { // Using Version 1 (requires BIC) EpcBuilder v1Builder = new EpcBuilder() .withVersion(Version.V001) .withBic("COBADEFFXXX") // Mandatory for V001 .withRecipient("Maria Garcia") .withIban("ES9121000418450200051332") .withPaymentAmount(250.00) .withPurposeText("Service payment"); // Using Version 2 with custom encoding EpcBuilder v2Builder = new EpcBuilder() .withVersion(Version.V002) .withEncoding(Encoding.ISO_8859_1) .withRecipient("François Dubois") .withIban("FR1420041010050500013M02606") .withPaymentAmount(150.75) .withPurposeText("Consultation fee"); // Version can also be set by string label EpcBuilder stringVersionBuilder = new EpcBuilder() .withVersion("002") .withRecipient("Test Recipient") .withIban("NL91ABNA0417164300") .withPaymentAmount(75.00) .withPurposeText("Test payment"); String epcString = v1Builder.build(); } catch (EpcException e) { System.err.println("Configuration error: " + e.getMessage()); } ``` -------------------------------- ### Generate Base64 QR Codes for EPC Payments in Java Source: https://context7.com/jomu78/epc-qr/llms.txt Illustrates generating QR code images as base64-encoded strings using Base64ImageGenerator. This is useful for web embedding and API transmission. It takes EpcBuilder-generated payment data as input and outputs a base64 string representing a PNG QR code. Custom dimensions can be set. Requires the epc-qr library. ```java import de.muehlencord.epcqr.Base64ImageGenerator; import de.muehlencord.epcqr.EpcBuilder; import de.muehlencord.epcqr.EpcException; try { // Build payment data EpcBuilder builder = new EpcBuilder() .withRecipient("Anna Schmidt") .withIban("AT611904300234573201") .withPaymentAmount(99.99) .withPurposeText("Membership fee 2024"); // Generate base64 QR code with default settings (300x300px PNG) Base64ImageGenerator generator = new Base64ImageGenerator(); String base64Image = generator.generate(builder); // Custom size QR code Base64ImageGenerator customGenerator = new Base64ImageGenerator() .withWidth(500) .withHeight(500); String largeBase64Image = customGenerator.generate(builder); // Use in HTML String htmlImg = "Payment QR Code"; System.out.println("Generated base64 image with length: " + base64Image.length()); } catch (EpcException e) { System.err.println("QR code generation failed: " + e.getMessage()); } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.