2017-09-28 2 views
0

を呼び出して、私は次のエラーが表示されます:<a href="https://github.com/square/connect-php-sdk" rel="nofollow noreferrer">installation instructions for Square's SDK</a>を読む未定義の機能を電荷に

Fatal error: Uncaught Error: Call to undefined function charge() in D:......\square\1.php on line 28

続行するかどうかはわからないだけれども、私が行方不明$access_tokenを追加しましたか?不足している充電機能のバグを修正するにはどうすればよいですか?

<?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()); 
} 
?> 

答えて

1

これはどこかからコピーして貼り付けましたか?

$transactions_api-charge 

$transactions_api->charge 
+0

勤務する必要があります!はい、SDKのインストール手順からコピーされます。私はGITにそこに提案を編集させようとしています(彼らがどのように修正をするのかはわかりません)。私はここに移動しています:https://stackoverflow.com/questions/46479573/square-card-nonce-not-found-in-this-sandbox-application-environmentそして私はあなたの助けに感謝します! – John

+0

私はあなたのためにプルリクエストを開いた:https://github.com/square/connect-api-specification/pull/83 – tristansokol

+0

恐ろしい!私はあなたの助けに感謝します!私が最終的にこれすべての仕事を得るとき、私のために働いたものを私のブログに投稿します。 – John

関連する問題

 関連する問題