composer require contributte/comgate
extensions:
comgate: Contributte\Comgate\DI\ComgateExtension
comgate:
merchant: "12345678"
secret: foobar
test: true/false
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();
}
}
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();
}
}