2020-06-16 06:00:26 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Invoice Ninja (https://invoiceninja.com)
|
|
|
|
*
|
|
|
|
* @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;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Class AuthorizeTransactions
|
|
|
|
* @package App\PaymentDrivers\Authorize
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
class AuthorizeTransactions
|
|
|
|
{
|
|
|
|
|
|
|
|
public $authorize;
|
|
|
|
|
|
|
|
public function __construct(AuthorizePaymentDriver $authorize)
|
|
|
|
{
|
|
|
|
$this->authorize = $authorize;
|
|
|
|
}
|
|
|
|
|
|
|
|
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();
|
|
|
|
|
|
|
|
$request = new GetTransactionDetailsRequest();
|
|
|
|
$request->setMerchantAuthentication($this->authorize->merchant_authentication);
|
|
|
|
$request->setTransId($transactionId);
|
|
|
|
|
|
|
|
$controller = new GetTransactionDetailsController($request);
|
|
|
|
|
|
|
|
$response = $controller->executeWithApiResponse($this->authorize->mode());
|
|
|
|
|
|
|
|
if (($response != null) && ($response->getMessages()->getResultCode() == "Ok"))
|
|
|
|
{
|
2020-06-24 03:15:51 +02:00
|
|
|
info( "SUCCESS: Transaction Status:" . $response->getTransaction()->getTransactionStatus() );
|
|
|
|
info( " Auth Amount:" . $response->getTransaction()->getAuthAmount() );
|
|
|
|
info( " Trans ID:" . $response->getTransaction()->getTransId() );
|
2020-06-16 06:00:26 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-06-24 03:15:51 +02:00
|
|
|
info( "ERROR : Invalid response\n");
|
2020-06-16 06:00:26 +02:00
|
|
|
$errorMessages = $response->getMessages()->getMessage();
|
2020-06-24 03:15:51 +02:00
|
|
|
info( "Response : " . $errorMessages[0]->getCode() . " " .$errorMessages[0]->getText() );
|
2020-06-16 06:00:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return $response;
|
|
|
|
}
|
|
|
|
}
|