cancel
Showing results for 
Search instead for 
Did you mean: 

Failed ACH transaction

A user is trying to make an ACH payment from our portal but it doesnt work , I get an Error - the ABA code is invalid (but its a valid code..) , when he does the same payment directly with autorize. net portal, it does work. Can anybody advise?

This is the code:

 

/**
 * Debit a Bank Account
 * Use this method to process an ACH debit transaction using bank account details.
 * @param float $amount
 * @param int $routingNumber
 * @param int $accountNumber
 * @param string $nameOnAccount
 * @param string $bankName
 * @return array
 */
public function paymentTransactionsDebitBankAccount(    float $amount,
    int $routingNumber,
    int $accountNumber,
    string $nameOnAccount,
    string $bankName,
    string $accountType,
    string $eCheckType
): array
{
    $paymentTransactions = new PaymentTransactions(
        $this->apiLoginId,
        $this->transactionKey,
        $this->apiKey,`your text`
        $this->endPointApi
    );


    $paymentTransactions->setOrderInformation(
        orderInformationInvoiceNumber: $this->contract->id,
        orderInformationDescription: 'Contract ' . $this->contract->name
    );

    $paymentTransactions->setTransactionRequest(
        transactionRequestType: 'authCaptureTransaction'
    );

    $debitBankAccount = $paymentTransactions->debitBankAccount(
        amount: $amount,
        routingNumber: $routingNumber,
        accountNumber: $accountNumber,
        nameOnAccount: $nameOnAccount,
        bankName: $bankName,
        accountType: $accountType,
        eCheckType: $eCheckType,
    );

    if ($debitBankAccount != null) {
        if ($debitBankAccount->getMessages()->getResultCode() == "Ok") {
            $tresponse = $debitBankAccount->getTransactionResponse();

            if ($tresponse != null && $tresponse->getMessages() != null) {
                $debitBankAccountMessageText = " Transaction Response code : " . $tresponse->getResponseCode() . "\n";
                $debitBankAccountMessageText .= " Debit Bank Account APPROVED  :" . "\n";
                $debitBankAccountMessageText .= " Debit Bank Account AUTH CODE : " . $tresponse->getAuthCode() . "\n";
                $debitBankAccountMessageText .= " Debit Bank Account TRANS ID  : " . $tresponse->getTransId() . "\n";
                $debitBankAccountMessageText .= " Code : " . $tresponse->getMessages()[0]->getCode() . "\n";
                $debitBankAccountMessageText .= " Description : " . $tresponse->getMessages()[0]->getDescription() . "\n";

                return [
                    'status' => 'Ok',
                    'message' => $debitBankAccountMessageText,
                    'data' => [
                        'transaction_response_code' => $tresponse->getResponseCode(),
                        'transaction_id' => $tresponse->getTransId(),
                        'auth_code' => $tresponse->getAuthCode(),
                        'message_code' => $tresponse->getMessages()[0]->getCode(),
                        'message_description' => $tresponse->getMessages()[0]->getDescription()
                    ],
                ];

            } else {
                $debitBankAccountMessageText = "Transaction Failed \n";
                if ($tresponse->getErrors() != null) {
                    $debitBankAccountMessageText .= " Error code  : " . $tresponse->getErrors()[0]->getErrorCode() . "\n";
                    $debitBankAccountMessageText .= " Error message : " . $tresponse->getErrors()[0]->getErrorText() . "\n";
                }

                return [
                    'status' => 'Error',
                    'message' => $debitBankAccountMessageText,
                    'data' => null,
                ];
            }
        } else {
            $debitBankAccountMessageText = "Transaction Failed \n";
            $tresponse = $debitBankAccount->getTransactionResponse();
            if ($tresponse != null && $tresponse->getErrors() != null) {
                $debitBankAccountMessageText .= " Error code  : " . $tresponse->getErrors()[0]->getErrorCode() . "\n";
                $debitBankAccountMessageText .= " Error message : " . $tresponse->getErrors()[0]->getErrorText() . "\n";
            } else {
                $debitBankAccountMessageText .= " Error code  : " . $debitBankAccount->getMessages()->getMessage()[0]->getCode() . "\n";
                $debitBankAccountMessageText .= " Error message : " . $debitBankAccount->getMessages()->getMessage()[0]->getText() . "\n";
            }

            return [
                'status' => 'Error',
                'message' => $debitBankAccountMessageText,
                'data' => null,
            ];
        }
    } else {
        return [
            'status' => 'Error',
            'message' => 'No response returned',
            'data' => null,
        ];
    }
} 

 

ssuccess
Member
0 REPLIES 0