Reading the installation instructions for Square's SDK I receive the following error:
Fatal error: Uncaught Error: Call to undefined function charge() in D:......\square\1.php on line 28
I added the missing $access_token though am unsure how to proceed? How do I fix the missing charge function 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 $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 (\SquareConnect\ApiException $e) {
echo "Exception when calling TransactionApi->charge:";
var_dump($e->getResponseBody());
}
?>