<?php require '../vendor/autoload.php'; use Guzzle\Http\Exception\ClientErrorResponseException; use Omnipay\GoPay\GatewayFactory; $dotenv = new Dotenv\Dotenv(__DIR__ . '/..'); $dotenv->load(); $goId = $_ENV['GO_ID']; $clientId = $_ENV['CLIENT_ID']; $clientSecret = $_ENV['CLIENT_SECRET']; $gateway = GatewayFactory::createInstance($goId, $clientId, $clientSecret, true); try { $completeRequest = ['transactionReference' => '3044354339']; $response = $gateway->completePurchase($completeRequest); echo "Is Successful: " . $response->isSuccessful() . PHP_EOL; echo "TransactionId: " . $response->getTransactionId() . PHP_EOL; echo "State code: " . $response->getCode() . PHP_EOL; echo "TransactionReference: ", $response->getTransactionReference() . PHP_EOL; echo "Data: " . var_export($response->getData(), true) . PHP_EOL; } catch (ClientErrorResponseException $e) { dump((string) $e); dump($e->getResponse()->getBody(true)); }
<?php require '../vendor/autoload.php'; use Omnipay\GoPay\GatewayFactory; use Symfony\Component\HttpFoundation\Request; $dotenv = new Dotenv\Dotenv(__DIR__ . '/..'); $dotenv->load(); $goId = $_ENV['GO_ID']; $clientId = $_ENV['CLIENT_ID']; $clientSecret = $_ENV['CLIENT_SECRET']; $parameters = ['id' => '3044372331']; $httpRequest = Request::create('/notify', 'GET', $parameters, [], [], [], []); $gateway = GatewayFactory::createInstance($goId, $clientId, $clientSecret, true, $httpRequest); try { if (!$gateway->supportsAcceptNotification()) { echo "This Gateway does not support notifications"; } $response = $gateway->acceptNotification(); echo "PaymentId: ", $response->getTransactionReference() . PHP_EOL; echo "Message: " . $response->getMessage() . PHP_EOL; echo "Status: " . $response->getTransactionStatus() . PHP_EOL; echo "Data: " . var_export($response->getData(), true) . PHP_EOL; } catch (\Exception $e) { dump($e->getResponse()->getBody(true)); dump((string) $e); }