PHPackages                             voicetube/taiwan-payment-gateway - 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. voicetube/taiwan-payment-gateway

AbandonedArchivedProject[Payment Processing](/categories/payments)

voicetube/taiwan-payment-gateway
================================

A payment gateway library for Taiwan.

v1.5.8@RC(5y ago)112.7k4MITPHPPHP &gt;=7.2.5

Since Apr 17Pushed 5y ago19 watchersCompare

[ Source](https://github.com/voicetube/Taiwan-Payment-Gateway)[ Packagist](https://packagist.org/packages/voicetube/taiwan-payment-gateway)[ RSS](/packages/voicetube-taiwan-payment-gateway/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (1)Dependencies (4)Versions (12)Used By (0)

Taiwan Payment Gateway
======================

[](#taiwan-payment-gateway)

#### A payment gateway library for Taiwan.

[](#a-payment-gateway-library-for-taiwan)

Created by [VoiceTube](https://www.voicetube.com/)

[![Build Status](https://camo.githubusercontent.com/bdb2e72c53928e28e6cb701161a16cf9265ab5f41aab11bd4ff27debe887c540/68747470733a2f2f7472617669732d63692e6f72672f6d6572696b2d6368656e2f54616977616e2d5061796d656e742d476174657761792e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/merik-chen/Taiwan-Payment-Gateway)[![Test Coverage](https://camo.githubusercontent.com/e478925ecb5635ff9c12bfc9192f8ac6ede7dc4bb91f012f27dbc706c0019c7c/68747470733a2f2f636f6465636c696d6174652e636f6d2f7265706f732f3538663265363861623035636539303235613030323363612f6261646765732f37383432346136313265643535383936633836642f636f7665726167652e737667)](https://codeclimate.com/repos/58f2e68ab05ce9025a0023ca/coverage)[![Code Climate](https://camo.githubusercontent.com/5f7df01e7d4bb183fb4ba5d7c963a3f5c459e9647a0721d240bf69b4edd86675/68747470733a2f2f636f6465636c696d6174652e636f6d2f7265706f732f3538663265363861623035636539303235613030323363612f6261646765732f37383432346136313265643535383936633836642f6770612e737667)](https://codeclimate.com/repos/58f2e68ab05ce9025a0023ca/feed)

Features
--------

[](#features)

- Create / Process order
- Unit-Testing with PHPUnit
- PSR-4 auto-loading compliant structure
- Support PHPStorm meta for auto-completion
- Easy to use to any framework or even a plain php file

Todo
----

[](#todo)

- Payment status
- E-Invoice features
- Credit Card cancel / refund API

Available Gateway
-----------------

[](#available-gateway)

- [智付通 Spgateway](https://www.spgateway.com)
- [歐付寶 allPay](https://www.allpay.com.tw/)
- [綠界 ECPay](https://www.ecpay.com.tw)

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

[](#how-to-use)

#### Accept payment method.

[](#accept-payment-method)

- WebATM
- BarCode
- TenPay (AllPay only)
- TopUp (AllPay only)
- Credit
- ATM
- CVS
- ALL (AllPay, EcPay only)

#### Load the library

[](#load-the-library)

```
require_once 'vendor/autoload.php';

use VoiceTube\TaiwanPaymentGateway;
```

#### Initial the gateway

[](#initial-the-gateway)

```
/**
* Use factory to create gateway or directly new the gateway
*/

$gw = TaiwanPaymentGateway\TaiwanPaymentGateway::create('SpGateway', [
    'hashKey'       => 'c7fe1bfba42369ec1add502c9917e14d',
    'hashIV'        => '245a49c8fb5151f0',
    'merchantId'    => 'MS1234567',
    'version'       => '1.2',
    'actionUrl'     => 'https://ccore.spgateway.com/MPG/mpg_gateway',
    'returnUrl'     => 'https://localhost/payment/confirm',
    'notifyUrl'     => 'https://localhost/payment/notify',
    'clientBackUrl' => 'https://localhost/payment/return',
    'paymentInfoUrl'=> 'https://localhost/payment/information',
]);

$sp = new TaiwanPaymentGateway\SpGatewayPaymentGateway([
    'hashKey'       => 'c7fe1bfba42369ec1add502c9917e14d',
    'hashIV'        => '245a49c8fb5151f0',
    'merchantId'    => 'MS1234567',
    'version'       => '1.2',
    'actionUrl'     => 'https://ccore.spgateway.com/MPG/mpg_gateway',
    'returnUrl'     => 'https://localhost/payment/confirm',
    'notifyUrl'     => 'https://localhost/payment/notify',
    'clientBackUrl' => 'https://localhost/payment/return',
    'paymentInfoUrl'=> 'https://localhost/payment/information',
]);

$ec = new TaiwanPaymentGateway\EcPayPaymentGateway([
    'hashKey'       => '5294y06JbISpM5x9',
    'hashIV'        => 'v77hoKGq4kWxNNIS',
    'merchantId'    => '2000132',
    'version'       => 'V4',
    'actionUrl'     => 'https://payment-stage.ecpay.com.tw/Cashier/AioCheckOut/',
    'returnUrl'     => 'https://localhost/payment/confirm',
    'clientBackUrl' => 'https://localhost/payment/return',
    'paymentInfoUrl'=> 'https://localhost/payment/information',
]);

$ap = new TaiwanPaymentGateway\AllPayPaymentGateway([
    'hashKey'       => '5294y06JbISpM5x9',
    'hashIV'        => 'v77hoKGq4kWxNNIS',
    'merchantId'    => '2000132',
    'version'       => 'V2',
    'actionUrl'     => 'https://payment-stage.allpay.com.tw/Cashier/AioCheckOut/',
    'returnUrl'     => 'https://localhost/payment/confirm',
    'clientBackUrl' => 'https://localhost/payment/return',
    'paymentInfoUrl'=> 'https://localhost/payment/information',
]);
```

#### New order

[](#new-order)

##### !! All order settings must called after create new order, or the `$gw->newOrder()` function will erase all previously order data.

[](#-all-order-settings-must-called-after-create-new-order-or-the-gw-neworder-function-will-erase-all-previously-order-data)

```
// create new order
// $respond_type:
//  SpGateway: `POST` or `JSON` (default to 'JSON')
//  AllPay, EcPay: `POST` only
$gw->newOrder(
    required:$merchant_order_no,
    required:$amount,
    required:$item_describe,
    required:$order_comment,
    optional:$respond_type,
    optional:$timestamp
);

// Available payment method
$gw->useBarCode();
$gw->useWebATM();
$gw->useCredit();
$gw->useTenPay(); // AllPay only
$gw->useTopUp(); // AllPay only
$gw->useATM();
$gw->useCVS();
$gw->useALL(); // AllPay, EcPay only

// spgateway only settings
$gw->setEmail('bonjour@voicetube.com'); // setting user email
$gw->triggerEmailModify(optional:boolean); // allow user update email address later.
$gw->onlyLoginMemberCanPay(optional:boolean); // force user must to be login later.

// Order settings
$gw->setUnionPay();
$gw->needExtraPaidInfo();
$gw->setCreditInstallment(required:$months, optional:$total_amount);
$gw->setOrderExpire(required:$expire_Date);

// It can be using like this

$rId = sprintf("VT%s", time());
$gw->newOrder($rId, 100, rId, $rId)
   ->useCredit()
   ->setUnionPay()
   ->needExtraPaidInfo();

// generate post form
$gw->genForm(optional:$auto_submit = true);
```

#### Process order result/information

[](#process-order-resultinformation)

##### Initial the gateway

[](#initial-the-gateway-1)

```
/**
* Use factory to create response or directly new the response
*/

$gwr = TaiwanPaymentGateway\TaiwanPaymentResponse::create('SpGateway', [
    'hashKey'       => 'c7fe1bfba42369ec1add502c9917e14d',
    'hashIV'        => '245a49c8fb5151f0',
]);

$spr = new TaiwanPaymentGateway\SpGatewayPaymentResponse([
    'hashKey'       => 'c7fe1bfba42369ec1add502c9917e14d',
    'hashIV'        => '245a49c8fb5151f0',
]);

$ecr = new TaiwanPaymentGateway\EcPayPaymentResponse([
    'hashKey'       => '5294y06JbISpM5x9',
    'hashIV'        => 'v77hoKGq4kWxNNIS',
]);

$apr = new TaiwanPaymentGateway\AllPayPaymentResponse([
    'hashKey'       => '5294y06JbISpM5x9',
    'hashIV'        => 'v77hoKGq4kWxNNIS',
]);
```

##### Check the payment response

[](#check-the-payment-response)

```
// processOrder will catch $_POST fields and clean it
// SpGateway: `POST` or `JSON`
// AllPay, EcPay: `POST` only
$result = $spr->processOrder(optional:$type='POST or JSON');

// dump the result
array(22) {
  ["Status"]=>
  string(7) "SUCCESS"
  ["Message"]=>
  string(12) "授權成功"
  ["MerchantID"]=>
  string(9) "MS1234567"
  ["Amt"]=>
  int(1200)
  ["TradeNo"]=>
  string(17) "17032311330952317"
  ["MerchantOrderNo"]=>
  string(15) "1703230034715"
  ["PaymentType"]=>
  string(6) "CREDIT"
  ["RespondType"]=>
  string(6) "String"
  ["CheckCode"]=>
  string(64) "4B3DDA5FE88966928FEB903D6037B06A1A929087046E5E8D7A8CB2778A30D67C"
  ["PayTime"]=>
  string(19) "2017-03-23 11:33:09"
  ["IP"]=>
  string(12) "XXX.XXX.XXX.XXX"
  ["EscrowBank"]=>
  string(3) "KGI"
  ["TokenUseStatus"]=>
  int(0)
  ["RespondCode"]=>
  string(2) "00"
  ["Auth"]=>
  string(6) "930637"
  ["Card6No"]=>
  string(6) "400022"
  ["Card4No"]=>
  string(4) "1111"
  ["Inst"]=>
  int(0)
  ["InstFirst"]=>
  int(1200)
  ["InstEach"]=>
  int(0)
  ["ECI"]=>
  string(0) ""
  ["matched"]=>
  bool(true)
}

// after processing, check the `matched` field.

// for allpay and ecpay, you will need to call `rspOk` or `rspError`.
$ecr->rspOk();
// or
$apr->rspError(optinal:'Custom error msg');
```

#### Ref.

[](#ref)

- [\[PDF\] SpGateway](https://www.spgateway.com/dw_files/info_api/spgateway_gateway_MPGapi_V1_0_3.pdf)
- [\[PDF\] AllPay](https://www.allpay.com.tw/Content/files/allpay_011.pdf)
- [\[PDF\] EcPay](https://www.ecpay.com.tw/Content/files/ecpay_011.pdf)

###  Health Score

30

—

LowBetter than 62% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity25

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity51

Maturing project, gaining track record

 Bus Factor1

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

###  Release Activity

Cadence

Unknown

Total

1

Last Release

2052d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/19898384?v=4)[MerikC](/maintainers/Merik-VT)[@Merik-VT](https://github.com/Merik-VT)

---

Top Contributors

[![Merik-VT](https://avatars.githubusercontent.com/u/19898384?v=4)](https://github.com/Merik-VT "Merik-VT (23 commits)")[![merik-chen](https://avatars.githubusercontent.com/u/1698227?v=4)](https://github.com/merik-chen "merik-chen (3 commits)")

---

Tags

paymentgatewayTaiwanVoiceTube

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/voicetube-taiwan-payment-gateway/health.svg)

```
[![Health](https://phpackages.com/badges/voicetube-taiwan-payment-gateway/health.svg)](https://phpackages.com/packages/voicetube-taiwan-payment-gateway)
```

###  Alternatives

[shetabit/multipay

PHP Payment Gateway Integration Package

293361.0k4](/packages/shetabit-multipay)[bitpay/sdk

Complete version of the PHP library for the new cryptographically secure BitPay API

42361.9k4](/packages/bitpay-sdk)[sebdesign/laravel-viva-payments

A Laravel package for integrating the Viva Payments gateway

4849.3k](/packages/sebdesign-laravel-viva-payments)[mrprompt/cielo

Integration with Cielo gateway.

472.1k1](/packages/mrprompt-cielo)

PHPackages © 2026

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