academe / omnipay-authorizenetapi

Omnipay 3.x implementation of Authorize.Net API
MIT License
14 stars 11 forks source link

unable to fetch a transaction in testing mode(sandbox) #7

Closed kleveralt closed 6 years ago

kleveralt commented 6 years ago
object(Omnipay\AuthorizeNetApi\Message\FetchTransactionResponse)[53]
  protected 'transactionIndex' => string 'transaction' (length=11)
  protected 'parsedData' => 
    object(Academe\AuthorizeNet\Response\Response)[44]
      protected 'refId' => null
      protected 'messages' => 
        object(Academe\AuthorizeNet\Response\Collections\Messages)[37]
          protected 'items' => 
            array (size=1)
              ...
          protected 'objectName' => null
          protected 'objectNameSuffix' => string '' (length=0)
          protected 'data' => 
            array (size=2)
              ...
      protected 'transaction' => null
      protected 'transactionResponse' => null
      protected 'token' => null
      protected 'resultCode' => string 'Error' (length=5)
      protected 'objectName' => null
      protected 'objectNameSuffix' => string '' (length=0)
      protected 'data' => 
        array (size=1)
          'messages' => 
            array (size=2)
              ...
  protected 'accessor' => null
  protected 'request' => 
    object(Omnipay\AuthorizeNetApi\Message\FetchTransactionRequest)[33]
      protected 'endpointSandbox' => string 'https://apitest.authorize.net/xml/v1/request.api' (length=48)
      protected 'endpointLive' => string 'https://api.authorize.net/xml/v1/request.api' (length=44)
      protected 'parameters' => 
        object(Symfony\Component\HttpFoundation\ParameterBag)[35]
          protected 'parameters' => 

it's a response var_dump of a fetching request.

judgej commented 6 years ago

Thanks, I should have some time today to look at this.

Is there any further information you can provide, such as example code to do the fetch?

kleveralt commented 6 years ago

very simple, I just capture then fetch

    $transactionReference = $response->getTransactionReference();

    $response = $gateway->capture([
        'amount' => '100',
        'currency' => 'USD',
        'transactionId' => $transactionId,
        'description' => 'Software Service',
        'transactionReference' => $transactionReference,
    ])->send();

    var_dump($response); //Passed

    $transactionReference = $response->getTransactionReference();

    $response = $gateway->fetchTransaction([
        'transactionReference' => $transactionReference,
    ])->send();

    var_dump($response); //Failed

on the other ways, failed too,

$f3->route('GET /fetch/@refid', function($f3){

    var_dump($f3->get('PARAMS.refid')); //for checking url params

    $gateway = Omnipay\Omnipay::create('AuthorizeNetApi_Api');
    $gateway->setAuthName('xxxxxx');  //hidden
    $gateway->setTransactionKey('xxxxxxxxx');
    $gateway->setTestMode(true);

    $response = $gateway->fetchTransaction([
        'transactionReference' => $f3->get('PARAMS.refid'),
    ])->send();

    var_dump($response); //failed
});
judgej commented 6 years ago

Instead of var_dump($response); what does var_dump($response->getData()); give you?

I get an array like this after a capture then a fetchTransaction:

array(3) {
  ["transaction"]=>
  array(20) {
    ["transId"]=>
    string(11) "60109955440"
    ["submitTimeUTC"]=>
    string(24) "2018-10-13T11:57:46.107Z"
    ["submitTimeLocal"]=>
    string(23) "2018-10-13T04:57:46.107"
    ["transactionType"]=>
    string(19) "authOnlyTransaction"
    ["transactionStatus"]=>
    string(25) "capturedPendingSettlement"
    ["responseCode"]=>
    int(1)
    ["responseReasonCode"]=>
    int(1)
    ["responseReasonDescription"]=>
    string(8) "Approval"
    ["authCode"]=>
    string(6) "IA5EKT"
    ["AVSResponse"]=>
    string(1) "Y"
    ["cardCodeResponse"]=>
    string(1) "P"
    ["authAmount"]=>
    float(7.98)
    ["settleAmount"]=>
    float(1.99)
    ["lineItems"]=>
    array(1) {
      [0]=>
      array(18) {
        ["itemId"]=>
        string(1) "0"
        ["name"]=>
        string(5) "Name1"
        ["description"]=>
        string(12) "Description1"
        ["quantity"]=>
        float(4)
        ["unitPrice"]=>
        float(3)
        ["taxable"]=>
        bool(false)
        ["taxRate"]=>
        float(0)
        ["taxAmount"]=>
        float(0)
        ["nationalTax"]=>
        float(0)
        ["localTax"]=>
        float(0)
        ["vatRate"]=>
        float(0)
        ["alternateTaxRate"]=>
        float(0)
        ["alternateTaxAmount"]=>
        float(0)
        ["totalAmount"]=>
        float(0)
        ["discountRate"]=>
        float(0)
        ["discountAmount"]=>
        float(0)
        ["taxIncludedInTotal"]=>
        bool(false)
        ["taxIsAfterDiscount"]=>
        bool(false)
      }
    }
    ["taxExempt"]=>
    bool(false)
    ["payment"]=>
    array(1) {
      ["creditCard"]=>
      array(3) {
        ["cardNumber"]=>
        string(8) "XXXX1234"
        ["expirationDate"]=>
        string(4) "XXXX"
        ["cardType"]=>
        string(4) "Visa"
      }
    }
    ["recurringBilling"]=>
    bool(false)
    ["customerIP"]=>
    string(13) "80.82.124.250"
    ["product"]=>
    string(16) "Card Not Present"
    ["marketType"]=>
    string(9) "eCommerce"
  }
  ["transrefId"]=>
  string(9) "500617443"
  ["messages"]=>
  array(2) {
    ["resultCode"]=>
    string(2) "Ok"
    ["message"]=>
    array(1) {
      [0]=>
      array(2) {
        ["code"]=>
        string(6) "I00001"
        ["text"]=>
        string(11) "Successful."
      }
    }
  }
}
kleveralt commented 6 years ago

My mistake, I found this information from getData(),

'code' => 'E00011', 'text' => 'Access denied. You do not have permissions to call the Transaction Details API.'

I enable Transaction Details API as https://community.developer.authorize.net/t5/Integration-and-Testing/E00011-Access-denied-You-do-not-have-permission-to-call-the/td-p/23989 , Everything just works fine.

Thanks for help.

judgej commented 6 years ago

Don't forget there are methods to help you get to that data:

$response->getResponseCode()
$response->getCode()
$response->getMessage()

One thing about this gateway is that there are messages at different levels, and multiple messages can be returned too (see getResponseMessages()). Hopefully the methods of AbstractResponse will help you get to the result you need without wading through the data structures. But the data structures are there if you need them.

Thanks for getting back with your solution.