2020-06-16 06:00:26 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
2020-09-06 11:38:10 +02:00
|
|
|
* Invoice Ninja (https://invoiceninja.com).
|
2020-06-16 06:00:26 +02:00
|
|
|
*
|
|
|
|
* @link https://github.com/invoiceninja/invoiceninja source repository
|
|
|
|
*
|
|
|
|
* @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com)
|
|
|
|
*
|
|
|
|
* @license https://opensource.org/licenses/AAL
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace App\PaymentDrivers\Authorize;
|
|
|
|
|
2020-06-24 07:20:33 +02:00
|
|
|
use App\PaymentDrivers\AuthorizePaymentDriver;
|
2020-06-16 06:00:26 +02:00
|
|
|
use net\authorize\api\contract\v1\GetTransactionDetailsRequest;
|
|
|
|
use net\authorize\api\controller\GetTransactionDetailsController;
|
|
|
|
|
|
|
|
/**
|
2020-09-06 11:38:10 +02:00
|
|
|
* Class AuthorizeTransactions.
|
2020-06-16 06:00:26 +02:00
|
|
|
*/
|
|
|
|
class AuthorizeTransactions
|
|
|
|
{
|
|
|
|
public $authorize;
|
|
|
|
|
|
|
|
public function __construct(AuthorizePaymentDriver $authorize)
|
|
|
|
{
|
|
|
|
$this->authorize = $authorize;
|
|
|
|
}
|
|
|
|
|
2020-09-06 11:38:10 +02:00
|
|
|
public function getTransactionDetails($transactionId)
|
|
|
|
{
|
|
|
|
/* Create a merchantAuthenticationType object with authentication details
|
|
|
|
retrieved from the constants file */
|
|
|
|
$this->authorize->init();
|
|
|
|
|
|
|
|
// Set the transaction's refId
|
|
|
|
$refId = 'ref'.time();
|
2020-06-16 06:00:26 +02:00
|
|
|
|
2020-09-06 11:38:10 +02:00
|
|
|
$request = new GetTransactionDetailsRequest();
|
|
|
|
$request->setMerchantAuthentication($this->authorize->merchant_authentication);
|
|
|
|
$request->setTransId($transactionId);
|
2020-06-16 06:00:26 +02:00
|
|
|
|
2020-09-06 11:38:10 +02:00
|
|
|
$controller = new GetTransactionDetailsController($request);
|
2020-06-16 06:00:26 +02:00
|
|
|
|
2020-09-06 11:38:10 +02:00
|
|
|
$response = $controller->executeWithApiResponse($this->authorize->mode());
|
2020-06-16 06:00:26 +02:00
|
|
|
|
2020-09-06 11:38:10 +02:00
|
|
|
if (($response != null) && ($response->getMessages()->getResultCode() == 'Ok')) {
|
|
|
|
info('SUCCESS: Transaction Status:'.$response->getTransaction()->getTransactionStatus());
|
|
|
|
info(' Auth Amount:'.$response->getTransaction()->getAuthAmount());
|
|
|
|
info(' Trans ID:'.$response->getTransaction()->getTransId());
|
|
|
|
} else {
|
|
|
|
info("ERROR : Invalid response\n");
|
|
|
|
$errorMessages = $response->getMessages()->getMessage();
|
|
|
|
info('Response : '.$errorMessages[0]->getCode().' '.$errorMessages[0]->getText());
|
|
|
|
}
|
2020-06-16 06:00:26 +02:00
|
|
|
|
2020-09-06 11:38:10 +02:00
|
|
|
return $response;
|
|
|
|
}
|
|
|
|
}
|