PHPackages                             phpbook/payment - 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. phpbook/payment

ActiveLibrary[Payment Processing](/categories/payments)

phpbook/payment
===============

PHP Payment Library For MundiPAGG, PagarMe

1.0.3(7y ago)113MITPHPPHP &gt;=7.1.0

Since Jun 14Pushed 7y agoCompare

[ Source](https://github.com/phpbook-sources/payment)[ Packagist](https://packagist.org/packages/phpbook/payment)[ Docs](https://github.com/phpbook-sources/payment)[ RSS](/packages/phpbook-payment/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (4)DependenciesVersions (5)Used By (0)

- [About Payment](#about-payment)
- [Composer Install](#composer-install)
- [Declare Configurations](#declare-configurations)
- [Transactions](#transactions)

### About Payment

[](#about-payment)

- A lightweight Payment Gateway PHP library available for PagarMe and MundiPagg.

### Composer Install

[](#composer-install)

```
composer require phpbook/payment

```

### Declare Configurations

[](#declare-configurations)

```
/********************************************
 *
 *  Declare Configurations
 *
 * ******************************************/

//Driver gateway PagarMe

\PHPBook\Payment\Configuration\Payment::setGateway('main',
	(new \PHPBook\Payment\Configuration\Gateway)
		->setName('Main')
		->setExceptionCatcher(function(String $message) {
			//the PHPBook Payment does not throw exceptions, but you can take it here
			//you can store $message in database or something else
		})
		->setDriver((new \PHPBook\Payment\Driver\PagarMe)->setKey('key')->setKeyVersion('v2017-08-28'))
);

//Driver gateway MundiPagg

\PHPBook\Payment\Configuration\Payment::setGateway('backups',
	(new \PHPBook\Payment\Configuration\Gateway)
		->setName('Backups')
		->setExceptionCatcher(function(String $message) {
			//the PHPBook Payment does not throw exceptions, but you can take it here
			//you can store $message in database or something else
		})
		->setDriver((new \PHPBook\Payment\Driver\MundiPagg)->setKey('key'))
);

//Set default gateway by gateway code

\PHPBook\Payment\Configuration\Payment::setDefault('main');

//Getting gateways

$gateways = \PHPBook\Payment\Configuration\Payment::getGateways();

foreach($gateways as $code => $gateway) {

	$gateway->getName();

	$gateway->getDriver();

};

?>
```

### Transactions

[](#transactions)

```

/*************************************************
 *
 *  Create Customer
 *  You cannot update customer here, only create
 *
 * ***********************************************/

	$customer = (new \PHPBook\Payment\Customer)
		->setToken(null) //gateway defines when create
		->setName('Jhon Doe')
		->setEmail('jhon@email.com')
		->setIdentity('16815587002')
		->setPhone('999999999')
		->setPhoneLocal('47')
		->setPhoneCountry('55');

	//getting customer attributes
	$customer->getToken();
	$customer->getName();
	$customer->getEmail();
	$customer->getIdentity();
	$customer->getPhone();
	$customer->getPhoneLocal();
	$customer->getPhoneCountry();

	(new \PHPBook\Payment\Transaction\Customer\Create)
		->setCustomer($customer)
		->create();

	//filled when customer is successfully created
	if ($customer->getToken()) {
		//$customer
	};

/*************************************************
 *
 *  Get Customer By Token
 *
 * ***********************************************/

$customerToken = '0001';

$customer = (new \PHPBook\Payment\Transaction\Customer\Get)
	->setToken($customerToken)
	->get();

//filled with customer
if ($customer) {
	//$customer
};

/*************************************************
 *
 *  Create Card
 *  You cannot update card here, only create
 *
 * ***********************************************/

	$number = '000000000000';
	$cvv = '123';
	$name = 'JHON DOE';
	$month = '01';
	$year = '20';

	$cardToken = (new \PHPBook\Payment\Transaction\Card\Create)
		->setCustomerToken($customerToken)
		->setCard($number, $cvv, $name, $month, $year)
		->create();

	//filled when card is successfully created
	if ($cardToken) {
		//$cardToken
	};

/*************************************************
 *
 *  Create Charge
 *  You cannot update charge here, only create
 *
 * ***********************************************/

	/********************************************************/
	/* Create Charge with Created Customer and Created Card */
	/********************************************************/

	$customerToken = '0001';

	$cardToken = '0001';

	$chargeMeta = 'billing-10';
	$chargePriceCents = 100;
	$chargeShippingAddressStreet = 'Praça Gov. Irineu Bornhausen';
	$chargeShippingAddressNumber = '100';
	$chargeShippingAddressNeighborhood = 'Centro';
	$chargeShippingAddressZipCode = '88310000';
	$chargeShippingAddressCity = 'Itajaí';
	$chargeShippingAddressState = 'SC';
	$chargeShippingAddressCountry = 'BR';

	$customer = (new \PHPBook\Payment\Transaction\Customer\Get)
		->setToken($customerToken)
		->get();

	//if you need you can update customer informations in the gateway
	$customer->setName('name');

	$charge = (new \PHPBook\Payment\Charge)
		->setToken(null) //gateway defines when create
		->setMeta($chargeMeta)
		->setPriceCents($chargePriceCents)
		->setShippingAddressStreet($chargeShippingAddressStreet)
		->setShippingAddressNumber($chargeShippingAddressNumber)
		->setShippingAddressNeighborhood($chargeShippingAddressNeighborhood)
		->setShippingAddressZipCode($chargeShippingAddressZipCode)
		->setShippingAddressCity($chargeShippingAddressCity)
		->setShippingAddressState($chargeShippingAddressState)
		->setShippingAddressCountry($chargeShippingAddressCountry);

	(new \PHPBook\Payment\Transaction\Charge\Create)
		->setCustomer($customer)
		->setCardToken($cardToken)
		->setCharge($charge)
		->create();

	//filled when charge is successfully created
	if ($charge->getToken()) {

		$charge->getStatus(); //filled with new status

	};

	/****************************************************/
	/* Create Charge with Created Customer and New Card */
	/****************************************************/

	$customerToken = '0001';

	$cardNumber = '000000000000';
	$cardCvv = '123';
	$cardName = 'JHON DOE';
	$cardMonth = '01';
	$cardYear = '20';

	$chargeMeta = 'billing-10';
	$chargePriceCents = 100;
	$chargeShippingAddressStreet = 'Praça Gov. Irineu Bornhausen';
	$chargeShippingAddressNumber = '100';
	$chargeShippingAddressNeighborhood = 'Centro';
	$chargeShippingAddressZipCode = '88310000';
	$chargeShippingAddressCity = 'Itajaí';
	$chargeShippingAddressState = 'SC';
	$chargeShippingAddressCountry = 'BR';

	$customer = (new \PHPBook\Payment\Transaction\Customer\Get)
		->setToken($customerToken)
		->get();

	$cardToken = (new \PHPBook\Payment\Transaction\Card\Create)
		->setCustomerToken($customerToken)
		->setCard($cardNumber, $cardCvv, $cardName, $cardMonth, $cardYear)
		->create();

	//filled when card is successfully created
	if ($cardToken) {

		//if you need you can update customer informations in the gateway
		$customer->setName('name');

		$charge = (new \PHPBook\Payment\Charge)
			->setToken(null) //gateway defines when create
			->setMeta($chargeMeta)
			->setPriceCents($chargePriceCents)
			->setShippingAddressStreet($chargeShippingAddressStreet)
			->setShippingAddressNumber($chargeShippingAddressNumber)
			->setShippingAddressNeighborhood($chargeShippingAddressNeighborhood)
			->setShippingAddressZipCode($chargeShippingAddressZipCode)
			->setShippingAddressCity($chargeShippingAddressCity)
			->setShippingAddressState($chargeShippingAddressState)
			->setShippingAddressCountry($chargeShippingAddressCountry);

		(new \PHPBook\Payment\Transaction\Charge\Create)
			->setCustomer($customer)
			->setCardToken($cardToken)
			->setCharge($charge)
			->create();

		//filled when charge is successfully created
		if ($charge->getToken()) {

			$charge->getStatus(); //filled with new status

		};

	};

	/************************************************/
	/* Create Charge with New Customer and New Card */
	/************************************************/

	$name = 'Jhon Doe';
	$email = 'jhon@email.com';
	$identity = '01684848421';
	$phone = '999999999999';
	$phoneLocal = '47';
	$phoneCountry = '55';

	$cardNumber = '000000000000';
	$cardCvv = '123';
	$cardName = 'JHON DOE';
	$cardMonth = '01';
	$cardYear = '20';

	$chargeMeta = 'billing-10';
	$chargePriceCents = 100;
	$chargeShippingAddressStreet = 'Praça Gov. Irineu Bornhausen';
	$chargeShippingAddressNumber = '100';
	$chargeShippingAddressNeighborhood = 'Centro';
	$chargeShippingAddressZipCode = '88310000';
	$chargeShippingAddressCity = 'Itajaí';
	$chargeShippingAddressState = 'SC';
	$chargeShippingAddressCountry = 'BR';

	$customer = (new \PHPBook\Payment\Customer)
		->setToken(null) //gateway defines when create
		->setName($name)
		->setEmail($email)
		->setIdentity($identity)
		->setPhone($phone)
		->setPhoneLocal($phoneLocal)
		->setPhoneCountry($phoneCountry);

	(new \PHPBook\Payment\Transaction\Customer\Create)
		->setCustomer($customer)
		->create();

	//filled when customer is successfully created
	if ($customer->getToken()) {

		$cardToken = (new \PHPBook\Payment\Transaction\Card\Create)
			->setCustomerToken($customer->getToken())
			->setCard($cardNumber, $cardCvv, $cardName, $cardMonth, $cardYear)
			->create();

		//filled when card is successfully created
		if ($cardToken) {

			$charge = (new \PHPBook\Payment\Charge)
				->setToken(null) //gateway defines when create
				->setMeta($chargeMeta)
				->setPriceCents($chargePriceCents)
				->setShippingAddressStreet($chargeShippingAddressStreet)
				->setShippingAddressNumber($chargeShippingAddressNumber)
				->setShippingAddressNeighborhood($chargeShippingAddressNeighborhood)
				->setShippingAddressZipCode($chargeShippingAddressZipCode)
				->setShippingAddressCity($chargeShippingAddressCity)
				->setShippingAddressState($chargeShippingAddressState)
				->setShippingAddressCountry($chargeShippingAddressCountry);

			(new \PHPBook\Payment\Transaction\Charge\Create)
				->setCustomer($customer)
				->setCardToken($cardToken)
				->setCharge($charge)
				->create();

			//filled when charge is successfully created
			if ($charge->getToken()) {

				$charge->getStatus(); //filled with new status

			};

		};

	};

/*************************************************
 *
 *  Working With Charge Attributes and Status
 *
 * ***********************************************/

	$charge->getToken();
	$charge->getMeta();
	$charge->getPriceCents();
	$charge->getShippingAddressStreet();
	$charge->getShippingAddressNumber();
	$charge->getShippingAddressNeighborhood();
	$charge->getShippingAddressZipCode();
	$charge->getShippingAddressCity();
	$charge->getShippingAddressState();
	$charge->getShippingAddressCountry();

	switch($charge->getStatus()) {

		case \PHPBook\Payment\Charge::$STATUS_COMPLETE:
				//complete
			break;

		case \PHPBook\Payment\Charge::$STATUS_WAITING:
				//waiting
			break;

		case \PHPBook\Payment\Charge::$STATUS_DENY:
				//deny
			break;

		case \PHPBook\Payment\Charge::$STATUS_REFUNDED:
				//refunded
			break;

		case \PHPBook\Payment\Charge::$STATUS_IDLE:
				//initial status
			break;

	};

/*************************************************
 *
 *  Get Charge By Token
 *
 * ***********************************************/

	$chargeToken = '00001';

	$charge = (new \PHPBook\Payment\Transaction\Charge\Get)
		->setToken($chargeToken)
		->get();

/*************************************************
 *
 *  Get List of Charges By Meta
 *
 * ***********************************************/

	$meta = 'billing-10';

	$charges = (new \PHPBook\Payment\Transaction\Charge\Meta\Get)
		->setMeta($meta)
		->get();

/*************************************************
 *
 *  Refund Charge
 *
 * ***********************************************/

	$chargeToken = '00001';

	$charge = (new \PHPBook\Payment\Transaction\Charge\Get)
		->setToken($chargeToken)
		->get();

	(new \PHPBook\Payment\Transaction\Charge\Refund)
		->setCharge($charge)
		->refund();

	$charge->getStatus(); //filled with new status. You should expect the refunded status

```

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity61

Established project with proven stability

 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

Every ~20 days

Total

4

Last Release

2832d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/31623868?v=4)[dz5362](/maintainers/phpbook)[@phpbook](https://github.com/phpbook)

---

Top Contributors

[![phpbook-sources](https://avatars.githubusercontent.com/u/34910819?v=4)](https://github.com/phpbook-sources "phpbook-sources (6 commits)")

---

Tags

phpfastpaymentgatewaylightweight

### Embed Badge

![Health badge](/badges/phpbook-payment/health.svg)

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

###  Alternatives

[omalizadeh/laravel-multi-payment

A driver-based laravel package for online payments via multiple gateways

491.1k](/packages/omalizadeh-laravel-multi-payment)

PHPackages © 2026

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