Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85 changes: 5 additions & 80 deletions .docs/README.md
Original file line number Diff line number Diff line change
@@ -1,86 +1,11 @@
# Contributte Comgate
# Comgate reference

## Content

- [Setup](#usage)
- [Configuration](#configuration)

## Setup

```bash
composer require contributte/comgate
```

```neon
extensions:
comgate: Contributte\Comgate\DI\ComgateExtension
```

## Configuration

```neon
comgate:
merchant: "12345678"
secret: foobar
test: true/false
```

## Usage

### Create payment

```php
use Brick\Money\Money;
use Contributte\Comgate\Entity\Codes\PaymentMethodCode;
use Contributte\Comgate\Entity\Payment;
use Contributte\Comgate\Gateway\PaymentService;

final class Payments
{

/** @var PaymentService */
private $paymentService;

public function createPayment(array $data): array
{
$payment = Payment::of(
Money::of($data['price'] ?? 50, $data['currency'] ?? 'CZK'),
$data['label'] ?? 'Test item',
$data['refId'] ?? 'order101',
$data['email'] ?? 'dev@contributte.org',
$data['fullName'] ?? 'John Doe',
PaymentMethodCode::ALL,
);

$res = $this->paymentService->create($payment);

// $res->isOk();
return $res->getData();
}

}
```

### Status
The root README contains the first test-payment flow. Check a transaction with the existing status API:

```php
use Contributte\Comgate\Entity\Codes\PaymentMethodCode;
use Contributte\Comgate\Entity\PaymentStatus;
use Contributte\Comgate\Gateway\PaymentService;

final class Payments
{

/** @var PaymentService */
private $paymentService;

public function getStatus(string $transaction): array
{
$res = $this->paymentService->status(PaymentStatus::of($transaction));

// $res->isOk();
return $res->getData();
}
$response = $payments->status(PaymentStatus::of($transaction));

if ($response->isOk()) {
$data = $response->getData();
}
```
68 changes: 59 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,25 +18,75 @@
Website 🚀 <a href="https://contributte.org">contributte.org</a> | Contact 👨🏻‍💻 <a href="https://f3l1x.io">f3l1x.io</a> | Twitter 🐦 <a href="https://twitter.com/contributte">@contributte</a>
</p>

## Usage
Comgate payment gateway integration for Nette applications.

## Versions

| State | Version | Branch | Nette | PHP |
|--------|---------|----------|--------|---------|
| dev | `^0.6` | `master` | `3.2+` | `>=8.2` |
| stable | `^0.5` | `master` | `3.2+` | `>=8.1` |
| stable | `^0.4` | `master` | `3.2+` | `>=8.1` |

## Installation

To install latest version of `contributte/comgate` use [Composer](https://getcomposer.org).

```bash
composer require contributte/comgate
```

## Documentation
Register the extension in your NEON configuration.

For details on how to use this package, check out our [documentation](.docs).
```neon
extensions:
comgate: Contributte\Comgate\DI\ComgateExtension
```

## Versions
## Quick start

| State | Version | Branch | Nette | PHP |
|--------|---------|----------|--------|---------|
| dev | `^0.6` | `master` | `3.2+` | `>=8.2` |
| stable | `^0.5` | `master` | `3.2+` | `>=8.1` |
| stable | `^0.4` | `master` | `3.2+` | `>=8.1` |
Configure **test-only development credentials** and inject `PaymentService` into an application service:

```neon
comgate:
merchant: 'test-merchant'
secret: test-secret
test: true
```

```php
use Brick\Money\Money;
use Contributte\Comgate\Entity\Codes\PaymentMethodCode;
use Contributte\Comgate\Entity\Payment;
use Contributte\Comgate\Gateway\PaymentService;

final class Payments
{
public function __construct(private PaymentService $payments)
{
}

public function create(): string
{
$response = $this->payments->create(Payment::of(
Money::of(50, 'CZK'), 'Test item', 'test-001', 'dev@example.test', 'John Doe', PaymentMethodCode::ALL,
));

return $response->getRedirect() ?? '';
}
}
```

A successful response provides a transaction ID and may provide the payment redirect URL through `getRedirect()`. Use real credentials only outside development; see [the detailed usage reference](.docs/README.md) for status lookups.

## Configuration

```neon
comgate:
merchant: "12345678"
secret: foobar
test: true/false
```

## Development

Expand Down