PHPackages                             fall1600/ecpay-invoice - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. fall1600/ecpay-invoice

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

fall1600/ecpay-invoice
======================

Invoice solution ECPay(綠界科技), implementing by pure PHP

2.0.x-dev(5y ago)319MITPHP

Since Sep 14Pushed 5y ago1 watchersCompare

[ Source](https://github.com/fall1600/ecpay-invoice)[ Packagist](https://packagist.org/packages/fall1600/ecpay-invoice)[ RSS](/packages/fall1600-ecpay-invoice/feed)WikiDiscussions master Synced 5d ago

READMEChangelogDependencies (1)Versions (2)Used By (0)

ecpay-invoice
=============

[](#ecpay-invoice)

How to use
----------

[](#how-to-use)

#### 建立發票資訊 (BasicInfo)

[](#建立發票資訊-basicinfo)

- $merchantId: 你在綠界申請的商店代號
- $order: 你的訂單物件, 務必實作package 中的OrderInterface
- $contact: 聯繫付款人方式, 務必實作package 中的ContactInterface
- $vatType: 商品單價是否為含稅價

```
$info = new BasicInfo($order, $contact, $vatType = 1);
```

#### 發票要去的地方(印出來, 捐贈, 載具), 則一decorate

[](#發票要去的地方印出來-捐贈-載具-則一decorate)

- $name: 買方姓名
- $addr: 買方地址
- $identifier: 統一編號
- $loveCode: 捐贈碼
- $carrierType: 載具類型(1: 綠界會員, 2: 自然人憑證, 3: 手機載具)
- $carrierVal: 載具值

```
$info = new Paper($info, $name, $addr, $identifier);
$info = new Donate($info, $loveCode = '168001');
$info = new Carrier($info, $carrierType, $carrierVal);
```

#### 建立Ecpay 物件, 注入商店資訊, 帶著發票資訊開立發票

[](#建立ecpay-物件-注入商店資訊-帶著發票資訊開立發票)

- $merchantId: 你在綠界商店代號
- $hashKey: 你在綠界商店專屬的HashKey
- $hashIv: 你在綠界商店專屬的HashIV

```
$ecpay = new Ecpay();
$ecpay
    ->setIsProduction(false) // 設定環境, 預設就是走正式機
    ->setMerchant(new Merchant($merchantId, $hashKey, $hashIv))
    ->issue($info);
```

#### 查詢發票明細

[](#查詢發票明細)

- $order: 你的訂單物件, 務必實作package 中的OrderInterface

```
$ecpay->queryIssue($order);
```

#### 作廢發票

[](#作廢發票)

- $invoiceNumber: 發票號碼
- $reason: 作廢原因

```
$ecpay->invalid(string $invoiceNumber, string $reason = '');
```

#### 查詢作廢明細

[](#查詢作廢明細)

```
$ecpay->queryInvalid($order);
```

#### 折讓發票, 建立折讓發票資訊, 塞入需折讓的品項

[](#折讓發票-建立折讓發票資訊-塞入需折讓的品項)

- $invoiceNumber: 發票號碼
- $returnUrl: 一律走線上折讓, 需要掛returnUrl, 用來收買家同意後綠界的webhook
- $vatType: 單價是否為含稅價

```
$info = new AllowanceBasicInfo($invoiceNumber, $returnUrl, $vatType = 1);
$info->appendItem(ItemInterface $item);
$info->appendItem(ItemInterface $item);

// 折讓通常要通知買方, 有掛NotifyByEmail, 或NotifyBySms 就會個別通知
$info = new NotifyByEmail($info, 'service@example.com');
$info = new NotifyBySms($info, '0988123456');

$ecpay->allowance(AllowanceInfo $info);
```

#### 查詢折讓明細

[](#查詢折讓明細)

- $invoiceNumber: 發票號碼
- $allowanceNumber: 作廢號碼

```
$ecpay->queryAllowance($invoiceNumber, $allownceNumber);
```

#### 作廢折讓

[](#作廢折讓)

- $invoiceNumber: 發票號碼
- $allowanceNumber: 作廢號碼
- $reason: 原因

```
$ecpay->invalidAllowance($invoiceNumber, $allownceNumber, $reason);
```

#### 查詢作廢折讓明細

[](#查詢作廢折讓明細)

- $invoiceNumber: 發票號碼
- $allowanceNumber: 作廢號碼

```
$ecpay->queryInvalidAllowance($invoiceNumber, $allownceNumber);
```

#### 驗證手機載具

[](#驗證手機載具)

- $carrier: 手機載具

```
$ecpay->verifyCarrier($carrier);
```

#### 驗證捐贈代碼

[](#驗證捐贈代碼)

- $lovecode: 捐贈代碼

```
$ecpay->verifyLovecode($lovecode);
```

###  Health Score

21

—

LowBetter than 19% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity40

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

2054d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/9515266f2bf21af17f8c977a32eb7f2e8b1f2c1d8807465f4109e59669fbb6da?d=identicon)[fall1600](/maintainers/fall1600)

---

Top Contributors

[![fall1600](https://avatars.githubusercontent.com/u/2196511?v=4)](https://github.com/fall1600 "fall1600 (54 commits)")

### Embed Badge

![Health badge](/badges/fall1600-ecpay-invoice/health.svg)

```
[![Health](https://phpackages.com/badges/fall1600-ecpay-invoice/health.svg)](https://phpackages.com/packages/fall1600-ecpay-invoice)
```

###  Alternatives

[sylius/refund-plugin

Plugin provides basic refunds functionality for Sylius application.

691.7M14](/packages/sylius-refund-plugin)[seboettg/citeproc-php

Full-featured CSL processor (https://citationstyles.org)

761.2M19](/packages/seboettg-citeproc-php)[timeweb/phpstan-enum

Enum class reflection extension for PHPStan

443.2M21](/packages/timeweb-phpstan-enum)[php-unit-conversion/php-unit-conversion

A fully PSR-4 compatible PHP library for converting between standard units of measure.

681.2M1](/packages/php-unit-conversion-php-unit-conversion)[open-feature/sdk

PHP implementation of the OpenFeature SDK

39514.9k15](/packages/open-feature-sdk)

PHPackages © 2026

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