PHPackages                             yfancc20/pay2go-einvoice - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Payment Processing](/categories/payments)
4. /
5. yfancc20/pay2go-einvoice

ActiveLibrary[Payment Processing](/categories/payments)

yfancc20/pay2go-einvoice
========================

A library of connecting Pay2go's invoice service.

4121PHP

Since Feb 20Pushed 6y ago1 watchersCompare

[ Source](https://github.com/yfancc20/Pay2go-eInvoice)[ Packagist](https://packagist.org/packages/yfancc20/pay2go-einvoice)[ RSS](/packages/yfancc20-pay2go-einvoice/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependenciesVersions (1)Used By (0)

Pay2go-eInvoice （智付寶 Pay2go 電子發票）
=================================

[](#pay2go-einvoice-智付寶-pay2go-電子發票)

A library of connecting Pay2go's invoice service.

Notice
------

[](#notice)

This project has been moved to [here](https://packagist.org/packages/treerful/pay2go-invoice)

Getting Started
---------------

[](#getting-started)

此 Package 共實作了四種發票 API 操作，分別為「開立」、「折讓」、「作廢」、「查詢」，並將結果以 Array 傳回。

- [開立發票](#create)
- [折讓發票](#allow)
- [作廢發票](#void)
- [查詢發票](#search)

Install
-------

[](#install)

1. Install from composer:

```
composer require yfancc20/pay2go-einvoice:dev-master

```

2. Copy the config file (2 methods):

(a) In `config/app.php`,

```
    'providers' => [
        /*
         * Laravel Framework Service Providers...
         */
        Illuminate\Auth\AuthServiceProvider::class,
        Illuminate\Broadcasting\BroadcastServiceProvider::class,
        ...
        ...
        Yfancc20\Pay2goInvoice\Pay2goInvoiceServiceProvider::class,

```

After adding the ServiceProvider, publish the config file.

```
php artisan vendor:publish

```

(b) Because the proivder is only for publishing the config, you can also copy it manually without adding the provider.

```
cp vendor/yfancc20/pay2go-einvoice/config/pay2goinv.php config/pay2goinv.php

```

*Remember that the filename `pay2goinv.php` should not be changed!*

Usage
-----

[](#usage)

### 引用、初始化類別：

[](#引用初始化類別)

```
use Yfancc20\Pay2goInvoice\Invoice;

```

### 開立發票：

[](#開立發票)

開立發票共有三種模式，分別為 B2C, 捐贈, B2B。 本 Package 使用欄位 *BuyerType* （非智付寶官方提供欄位）做區分，此欄位為必填。

1. B2C (BuyerType = 0)

```
$data = [
    'BuyerType' => '0', // B2C
    'MerchantOrderNo' => ,
    'BuyerName' => ,
    'CarrierType' => , // 0:手機條碼, 1:自然人憑證條碼載具 2:智付寶載具
    'CarrierNum' => ,
    'ItemPrice' => ,
    'ItemName' => ,
    'ItemUnit' => ,
];

```

2. 捐贈 (BuyerType = 1)

```
// 捐贈
$data = [
    'BuyerType' => '1',
    'MerchantOrderNo' => ,
    'BuyerName' => ,
    'LoveCode' => ,
    'ItemPrice' => ,
    'ItemName' => ,
    'ItemUnit' => ,
];

```

3. B2B（BuyerType = 2）

```
// B2B
$data = [
    'BuyerType' => '2', // B2B
    'MerchantOrderNo' => ,
    'BuyerName' => ,
    'BuyerUBN' => ,
    'ItemPrice' => ,
    'ItemName' => ,
    'ItemUnit' => ,
];

```

呼叫函式

```
$invoice = new Invoice();
$result = $invoice->create(data);

```

*\[補充\]*

- 除了上述欄位外，可參考官方API提供其他需要的欄位，例如：*BuyerAddress*(買受人地址), *BuyerEmail*(買受人信箱), *Comment*(發票備註)。
- 商品數量預設為 1。
- 商品單位若不設置，預設為「個」。

### 折讓發票：

[](#折讓發票)

```
$data = [
    'InvoiceNo' => ,
    'MerchantOrderNo' => ,
    'ItemName' => ,
    'ItemUnit' => ,
    'TotalAmt' => ,
    'BuyerEmail' => , // 可不填，若填寫則智付寶將寄信通知買受人。
];

$invoice = new Invoice();
$result = $invoice->allow($data);

```

*\[補充\]*

- 商品數量預設為 1。
- 商品單位若不設置，預設為「個」。

### 作廢發票：

[](#作廢發票)

```
$data = [
    'InvoiceNumber' => ,
    'InvalidReason' => ,
];
$invoice = new Invoice();
$result = $invoice->void($data);

```

### 查詢發票：

[](#查詢發票)

查詢發票的回傳結果有兩種顯示方式，一為直接回傳資料，二為以Post Form的方式導向智付寶發票頁面，可在 `config/pay2goinv.php` 中設定 `DisplayFlag` 的值。

```
// 直接回傳資料
// 'DisplayFlag' => '',

// 導向智付寶發票頁面
// 'DisplayFlag' => '1',

```

查詢發票的查詢方式亦有兩種，一為發票金額＆隨機碼，二為自訂商品編號與總金額，可在 `config/pay2goinv.php` 中設定 `SearchType` 的值。

```
// 發票金額&隨機碼
// 'SearchType' => '0'
// 商品編號&總金額
// 'SearchType' => '1'

```

根據上述兩種方式：

```
// When SearchType is 0

```

$data = \[ 'InvoiceNumber' =&gt; &lt;發票號碼&gt;, 'RandomNum' =&gt; &lt;隨機碼&gt;, \];

```
// When SearchType is 1
$data = [
    'MerchantOrderNo' => ,
    'TotalAmt' => ,
];

$invoice = new Invoice();
$result = $invoice->search($data);

```

### Notes

[](#notes)

- 以上的 `$data` 可接受 Object or Array 兩種型態。
- 除了上述欄位外，其他欄位請參考 [智付寶API](https://inv.pay2go.com/Invoice_index/download)，並自行在`$data`中新增參數即可

Other Usage:
------------

[](#other-usage)

- 當呼叫過四個函式其中一個後，除了原本回傳的結果外，亦可使用 `getPostData()` 取得類別中實際送出的資料。

```
// Example: (This will get nothing.)
$invoice = new Invoice();
$result = $invoice->getPostData();

// Example: (Cont. This will get the original data you posted to Pay2go.)
$invoice = new Invoice();
$invoice->create($data);
$postData = $invoice->getPostData();

```

- 當呼叫過四個函式其中一個後，除了原本回傳的結果外，亦可使用 `getRawResult()` 取得API呼叫結果後的原始資料。

```
// Example: (This will get nothing.)
$invoice = new Invoice();
$result = $invoice->getRawResult();

// Example: (This will get the raw data you got from Pay2go.)
$invoice = new Invoice();
$invoice->create($data);
$rawResult = $invoice->getRawResult();

```

Authors
-------

[](#authors)

- **Yifan Wu** - *Initial work* - [Github](https://github.com/yfancc20)

Official Reference
------------------

[](#official-reference)

[Pay2go E-Invoice API](https://inv.pay2go.com/Invoice_index/download)

###  Health Score

20

—

LowBetter than 14% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity34

Early-stage or recently created project

 Bus Factor1

Top contributor holds 95.5% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/5ec54741a10e8fdc135ecf083f3cbdc3f21bfcca01de77cfa24c64fd18949ca7?d=identicon)[yfancc20](/maintainers/yfancc20)

---

Top Contributors

[![yfancc20](https://avatars.githubusercontent.com/u/18461272?v=4)](https://github.com/yfancc20 "yfancc20 (21 commits)")[![g8787856](https://avatars.githubusercontent.com/u/28570542?v=4)](https://github.com/g8787856 "g8787856 (1 commits)")

### Embed Badge

![Health badge](/badges/yfancc20-pay2go-einvoice/health.svg)

```
[![Health](https://phpackages.com/badges/yfancc20-pay2go-einvoice/health.svg)](https://phpackages.com/packages/yfancc20-pay2go-einvoice)
```

###  Alternatives

[omnipay/paypal

PayPal gateway for Omnipay payment processing library

3156.8M53](/packages/omnipay-paypal)[eduardokum/laravel-boleto

Biblioteca com boletos para o laravel

626351.9k2](/packages/eduardokum-laravel-boleto)[tbbc/money-bundle

This is a Symfony bundle that integrates moneyphp/money library (Fowler pattern): https://github.com/moneyphp/money.

1961.9M](/packages/tbbc-money-bundle)[2checkout/2checkout-php

2Checkout PHP Library

83740.3k2](/packages/2checkout-2checkout-php)[smhg/sepa-qr-data

Generate QR code data for SEPA payments

61717.2k5](/packages/smhg-sepa-qr-data)[omnipay/dummy

Dummy driver for the Omnipay payment processing library

271.2M33](/packages/omnipay-dummy)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
