Php 方形API-无效字符';C';寻找价值的起点

Php 方形API-无效字符';C';寻找价值的起点,php,square,square-connect,Php,Square,Square Connect,我使用的是Square Charge API,下面是我对测试卡的请求对象- 我正在使用Square提供的PHP客户端连接到API。我收到以下关于“收费”端点的回复- [HTTP/1.1 400 Bad Request] {"errors":[{"category":"INVALID_REQUEST_ERROR","code":"BAD_REQUEST","detail":"invalid character 'C' looking for beginning of value (line 1,

我使用的是Square Charge API,下面是我对测试卡的请求对象-

我正在使用Square提供的PHP客户端连接到API。我收到以下关于“收费”端点的回复-

[HTTP/1.1 400 Bad Request] {"errors":[{"category":"INVALID_REQUEST_ERROR","code":"BAD_REQUEST","detail":"invalid character 'C' looking for beginning of value (line 1, character 1)"}]}
下面是我用PHP编写的代码-

public function chargeCustomerCard($userId, $custId, $cardId, $note, $billingAddres, $amount, $idempotencyKey){
        $billingAddrRequest = array("address_line_1" => $billingAddres->addr1, "address_line_2" => $billingAddres->addr2, "locality" => $billingAddres->city, "administrative_district_level_1" => $billingAddres->state, "postal_code" => $billingAddres->zip, "country" => $billingAddres->country);
        $billingAddressReq = new \SquareConnect\Model\Address($billingAddrRequest);
        $moneyRequest = array("amount" => $amount, "currency" => "USD");
        $money = new \SquareConnect\Model\Money($moneyRequest);
        $request = array("idempotency_key" => $idempotencyKey, "customer_id" => $custId, "customer_card_id" => $cardId, "delay_capture" => false, "amount_money" => $money, "billing_address" => $billingAddressReq, "note" => $note, "reference_id" => $userId);
        $charge = new \SquareConnect\Model\ChargeRequest($request);
        $response = null;

        try{
            $charge_api = new \SquareConnect\Api\TransactionsApi();
            $response = $charge_api->charge($this->authtoken, $this->locationId, $charge);
            if($response != null && count($response->getErrors()) == 0){
                $transaction = $response->getTransaction();
                $data = array();
                $data['transactionId'] = $transaction->getId();
                $data['created'] = $transaction->getCreatedAt();
                $data['referenceId'] = $transaction->getReferenceId();  //this should be equal to userid
                $tender = $transaction->getTenders()[0];    
                $data['tenderId'] = $tender->getId();
                $data['note'] = $tender->getNote();
                $data['amount'] = ($tender->getAmountMoney()->getAmount())/100;
                $data['currency'] = $tender->getAmountMoney()->getCurrency();
                $processingFee = $tender->getProcessingFeeMoney();
                if(isset($processingFee) && !empty($processingFee)){
                    $data['processingFee'] = $tender->getProcessingFeeMoney()->getAmount();
                }else{
                    $data['processingFee'] = 0;
                }
                $data['tendertype'] = $tender->getType();
                $data['cardStatus'] = $tender->getCardDetails()->getStatus();
                $data['cardBrand'] = $tender->getCardDetails()->getCard()->getCardBrand();
                $data['cardLast4'] = $tender->getCardDetails()->getCard()->getLast4();
                $data['idempotencyKey'] = $idempotencyKey;
                $data['customerPayId'] = $custId;
                $data['customerCardId'] = $cardId;
                return $this->generateReturnData(PAY_API_SUCCESS, '', $data);
            }else{
                return $this->generateReturnData(PAY_API_FAIL, '', $response->getErrors());
            }
        }catch(Exception  $e) {
            return $e->getMessage();
        }
    }
有人能告诉我我做错了什么吗。我真的被困在这里了。其他API端点工作正常,例如,使用square提供的相同方法和相同PHP客户端创建客户、创建客户卡API端点


PS-这是在sandbox上的

首先,我要求您升级到更新的SDK版本。已经一年多没有访问令牌参数了。这可能是你错误的根源。非常感谢。这就是问题所在。我昨天花了好几个小时。我的坏朋友。:)