Square:调用未定义的函数 charge
Square: Call to undefined function charge
读取 installation instructions for Square's SDK 我收到以下错误:
Fatal error: Uncaught Error: Call to undefined function charge() in
D:......\square.php on line 28
我添加了缺失的 $access_token
,但不确定如何继续?怎么修复充值功能缺失的bug?
<?php
require 'vendor/autoload.php';
$access_token = 'sandbox-abcdefghijkl_mnopqrstivwxyzzz';
# setup authorization
\SquareConnect\Configuration::getDefaultConfiguration()->setAccessToken($access_token);
# create an instance of the Transaction API class
$transactions_api = new \SquareConnect\Api\TransactionsApi();
$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 .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 (\SquareConnect\ApiException $e) {
echo "Exception when calling TransactionApi->charge:";
var_dump($e->getResponseBody());
}
?>
您是从某处复制粘贴的吗?
$transactions_api-charge
应该是
$transactions_api->charge
读取 installation instructions for Square's SDK 我收到以下错误:
Fatal error: Uncaught Error: Call to undefined function charge() in D:......\square.php on line 28
我添加了缺失的 $access_token
,但不确定如何继续?怎么修复充值功能缺失的bug?
<?php
require 'vendor/autoload.php';
$access_token = 'sandbox-abcdefghijkl_mnopqrstivwxyzzz';
# setup authorization
\SquareConnect\Configuration::getDefaultConfiguration()->setAccessToken($access_token);
# create an instance of the Transaction API class
$transactions_api = new \SquareConnect\Api\TransactionsApi();
$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 .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 (\SquareConnect\ApiException $e) {
echo "Exception when calling TransactionApi->charge:";
var_dump($e->getResponseBody());
}
?>
您是从某处复制粘贴的吗?
$transactions_api-charge
应该是
$transactions_api->charge