1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-14 15:13:29 +01:00
invoiceninja/app/PaymentDrivers/Authorize/AuthorizeTransactions.php

62 lines
2.0 KiB
PHP
Raw Normal View History

<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
*
2021-06-16 08:58:16 +02:00
* @license https://www.elastic.co/licensing/elastic-license
*/
namespace App\PaymentDrivers\Authorize;
2020-06-24 07:20:33 +02:00
use App\PaymentDrivers\AuthorizePaymentDriver;
use net\authorize\api\contract\v1\GetTransactionDetailsRequest;
use net\authorize\api\controller\GetTransactionDetailsController;
/**
* Class AuthorizeTransactions.
*/
class AuthorizeTransactions
{
public $authorize;
public function __construct(AuthorizePaymentDriver $authorize)
{
$this->authorize = $authorize;
}
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();
$request = new GetTransactionDetailsRequest();
$request->setMerchantAuthentication($this->authorize->merchant_authentication);
$request->setTransId($transactionId);
$controller = new GetTransactionDetailsController($request);
$response = $controller->executeWithApiResponse($this->authorize->mode());
2021-09-16 00:43:14 +02:00
// if (($response != null) && ($response->getMessages()->getResultCode() == 'Ok')) {
if ($response != null && $response->getMessages() != null) {
2020-12-29 22:10:03 +01:00
nlog('SUCCESS: Transaction Status:'.$response->getTransaction()->getTransactionStatus());
nlog(' Auth Amount:'.$response->getTransaction()->getAuthAmount());
nlog(' Trans ID:'.$response->getTransaction()->getTransId());
} else {
2020-12-29 22:10:03 +01:00
nlog("ERROR : Invalid response\n");
$errorMessages = $response->getMessages()->getMessage();
2020-12-29 22:10:03 +01:00
nlog('Response : '.$errorMessages[0]->getCode().' '.$errorMessages[0]->getText());
}
return $response;
}
}