定制 kayon-ariel/pix-php 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

kayon-ariel/pix-php

最新稳定版本:v1.0.2

Composer 安装命令:

composer require kayon-ariel/pix-php

包简介

Library to generate Static PIX codes in PHP

README 文档

README

A PHP library to generate static PIX codes, facilitating online payments with PIX copy and paste.

PHP Version License Packagist Downloads

Table of Contents

Installation

You can install the library via Composer. Run the following command:

composer require kayon-ariel/pix-php

Usage

Step 1: Include the Autoloader

Once installed, include the Composer autoloader in your PHP script:

require 'vendor/autoload.php';

Step 2: Import the Namespace

Import the PixPhp namespace at the beginning of your PHP file:

use PixPhp\StaticPix;

Step 3: Generate a PIX Code

You can generate a PIX code using the generatePix method. Here's a basic example:

// Generate a PIX code
$pixCode = StaticPix::generatePix('your-pix-key', 'Transaction-ID', 100.00, 'Payment description');

// Display the generated PIX code
echo $pixCode;

Accepted Key Types

In the PixPhp library, the following types of keys are accepted for generating PIX codes:

  1. CPF (Cadastro de Pessoas Físicas)

    • Format: 123.456.789-09
    • Description: A Brazilian individual taxpayer identification number. The library accepts CPF numbers with or without formatting.
  2. CNPJ (Cadastro Nacional da Pessoa Jurídica)

    • Format: 12.345.678/0001-95
    • Description: A Brazilian business taxpayer identification number. The library accepts CNPJ numbers with or without formatting.
  3. Email

    • Format: example@test.com
    • Description: A valid email address. The library accepts well-formed email addresses as PIX keys.
  4. Phone

    • Format: +55 11 91234-5678
    • Description: A Brazilian phone number including the country code. The library accepts phone numbers with various formatting styles, including spaces and dashes, while retaining the +55 prefix.
  5. Random Key

    • Format: 617ef6be-e18e-427f-919b-6e43bae33400
    • Description: The Pix random key is a 32-character alphanumeric code, randomly generated by the Central Bank to be linked to a single account.

Example Usage

You can pass any of the accepted key types to the generatePix method:

// Using CPF
$pixCodeCpf = StaticPix::generatePix("123.456.789-09", "ID123", 100.00);

// Using CNPJ
$pixCodeCnpj = StaticPix::generatePix("12.345.678/0001-95", "ID456", 250.50);

// Using Email
$pixCodeEmail = StaticPix::generatePix("example@test.com", "ID789", 50.00);

// Using Phone
$pixCodePhone = StaticPix::generatePix("+55 11 91234-5678", "ID101", 75.00);

// Using Random Key
$pixCodeRandom = StaticPix::generatePix("617ef6be-e18e-427f-919b-6e43bae33400", "ID102", 30.00);

统计信息

  • 总下载量: 683
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 20
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 19
  • Watchers: 2
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-10-09