Home > Net >  how to get Card last four digits of transaction from Authorize.net in php laravel
how to get Card last four digits of transaction from Authorize.net in php laravel

Time:11-15

I have try this code and get the result

public function getTransactionDetails($transactionId)
        {
        $merchantAuthentication = new AnetAPI\MerchantAuthenticationType();
        $merchantAuthentication->setName(env('MERCHANT_LOGIN_ID'));
        $merchantAuthentication->setTransactionKey(env('MERCHANT_TRANSACTION_KEY'));

        // Set the transaction's refId
        $refId = 'ref' . time();
        $request = new AnetAPI\GetTransactionDetailsRequest();
        $request->setMerchantAuthentication($merchantAuthentication);
        $request->setTransId($transactionId);
        $controller = new AnetController\GetTransactionDetailsController($request);
        $response = $controller->executeWithApiResponse( 
          \net\authorize\api\constants\ANetEnvironment::SANDBOX);

        return $response;
    }

when i return the response it gives me the following output

net\authorize\api\contract\v1\GetTransactionDetailsResponse {#1635 ▼
  -transaction: net\authorize\api\contract\v1\TransactionDetailsType {#1634 ▼
    -transId: "60179386025"
    -refTransId: null
    -splitTenderId: null
    -submitTimeUTC: DateTime @1636637863 {#1636 ▶}
    -submitTimeLocal: DateTime @1636609063 {#1637 ▶}
    -transactionType: "authCaptureTransaction"
    -transactionStatus: "settledSuccessfully"
    -responseCode: 1
    -responseReasonCode: 1
    -subscription: null
    -responseReasonDescription: "Approval"
    -authCode: "5DQLVA"
    -aVSResponse: "Y"
    -cardCodeResponse: "P"
    -cAVVResponse: null
    -fDSFilterAction: null
    -fDSFilters: null
    -batch: net\authorize\api\contract\v1\BatchDetailsType {#1638 ▶}
    -order: null
    -requestedAmount: null
    -authAmount: 3.0
    -settleAmount: 3.0
    -tax: null
    -shipping: null
    -duty: null
    -lineItems: null
    -prepaidBalanceRemaining: null
    -taxExempt: false
    -payment: net\authorize\api\contract\v1\PaymentMaskedType {#1643 ▶}
    -customer: null
    -billTo: net\authorize\api\contract\v1\CustomerAddressType {#1639 ▶}
    -shipTo: null
    -recurringBilling: false
    -customerIP: "59.103.97.140"
    -product: "Card Not Present"
    -entryMode: null
    -marketType: "eCommerce"
    -mobileDeviceId: null
    -customerSignature: null
    -returnedItems: null
    -solution: null
    -emvDetails: null
    -profile: null
    -surcharge: null
    -employeeId: null
    -tip: null
    -otherTax: null
    -shipFrom: null
    -networkTransId: "2OE7KPRVGKYY58S7PISZRQI"
    -originalNetworkTransId: null
    -originalAuthAmount: null
    -authorizationIndicator: "final"
  }
  -clientId: "accept-hosted"
  -transrefId: "ref1636637807"
  -refId: null
  -messages: net\authorize\api\contract\v1\MessagesType {#1633 ▶}
  -sessionToken: null
}

now i am not possible to get the transaction details when i am going to access transaction so it gives me an error which is:

dd($response->transaction);

Cannot access private property net\authorize\api\contract\v1\GetTransactionDetailsResponse::$transaction

Anyone please help me what is the issue here and why the transaction details are not accessing The credentilas are of sandbox account.

CodePudding user response:

Try this: $response->getTransaction()

  • Related