nattreid / comgate
Comgate for Nette Framework
1.1.3
2018-12-13 12:48 UTC
Requires
- php: >= 7.1
- guzzlehttp/guzzle: ~6.2
- nette/di: ~2.4
Requires (Dev)
- nattreid/form: ~1.0
- nattreid/web-manager: ~1.0
- nette/tester: ~1.7
- tracy/tracy: ~2.4
README
Nastavení v config.neon
extensions: comgate: NAttreid\Comgate\DI\ComgateExtension comgate: paymentsUrl: https://payments.comgate.cz/v1.0/ merchant: 123456 debug: true password: password
Použití
/** @var \NAttreid\Comgate\ComgateClient @inject */ public $comgateClient; private function actionProcess(): void { $comgateClient = $this->comgateClient; $transaction= new \NAttreid\Comgate\Helpers\Transaction; $transaction->refId=$this->order->id; $transaction->country=$this->order->customer->country->code; $transaction->currency=$this->order->currency->code; $transaction->price=$this->order->price; $response = $comgate->transaction($transaction); $this->order->setComgateTransactionId($response->transactionId); $this->sendResponse($response->response); } private function actionRefund(float $price): void { $comgateClient = $this->comgateClient; $refund = new \NAttreid\Comgate\Helpers\Refund; $refund->transactionId = $this->order->comgateTransactionId; $refund->price = $price; $refund->currency = $this->order->currency->code; $response = $comgateClient->refund($refund); return $response->isOk(); } public function actionComgateStatus(): void { $response = $this->comgateClient->getStatus(); if ($response->isOk()) { if ($response->status === 'PAID') { // paid code } } else { // error code } $this->sendResponse($response->reponse); }