📜  PHP Create Swiss QR-Bill API - PHP (1)

📅  最后修改于: 2023-12-03 15:33:28.262000             🧑  作者: Mango

PHP Create Swiss QR-Bill API - PHP

Introduction

The Swiss QR-bill is a new payment slip format that was introduced in Switzerland in 2019 to simplify and streamline the payment process. It combines the information necessary for payment and the recipient's account information in one QR code. This makes it easier for customers to make payments, and for businesses to receive payments.

To create Swiss QR-bills for your business, or to integrate Swiss QR-bill creation into your software, you can use the PHP Create Swiss QR-Bill API. This API allows you to generate Swiss QR-bills that comply with the latest Swiss standards.

Requirements

To use the PHP Create Swiss QR-Bill API, you will need the following:

  • PHP version 7.3 or higher
  • PHP XML extension
  • PHP SimpleXML extension
  • Composer (https://getcomposer.org/)
Installation

To install the PHP Create Swiss QR-Bill API, you can use Composer. Simply run the following command in your command line interface:

composer require kingflamez/swiss-qr-bill
Usage

To use the PHP Create Swiss QR-Bill API, you can follow these steps:

  1. Create a new instance of the SwissQrBill\Payment\Payment class.
use SwissQrBill\Payment\Payment;

$bill = new Payment('Customer Name', 'CH4431999123000889012');
  1. Set the bill amount.
$bill->setAmount(100.00);
  1. Set the currency. The default is CHF.
$bill->setCurrency('USD');
  1. Set the bill reference number (if any).
$bill->setReference('123456789012345678901234567');
  1. Set the bill additional information (if any).
$bill->setAdditionalInformation('Monthly Subscription');
  1. Set the creditor information.
$bill->setCreditor(
    'Business Name',
    'CH4431999123000889012',
    'Address',
    'City',
    'CH',
    'John Doe'
);
  1. Set the bill debtor information.
$bill->setDebtor(
    'Customer Name',
    'Address',
    'City',
    'CH'
);
  1. Generate the QR code image.
// Output as raw image data
$imageData = $bill->getQrCodeImage();

// Output as SVG string
$svgString = $bill->getQrCodeSvg();
Conclusion

The PHP Create Swiss QR-Bill API makes it easy to generate Swiss QR-bills for your business or software. By following the steps above, you can create QR-bills that comply with the latest Swiss standards.