in-app payment use only sandbox environment


i develope credit-card-payment WEB application.
now, i can not remove trouble follows; ( only with sandbox , without SDKs )

 

[ Square Sample Source]
--- list location ---
$api_response = $client->getLocationsApi()->listLocations();

if ($api_response->isSuccess()) {
$result = $api_response->getResult();
} else {
$errors = $api_response->getErrors();
}
--- Run with my sandbox accesstoken EAAAEGSV............ ---
--- 200 Response ----
cache-control: max-age=0, private, must-revalidate
content-encoding: gzip
content-type: application/json
date: Fri, 09 Oct 2020 09:11:09 GMT
square-version: 2020-09-23


{
"locations": [
{
"id": "LRWGXA60SQS2D", <--- Default Location
"name": "Default Test Account",
"address": {
"address_line_1": "1",
"locality": "Chiyoda City",
"administrative_district_level_1": "13",
"postal_code": "100-0014",
"country": "JP"
},
"timezone": "UTC",
"capabilities": [
"CREDIT_CARD_PROCESSING"
],
"status": "ACTIVE",
"created_at": "2020-09-25T06:38:32Z",
"merchant_id": "MLRDXJP2WCFT0",
"country": "JP",
"language_code": "en-US",
"currency": "JPY",
"business_name": "Default Test Account",
"type": "PHYSICAL",
"business_hours": {},
"mcc": "5944"
}
]
}

[ My Simple Nonce Processing ]
\SquareConnect\Configuration::getDefaultConfiguration()->setAccessToken($access_token);
$locations_api = new \SquareConnect\Api\LocationsApi();
echo("<b>[get locations_api]</b><br>");
var_dump($locations_api);
echo("<br><br>");

try {
$locations = $locations_api->listLocations();
# カード処理が実行できる店舗情報を取得します
$location = current(array_filter($locations->getLocations(), function($location) {
$capabilities = $location->getCapabilities();
return is_array($capabilities) &&
in_array('CREDIT_CARD_PROCESSING', $capabilities);
}));

} catch (\SquareConnect\ApiException $e) {
echo "店舗が見つかりません!!( location not found)<br/>"; <-- caught
print_r("<strong>Response body:</strong><br/>");
echo "<pre>"; var_dump($e->getResponseBody()); echo "</pre>";
echo "<br/><strong>Response headers:</strong><br/>";
echo "<pre>"; var_dump($e->getResponseHeaders()); echo "</pre>";
exit(1);
}
--- Result ( fail )---
[get locations_api]
object(SquareConnect\Api\LocationsApi)#2 (1) { ["apiClient":protected]=> object(SquareConnect\ApiClient)#4 (2) { ["config":protected]=> object(SquareConnect\Configuration)#3 (13) { ["apiKeys":protected]=> array(0) { } ["apiKeyPrefixes":protected]=> array(0) { } ["accessToken":protected]=> string(64) "EAAAEGSV............" ["username":protected]=> string(0) "" ["password":protected]=> string(0) "" ["defaultHeaders":protected]=> array(0) { } ["host":protected]=> string(28) "https://connect.squareup.com" ["curlTimeout":protected]=> int(0) ["userAgent":protected]=> string(31) "Square-Connect-PHP/3.20200528.1" ["debug":protected]=> bool(false) ["debugFile":protected]=> string(12) "php://output" ["tempFolderPath":protected]=> string(4) "/tmp" ["sslVerification":protected]=> bool(true) } ["serializer":protected]=> object(SquareConnect\ObjectSerializer)#5 (0) { } } }

店舗が見つかりません!!( location not found)
Response body:
NULL

Response headers:
NULL

--- [ my analysis ]---
1. i think that object is loaded normally.

2. "https://connect.squareup.com" is "https://connect.squareupsandbox.com"
i do not know how i change this.

3. why response 'NULL' ?
is no-response ? ( time-out ? )

4. i confirmed any other environment, composer-version, php-version,...
any other reason to fail ?

 

1,697件の閲覧回数
メッセージ1/6
不適切なコンテンツを報告
2 2つのベストアンサー
Admin

ベストアンサー

Hi @remotegolf ,

Unfortunately, we don't offer developer support in Japan. If you'd like further assistant with API, please reach out to our developer support team in English. Thank you!

 

( @remotegolf さん、コメントありがとうございます。恐れ入りますが、APIに関しては日本のSquareではサポート外となっておりますため、 APIに関する更に詳しい内容につきましては、恐れ入りますこちらから英語で開発者サポートへお問い合わせ下さい。)

 

間宮 −Mamiya
Square コミュニティ管理者
解決策や有用な回答には、ログイン して ベストアンサーとしてマークをクリックしましょう!

ベストアンサーを見る >

1,625件の閲覧回数
メッセージ5/6
不適切なコンテンツを報告

ベストアンサー

Hi, Bryan and Mamiya.

 

i can do it successfully. 

 

[ i try as follows]

// change ApiClient environment
\SquareConnect\Configuration::getDefaultConfiguration()->setSSLVerification(false);
// change ApiClient environment HOST
\SquareConnect\Configuration::getDefaultConfiguration()->setHost(SQUARE_BASEPATH);

$client = new \SquareConnect\ApiClient();
$transactions_api = new \SquareConnect\Api\TransactionsApi($client);

 

1. SSLVerification => false ; maybe not enough to secure

    CURLOPT_SSL_VERIFYHOST 

2. set Host to sandbox

    SQUARE_BASEPATH is defined in external file.

3. set $client as parameter of TransactionApi

    for using default;

 

thanks so much,

ベストアンサーを見る >

1,618件の閲覧回数
メッセージ6/6
不適切なコンテンツを報告
5 返信
Admin

Hi @remotegolf, It seems that you are using our old SDK. We recommend updating to our new SDK from here: https://github.com/square/square-php-sdk

With the new SDK, see below on how to use the Sandbox:

------------------------------------------------

$client = new SquareClient([

    'accessToken' => 'YOUR SANDBOX ACCESS TOKEN HERE',

    'environment' => Environment::SANDBOX,

]);

...

$locationsApi = $client->getLocationsApi();

$apiResponse = $locationsApi->listLocations();

...

------------------------------------------------

 

Unfortunately, we don't offer developer support in Japan. If you'd like further assistant with API, please reach out to our developer support team in English. Thank you!

間宮 −Mamiya
Square コミュニティ管理者
解決策や有用な回答には、ログイン して ベストアンサーとしてマークをクリックしましょう!
1,654件の閲覧回数
メッセージ2/6
不適切なコンテンツを報告

i try on the environment only sandbox without SDK.

i know the SDK is powerfull and simple, but     my PC environment is very tight.

 

my environment is as follows;

OS   centOS7

PHP version 7.2.34

HTTPD Apache/2.4.6

 

composer.json is 

{
"require": {
"square/square": "^5.0.0",
"square/connect": "*",
"vlucas/phpdotenv": "^3.3"
}
}

 

Result of execution:

http-code is zero, i guess connect.square.com reject my request,

 

[My Code]

code is very simple;

\SquareConnect\Configuration::getDefaultConfiguration()->setAccessToken($access_token);

$transactions_api = new \SquareConnect\Api\TransactionsApi();

$request_body = array (
"card_nonce" => $nonce,
// 決済額について。
"amount_money" => array (
"amount" => $amount,
"currency" => "JPY"
),

// すべての決済処理についてSDKはユニークなIDが必要です。
// もし課金成功したか分からない場合は、同じユニークなIDを使えますので、重複課金を防げます。
"idempotency_key" => uniqid()
);

// 決済処理が失敗した場合、SDKは例外処理を返します。うまくいった場合には2xx系のステータスを返します
try {
$result = $transactions_api->charge($locationid, $request_body);
echo "<pre>";
print_r($result);
echo "</pre>";
} catch (\SquareConnect\ApiException $e) {
echo "Caught exception!<br/>";
print_r("<strong>Response body:</strong><br/>");
echo "<pre>"; var_dump($e->getResponseBody()); echo "</pre>";
echo "<br/><strong>Response headers:</strong><br/>";
echo "<pre>"; var_dump($e->getResponseHeaders()); echo "</pre>";
}

 

 

 

 

1,648件の閲覧回数
メッセージ3/6
不適切なコンテンツを報告

Sorry, i 'm wrong.

 

i want to use 'web site payment' , not in-app.

 

the result shown above is for web-site payment.

1,641件の閲覧回数
メッセージ4/6
不適切なコンテンツを報告
Admin

ベストアンサー

Hi @remotegolf ,

Unfortunately, we don't offer developer support in Japan. If you'd like further assistant with API, please reach out to our developer support team in English. Thank you!

 

( @remotegolf さん、コメントありがとうございます。恐れ入りますが、APIに関しては日本のSquareではサポート外となっておりますため、 APIに関する更に詳しい内容につきましては、恐れ入りますこちらから英語で開発者サポートへお問い合わせ下さい。)

 

間宮 −Mamiya
Square コミュニティ管理者
解決策や有用な回答には、ログイン して ベストアンサーとしてマークをクリックしましょう!
1,626件の閲覧回数
メッセージ5/6
不適切なコンテンツを報告

ベストアンサー

Hi, Bryan and Mamiya.

 

i can do it successfully. 

 

[ i try as follows]

// change ApiClient environment
\SquareConnect\Configuration::getDefaultConfiguration()->setSSLVerification(false);
// change ApiClient environment HOST
\SquareConnect\Configuration::getDefaultConfiguration()->setHost(SQUARE_BASEPATH);

$client = new \SquareConnect\ApiClient();
$transactions_api = new \SquareConnect\Api\TransactionsApi($client);

 

1. SSLVerification => false ; maybe not enough to secure

    CURLOPT_SSL_VERIFYHOST 

2. set Host to sandbox

    SQUARE_BASEPATH is defined in external file.

3. set $client as parameter of TransactionApi

    for using default;

 

thanks so much,

1,619件の閲覧回数
メッセージ6/6
不適切なコンテンツを報告