Contributte Comgate
# Content
# Setup
composer require contributte/comgate
1
extensions:
comgate: Contributte\Comgate\DI\ComgateExtension
1
2
2
# Configuration
comgate:
merchant: "12345678"
secret: foobar
test: true/false
1
2
3
4
2
3
4
# Usage
# Create payment
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();
}
}
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
29
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
29
# 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 = $this->paymentService->status(PaymentStatus::of($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
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19