PHPackages                             carllee1983/ecpay-core - 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. carllee1983/ecpay-core

ActiveLibrary[Payment Processing](/categories/payments)

carllee1983/ecpay-core
======================

綠界科技 ECPay SDK 共用核心套件

v1.0.0(5mo ago)044MITPHPPHP ^8.3

Since Nov 26Pushed 5mo agoCompare

[ Source](https://github.com/CarlLee1983/ecpay-core)[ Packagist](https://packagist.org/packages/carllee1983/ecpay-core)[ Docs](https://github.com/CarlLee1983/ecpay-core)[ RSS](/packages/carllee1983-ecpay-core/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (6)Versions (3)Used By (4)

ECPay Core - 綠界科技 SDK 共用核心套件
============================

[](#ecpay-core---綠界科技-sdk-共用核心套件)

[![PHP Version](https://camo.githubusercontent.com/ef0054230522e542bc1f908ac005c6c75888dea255bac910f9015e12095e31d7/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253545382e332d626c7565)](https://php.net)[![License](https://camo.githubusercontent.com/f8df3091bbe1149f398a5369b2c39e896766f9f6efba3477c63e9b4aa940ef14/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d677265656e)](LICENSE)

簡介
--

[](#簡介)

`ecpay-core` 是綠界科技 (ECPay) SDK 系列套件的共用核心，提供所有子套件（電子發票、金流、物流）共用的基礎類別、介面、例外處理與加解密服務。

套件架構
----

[](#套件架構)

```
carllee1983/ecpay (全家桶)
├── carllee1983/ecpay-core (本套件)
├── carllee1983/ecpay-einvoice (電子發票)
│   ├── carllee1983/ecpay-einvoice-b2b
│   └── carllee1983/ecpay-einvoice-b2c
├── carllee1983/ecpay-payment (金流) [開發中]
└── carllee1983/ecpay-logistics (物流) [開發中]

```

安裝
--

[](#安裝)

```
composer require carllee1983/ecpay-core
```

> **注意**：一般使用者不需要直接安裝此套件，它會作為其他 ECPay 套件的依賴自動安裝。

提供的功能
-----

[](#提供的功能)

### 基礎類別

[](#基礎類別)

- `AbstractContent` - 所有 API 操作的抽象基礎類別
- `AbstractOperationFactory` - 工廠模式抽象類別
- `Request` - HTTP 請求處理
- `Response` - API 回應封裝

### 介面 (Contracts)

[](#介面-contracts)

- `ContentInterface` - 內容物件介面
- `CommandInterface` - 命令介面
- `OperationFactoryInterface` - 工廠介面

### 例外處理 (Exceptions)

[](#例外處理-exceptions)

- `EcPayException` - 基礎例外
- `ApiException` - API 錯誤
- `ConfigurationException` - 設定錯誤
- `EncryptionException` - 加解密錯誤
- `ValidationException` - 驗證錯誤
- `PayloadException` - Payload 錯誤

### 基礎設施 (Infrastructure)

[](#基礎設施-infrastructure)

- `CipherService` - AES 加解密服務
- `PayloadEncoder` - Payload 編碼器

### DTO

[](#dto)

- `ItemCollection` - 項目集合
- `ItemDtoInterface` - 項目 DTO 介面
- `RqHeaderDto` - 請求標頭 DTO

### Laravel 支援

[](#laravel-支援)

- `CoreServiceProvider` - 核心 Service Provider（自動發布共用設定）
- `AbstractEcPayServiceProvider` - 抽象 Service Provider（子套件繼承）
- `RegistersOperations` Trait - 操作註冊輔助

Laravel 整合
----------

[](#laravel-整合)

安裝後，Laravel 會自動註冊 `CoreServiceProvider`。

### 發布設定檔

[](#發布設定檔)

```
php artisan vendor:publish --tag=ecpay-config
```

這會發布 `config/ecpay.php` 共用設定檔，包含：

- `environment` - 環境設定（sandbox/production）
- `verify_ssl` - SSL 驗證開關
- `http.timeout` - HTTP 請求逾時設定

### 環境變數

[](#環境變數)

```
ECPAY_ENVIRONMENT=sandbox
ECPAY_VERIFY_SSL=true
ECPAY_HTTP_TIMEOUT=30
ECPAY_HTTP_CONNECT_TIMEOUT=10
```

開發子套件
-----

[](#開發子套件)

如果你要開發新的 ECPay 子套件，請繼承核心類別：

```
