# Contributte Comgate

# Content

# Setup

composer require contributte/comgate
1
extensions:
    # Nette 3.0 +
    comgate: Contributte\Comgate\DI\ComgateExtension
    # Nette 2.4
    comgate: Contributte\Comgate\DI\ComgateExtension24
1
2
3
4
5

# Configuration

comgate:
    merchant: 12345678
    secret: foobar
    test: true/false
1
2
3
4

# Usage

# Create payment

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(
        $data['price'] ?? 50,
        $data['currency'] ?? 'CZK',
        $data['label'] ?? 'Test item',
        $data['refId'] ?? 'order101',
        $data['email'] ?? 'dev@contributte.org',
        PaymentMethodCode::ALL
    );

    $res = $payments->create($payment);
    
    // $res->isOk();
    return $res->getData();
  }

}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28

# Status

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 = $payments->status(PaymentStatus::from($transaction);
    
    // $res->isOk();
    return $res->getData();
  }

}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19