正方形:致电未定义功能充电



阅读Square SDK的安装说明我收到以下错误:

致命错误:未定的错误:致电未定义的功能culce() D:............ Square 1.Php在第28行

我添加了缺少的$access_token,尽管不确定如何进行?如何修复丢失的充电功能错误?

<?php
require 'vendor/autoload.php';
$access_token = 'sandbox-abcdefghijkl_mnopqrstivwxyzzz';
# setup authorization
SquareConnectConfiguration::getDefaultConfiguration()->setAccessToken($access_token);
# create an instance of the Transaction API class
$transactions_api = new SquareConnectApiTransactionsApi();
$location_id = 'CBASEEum0KeFu_h-4VA4OWaV3F8gAQ';
$nonce = 'CBA15363g28251525625624455255A';
$request_body = array (
  "card_nonce" => $nonce,
  # Monetary amounts are specified in the smallest unit of the applicable currency.
  # This amount is in cents. It's also hard-coded for $1.00, which isn't very useful.
  "amount_money" => array (
    "amount" => 100,
    "currency" => "USD"
  ),
  # Every payment you process with the SDK must have a unique idempotency key.
  # If you're unsure whether a particular payment succeeded, you can reattempt
  # it with the same idempotency key without worrying about double charging
  # the buyer.
  "idempotency_key" => uniqid()
);
try {
  $result = $transactions_api-charge($location_id, $request_body);
  print_r($result);
} catch (SquareConnectApiException $e) {
  echo "Exception when calling TransactionApi->charge:";
  var_dump($e->getResponseBody());
}
?>

您是否从某个地方复制并粘贴了它?

$transactions_api-charge

应该是

$transactions_api->charge

最新更新