Skip to content

Latest commit

 

History

History
 
 

.docs

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 

Contributte Comgate

Content

Setup

composer require contributte/comgate
extensions:
	comgate: Contributte\Comgate\DI\ComgateExtension

Configuration

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

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'] ?? '[email protected]',
			$data['fullName'] ?? 'John Doe',
			PaymentMethodCode::ALL,
		);

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

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

}

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();
	}

}