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

ActiveLibrary[Payment Processing](/categories/payments)

elitehub/payment
================

Pacote modular para integração com múltiplos gateways de pagamento

1.0.0(4mo ago)09MITPHPPHP ^8.4

Since Jan 5Pushed 4mo agoCompare

[ Source](https://github.com/for4izen/payment-lib)[ Packagist](https://packagist.org/packages/elitehub/payment)[ Docs](https://github.com/for4izen/payment-lib/tree/1.0.0)[ RSS](/packages/elitehub-payment/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)DependenciesVersions (2)Used By (0)

💳 EliteHub PHP Payment — Gateway Modular
========================================

[](#-elitehub-php-payment--gateway-modular)

[![Packagist Version](https://camo.githubusercontent.com/bade0e8b40d1affee43bb79a77d42b79d04fc96ce8d69e02e1fc1b62f2d1cb81/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f656c6974656875622f7061796d656e742e737667)](https://camo.githubusercontent.com/bade0e8b40d1affee43bb79a77d42b79d04fc96ce8d69e02e1fc1b62f2d1cb81/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f656c6974656875622f7061796d656e742e737667)[![Laravel](https://camo.githubusercontent.com/3f3872fde8203e931d8bb8abb1d9b2af03b3e3f27257cd7211b1f023da6ba87b/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c61726176656c2d31302b2d7265642e737667)](https://camo.githubusercontent.com/3f3872fde8203e931d8bb8abb1d9b2af03b3e3f27257cd7211b1f023da6ba87b/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c61726176656c2d31302b2d7265642e737667)[![License](https://camo.githubusercontent.com/8bb50fd2278f18fc326bf71f6e88ca8f884f72f179d3e555e20ed30157190d0d/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d677265656e2e737667)](https://camo.githubusercontent.com/8bb50fd2278f18fc326bf71f6e88ca8f884f72f179d3e555e20ed30157190d0d/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d677265656e2e737667)[![Status](https://camo.githubusercontent.com/9be2d82e1c8b3c320e6c92a4d9c526237dc1136167c1d4595aaaec2d11c1b735/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7374617475732d737461626c652d626c75652e737667)](https://camo.githubusercontent.com/9be2d82e1c8b3c320e6c92a4d9c526237dc1136167c1d4595aaaec2d11c1b735/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7374617475732d737461626c652d626c75652e737667)

Pacote Laravel para integração **modular, leve e desacoplada** com múltiplos gateways de pagamento — como **Mercado Pago**, com suporte a **PIX**, **Checkout** e **expansão customizada**.

---

🚀 Instalação
------------

[](#-instalação)

```
composer require elitehub/payment
```

O pacote registra automaticamente o `PaymentServiceProvider` e executa:

- Cópia do arquivo `config/payments.php`
- Migrations de `payment_providers` e `payment_methods`
- Models padrão: `PaymentProvider` e `PaymentMethod`

Se quiser publicar manualmente:

```
php artisan vendor:publish --provider="EliteHub\Payment\Providers\PaymentServiceProvider"
```

---

🧱 Estrutura gerada
------------------

[](#-estrutura-gerada)

```
app/
 └── Models/
      ├── PaymentProvider.php
      ├── PaymentMethod.php
database/
 └── migrations/
      ├── create_payment_providers_table.php
      ├── create_payment_methods_table.php
config/
 └── payments.php

```

---

⚡ Exemplo de uso
----------------

[](#-exemplo-de-uso)

```
    $order = [
        'id' => 555,
        'total' => 59.90,
        'user' => ['email' => 'user@teste.com'],
        'items' => collect([
            [
                'product' => ['id' => 1, 'name' => 'Plano Premium'],
                'price' => 59.90
            ]
        ])
    ];

    $method = PaymentMethod::with('provider')
        ->where('method_key', 'pix')
        ->whereHas('provider', fn($q) => $q->where('provider_key', 'mercadopago'))
        ->firstOrFail();

    $payment = [
        'payment_method' => $method->method_key,
        'reference' => uniqid('ref_', true),
    ];

    $gateway = PaymentManager::resolve($method->provider);
    $response = $gateway->initiate($order, $payment);

    return response()->json($response);
```

✅ Nenhum model é obrigatório — apenas informe o `payment_method` (ex: `pix`, `preference`) e o `PaymentManager` cuida do resto.

---

💡 Fluxo interno
---------------

[](#-fluxo-interno)

1. O cliente envia `payment_method` (ex: `"pix"`);
2. O `PaymentManager` identifica o provedor ativo (`mercadopago`);
3. O gateway correspondente inicia a cobrança;
4. O retorno traz QR Code, URL ou dados de checkout.

---

💳 Exemplo de resposta (PIX)
---------------------------

[](#-exemplo-de-resposta-pix)

```
{
  "type": "pix",
  "reference": "ref_695b97a0dd6323.41320692",
  "qr_code": "000201...",
  "qr_code_base64": "data:image/png;base64,...",
  "expires_at": "2026-01-05T12:00:00Z"
}
```

---

💳 Exemplo de resposta (Checkout)
--------------------------------

[](#-exemplo-de-resposta-checkout)

```
{
  "type": "preference",
  "reference": "ref_695b97a0dd6323.41320692",
  "checkout_url": "https://www.mercadopago.com/checkout/v1/redirect?pref_id=...",
  "sandbox_url": "https://sandbox.mercadopago.com/checkout/v1/redirect?pref_id=..."
}
```

---

🔌 Gateways disponíveis
----------------------

[](#-gateways-disponíveis)

GatewayProvider KeyMétodos**Mercado Pago**`mercadopago``pix`, `preference`Para criar novos gateways, implemente:

```
EliteHub\Payment\Contracts\PaymentGatewayInterface
```

---

⚙️ Configuração
---------------

[](#️-configuração)

Arquivo: `config/payments.php`

```
return [
    'gateways' => [
        'mercadopago' => [
            'token' => env('MERCADOPAGO_TOKEN'),
            'webhook' => env('MERCADOPAGO_WEBHOOK_URL', 'https://example.com/webhook'),
        ],
    ],
];
```

Arquivo `.env`:

```
MERCADOPAGO_TOKEN=SEU_TOKEN_AQUI
MERCADOPAGO_WEBHOOK_URL=https://seusite.com/webhook
```

---

🧩 Criando um novo Gateway
-------------------------

[](#-criando-um-novo-gateway)

1️⃣ Crie `src/Gateways/MeuGateway.php`

```
use EliteHub\Payment\Contracts\PaymentGatewayInterface;
use Illuminate\Http\Request;

class MeuGateway implements PaymentGatewayInterface
{
    public function initiate($order, $payment)
    {
        // Lógica de cobrança customizada
    }

    public function handleWebhook(Request $request)
    {
        // Lógica de callback (notificação)
    }
}
```

2️⃣ Registre o gateway no `PaymentManager`:

```
return match ($provider->provider_key) {
    'mercadopago' => app(MercadoPagoGateway::class),
    'meugateway'  => app(MeuGateway::class),
    default => throw new Exception('Gateway não suportado'),
};
```

---

🧾 Logs e Debug
--------------

[](#-logs-e-debug)

```
use Illuminate\Support\Facades\Log;

Log::info('Order enviada', $order);
Log::info('Payment criado', $payment);
```

---

✅ Recursos
----------

[](#-recursos)

RecursoSuporteMúltiplos gateways✅Estrutura modular✅PIX e Checkout✅Independente de Models✅Publicação automática✅Extensível com novos gateways✅Compatível com Laravel 10+✅---

🧑‍💻 Autor
---------

[](#‍-autor)

**EliteHub Technologies**
Desenvolvido por [EliteHub](https://elitehub.tech)
para soluções modulares e escaláveis de pagamento em Laravel.

---

🪪 Licença
---------

[](#-licença)

Open-source sob a licença **MIT**.

###  Health Score

36

—

LowBetter than 82% of packages

Maintenance75

Regular maintenance activity

Popularity4

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity52

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

133d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/3efe02ce91ded456648d75561c2e18203aa333a4f75bacf9a0b84eae7c00d68a?d=identicon)[For4izen](/maintainers/For4izen)

---

Top Contributors

[![for4izen](https://avatars.githubusercontent.com/u/91918972?v=4)](https://github.com/for4izen "for4izen (16 commits)")

---

Tags

laravelpaymentsgatewaymercadopagomodularcheckoutpixelitehub

### Embed Badge

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

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

###  Alternatives

[sebdesign/laravel-viva-payments

A Laravel package for integrating the Viva Payments gateway

4845.9k](/packages/sebdesign-laravel-viva-payments)[sostheblack/moip

Laravel Package for Moip.

171.9k](/packages/sostheblack-moip)

PHPackages © 2026

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