首页 > 解决方案 > 支付 API 返回 AuthenticationFailed 错误

问题描述

在通过以下代码创建电子支票借记时,我正在将付款集成到我的应用程序并使用 Intuit 的 PHP-Payments-SDK。

public function echeck(Request $request){
    $this->refreshToken();  
    $record = QuickbookModel::first();
    $client = new PaymentClient([
        'access_token' => $record->accessToken,
        'environment' => "sandbox" //  or 'environment' => "production"
        ]);
        $array = [
            "bankAccount" => [
                "phone" => $request->phone,
                "routingNumber" => $request->routingNumber, 
                "name" => $request->name, 
                "accountType" => $request->accountType, 
                "accountNumber" => $request->accountNumber
            ],
            "description" => "Easyfi Testing", 
            "paymentMode" => "WEB", 
            "amount" => "5.55",
        ];

        $bank = ECheckOperations::buildFrom($array);
        $response = $client->debit($bank);

        if($response->failed()){
            $code = $response->getStatusCode();
            $errorMessage = $response->getBody();
            return json_encode(["status" => $code, "message" => $errorMessage]);
        }else{
            $responseCharge = $response->getBody();
            //Get the Id of the charge request
            $id = $responseCharge->id;
            //Get the Status of the charge request
            $status = $responseCharge->status;
            return json_encode(["status" => $status, "message" => $responseCharge, "data" => $id]);
        }

    }

我总是收到以下错误,即使一切都符合要求,包括访问令牌

{status: 401, message: "{"code":"AuthenticationFailed","type":"INPUT","message":null,"detail":null,"moreInfo":null}"}

标签: phpquickbooksintuit

解决方案


推荐阅读