Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getTransactionDetailsRequest Sample Code Not Working #13

Closed
PostAlmostAnything opened this issue Jun 7, 2021 · 1 comment
Closed

getTransactionDetailsRequest Sample Code Not Working #13

PostAlmostAnything opened this issue Jun 7, 2021 · 1 comment

Comments

@PostAlmostAnything
Copy link

PostAlmostAnything commented Jun 7, 2021

I am having some difficulty with the getTransactionDetailsRequest part of your sample code. Whenever I run the following the results from transactionType and transactionStatus are empty:

$transactionId = $webhook->payload->id;
    $merchantrefid = $webhook->payload->merchantReferenceId;
    $eventtype = $webhook->eventType;
    // Here you can get more information about the transaction
    $request  = AuthnetApiFactory::getJsonApiHandler(\SampleCodeConstants::MERCHANT_LOGIN_ID, \SampleCodeConstants::MERCHANT_TRANSACTION_KEY);
    $response = $request->getTransactionDetailsRequest(array(
        'transId' => $transactionId,
    ));
    $transtype = $response->transaction->transactionType;
    $transstatus = $response->transaction->transactionStatus;
    if($eventtype == 'net.authorize.payment.authcapture.created')
    {
        print_log('TID = ' . $transactionId.' RefID = '.$merchantrefid.' EventType = '.$eventtype.' TransactionType = '.$transtype.' TransactionStatus = '.$transstatus);
    }
@stymiee
Copy link
Owner

stymiee commented Jun 16, 2021

Unable to reproduce.

PHP code

try {
    $request = AuthnetApiFactory::getJsonApiHandler(
        AUTHNET_LOGIN,
        AUTHNET_TRANSKEY,
        AuthnetApiFactory::USE_DEVELOPMENT_SERVER
    );
    $response = $request->getTransactionDetailsRequest([
        'transId' => '40067511400'
    ]);
} catch (Exception $e) {
    echo $e;
    exit;
}

JSON Response

{
    "transaction": {
        "transId": "40067511400",
        "submitTimeUTC": "2021-06-16T22:50:01.42Z",
        "submitTimeLocal": "2021-06-16T15:50:01.42",
        "transactionType": "authCaptureTransaction",
        "transactionStatus": "capturedPendingSettlement",
        "responseCode": 1,
        "responseReasonCode": 1,
        "responseReasonDescription": "Approval",
        "authCode": "SRE1JF",
        "AVSResponse": "Y",
        "cardCodeResponse": "P",
        "order": {
            "purchaseOrderNumber": "456654",
            "invoiceNumber": "1324567890",
            "description": "this is a test transaction",
            "discountAmount": 0.0,
            "taxIsAfterDiscount": false
        },
        "authAmount": 5.00,
        "settleAmount": 5.00,
        "tax": {
            "amount": 4.26,
            "description": "level2 tax"
        },
        "shipping": {
            "amount": 4.26,
            "description": "level2 tax"
        },
        "duty": {
            "amount": 8.55,
            "description": "duty description"
        },
        "lineItems": [
            {
                "itemId": "1",
                "name": "vase",
                "description": "Cannes logo",
                "quantity": 18.00000,
                "unitPrice": 45.00,
                "taxable": false,
                "taxRate": 0.0,
                "taxAmount": 0.0,
                "nationalTax": 0.0,
                "localTax": 0.0,
                "vatRate": 0.0,
                "alternateTaxRate": 0.0,
                "alternateTaxAmount": 0.0,
                "totalAmount": 0.0,
                "discountRate": 0.0,
                "discountAmount": 0.0,
                "taxIncludedInTotal": false,
                "taxIsAfterDiscount": false
            },
            {
                "itemId": "2",
                "name": "desk",
                "description": "Big Desk",
                "quantity": 10.00000,
                "unitPrice": 85.00,
                "taxable": false,
                "taxRate": 0.0,
                "taxAmount": 0.0,
                "nationalTax": 0.0,
                "localTax": 0.0,
                "vatRate": 0.0,
                "alternateTaxRate": 0.0,
                "alternateTaxAmount": 0.0,
                "totalAmount": 0.0,
                "discountRate": 0.0,
                "discountAmount": 0.0,
                "taxIncludedInTotal": false,
                "taxIsAfterDiscount": false
            }
        ],
        "taxExempt": false,
        "payment": {
            "creditCard": {
                "cardNumber": "XXXX1111",
                "expirationDate": "XXXX",
                "cardType": "Visa"
            }
        },
        "customer": {
            "id": "18",
            "email": "someone@blackhole.tv"
        },
        "billTo": {
            "firstName": "Ellen",
            "lastName": "Johnson",
            "company": "Souveniropolis",
            "address": "14 Main Street",
            "city": "Pecan Springs",
            "state": "TX",
            "zip": "44628",
            "country": "USA"
        },
        "shipTo": {
            "firstName": "China",
            "lastName": "Bayles",
            "company": "Thyme for Tea",
            "address": "12 Main Street",
            "city": "Pecan Springs",
            "state": "TX",
            "zip": "44628",
            "country": "USA"
        },
        "recurringBilling": false,
        "customerIP": "192.168.1.1",
        "product": "Card Not Present",
        "marketType": "eCommerce",
        "networkTransId": "9E2ABXXQA4LDBPMTL5I9SK3",
        "authorizationIndicator": "final"
    },
    "transrefId": "46745146",
    "messages": {
        "resultCode": "Ok",
        "message": [
            {
                "code": "I00001",
                "text": "Successful."
            }
        ]
    }
}

Output

<table>
    <tr>
        <th>Transaction</th>
        <td>
            <b>ID</b>: <?php echo $response->transaction->transId; ?><br>
            <b>Type</b>: <?php echo $response->transaction->transactionType; ?><br>
            <b>Status</b>: <?php echo $response->transaction->transactionStatus; ?><br>
            <b>Authorization Code</b>: <?php echo $response->transaction->authCode; ?><br>
            <b>AVS Response</b>: <?php echo $response->transaction->AVSResponse; ?><br>
        </td>
    </tr>
</table>

authcapture
transdetails

@stymiee stymiee closed this as completed Jun 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants